Index: libmpdemux/demux_rtp_codec.cpp =================================================================== --- libmpdemux/demux_rtp_codec.cpp (Revision 22766) +++ libmpdemux/demux_rtp_codec.cpp (Arbeitskopie) @@ -6,8 +6,54 @@ #include #include #include "stheader.h" +#include "base64.h" + +extern int correct_pts; } +// 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 needVideoFrameRate(demuxer_t* demuxer, MediaSubsession* subsession); // forward static Boolean @@ -63,6 +109,12 @@ } 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; + correct_pts = 1; needVideoFrameRate(demuxer, subsession); } else if (strcmp(subsession->codecName(), "H261") == 0) { bih->biCompression = sh_video->format Index: libmpdemux/demux_rtp.cpp =================================================================== --- libmpdemux/demux_rtp.cpp (Revision 22766) +++ libmpdemux/demux_rtp.cpp (Arbeitskopie) @@ -8,6 +8,12 @@ #endif #include "demux_rtp.h" #include "stheader.h" +#include "codec-cfg.h" +#ifdef USE_LIBAVCODEC_SO +#include +#elif defined(USE_LIBAVCODEC) +#include "libavcodec/avcodec.h" +#endif } #include "demux_rtp_internal.h" @@ -373,10 +379,18 @@ if (frameSize > 0) demuxer->stream->eof = 0; + demux_packet_t* dp = bufferQueue->dp; + if (bufferQueue->readSource()->isAMRAudioSource()) headersize = 1; + else if (bufferQueue == rtpState->videoBufferQueue && + ((sh_video_t*)demuxer->video->sh)->format == mmioFOURCC('H','2','6','4')) { + dp->buffer[0]=0x00; + dp->buffer[1]=0x00; + dp->buffer[2]=0x01; + headersize = 3; + } - demux_packet_t* dp = bufferQueue->dp; resize_demux_packet(dp, frameSize + headersize); // Set the packet's presentation time stamp, depending on whether or @@ -439,6 +453,15 @@ int headersize = 0; if (ds == demuxer->video) { bufferQueue = rtpState->videoBufferQueue; + if (((sh_video_t*)ds->sh)->format == mmioFOURCC('H','2','6','4')) + headersize = 3; +#ifdef USE_LIBAVCODEC + if (((sh_video_t*)ds->sh)->context && + ((sh_video_t*)ds->sh)->codec && + !strcmp(((sh_video_t*)ds->sh)->codec->name, "ffh264")) + (*(AVCodecContext**)((sh_video_t*)ds->sh)->context)->flags2 |= + CODEC_FLAG2_CHUNKS; +#endif } else if (ds == demuxer->audio) { bufferQueue = rtpState->audioBufferQueue; if (bufferQueue->readSource()->isAMRAudioSource())