Bug 223 - Added in custom mime-type initialisations.
git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1659 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
parent
588e308531
commit
fa0c5348a0
|
@ -618,6 +618,8 @@ void Event::StreamMpeg( int event_id, const char *format, int scale, int rate, i
|
|||
if ( !vid_stream )
|
||||
{
|
||||
vid_stream = new VideoStream( "pipe:", format, bitrate, effective_fps, image.Colours(), (image.Width()*scale)/ZM_SCALE_SCALE, (image.Height()*scale)/ZM_SCALE_SCALE );
|
||||
fprintf( stdout, "Content-type: %s\r\n\r\n", vid_stream->MimeType() );
|
||||
vid_stream->OpenStream();
|
||||
}
|
||||
|
||||
if ( scale != 100 )
|
||||
|
|
|
@ -1547,6 +1547,9 @@ void Monitor::StreamMpeg( const char *format, int scale, int maxfps, int bitrate
|
|||
|
||||
VideoStream vid_stream( "pipe:", format, bitrate, effective_fps, camera->Colours(), (width*scale)/ZM_SCALE_SCALE, (height*scale)/ZM_SCALE_SCALE );
|
||||
|
||||
fprintf( stdout, "Content-type: %s\r\n\r\n", vid_stream.MimeType() );
|
||||
vid_stream.OpenStream();
|
||||
|
||||
int last_read_index = image_buffer_count;
|
||||
|
||||
time_t stream_start_time;
|
||||
|
|
|
@ -27,6 +27,13 @@
|
|||
|
||||
bool VideoStream::initialised = false;
|
||||
|
||||
VideoStream::MimeData VideoStream::mime_data[] = {
|
||||
{ "asf", "video/x-ms-asf" },
|
||||
{ "swf", "application/x-shockwave-flash" },
|
||||
{ "mp4", "video/mp4" },
|
||||
{ "move", "video/quicktime" }
|
||||
};
|
||||
|
||||
void VideoStream::Initialise()
|
||||
{
|
||||
av_register_all();
|
||||
|
@ -123,6 +130,25 @@ void VideoStream::SetParameters()
|
|||
//dump_format(ofc, 0, filename, 1);
|
||||
}
|
||||
|
||||
const char *VideoStream::MimeType() const
|
||||
{
|
||||
for ( int i = 0; i < sizeof(mime_data)/sizeof(*mime_data); i++ )
|
||||
{
|
||||
if ( strcmp( format, mime_data[i].format ) == 0 )
|
||||
{
|
||||
return( mime_data[i].mime_type );
|
||||
}
|
||||
}
|
||||
const char *mime_type = of->mime_type;
|
||||
if ( !mime_type )
|
||||
{
|
||||
mime_type = "video/mpeg";
|
||||
Warning(( "Unable to determine mime type for '%s' format, using '%s' as default", format, mime_type ));
|
||||
}
|
||||
|
||||
return( mime_type );
|
||||
}
|
||||
|
||||
void VideoStream::OpenStream()
|
||||
{
|
||||
/* now that all the parameters are set, we can open the
|
||||
|
@ -203,14 +229,6 @@ void VideoStream::OpenStream()
|
|||
video_outbuf = (uint8_t *)malloc(video_outbuf_size);
|
||||
}
|
||||
|
||||
const char *mime_type = of->mime_type;
|
||||
if ( !mime_type )
|
||||
{
|
||||
mime_type = "video/mpeg";
|
||||
Warning(( "Unable to determine mime type for '%s' format, using '%s' as default", format, mime_type ));
|
||||
}
|
||||
fprintf( stdout, "Content-type: %s\r\n\r\n", mime_type );
|
||||
|
||||
/* write the stream header, if any */
|
||||
av_write_header(ofc);
|
||||
}
|
||||
|
@ -225,7 +243,6 @@ VideoStream::VideoStream( const char *filename, const char *format, int bitrate,
|
|||
SetupFormat( filename, format );
|
||||
SetupCodec( colours, width, height, bitrate, frame_rate );
|
||||
SetParameters();
|
||||
OpenStream();
|
||||
}
|
||||
|
||||
VideoStream::~VideoStream()
|
||||
|
|
|
@ -32,8 +32,16 @@
|
|||
|
||||
class VideoStream
|
||||
{
|
||||
protected:
|
||||
struct MimeData
|
||||
{
|
||||
const char *format;
|
||||
const char *mime_type;
|
||||
};
|
||||
|
||||
protected:
|
||||
static bool initialised;
|
||||
static struct MimeData mime_data[];
|
||||
|
||||
protected:
|
||||
const char *filename;
|
||||
|
@ -54,11 +62,12 @@ protected:
|
|||
void SetupFormat( const char *p_filename, const char *format );
|
||||
void SetupCodec( int colours, int width, int height, int bitrate, int frame_rate );
|
||||
void SetParameters();
|
||||
void OpenStream();
|
||||
|
||||
public:
|
||||
VideoStream( const char *filename, const char *format, int bitrate, int frame_rate, int colours, int width, int height );
|
||||
~VideoStream();
|
||||
const char *MimeType() const;
|
||||
void OpenStream();
|
||||
double EncodeFrame( uint8_t *buffer, int buffer_size, bool add_timestamp=false, unsigned int timestamp=0 );
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue