[MPlayer-cvslog] r22481 - in trunk/libmpdemux: demux_rtp.cpp demux_rtp_codec.cpp

nicodvb subversion at mplayerhq.hu
Tue Mar 6 23:53:52 CET 2007


Author: nicodvb
Date: Tue Mar  6 23:53:52 2007
New Revision: 22481

Modified:
   trunk/libmpdemux/demux_rtp.cpp
   trunk/libmpdemux/demux_rtp_codec.cpp

Log:
support for AMR; it works inserting in the first byte of the demux_packet
a 1-byte header that live555 seems to be stripping for some reason, although according
to the specs it should be there. Patch by Carl Eugen Hoyos.



Modified: trunk/libmpdemux/demux_rtp.cpp
==============================================================================
--- trunk/libmpdemux/demux_rtp.cpp	(original)
+++ trunk/libmpdemux/demux_rtp.cpp	Tue Mar  6 23:53:52 2007
@@ -362,6 +362,7 @@ static void afterReading(void* clientDat
 			 unsigned /*numTruncatedBytes*/,
 			 struct timeval presentationTime,
 			 unsigned /*durationInMicroseconds*/) {
+  int headersize = 0;
   if (frameSize >= MAX_RTP_FRAME_SIZE) {
     fprintf(stderr, "Saw an input frame too large (>=%d).  Increase MAX_RTP_FRAME_SIZE in \"demux_rtp.cpp\".\n",
 	    MAX_RTP_FRAME_SIZE);
@@ -372,8 +373,11 @@ static void afterReading(void* clientDat
 
   if (frameSize > 0) demuxer->stream->eof = 0;
 
+  if (bufferQueue->readSource()->isAMRAudioSource())
+    headersize = 1;
+
   demux_packet_t* dp = bufferQueue->dp;
-  resize_demux_packet(dp, frameSize);
+  resize_demux_packet(dp, frameSize + headersize);
 
   // Set the packet's presentation time stamp, depending on whether or
   // not our RTP source's timestamps have been synchronized yet: 
@@ -432,10 +436,13 @@ static demux_packet_t* getBuffer(demuxer
   //  the demuxer's 'priv' field)
   RTPState* rtpState = (RTPState*)(demuxer->priv);
   ReadBufferQueue* bufferQueue = NULL;
+  int amr = 0;
   if (ds == demuxer->video) {
     bufferQueue = rtpState->videoBufferQueue;
   } else if (ds == demuxer->audio) {
     bufferQueue = rtpState->audioBufferQueue;
+    if (bufferQueue->readSource()->isAMRAudioSource())
+      amr = 1;
   } else {
     fprintf(stderr, "(demux_rtp)getBuffer: internal error: unknown stream\n");
     return NULL;
@@ -463,7 +470,7 @@ static demux_packet_t* getBuffer(demuxer
 
   // Schedule the read operation:
   bufferQueue->blockingFlag = 0;
-  bufferQueue->readSource()->getNextFrame(dp->buffer, MAX_RTP_FRAME_SIZE,
+  bufferQueue->readSource()->getNextFrame(&dp->buffer[amr], MAX_RTP_FRAME_SIZE - amr,
 					  afterReading, bufferQueue,
 					  onSourceClosure, bufferQueue);
   // Block ourselves until data becomes available:
@@ -471,6 +478,10 @@ static demux_packet_t* getBuffer(demuxer
     = bufferQueue->readSource()->envir().taskScheduler();
   scheduler.doEventLoop(&bufferQueue->blockingFlag);
 
+  if (amr)
+    dp->buffer[0] =
+        ((AMRAudioSource*)bufferQueue->readSource())->lastFrameHeader();
+
   // Set the "ptsBehind" result parameter:
   if (bufferQueue->prevPacketPTS != 0.0
       && bufferQueue->prevPacketWasSynchronized

Modified: trunk/libmpdemux/demux_rtp_codec.cpp
==============================================================================
--- trunk/libmpdemux/demux_rtp_codec.cpp	(original)
+++ trunk/libmpdemux/demux_rtp_codec.cpp	Tue Mar  6 23:53:52 2007
@@ -184,6 +184,10 @@ void rtpCodecInitialize_audio(demuxer_t*
     wf->nBlockAlign = 1;
     wf->wBitsPerSample = 8;
     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(), "GSM") == 0) {
     wf->wFormatTag = sh_audio->format = mmioFOURCC('a','g','s','m');
     wf->nAvgBytesPerSec = 1650;



More information about the MPlayer-cvslog mailing list