liveMedia/AMRAudioRTPSource.cpp File Reference

#include "AMRAudioRTPSource.hh"
#include "MultiFramedRTPSource.hh"
#include "BitVector.hh"
#include <string.h>
#include <stdlib.h>

Include dependency graph for AMRAudioRTPSource.cpp:

Go to the source code of this file.

Data Structures

class  RawAMRRTPSource
class  AMRDeinterleaver
class  AMRBufferedPacket
class  AMRBufferedPacketFactory
class  AMRDeinterleavingBuffer
class  AMRDeinterleavingBuffer::FrameDescriptor

Defines

#define MAX_NUM_CHANNELS   20
#define MAX_INTERLEAVING_GROUP_SIZE   1000
#define FT_SPEECH_LOST   14
#define FT_NO_DATA   15
#define FT_INVALID   65535
#define AMR_MAX_FRAME_SIZE   60

Functions

static void unpackBandwidthEfficientData (BufferedPacket *packet, Boolean isWideband)

Variables

static unsigned short const frameBytesFromFT [16]
static unsigned short const frameBytesFromFTWideband [16]
static unsigned const uSecsPerFrame = 20000
static unsigned short const frameBitsFromFT [16]
static unsigned short const frameBitsFromFTWideband [16]


Define Documentation

#define AMR_MAX_FRAME_SIZE   60

Definition at line 378 of file AMRAudioRTPSource.cpp.

Referenced by AMRDeinterleavingBuffer::inputBufferSize().

#define FT_INVALID   65535

Definition at line 328 of file AMRAudioRTPSource.cpp.

#define FT_NO_DATA   15

Definition at line 226 of file AMRAudioRTPSource.cpp.

Referenced by AMRDeinterleavingBuffer::deliverIncomingFrame(), RawAMRRTPSource::processSpecialHeader(), and AMRDeinterleavingBuffer::retrieveFrame().

#define FT_SPEECH_LOST   14

Definition at line 225 of file AMRAudioRTPSource.cpp.

Referenced by RawAMRRTPSource::processSpecialHeader().

#define MAX_INTERLEAVING_GROUP_SIZE   1000

Definition at line 110 of file AMRAudioRTPSource.cpp.

Referenced by AMRAudioRTPSource::createNew().

#define MAX_NUM_CHANNELS   20

Definition at line 109 of file AMRAudioRTPSource.cpp.

Referenced by AMRAudioRTPSource::createNew().


Function Documentation

static void unpackBandwidthEfficientData ( BufferedPacket packet,
Boolean  isWideband 
) [static]

Definition at line 688 of file AMRAudioRTPSource.cpp.

References frameBitsFromFT, frameBitsFromFTWideband, and shiftBits().

Referenced by RawAMRRTPSource::processSpecialHeader().

00689                                                              {
00690 #ifdef DEBUG
00691   fprintf(stderr, "Unpacking 'bandwidth-efficient' payload (%d bytes):\n", packet->dataSize());
00692   for (unsigned j = 0; j < packet->dataSize(); ++j) {
00693     fprintf(stderr, "%02x:", (packet->data())[j]);
00694   }
00695   fprintf(stderr, "\n");
00696 #endif
00697   BitVector fromBV(packet->data(), 0, 8*packet->dataSize());
00698 
00699   unsigned const toBufferSize = 2*packet->dataSize(); // conservatively large
00700   unsigned char* toBuffer = new unsigned char[toBufferSize];
00701   unsigned toCount = 0;
00702 
00703   // Begin with the payload header:
00704   unsigned CMR = fromBV.getBits(4);
00705   toBuffer[toCount++] = CMR << 4;
00706 
00707   // Then, run through and unpack the TOC entries:
00708   while (1) {
00709     unsigned toc = fromBV.getBits(6);
00710     toBuffer[toCount++] = toc << 2;
00711 
00712     if ((toc&0x20) == 0) break; // the F bit is 0
00713   }
00714 
00715   // Then, using the TOC data, unpack each frame payload:
00716   unsigned const tocSize = toCount - 1;
00717   for (unsigned i = 1; i <= tocSize; ++i) {
00718     unsigned char tocByte = toBuffer[i];
00719     unsigned char const FT = (tocByte&0x78) >> 3;
00720     unsigned short frameSizeBits
00721       = isWideband ? frameBitsFromFTWideband[FT] : frameBitsFromFT[FT];
00722     unsigned short frameSizeBytes = (frameSizeBits+7)/8;
00723 
00724     shiftBits(&toBuffer[toCount], 0, // to
00725               packet->data(), fromBV.curBitIndex(), // from
00726               frameSizeBits // num bits
00727               );
00728 #ifdef DEBUG
00729     if (frameSizeBits > fromBV.numBitsRemaining()) {
00730       fprintf(stderr, "\tWarning: Unpacking frame %d of %d: want %d bits, but only %d are available!\n", i, tocSize, frameSizeBits, fromBV.numBitsRemaining());
00731     }
00732 #endif
00733     fromBV.skipBits(frameSizeBits);
00734     toCount += frameSizeBytes;
00735   }
00736 
00737 #ifdef DEBUG
00738   if (fromBV.numBitsRemaining() > 7) {
00739     fprintf(stderr, "\tWarning: %d bits remain unused!\n", fromBV.numBitsRemaining());
00740   }
00741 #endif
00742 
00743   // Finally, replace the current packet data with the unpacked data:
00744   packet->removePadding(packet->dataSize()); // throws away current packet data
00745   packet->appendData(toBuffer, toCount);
00746   delete[] toBuffer;
00747 }


Variable Documentation

unsigned short const frameBitsFromFT[16] [static]

Initial value:

 {
  95, 103, 118, 134,
  148, 159, 204, 244,
  39, 0, 0, 0,
  0, 0, 0, 0
}

Definition at line 675 of file AMRAudioRTPSource.cpp.

Referenced by unpackBandwidthEfficientData().

unsigned short const frameBitsFromFTWideband[16] [static]

Initial value:

 {
  132, 177, 253, 285,
  317, 365, 397, 461,
  477, 40, 0, 0,
  0, 0, 0, 0
}

Definition at line 681 of file AMRAudioRTPSource.cpp.

Referenced by unpackBandwidthEfficientData().

unsigned short const frameBytesFromFT[16] [static]

Initial value:

 {
  12, 13, 15, 17,
  19, 20, 26, 31,
  5, FT_INVALID, FT_INVALID, FT_INVALID,
  FT_INVALID, FT_INVALID, FT_INVALID, 0
}

Definition at line 329 of file AMRAudioRTPSource.cpp.

Referenced by AMRBufferedPacket::nextEnclosedFrameSize().

unsigned short const frameBytesFromFTWideband[16] [static]

Initial value:

 {
  17, 23, 32, 36,
  40, 46, 50, 58,
  60, 5, FT_INVALID, FT_INVALID,
  FT_INVALID, FT_INVALID, 0, 0
}

Definition at line 335 of file AMRAudioRTPSource.cpp.

Referenced by AMRBufferedPacket::nextEnclosedFrameSize().

unsigned const uSecsPerFrame = 20000 [static]

Definition at line 450 of file AMRAudioRTPSource.cpp.

Referenced by QCELPDeinterleavingBuffer::deliverIncomingFrame(), AMRDeinterleavingBuffer::deliverIncomingFrame(), QCELPDeinterleaver::doGetNextFrame(), AMRDeinterleaver::doGetNextFrame(), QCELPDeinterleavingBuffer::retrieveFrame(), and AMRDeinterleavingBuffer::retrieveFrame().


Generated on Thu Feb 2 23:51:46 2012 for live by  doxygen 1.5.2