Index: libmpdemux/demux_rtp.cpp =================================================================== --- libmpdemux/demux_rtp.cpp (Revision 22754) +++ libmpdemux/demux_rtp.cpp (Arbeitskopie) @@ -375,6 +375,9 @@ if (bufferQueue->readSource()->isAMRAudioSource()) headersize = 1; + else if (rtpState->videoBufferQueue == bufferQueue && + ((sh_video_t*)demuxer->video->sh)->format == mmioFOURCC('H','2','6','4')) + headersize = 3; demux_packet_t* dp = bufferQueue->dp; resize_demux_packet(dp, frameSize + headersize); @@ -439,6 +442,11 @@ int headersize = 0; if (ds == demuxer->video) { bufferQueue = rtpState->videoBufferQueue; + if (((sh_video_t*)ds->sh)->format == mmioFOURCC('H','2','6','4')) + headersize = 3; + if (((sh_video_t*)ds->sh)->context) + (*(AVCodecContext**)((sh_video_t*)ds->sh)->context)->flags2 |= + CODEC_FLAG2_CHUNKS; } else if (ds == demuxer->audio) { bufferQueue = rtpState->audioBufferQueue; if (bufferQueue->readSource()->isAMRAudioSource()) @@ -481,6 +489,11 @@ if (headersize == 1) // amr dp->buffer[0] = ((AMRAudioSource*)bufferQueue->readSource())->lastFrameHeader(); + else if (headersize == 3) { // h264 + dp->buffer[0]=0x00; + dp->buffer[1]=0x00; + dp->buffer[2]=0x01; + } // Set the "ptsBehind" result parameter: if (bufferQueue->prevPacketPTS != 0.0 Index: libmpdemux/demux_rtp_codec.cpp =================================================================== --- libmpdemux/demux_rtp_codec.cpp (Revision 22754) +++ 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_internal.h =================================================================== --- libmpdemux/demux_rtp_internal.h (Revision 22754) +++ libmpdemux/demux_rtp_internal.h (Arbeitskopie) @@ -10,6 +10,11 @@ #ifndef __DEMUXER_H #include "demuxer.h" #endif +#ifdef USE_LIBAVCODEC_SO +#include +#elif defined(USE_LIBAVCODEC) +#include "libavcodec/avcodec.h" +#endif } #ifndef _LIVEMEDIA_HH