diff options
author | cehoyos <cehoyos@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2007-04-01 03:03:05 +0000 |
---|---|---|
committer | cehoyos <cehoyos@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2007-04-01 03:03:05 +0000 |
commit | 407c037cfb165956fad9abf21ea9201047f58ab5 (patch) | |
tree | 2d68756c0cb2f646f7acd65c5dbbd803af65110d /libmpdemux/demux_rtp_codec.cpp | |
parent | 46fbb1bd66b8aff9aea086eeb3c6e309420ce704 (diff) | |
download | mpv-407c037cfb165956fad9abf21ea9201047f58ab5.tar.bz2 mpv-407c037cfb165956fad9abf21ea9201047f58ab5.tar.xz |
Support h264 over rtsp
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@22870 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux/demux_rtp_codec.cpp')
-rw-r--r-- | libmpdemux/demux_rtp_codec.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
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 <limits.h> #include <math.h> #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 |