From 407c037cfb165956fad9abf21ea9201047f58ab5 Mon Sep 17 00:00:00 2001 From: cehoyos Date: Sun, 1 Apr 2007 03:03:05 +0000 Subject: Support h264 over rtsp git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@22870 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpdemux/demux_rtp_codec.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'libmpdemux/demux_rtp_codec.cpp') diff --git a/libmpdemux/demux_rtp_codec.cpp b/libmpdemux/demux_rtp_codec.cpp index 578d4e6cc0..b2258e42ce 100644 --- a/libmpdemux/demux_rtp_codec.cpp +++ b/libmpdemux/demux_rtp_codec.cpp @@ -6,6 +6,54 @@ extern "C" { #include #include #include "stheader.h" +#include "base64.h" +} + +#ifdef USE_LIBAVCODEC +AVCodecParserContext * h264parserctx; +#endif + +// Copied from vlc +static unsigned char* parseH264ConfigStr( char const* configStr, + unsigned int& configSize ) +{ + + char *dup, *psz; + int i, i_records = 1; + + if( configSize ) + configSize = 0; + if( configStr == NULL || *configStr == '\0' ) + return NULL; + psz = dup = strdup( configStr ); + + /* Count the number of comma's */ + for( psz = dup; *psz != '\0'; ++psz ) + { + if( *psz == ',') + { + ++i_records; + *psz = '\0'; + } + } + + unsigned char *cfg = new unsigned char[5 * strlen(dup)]; + psz = dup; + for( i = 0; i < i_records; i++ ) + { + + cfg[configSize++] = 0x00; + cfg[configSize++] = 0x00; + cfg[configSize++] = 0x01; + configSize += av_base64_decode( (uint8_t*)&cfg[configSize], + psz, + 5 * strlen(dup) - 3 ); + + psz += strlen(psz)+1; + } + if( dup ) free( dup ); + + return cfg; } static void @@ -63,6 +111,15 @@ void rtpCodecInitialize_video(demuxer_t* demuxer, } else if (strcmp(subsession->codecName(), "H264") == 0) { bih->biCompression = sh_video->format = mmioFOURCC('H','2','6','4'); + unsigned int configLen = 0; + unsigned char* configData + = parseH264ConfigStr(subsession->fmtp_spropparametersets(), configLen); + sh_video->bih = bih = insertVideoExtradata(bih, configData, configLen); + delete[] configData; +#ifdef USE_LIBAVCODEC + av_register_codec_parser(&h264_parser); + h264parserctx = av_parser_init(CODEC_ID_H264); +#endif needVideoFrameRate(demuxer, subsession); } else if (strcmp(subsession->codecName(), "H261") == 0) { bih->biCompression = sh_video->format -- cgit v1.2.3