Index: libmpdemux/demux_rtp_codec.cpp =================================================================== --- libmpdemux/demux_rtp_codec.cpp (Revision 22495) +++ libmpdemux/demux_rtp_codec.cpp (Arbeitskopie) @@ -6,8 +6,54 @@ #include #include #include "stheader.h" +int av_base64_decode(uint8_t * out, const char *in, int out_length); } +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 22495) +++ 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,9 @@ int amr = 0; if (ds == demuxer->video) { bufferQueue = rtpState->videoBufferQueue; + if (((sh_video_t*)ds->sh)->format == mmioFOURCC('H','2','6','4')) amr = 3; +//FIXME The following does not work - even if avcodec was included ;-) +//if(sh_video->context)((AVCodecContext*)sh_video->context)->flags2 |= CODEC_FLAG2_CHUNKS; } else if (ds == demuxer->audio) { bufferQueue = rtpState->audioBufferQueue; if (bufferQueue->readSource()->isAMRAudioSource()) @@ -468,6 +474,12 @@ bufferQueue->dp = dp; if (dp == NULL) return NULL; + if (amr == 3) { + dp->buffer[0]=0x00; + dp->buffer[1]=0x00; + dp->buffer[2]=0x01; + } + // Schedule the read operation: bufferQueue->blockingFlag = 0; bufferQueue->readSource()->getNextFrame(&dp->buffer[amr], MAX_RTP_FRAME_SIZE - amr, @@ -478,7 +490,7 @@ = bufferQueue->readSource()->envir().taskScheduler(); scheduler.doEventLoop(&bufferQueue->blockingFlag); - if (amr) + if (amr == 1) dp->buffer[0] = ((AMRAudioSource*)bufferQueue->readSource())->lastFrameHeader(); Index: libavcodec/h264.c =================================================================== --- libavcodec/h264.c (Revision 8301) +++ libavcodec/h264.c (Arbeitskopie) @@ -8268,6 +8268,7 @@ MpegEncContext *s = &h->s; AVFrame *pict = data; int buf_index; +avctx->flags2 |= CODEC_FLAG2_CHUNKS; s->flags= avctx->flags; s->flags2= avctx->flags2;