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

Choon Yoong Goh choonyoong at gmail.com
Mon Sep 4 09:41:30 CEST 2006


Hi,

The attached patch adds AMR support over RTSP.

It adds checking for AMR, AMR-WB in demux_rtp_codec.cpp. And add
1-byte header to each amr frame in afterReading() of demux_rtp.cpp for
proper decoding.
-------------- next part --------------
Index: libmpdemux/demux_rtp_codec.cpp
===================================================================
--- libmpdemux/demux_rtp_codec.cpp	(revision 19666)
+++ 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 19666)
+++ libmpdemux/demux_rtp.cpp	(working copy)
@@ -438,6 +438,19 @@
 
   dp->pos = demuxer->filepos;
   demuxer->filepos += frameSize;
+  
+  // Add 1-byte header for frame decoding of AMR
+  if (strcmp(bufferQueue->tag(), "audio") == 0 &&
+      (((sh_audio_t*)demuxer->audio->sh)->format == mmioFOURCC('s','a','m','r') ||
+       ((sh_audio_t*)demuxer->audio->sh)->format == mmioFOURCC('s','a','w','b'))) {
+    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