
Public Member Functions | |
| AMRDeinterleavingBuffer (unsigned numChannels, unsigned maxInterleaveGroupSize) | |
| virtual | ~AMRDeinterleavingBuffer () |
| void | deliverIncomingFrame (unsigned frameSize, RawAMRRTPSource *source, struct timeval presentationTime) |
| Boolean | retrieveFrame (unsigned char *to, unsigned maxSize, unsigned &resultFrameSize, unsigned &resultNumTruncatedBytes, u_int8_t &resultFrameHeader, struct timeval &resultPresentationTime, Boolean &resultIsSynchronized) |
| unsigned char * | inputBuffer () |
| unsigned | inputBufferSize () const |
Private Member Functions | |
| unsigned char * | createNewBuffer () |
Private Attributes | |
| unsigned | fNumChannels |
| unsigned | fMaxInterleaveGroupSize |
| FrameDescriptor * | fFrames [2] |
| unsigned char | fIncomingBankId |
| unsigned char | fIncomingBinMax |
| unsigned char | fOutgoingBinMax |
| unsigned char | fNextOutgoingBin |
| Boolean | fHaveSeenPackets |
| u_int16_t | fLastPacketSeqNumForGroup |
| unsigned char * | fInputBuffer |
| timeval | fLastRetrievedPresentationTime |
Data Structures | |
| class | FrameDescriptor |
Definition at line 389 of file AMRAudioRTPSource.cpp.
| AMRDeinterleavingBuffer::AMRDeinterleavingBuffer | ( | unsigned | numChannels, | |
| unsigned | maxInterleaveGroupSize | |||
| ) |
Definition at line 516 of file AMRAudioRTPSource.cpp.
00517 : fNumChannels(numChannels), fMaxInterleaveGroupSize(maxInterleaveGroupSize), 00518 fIncomingBankId(0), fIncomingBinMax(0), 00519 fOutgoingBinMax(0), fNextOutgoingBin(0), 00520 fHaveSeenPackets(False) { 00521 // Use two banks of descriptors - one for incoming, one for outgoing 00522 fFrames[0] = new FrameDescriptor[fMaxInterleaveGroupSize]; 00523 fFrames[1] = new FrameDescriptor[fMaxInterleaveGroupSize]; 00524 fInputBuffer = createNewBuffer(); 00525 }
| AMRDeinterleavingBuffer::~AMRDeinterleavingBuffer | ( | ) | [virtual] |
Definition at line 527 of file AMRAudioRTPSource.cpp.
References fFrames, and fInputBuffer.
00527 { 00528 delete[] fInputBuffer; 00529 delete[] fFrames[0]; delete[] fFrames[1]; 00530 }
| void AMRDeinterleavingBuffer::deliverIncomingFrame | ( | unsigned | frameSize, | |
| RawAMRRTPSource * | source, | |||
| struct timeval | presentationTime | |||
| ) |
Definition at line 533 of file AMRAudioRTPSource.cpp.
References createNewBuffer(), RTPSource::curPacketRTPSeqNum(), fFrames, fHaveSeenPackets, fIncomingBankId, fIncomingBinMax, fInputBuffer, AMRDeinterleavingBuffer::FrameDescriptor::fIsSynchronized, fLastPacketSeqNumForGroup, fMaxInterleaveGroupSize, fNextOutgoingBin, fNumChannels, fOutgoingBinMax, AMRDeinterleavingBuffer::FrameDescriptor::frameData, AMRDeinterleavingBuffer::FrameDescriptor::frameHeader, RawAMRRTPSource::frameIndex(), AMRDeinterleavingBuffer::FrameDescriptor::frameSize, FT_NO_DATA, RawAMRRTPSource::ILL(), RawAMRRTPSource::ILP(), NULL, AMRDeinterleavingBuffer::FrameDescriptor::presentationTime, seqNumLT(), RawAMRRTPSource::TOC(), RawAMRRTPSource::TOCSize(), True, and uSecsPerFrame.
Referenced by AMRDeinterleaver::afterGettingFrame1().
00534 { 00535 unsigned char const ILL = source->ILL(); 00536 unsigned char const ILP = source->ILP(); 00537 unsigned frameIndex = source->frameIndex(); 00538 unsigned short packetSeqNum = source->curPacketRTPSeqNum(); 00539 00540 // First perform a sanity check on the parameters: 00541 // (This is overkill, as the source should have already done this.) 00542 if (ILP > ILL || frameIndex == 0) { 00543 #ifdef DEBUG 00544 fprintf(stderr, "AMRDeinterleavingBuffer::deliverIncomingFrame() param sanity check failed (%d,%d,%d,%d)\n", frameSize, ILL, ILP, frameIndex); 00545 #endif 00546 exit(1); 00547 } 00548 00549 --frameIndex; // because it was incremented by the source when this frame was read 00550 u_int8_t frameHeader; 00551 if (frameIndex >= source->TOCSize()) { // sanity check 00552 frameHeader = FT_NO_DATA<<3; 00553 } else { 00554 frameHeader = source->TOC()[frameIndex]; 00555 } 00556 00557 unsigned frameBlockIndex = frameIndex/fNumChannels; 00558 unsigned frameWithinFrameBlock = frameIndex%fNumChannels; 00559 00560 // The input "presentationTime" was that of the first frame-block in this 00561 // packet. Update it for the current frame: 00562 unsigned uSecIncrement = frameBlockIndex*(ILL+1)*uSecsPerFrame; 00563 presentationTime.tv_usec += uSecIncrement; 00564 presentationTime.tv_sec += presentationTime.tv_usec/1000000; 00565 presentationTime.tv_usec = presentationTime.tv_usec%1000000; 00566 00567 // Next, check whether this packet is part of a new interleave group 00568 if (!fHaveSeenPackets 00569 || seqNumLT(fLastPacketSeqNumForGroup, packetSeqNum + frameBlockIndex)) { 00570 // We've moved to a new interleave group 00571 #ifdef DEBUG 00572 fprintf(stderr, "AMRDeinterleavingBuffer::deliverIncomingFrame(): new interleave group\n"); 00573 #endif 00574 fHaveSeenPackets = True; 00575 fLastPacketSeqNumForGroup = packetSeqNum + ILL - ILP; 00576 00577 // Switch the incoming and outgoing banks: 00578 fIncomingBankId ^= 1; 00579 unsigned char tmp = fIncomingBinMax; 00580 fIncomingBinMax = fOutgoingBinMax; 00581 fOutgoingBinMax = tmp; 00582 fNextOutgoingBin = 0; 00583 } 00584 00585 // Now move the incoming frame into the appropriate bin: 00586 unsigned const binNumber 00587 = ((ILP + frameBlockIndex*(ILL+1))*fNumChannels + frameWithinFrameBlock) 00588 % fMaxInterleaveGroupSize; // the % is for sanity 00589 #ifdef DEBUG 00590 fprintf(stderr, "AMRDeinterleavingBuffer::deliverIncomingFrame(): frameIndex %d (%d,%d) put in bank %d, bin %d (%d): size %d, header 0x%02x, presentationTime %lu.%06ld\n", frameIndex, frameBlockIndex, frameWithinFrameBlock, fIncomingBankId, binNumber, fMaxInterleaveGroupSize, frameSize, frameHeader, presentationTime.tv_sec, presentationTime.tv_usec); 00591 #endif 00592 FrameDescriptor& inBin = fFrames[fIncomingBankId][binNumber]; 00593 unsigned char* curBuffer = inBin.frameData; 00594 inBin.frameData = fInputBuffer; 00595 inBin.frameSize = frameSize; 00596 inBin.frameHeader = frameHeader; 00597 inBin.presentationTime = presentationTime; 00598 inBin.fIsSynchronized = ((RTPSource*)source)->hasBeenSynchronizedUsingRTCP(); 00599 00600 if (curBuffer == NULL) curBuffer = createNewBuffer(); 00601 fInputBuffer = curBuffer; 00602 00603 if (binNumber >= fIncomingBinMax) { 00604 fIncomingBinMax = binNumber + 1; 00605 } 00606 }
| Boolean AMRDeinterleavingBuffer::retrieveFrame | ( | unsigned char * | to, | |
| unsigned | maxSize, | |||
| unsigned & | resultFrameSize, | |||
| unsigned & | resultNumTruncatedBytes, | |||
| u_int8_t & | resultFrameHeader, | |||
| struct timeval & | resultPresentationTime, | |||
| Boolean & | resultIsSynchronized | |||
| ) |
Definition at line 609 of file AMRAudioRTPSource.cpp.
References False, fFrames, fIncomingBankId, AMRDeinterleavingBuffer::FrameDescriptor::fIsSynchronized, fLastRetrievedPresentationTime, fNextOutgoingBin, fOutgoingBinMax, AMRDeinterleavingBuffer::FrameDescriptor::frameData, AMRDeinterleavingBuffer::FrameDescriptor::frameHeader, AMRDeinterleavingBuffer::FrameDescriptor::frameSize, FT_NO_DATA, AMRDeinterleavingBuffer::FrameDescriptor::presentationTime, True, and uSecsPerFrame.
Referenced by AMRDeinterleaver::doGetNextFrame().
00613 { 00614 00615 if (fNextOutgoingBin >= fOutgoingBinMax) return False; // none left 00616 00617 FrameDescriptor& outBin = fFrames[fIncomingBankId^1][fNextOutgoingBin]; 00618 unsigned char* fromPtr = outBin.frameData; 00619 unsigned char fromSize = outBin.frameSize; 00620 outBin.frameSize = 0; // for the next time this bin is used 00621 resultIsSynchronized = outBin.fIsSynchronized; 00622 00623 // Check whether this frame is missing; if so, return a FT_NO_DATA frame: 00624 if (fromSize == 0) { 00625 resultFrameHeader = FT_NO_DATA<<3; 00626 00627 // Compute this erasure frame's presentation time via extrapolation: 00628 resultPresentationTime = fLastRetrievedPresentationTime; 00629 resultPresentationTime.tv_usec += uSecsPerFrame; 00630 if (resultPresentationTime.tv_usec >= 1000000) { 00631 ++resultPresentationTime.tv_sec; 00632 resultPresentationTime.tv_usec -= 1000000; 00633 } 00634 } else { 00635 // Normal case - a frame exists: 00636 resultFrameHeader = outBin.frameHeader; 00637 resultPresentationTime = outBin.presentationTime; 00638 } 00639 00640 fLastRetrievedPresentationTime = resultPresentationTime; 00641 00642 if (fromSize > maxSize) { 00643 resultNumTruncatedBytes = fromSize - maxSize; 00644 resultFrameSize = maxSize; 00645 } else { 00646 resultNumTruncatedBytes = 0; 00647 resultFrameSize = fromSize; 00648 } 00649 memmove(to, fromPtr, resultFrameSize); 00650 #ifdef DEBUG 00651 fprintf(stderr, "AMRDeinterleavingBuffer::retrieveFrame(): from bank %d, bin %d: size %d, header 0x%02x, presentationTime %lu.%06ld\n", fIncomingBankId^1, fNextOutgoingBin, resultFrameSize, resultFrameHeader, resultPresentationTime.tv_sec, resultPresentationTime.tv_usec); 00652 #endif 00653 00654 ++fNextOutgoingBin; 00655 return True; 00656 }
| unsigned char* AMRDeinterleavingBuffer::inputBuffer | ( | ) | [inline] |
Definition at line 402 of file AMRAudioRTPSource.cpp.
Referenced by AMRDeinterleaver::doGetNextFrame().
00402 { return fInputBuffer; }
| unsigned AMRDeinterleavingBuffer::inputBufferSize | ( | ) | const [inline] |
Definition at line 403 of file AMRAudioRTPSource.cpp.
References AMR_MAX_FRAME_SIZE.
Referenced by createNewBuffer(), and AMRDeinterleaver::doGetNextFrame().
00403 { return AMR_MAX_FRAME_SIZE; }
| unsigned char * AMRDeinterleavingBuffer::createNewBuffer | ( | ) | [private] |
Definition at line 658 of file AMRAudioRTPSource.cpp.
References inputBufferSize().
Referenced by deliverIncomingFrame().
00658 { 00659 return new unsigned char[inputBufferSize()]; 00660 }
unsigned AMRDeinterleavingBuffer::fNumChannels [private] |
unsigned AMRDeinterleavingBuffer::fMaxInterleaveGroupSize [private] |
FrameDescriptor* AMRDeinterleavingBuffer::fFrames[2] [private] |
Definition at line 421 of file AMRAudioRTPSource.cpp.
Referenced by deliverIncomingFrame(), retrieveFrame(), and ~AMRDeinterleavingBuffer().
unsigned char AMRDeinterleavingBuffer::fIncomingBankId [private] |
Definition at line 422 of file AMRAudioRTPSource.cpp.
Referenced by deliverIncomingFrame(), and retrieveFrame().
unsigned char AMRDeinterleavingBuffer::fIncomingBinMax [private] |
unsigned char AMRDeinterleavingBuffer::fOutgoingBinMax [private] |
Definition at line 424 of file AMRAudioRTPSource.cpp.
Referenced by deliverIncomingFrame(), and retrieveFrame().
unsigned char AMRDeinterleavingBuffer::fNextOutgoingBin [private] |
Definition at line 425 of file AMRAudioRTPSource.cpp.
Referenced by deliverIncomingFrame(), and retrieveFrame().
u_int16_t AMRDeinterleavingBuffer::fLastPacketSeqNumForGroup [private] |
unsigned char* AMRDeinterleavingBuffer::fInputBuffer [private] |
Definition at line 428 of file AMRAudioRTPSource.cpp.
Referenced by deliverIncomingFrame(), and ~AMRDeinterleavingBuffer().
struct timeval AMRDeinterleavingBuffer::fLastRetrievedPresentationTime [read, private] |
1.5.2