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 frameBytesFromFT [16]
static unsigned short frameBytesFromFTWideband [16]
static unsigned const uSecsPerFrame = 20000
static unsigned short frameBitsFromFT [16]
static unsigned short frameBitsFromFTWideband [16]


Define Documentation

#define AMR_MAX_FRAME_SIZE   60

Definition at line 387 of file AMRAudioRTPSource.cpp.

Referenced by AMRDeinterleavingBuffer::inputBufferSize().

#define FT_INVALID   65535

Definition at line 337 of file AMRAudioRTPSource.cpp.

#define FT_NO_DATA   15

Definition at line 228 of file AMRAudioRTPSource.cpp.

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

#define FT_SPEECH_LOST   14

Definition at line 227 of file AMRAudioRTPSource.cpp.

Referenced by RawAMRRTPSource::processSpecialHeader().

#define MAX_INTERLEAVING_GROUP_SIZE   1000

Definition at line 111 of file AMRAudioRTPSource.cpp.

Referenced by AMRAudioRTPSource::createNew().

#define MAX_NUM_CHANNELS   20

Definition at line 110 of file AMRAudioRTPSource.cpp.

Referenced by AMRAudioRTPSource::createNew().


Function Documentation

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

Definition at line 684 of file AMRAudioRTPSource.cpp.

References frameBitsFromFT, frameBitsFromFTWideband, and shiftBits().

Referenced by RawAMRRTPSource::processSpecialHeader().

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


Variable Documentation

unsigned short frameBitsFromFT[16] [static]

Initial value:

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

Definition at line 671 of file AMRAudioRTPSource.cpp.

Referenced by unpackBandwidthEfficientData().

unsigned short frameBitsFromFTWideband[16] [static]

Initial value:

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

Definition at line 677 of file AMRAudioRTPSource.cpp.

Referenced by unpackBandwidthEfficientData().

unsigned short 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 338 of file AMRAudioRTPSource.cpp.

Referenced by AMRBufferedPacket::nextEnclosedFrameSize().

unsigned short 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 344 of file AMRAudioRTPSource.cpp.

Referenced by AMRBufferedPacket::nextEnclosedFrameSize().

unsigned const uSecsPerFrame = 20000 [static]

Definition at line 457 of file AMRAudioRTPSource.cpp.

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


Generated on Tue Oct 7 15:38:21 2008 for live by  doxygen 1.5.2