summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordeva <deva>2005-10-18 12:07:40 +0000
committerdeva <deva>2005-10-18 12:07:40 +0000
commit1099eeae24b28306022ae3663a2766261b3455e4 (patch)
tree8f40fa2017c8955e014701dd2dd19861bfe68200
parent38e4cbdb7aabf90d9a56ac95f1c8beca810c9436 (diff)
*** empty log message ***
-rw-r--r--etc/Makefile.am6
-rw-r--r--etc/miav.conf6
-rw-r--r--src/file.cc49
-rw-r--r--src/file.h13
-rw-r--r--src/historywidget.cc2
-rw-r--r--src/historywidget.h2
-rw-r--r--src/mov_encoder_thread.cc5
-rw-r--r--src/mov_encoder_thread.h5
-rw-r--r--src/mov_encoder_writer.cc11
-rw-r--r--src/mov_encoder_writer.h5
-rw-r--r--src/multicast.cc62
-rw-r--r--src/multicast.h4
-rw-r--r--src/multiplexer.cc2
-rw-r--r--src/player.cc2
-rw-r--r--src/server.cc4
-rw-r--r--src/yuv_draw.cc3
-rw-r--r--src/yuv_draw.h2
17 files changed, 161 insertions, 22 deletions
diff --git a/etc/Makefile.am b/etc/Makefile.am
index e149dab..1e4ee34 100644
--- a/etc/Makefile.am
+++ b/etc/Makefile.am
@@ -1,7 +1,9 @@
EXTRA_DIST = \
- miav.conf
+ miav.conf \
+ multicast.conf
sysconfdir=${prefix}/etc/miav
dist_sysconf_DATA = \
- miav.conf \ No newline at end of file
+ miav.conf \
+ multicast.conf \ No newline at end of file
diff --git a/etc/miav.conf b/etc/miav.conf
index 13770e3..7c65300 100644
--- a/etc/miav.conf
+++ b/etc/miav.conf
@@ -20,9 +20,6 @@ screensize = 19.0
pixel_width = 1024
pixel_height = 768
-# mcast conf file
-multicast_configurationfile= "/home/miav/etc/miav/multicast.conf"
-
# Set to 1 if client is slow ( less than 1.5 ghz )
player_skip_frames = 1
@@ -38,6 +35,9 @@ server_group = "miav"
server_movie_root = "/home/miav/miav_movie_files"
server_image_root = "/home/miav/miav_image_files"
+# Defines the size of the multicasted upd packages (1500 is normal)
+udp_packet_size = 1500
+
# Video output controls. A sequence of I and P, where I is keyframes
# which is fast to create, but uses a lot of discspace.
# B uses changes since last frame, is more cpu intensive, but uses a
diff --git a/src/file.cc b/src/file.cc
index c3fad30..f3c0cbc 100644
--- a/src/file.cc
+++ b/src/file.cc
@@ -44,6 +44,8 @@ File::File(char *fn, char* ext, Info *i)
info = i;
+ savestate = SAVE;
+
filename = new char[strlen(fn) + 1];
extension = new char[strlen(ext) + 1];
@@ -70,6 +72,35 @@ File::~File()
{
close(fd);
+ info->info("This session contains the following files...");
+ for(unsigned int cnt = 0; cnt < filelist.size(); cnt ++) {
+ info->info("[%s]", filelist[cnt].c_str());
+ }
+
+ switch(savestate) {
+ case NO_CHANGE:
+ info->warn("File had no savestate!");
+ break;
+
+ case SAVE:
+ info->info("Files in this session is to be saved.");
+ break;
+
+ case DELETE:
+ info->info("Files in this session is to be deleted (moved to trash).");
+ for(unsigned int cnt = 0; cnt < filelist.size(); cnt ++) {
+ // TODO: Move file filelist[cnt] to trash
+ }
+ break;
+
+ case LATER:
+ info->info("Files in this session is stored for later decisson.");
+ for(unsigned int cnt = 0; cnt < filelist.size(); cnt ++) {
+ // TODO: Move file filelist[cnt] to the later folder.
+ }
+ break;
+ }
+
delete filename;
delete extension;
}
@@ -78,8 +109,10 @@ int File::Open()
{
char fname[256];
- if(fd) close(fd);
- fd = -1;
+ if(fd != -1) {
+ close(fd);
+ fd = -1;
+ }
while(fd == -1) {
if(seqnum) {
@@ -93,14 +126,17 @@ int File::Open()
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if(fd == -1) num ++;
- // If more than 1000 files are created in one day, something is terribly wrong!
- if(num > 1000) {
+ // If more than 100 files are created in one day, something is terribly wrong!
+ if(num > 100) {
info->error("Something is wrong with the path [%s]!", fname);
exit(1);
}
}
+ std::string filename_string(fname);
+ filelist.push_back(filename_string);
+
seqnum ++;
info->info("Output file: %s", fname);
@@ -245,6 +281,11 @@ int File::createPath(char* path)
return 0;
}
+void File::setSaveState(n_savestate savestate)
+{
+ this->savestate = savestate;
+}
+
#ifdef __TEST_FILE
#include "info_simple.h"
diff --git a/src/file.h b/src/file.h
index 36be4d2..0ef9aa4 100644
--- a/src/file.h
+++ b/src/file.h
@@ -31,8 +31,13 @@
#include "info.h"
#include <stdio.h>
+#include <vector>
+#include <string>
+
#include <string.h>
-using namespace std;
+
+// For savestate_n
+#include "package.h"
class File {
public:
@@ -52,9 +57,15 @@ public:
int Write(short int val);
int Write(unsigned short int val);
*/
+
+ void setSaveState(n_savestate savestate);
+
private:
+ volatile n_savestate savestate;
Info* info;
+ std::vector<std::string> filelist;
+
int Open();
int fd;
diff --git a/src/historywidget.cc b/src/historywidget.cc
index c517e7a..bdeb880 100644
--- a/src/historywidget.cc
+++ b/src/historywidget.cc
@@ -25,6 +25,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
#include <config.h>
+#ifdef USE_GUI
#include "historywidget.h"
#include "miav_config.h"
@@ -73,3 +74,4 @@ void HistoryWidget::mouseReleaseEvent(QMouseEvent *event)
}
}
+#endif/*USE_GUI*/
diff --git a/src/historywidget.h b/src/historywidget.h
index af06325..d464d59 100644
--- a/src/historywidget.h
+++ b/src/historywidget.h
@@ -25,6 +25,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
#include "config.h"
+#ifdef USE_GUI
#ifndef __MIAV_HISTORYWIDGET_H__
#define __MIAV_HISTORYWIDGET_H__
@@ -48,3 +49,4 @@ private:
};
#endif/*__MIAV_HISTORYWIDGET_H__*/
+#endif/*USE_GUI*/
diff --git a/src/mov_encoder_thread.cc b/src/mov_encoder_thread.cc
index 35f62a6..2ff013d 100644
--- a/src/mov_encoder_thread.cc
+++ b/src/mov_encoder_thread.cc
@@ -151,3 +151,8 @@ void MovEncoderThread::encode(Frame* frame)
frame_number ++;
}
+
+void MovEncoderThread::setSaveState(n_savestate savestate)
+{
+ writer->setSaveState(savestate);
+}
diff --git a/src/mov_encoder_thread.h b/src/mov_encoder_thread.h
index 201a332..feea8e2 100644
--- a/src/mov_encoder_thread.h
+++ b/src/mov_encoder_thread.h
@@ -47,6 +47,9 @@ using namespace std;
#include "info.h"
+// For savestate_n
+#include "package.h"
+
class MovEncoderThread {
public:
MovEncoderThread(const char *clientip, const char *cpr, Info *info);
@@ -54,6 +57,8 @@ public:
void encode(Frame* frame);
+ void setSaveState(n_savestate savestate);
+
private:
Info *info;
diff --git a/src/mov_encoder_writer.cc b/src/mov_encoder_writer.cc
index d533b81..0d9081b 100644
--- a/src/mov_encoder_writer.cc
+++ b/src/mov_encoder_writer.cc
@@ -59,7 +59,6 @@ MovEncoderWriter::MovEncoderWriter(const char *clientip, const char* cpr,
// Create path and filename
char fname[256];
string *server_root;
- string *mcconfig_file;
char birthmonth[3];
char date[32];
@@ -84,10 +83,7 @@ MovEncoderWriter::MovEncoderWriter(const char *clientip, const char* cpr,
file = new File(fname, "mpg", info);
- // Get multicast configuration filename
- mcconfig_file = config->readString("multicast_configurationfile");
-
- MulticastConfiguration mcconfig(info, (char*)mcconfig_file->c_str());
+ MulticastConfiguration mcconfig(info, ETC"/multicast.conf");
mcastconf_t mcclientconf = mcconfig.getConf((char*)clientip);
@@ -116,7 +112,6 @@ MovEncoderWriter::~MovEncoderWriter()
if(multicast) delete multicast;
}
-
void MovEncoderWriter::thread_main()
{
info->info("MovEncoderWriter::run");
@@ -130,3 +125,7 @@ void MovEncoderWriter::thread_main()
info->info("MovEncoderWriter::stop");
}
+void MovEncoderWriter::setSaveState(n_savestate savestate)
+{
+ file->setSaveState(savestate);
+}
diff --git a/src/mov_encoder_writer.h b/src/mov_encoder_writer.h
index eaf4fc8..ba9ff16 100644
--- a/src/mov_encoder_writer.h
+++ b/src/mov_encoder_writer.h
@@ -39,6 +39,9 @@
#include <string>
using namespace std;
+// For n_savestate
+#include "package.h"
+
#define AUDIO_FRAME(x) x->number%2==1
#define VIDEO_FRAME(x) x->number%2==0
@@ -52,6 +55,8 @@ public:
void thread_main();
+ void setSaveState(n_savestate savestate);
+
volatile bool running;
private:
diff --git a/src/multicast.cc b/src/multicast.cc
index 34c7241..ff3f557 100644
--- a/src/multicast.cc
+++ b/src/multicast.cc
@@ -27,25 +27,83 @@
#include "config.h"
#include "multicast.h"
+#include "miav_config.h"
+
+#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
-#include <sys/socket.h>
#include <sys/param.h>
#include <arpa/inet.h>
+#include <sys/types.h>
+
+// For IP_MTU
+//#include <linux/in.h>
+//#ifndef IP_MTU
+//#define IP_MTU 14
+//#endif
+
+#include <errno.h>
Multicast::Multicast(Info *i, char *addr, int port)
{
info = i;
+ udp_buffer = NULL;
+
+ // Open connection socket
if(!UDPOpen(addr, port)) info->error("Error creating socket %s:%d", addr, port);
+
+ int mtu = config->readInt("udp_packet_size");
+
+ // Create buffer with the size of MTU
+ // socklen_t mtu_sz;
+ // if(getsockopt(sock, SOL_IP, IP_MTU, &mtu, &mtu_sz) != -1) {
+
+ udp_buffer_size = mtu - 28;
+ if(udp_buffer_size < 1) udp_buffer_size = 1;
+ udp_buffer = new char[udp_buffer_size];
+ udp_buffer_pointer = udp_buffer;
+ info->info("UDP packet buffer size %db", udp_buffer_size);
+
+ //} else {
+ // info->error("Error getting MTU size from socket: %s", strerror(errno));
+ // return;
+ //}
}
Multicast::~Multicast()
{
+ if(udp_buffer) delete udp_buffer;
}
void Multicast::Write(void* buf, int size)
{
- if(write(sock, buf, size) != size) info->error("Error Writing to socket.");
+ if(!udp_buffer) return; // no buffer to write in... better break out!
+
+ // info->info("To send: %d", size);
+
+ char *p = (char*)buf;
+ int left = udp_buffer_size - (udp_buffer_pointer - udp_buffer);
+
+ while(size) {
+ int to_copy = size > left ? left : size;
+
+ memcpy(udp_buffer_pointer, p, to_copy);
+
+ left-=to_copy;
+ udp_buffer_pointer += to_copy;
+
+ p+=to_copy;
+ size-=to_copy;
+
+ // info->info("Copied %d - %d to go", to_copy, size);
+
+ if(left == 0) {
+ // info->info("Sending full packet");
+ write(sock, udp_buffer, udp_buffer_size);
+ left = udp_buffer_size;
+ udp_buffer_pointer = udp_buffer;
+ }
+ }
}
bool Multicast::is_address_multicast(unsigned long address)
diff --git a/src/multicast.h b/src/multicast.h
index 0f83e87..3d222a0 100644
--- a/src/multicast.h
+++ b/src/multicast.h
@@ -43,6 +43,10 @@ private:
bool is_address_multicast(unsigned long address);
bool UDPOpen(char *address, int port);
int sock;
+
+ int udp_buffer_size;
+ char *udp_buffer;
+ char *udp_buffer_pointer;
};
#endif/*__MIAV_MULTICAST_H__*/
diff --git a/src/multiplexer.cc b/src/multiplexer.cc
index 69e727a..0b75723 100644
--- a/src/multiplexer.cc
+++ b/src/multiplexer.cc
@@ -297,7 +297,7 @@ bool Multiplexer::packet()
StreamType type;
// New switching mechanism
- if(written[TYPE_AUDIO] < written[TYPE_VIDEO]) {
+ if(written[TYPE_AUDIO] < written[TYPE_VIDEO] + 10) {
type = TYPE_AUDIO;
} else {
type = TYPE_VIDEO;
diff --git a/src/player.cc b/src/player.cc
index 2f0638f..23dbcf3 100644
--- a/src/player.cc
+++ b/src/player.cc
@@ -76,7 +76,7 @@ Player::Player(Info *ginfo,
// Do not show the text
showtext = false;
- recording = false;
+ recording = true;
recording_prev = !recording;
cprchanged = false;
}
diff --git a/src/server.cc b/src/server.cc
index 34f0b30..2ecb4be 100644
--- a/src/server.cc
+++ b/src/server.cc
@@ -119,12 +119,12 @@ void newConnection(Socket *socket, Info *info)
frame = new Frame(NULL, DVPACKAGE_SIZE);
}
- // TODO: Use save state
-
info->info("Closing connection...");
// No encoder exists, if this is a pure snapshot (image) connection.
if(enc) {
+ enc->setSaveState(savestate);
+
// Send end of stream frame.
frame->endOfFrameStream = true;
enc->encode(frame);
diff --git a/src/yuv_draw.cc b/src/yuv_draw.cc
index 30427b3..a444fa7 100644
--- a/src/yuv_draw.cc
+++ b/src/yuv_draw.cc
@@ -25,6 +25,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
#include "config.h"
+#ifdef USE_GUI
#include "yuv_draw.h"
// for miav_app
@@ -196,3 +197,5 @@ typedef struct{
Uint32 hw_overlay:1;
} SDL_Overlay;
*/
+
+#endif/*USE_GUI*/
diff --git a/src/yuv_draw.h b/src/yuv_draw.h
index c0cebf6..9c5b84a 100644
--- a/src/yuv_draw.h
+++ b/src/yuv_draw.h
@@ -25,6 +25,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
#include "config.h"
+#ifdef USE_GUI
#ifndef __MIAV_YUV_DRAW_H__
#define __MIAV_YUV_DRAW_H__
@@ -59,3 +60,4 @@ private:
};
#endif/*__MIAV_YUV_DRAW_H__*/
+#endif/*USE_GUI*/