[MPlayer-dev-eng] Re: [PATCH] Add AMR support over RTSP

Choon Yoong Goh choonyoong at gmail.com
Tue Sep 5 07:58:31 CEST 2006


Hi,

Updated patch. Uses isAMRAudioSource() for checking.
-------------- next part --------------
Index: libmpdemux/demux_rtp_codec.cpp
===================================================================
--- libmpdemux/demux_rtp_codec.cpp	(revision 19679)
+++ libmpdemux/demux_rtp_codec.cpp	(working copy)
@@ -149,6 +149,10 @@
     wf->nBlockAlign = 33;
     wf->wBitsPerSample = 16;
     wf->cbSize = 0;
+  } else if (strcmp(subsession->codecName(), "AMR") == 0) {
+    wf->wFormatTag = sh_audio->format = mmioFOURCC('s','a','m','r');
+  } else if (strcmp(subsession->codecName(), "AMR-WB") == 0) {
+    wf->wFormatTag = sh_audio->format = mmioFOURCC('s','a','w','b');
   } else if (strcmp(subsession->codecName(), "QCELP") == 0) {
     wf->wFormatTag = sh_audio->format = mmioFOURCC('Q','c','l','p');
     wf->nAvgBytesPerSec = 1750;
Index: libmpdemux/demux_rtp.cpp
===================================================================
--- libmpdemux/demux_rtp.cpp	(revision 19679)
+++ libmpdemux/demux_rtp.cpp	(working copy)
@@ -438,6 +438,17 @@
 
   dp->pos = demuxer->filepos;
   demuxer->filepos += frameSize;
+  
+  // Add 1-byte header for frame decoding of AMR
+  if (bufferQueue->readSource()->isAMRAudioSource()) {
+    AMRAudioSource *amrSource = (AMRAudioSource*)bufferQueue->readSource();
+    unsigned char* buffer = (unsigned char *)malloc(frameSize);
+    memcpy( buffer, dp->buffer, frameSize );
+    resize_demux_packet(dp, frameSize + 1);
+    dp->buffer[0] = amrSource->lastFrameHeader();
+    memcpy( dp->buffer + 1, buffer, frameSize);
+    free(buffer);
+  }
 
   // Signal any pending 'doEventLoop()' call on this queue:
   bufferQueue->blockingFlag = ~0;


More information about the MPlayer-dev-eng mailing list