diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mov_encoder.cc | 11 | ||||
-rw-r--r-- | src/mov_encoder_thread.cc | 24 | ||||
-rw-r--r-- | src/server.cc | 8 |
3 files changed, 34 insertions, 9 deletions
diff --git a/src/mov_encoder.cc b/src/mov_encoder.cc index bb24c5a..172051d 100644 --- a/src/mov_encoder.cc +++ b/src/mov_encoder.cc @@ -39,6 +39,10 @@ /* * $Log$ + * Revision 1.22 2005/05/17 19:16:26 deva + * + * Made new mpeg writer work, with proper file permissions. + * * Revision 1.21 2005/05/17 14:30:56 deva * Added code, preparing threaded encoding. * @@ -288,15 +292,18 @@ Frame *MovEncoder::encode_video(Frame *dvframe) // Allocate a new frame for the output Frame *output = new Frame(NULL, FAME_BUFFER_SIZE); - unsigned int pt = (unsigned int)output->data; + output->size = 0; + unsigned char* pt = output->data; // Encode YUV frame and write it to disk. fame_start_frame(fame_context, &yuv, 0); int written; + while((written = fame_encode_slice(fame_context))) { // fwrite(fame_buffer, written, 1, f); - memcpy((void *)pt, fame_buffer, written); + memcpy(pt, fame_buffer, written); pt += written; + output->size += written; } fame_end_frame(fame_context,0); diff --git a/src/mov_encoder_thread.cc b/src/mov_encoder_thread.cc index 63c0bd2..da83744 100644 --- a/src/mov_encoder_thread.cc +++ b/src/mov_encoder_thread.cc @@ -31,6 +31,10 @@ /* * $Log$ + * Revision 1.4 2005/05/17 19:16:26 deva + * + * Made new mpeg writer work, with proper file permissions. + * * Revision 1.3 2005/05/17 15:13:15 deva * *** empty log message *** * @@ -44,11 +48,17 @@ #include <config.h> #include "mov_encoder_thread.h" +#include <errno.h> MovEncoderThread::MovEncoderThread(const char *filename) { - file = open(filename, O_CREAT | O_EXCL, S_IRWXU | S_IRGRP | S_IROTH); - + file = open(filename, + O_CREAT | O_WRONLY, //| O_LARGEFILE + S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + if(file == -1) { + fprintf(stderr, "File not opened %s\n", strerror(errno)); + return; + } threads = 4; for(int cnt = 0; cnt < threads; cnt++) { @@ -61,13 +71,17 @@ MovEncoderThread::~MovEncoderThread() for(int cnt = 0; cnt < threads; cnt++) { delete encs[cnt]; } - if(file) close(file); + if(file != -1) close(file); } void MovEncoderThread::encode(Frame* frame) { - if(!file) return; + if(file == -1) return; + Frame *enc_frame = encs[0]->encode(frame); - write(file, enc_frame->data, enc_frame->size); + // fprintf(stderr, "[%d]", enc_frame->size); fflush(stderr); + int i = write(file, enc_frame->data, enc_frame->size); + if(i == -1) perror("Write failed"); + delete enc_frame; } diff --git a/src/server.cc b/src/server.cc index 03f9552..135fb27 100644 --- a/src/server.cc +++ b/src/server.cc @@ -31,6 +31,10 @@ /* * $Log$ + * Revision 1.17 2005/05/17 19:16:26 deva + * + * Made new mpeg writer work, with proper file permissions. + * * Revision 1.16 2005/05/17 15:12:51 deva * Fixed file rights (All read on files and directories, and all execute on directories). * @@ -232,7 +236,7 @@ MovEncoderThread *newMovEncoder(char* cpr) // Create folder named birthmonth in server root sprintf(fname, "%s/%s", root->c_str(), birthmonth); - if(!mkdir(fname, S_IRWXU) == -1 && errno != EEXIST) { + if(!mkdir(fname, S_IRWXU | S_IRGRP | S_IXGRP | S_IXOTH | S_IROTH) == -1 && errno != EEXIST) { int r = rand(); fprintf(stderr, "Not possible to create subfolder %s\n", fname); fprintf(stderr, "Redirecting output to [/tmp/miav-%d.mpg]\n", r); @@ -243,7 +247,7 @@ MovEncoderThread *newMovEncoder(char* cpr) // Create folder named cpr in serverroot/birthmonth sprintf(fname, "%s/%s/%s", root->c_str(), birthmonth, cpr); - if(!mkdir(fname, S_IRWXU) == -1 && errno != EEXIST) { + if(!mkdir(fname, S_IRWXU | S_IRGRP | S_IXGRP | S_IXOTH | S_IROTH) == -1 && errno != EEXIST) { int r = rand(); fprintf(stderr, "Not possible to create subfolder %s\n", fname); fprintf(stderr, "Redirecting output to [/tmp/miav-%d.mpg]\n", r); |