Fixes to work with latest ffmpeg

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@3338 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
stan 2011-05-15 20:38:51 +00:00
parent 70505b5f6a
commit b3b715e022
6 changed files with 81 additions and 3 deletions

View File

@ -102,7 +102,11 @@ int FfmpegCamera::PrimeCapture()
mVideoStreamId = -1;
for ( int i=0; i < mFormatContext->nb_streams; i++ )
{
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,2,1)
if ( mFormatContext->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO )
#else
if ( mFormatContext->streams[i]->codec->codec_type == CODEC_TYPE_VIDEO )
#endif
{
mVideoStreamId = i;
break;

View File

@ -90,7 +90,11 @@ void VideoStream::SetupCodec( int colours, int width, int height, int bitrate, d
#endif
c->codec_id = of->video_codec;
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,2,1)
c->codec_type = AVMEDIA_TYPE_VIDEO;
#else
c->codec_type = CODEC_TYPE_VIDEO;
#endif
/* put sample parameters */
c->bit_rate = bitrate;
@ -217,7 +221,11 @@ void VideoStream::OpenStream()
/* open the output file, if needed */
if ( !(of->flags & AVFMT_NOFILE) )
{
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,2,1)
if ( avio_open(&ofc->pb, filename, URL_WRONLY) < 0 )
#else
if ( url_fopen(&ofc->pb, filename, URL_WRONLY) < 0 )
#endif
{
Fatal( "Could not open '%s'", filename );
}
@ -281,7 +289,11 @@ VideoStream::~VideoStream()
{
/* close the output file */
#if ZM_FFMPEG_SVN
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,2,1)
avio_close(ofc->pb);
#else
url_fclose(ofc->pb);
#endif
#else
url_fclose(&ofc->pb);
#endif
@ -343,7 +355,11 @@ double VideoStream::EncodeFrame( uint8_t *buffer, int buffer_size, bool add_time
AVPacket pkt;
av_init_packet( &pkt );
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,2,1)
pkt.flags |= AV_PKT_FLAG_KEY;
#else
pkt.flags |= PKT_FLAG_KEY;
#endif
pkt.stream_index = ost->index;
pkt.data = (uint8_t *)opicture_ptr;
pkt.size = sizeof(AVPicture);
@ -370,7 +386,11 @@ double VideoStream::EncodeFrame( uint8_t *buffer, int buffer_size, bool add_time
pkt.pts= av_rescale_q( c->coded_frame->pts, c->time_base, ost->time_base );
#endif
if(c->coded_frame->key_frame)
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,2,1)
pkt.flags |= AV_PKT_FLAG_KEY;
#else
pkt.flags |= PKT_FLAG_KEY;
#endif
pkt.stream_index = ost->index;
pkt.data = video_outbuf;
pkt.size = out_size;

View File

@ -124,7 +124,11 @@ int RemoteCameraRtsp::PrimeCapture()
// Find the first video stream
int videoStream=-1;
for ( int i = 0; i < formatContext->nb_streams; i++ )
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,2,1)
if ( formatContext->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO )
#else
if ( formatContext->streams[i]->codec->codec_type == CODEC_TYPE_VIDEO )
#endif
{
videoStream = i;
break;

View File

@ -335,7 +335,11 @@ int RtspThread::run()
for ( int i = 0; i < mFormatContext->nb_streams; i++ )
{
SessionDescriptor::MediaDescriptor *mediaDesc = sessDesc->getStream( i );
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,2,1)
if ( mFormatContext->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO )
#else
if ( mFormatContext->streams[i]->codec->codec_type == CODEC_TYPE_VIDEO )
#endif
{
trackUrl += "/"+mediaDesc->getControlUrl();
rtpClock = mediaDesc->getClock();

View File

@ -23,6 +23,44 @@
#include "zm_sdp.h"
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,2,1)
SessionDescriptor::StaticPayloadDesc SessionDescriptor::smStaticPayloads[] = {
{ 0, "PCMU", AVMEDIA_TYPE_AUDIO, CODEC_ID_PCM_MULAW, 8000, 1 },
{ 3, "GSM", AVMEDIA_TYPE_AUDIO, CODEC_ID_NONE, 8000, 1 },
{ 4, "G723", AVMEDIA_TYPE_AUDIO, CODEC_ID_NONE, 8000, 1 },
{ 5, "DVI4", AVMEDIA_TYPE_AUDIO, CODEC_ID_NONE, 8000, 1 },
{ 6, "DVI4", AVMEDIA_TYPE_AUDIO, CODEC_ID_NONE, 16000, 1 },
{ 7, "LPC", AVMEDIA_TYPE_AUDIO, CODEC_ID_NONE, 8000, 1 },
{ 8, "PCMA", AVMEDIA_TYPE_AUDIO, CODEC_ID_PCM_ALAW, 8000, 1 },
{ 9, "G722", AVMEDIA_TYPE_AUDIO, CODEC_ID_NONE, 8000, 1 },
{ 10, "L16", AVMEDIA_TYPE_AUDIO, CODEC_ID_PCM_S16BE, 44100, 2 },
{ 11, "L16", AVMEDIA_TYPE_AUDIO, CODEC_ID_PCM_S16BE, 44100, 1 },
{ 12, "QCELP", AVMEDIA_TYPE_AUDIO, CODEC_ID_QCELP, 8000, 1 },
{ 13, "CN", AVMEDIA_TYPE_AUDIO, CODEC_ID_NONE, 8000, 1 },
{ 14, "MPA", AVMEDIA_TYPE_AUDIO, CODEC_ID_MP2, -1, -1 },
{ 14, "MPA", AVMEDIA_TYPE_AUDIO, CODEC_ID_MP3, -1, -1 },
{ 15, "G728", AVMEDIA_TYPE_AUDIO, CODEC_ID_NONE, 8000, 1 },
{ 16, "DVI4", AVMEDIA_TYPE_AUDIO, CODEC_ID_NONE, 11025, 1 },
{ 17, "DVI4", AVMEDIA_TYPE_AUDIO, CODEC_ID_NONE, 22050, 1 },
{ 18, "G729", AVMEDIA_TYPE_AUDIO, CODEC_ID_NONE, 8000, 1 },
{ 25, "CelB", AVMEDIA_TYPE_VIDEO, CODEC_ID_NONE, 90000, -1 },
{ 26, "JPEG", AVMEDIA_TYPE_VIDEO, CODEC_ID_MJPEG, 90000, -1 },
{ 28, "nv", AVMEDIA_TYPE_VIDEO, CODEC_ID_NONE, 90000, -1 },
{ 31, "H261", AVMEDIA_TYPE_VIDEO, CODEC_ID_H261, 90000, -1 },
{ 32, "MPV", AVMEDIA_TYPE_VIDEO, CODEC_ID_MPEG1VIDEO, 90000, -1 },
{ 32, "MPV", AVMEDIA_TYPE_VIDEO, CODEC_ID_MPEG2VIDEO, 90000, -1 },
{ 33, "MP2T", AVMEDIA_TYPE_DATA, CODEC_ID_MPEG2TS, 90000, -1 },
{ 34, "H263", AVMEDIA_TYPE_VIDEO, CODEC_ID_H263, 90000, -1 },
{ -1, "", AVMEDIA_TYPE_UNKNOWN, CODEC_ID_NONE, -1, -1 }
};
SessionDescriptor::DynamicPayloadDesc SessionDescriptor::smDynamicPayloads[] = {
{ "MP4V-ES", AVMEDIA_TYPE_VIDEO, CODEC_ID_MPEG4 },
{ "mpeg4-generic", AVMEDIA_TYPE_AUDIO, CODEC_ID_AAC },
{ "H264", AVMEDIA_TYPE_VIDEO, CODEC_ID_H264 },
{ "AMR", AVMEDIA_TYPE_AUDIO, CODEC_ID_AMR_NB }
};
#else
SessionDescriptor::StaticPayloadDesc SessionDescriptor::smStaticPayloads[] = {
{ 0, "PCMU", CODEC_TYPE_AUDIO, CODEC_ID_PCM_MULAW, 8000, 1 },
{ 3, "GSM", CODEC_TYPE_AUDIO, CODEC_ID_NONE, 8000, 1 },
@ -59,6 +97,7 @@ SessionDescriptor::DynamicPayloadDesc SessionDescriptor::smDynamicPayloads[] = {
{ "H264", CODEC_TYPE_VIDEO, CODEC_ID_H264 },
{ "AMR", CODEC_TYPE_AUDIO, CODEC_ID_AMR_NB }
};
#endif
SessionDescriptor::ConnInfo::ConnInfo( const std::string &connInfo ) :
mTtl( 16 ),
@ -298,10 +337,17 @@ AVFormatContext *SessionDescriptor::generateFormatContext() const
AVStream *stream = av_new_stream( formatContext, i );
Debug( 1, "Looking for codec for %s payload type %d / %s", mediaDesc->getType().c_str(), mediaDesc->getPayloadType(), mediaDesc->getPayloadDesc().c_str() );
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,2,1)
if ( mediaDesc->getType() == "video" )
stream->codec->codec_type = AVMEDIA_TYPE_VIDEO;
else if ( mediaDesc->getType() == "audio" )
stream->codec->codec_type = AVMEDIA_TYPE_AUDIO;
#else
if ( mediaDesc->getType() == "video" )
stream->codec->codec_type = CODEC_TYPE_VIDEO;
else if ( mediaDesc->getType() == "audio" )
stream->codec->codec_type = CODEC_TYPE_AUDIO;
#endif
if ( mediaDesc->getPayloadType() < PAYLOAD_TYPE_DYNAMIC )
{

View File

@ -40,7 +40,7 @@ protected:
{
int payloadType;
const char payloadName[6];
enum CodecType codecType;
enum AVMediaType codecType;
enum CodecID codecId;
int clockRate;
int autoChannels;
@ -49,7 +49,7 @@ protected:
struct DynamicPayloadDesc
{
const char payloadName[32];
enum CodecType codecType;
enum AVMediaType codecType;
enum CodecID codecId;
//int clockRate;
//int autoChannels;