
Public Member Functions | |
| QCELPDeinterleavingBuffer () | |
| virtual | ~QCELPDeinterleavingBuffer () |
| void | deliverIncomingFrame (unsigned frameSize, unsigned char interleaveL, unsigned char interleaveN, unsigned char frameIndex, unsigned short packetSeqNum, struct timeval presentationTime) |
| Boolean | retrieveFrame (unsigned char *to, unsigned maxSize, unsigned &resultFrameSize, unsigned &resultNumTruncatedBytes, struct timeval &resultPresentationTime) |
| unsigned char * | inputBuffer () |
| unsigned | inputBufferSize () const |
Private Attributes | |
| FrameDescriptor | fFrames [QCELP_MAX_INTERLEAVE_GROUP_SIZE][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 263 of file QCELPAudioRTPSource.cpp.
| QCELPDeinterleavingBuffer::QCELPDeinterleavingBuffer | ( | ) |
Definition at line 385 of file QCELPAudioRTPSource.cpp.
References fInputBuffer, and QCELP_MAX_FRAME_SIZE.
00386 : fIncomingBankId(0), fIncomingBinMax(0), 00387 fOutgoingBinMax(0), fNextOutgoingBin(0), 00388 fHaveSeenPackets(False) { 00389 fInputBuffer = new unsigned char[QCELP_MAX_FRAME_SIZE]; 00390 }
| QCELPDeinterleavingBuffer::~QCELPDeinterleavingBuffer | ( | ) | [virtual] |
Definition at line 392 of file QCELPAudioRTPSource.cpp.
References fInputBuffer.
00392 { 00393 delete[] fInputBuffer; 00394 }
| void QCELPDeinterleavingBuffer::deliverIncomingFrame | ( | unsigned | frameSize, | |
| unsigned char | interleaveL, | |||
| unsigned char | interleaveN, | |||
| unsigned char | frameIndex, | |||
| unsigned short | packetSeqNum, | |||
| struct timeval | presentationTime | |||
| ) |
Definition at line 397 of file QCELPAudioRTPSource.cpp.
References fFrames, fHaveSeenPackets, fIncomingBankId, fIncomingBinMax, fInputBuffer, fLastPacketSeqNumForGroup, fNextOutgoingBin, fOutgoingBinMax, QCELPDeinterleavingBuffer::FrameDescriptor::frameData, QCELPDeinterleavingBuffer::FrameDescriptor::frameSize, NULL, QCELPDeinterleavingBuffer::FrameDescriptor::presentationTime, QCELP_MAX_FRAME_SIZE, QCELP_MAX_FRAMES_PER_PACKET, QCELP_MAX_INTERLEAVE_L, seqNumLT(), True, and uSecsPerFrame.
Referenced by QCELPDeinterleaver::afterGettingFrame1().
00402 { 00403 // First perform a sanity check on the parameters: 00404 // (This is overkill, as the source should have already done this.) 00405 if (frameSize > QCELP_MAX_FRAME_SIZE 00406 || interleaveL > QCELP_MAX_INTERLEAVE_L || interleaveN > interleaveL 00407 || frameIndex == 0 || frameIndex > QCELP_MAX_FRAMES_PER_PACKET) { 00408 #ifdef DEBUG 00409 fprintf(stderr, "QCELPDeinterleavingBuffer::deliverIncomingFrame() param sanity check failed (%d,%d,%d,%d)\n", frameSize, interleaveL, interleaveN, frameIndex); 00410 #endif 00411 return; 00412 } 00413 00414 // The input "presentationTime" was that of the first frame in this 00415 // packet. Update it for the current frame: 00416 unsigned uSecIncrement = (frameIndex-1)*(interleaveL+1)*uSecsPerFrame; 00417 presentationTime.tv_usec += uSecIncrement; 00418 presentationTime.tv_sec += presentationTime.tv_usec/1000000; 00419 presentationTime.tv_usec = presentationTime.tv_usec%1000000; 00420 00421 // Next, check whether this packet is part of a new interleave group 00422 if (!fHaveSeenPackets 00423 || seqNumLT(fLastPacketSeqNumForGroup, packetSeqNum)) { 00424 // We've moved to a new interleave group 00425 fHaveSeenPackets = True; 00426 fLastPacketSeqNumForGroup = packetSeqNum + interleaveL - interleaveN; 00427 00428 // Switch the incoming and outgoing banks: 00429 fIncomingBankId ^= 1; 00430 unsigned char tmp = fIncomingBinMax; 00431 fIncomingBinMax = fOutgoingBinMax; 00432 fOutgoingBinMax = tmp; 00433 fNextOutgoingBin = 0; 00434 } 00435 00436 // Now move the incoming frame into the appropriate bin: 00437 unsigned const binNumber 00438 = interleaveN + (frameIndex-1)*(interleaveL+1); 00439 FrameDescriptor& inBin = fFrames[binNumber][fIncomingBankId]; 00440 unsigned char* curBuffer = inBin.frameData; 00441 inBin.frameData = fInputBuffer; 00442 inBin.frameSize = frameSize; 00443 inBin.presentationTime = presentationTime; 00444 00445 if (curBuffer == NULL) curBuffer = new unsigned char[QCELP_MAX_FRAME_SIZE]; 00446 fInputBuffer = curBuffer; 00447 00448 if (binNumber >= fIncomingBinMax) { 00449 fIncomingBinMax = binNumber + 1; 00450 } 00451 }
| Boolean QCELPDeinterleavingBuffer::retrieveFrame | ( | unsigned char * | to, | |
| unsigned | maxSize, | |||
| unsigned & | resultFrameSize, | |||
| unsigned & | resultNumTruncatedBytes, | |||
| struct timeval & | resultPresentationTime | |||
| ) |
Definition at line 454 of file QCELPAudioRTPSource.cpp.
References False, fFrames, fIncomingBankId, fLastRetrievedPresentationTime, fNextOutgoingBin, fOutgoingBinMax, QCELPDeinterleavingBuffer::FrameDescriptor::frameData, QCELPDeinterleavingBuffer::FrameDescriptor::frameSize, QCELPDeinterleavingBuffer::FrameDescriptor::presentationTime, True, and uSecsPerFrame.
Referenced by QCELPDeinterleaver::doGetNextFrame().
00456 { 00457 if (fNextOutgoingBin >= fOutgoingBinMax) return False; // none left 00458 00459 FrameDescriptor& outBin = fFrames[fNextOutgoingBin][fIncomingBankId^1]; 00460 unsigned char* fromPtr; 00461 unsigned char fromSize = outBin.frameSize; 00462 outBin.frameSize = 0; // for the next time this bin is used 00463 00464 // Check whether this frame is missing; if so, return an 'erasure' frame: 00465 unsigned char erasure = 14; 00466 if (fromSize == 0) { 00467 fromPtr = &erasure; 00468 fromSize = 1; 00469 00470 // Compute this erasure frame's presentation time via extrapolation: 00471 resultPresentationTime = fLastRetrievedPresentationTime; 00472 resultPresentationTime.tv_usec += uSecsPerFrame; 00473 if (resultPresentationTime.tv_usec >= 1000000) { 00474 ++resultPresentationTime.tv_sec; 00475 resultPresentationTime.tv_usec -= 1000000; 00476 } 00477 } else { 00478 // Normal case - a frame exists: 00479 fromPtr = outBin.frameData; 00480 resultPresentationTime = outBin.presentationTime; 00481 } 00482 00483 fLastRetrievedPresentationTime = resultPresentationTime; 00484 00485 if (fromSize > maxSize) { 00486 resultNumTruncatedBytes = fromSize - maxSize; 00487 resultFrameSize = maxSize; 00488 } else { 00489 resultNumTruncatedBytes = 0; 00490 resultFrameSize = fromSize; 00491 } 00492 memmove(to, fromPtr, resultFrameSize); 00493 00494 ++fNextOutgoingBin; 00495 return True; 00496 }
| unsigned char* QCELPDeinterleavingBuffer::inputBuffer | ( | ) | [inline] |
Definition at line 278 of file QCELPAudioRTPSource.cpp.
Referenced by QCELPDeinterleaver::doGetNextFrame().
00278 { return fInputBuffer; }
| unsigned QCELPDeinterleavingBuffer::inputBufferSize | ( | ) | const [inline] |
Definition at line 279 of file QCELPAudioRTPSource.cpp.
References QCELP_MAX_FRAME_SIZE.
Referenced by QCELPDeinterleaver::doGetNextFrame().
00279 { return QCELP_MAX_FRAME_SIZE; }
FrameDescriptor QCELPDeinterleavingBuffer::fFrames[QCELP_MAX_INTERLEAVE_GROUP_SIZE][2] [private] |
Definition at line 293 of file QCELPAudioRTPSource.cpp.
Referenced by deliverIncomingFrame(), and retrieveFrame().
unsigned char QCELPDeinterleavingBuffer::fIncomingBankId [private] |
Definition at line 294 of file QCELPAudioRTPSource.cpp.
Referenced by deliverIncomingFrame(), and retrieveFrame().
unsigned char QCELPDeinterleavingBuffer::fIncomingBinMax [private] |
unsigned char QCELPDeinterleavingBuffer::fOutgoingBinMax [private] |
Definition at line 296 of file QCELPAudioRTPSource.cpp.
Referenced by deliverIncomingFrame(), and retrieveFrame().
unsigned char QCELPDeinterleavingBuffer::fNextOutgoingBin [private] |
Definition at line 297 of file QCELPAudioRTPSource.cpp.
Referenced by deliverIncomingFrame(), and retrieveFrame().
u_int16_t QCELPDeinterleavingBuffer::fLastPacketSeqNumForGroup [private] |
unsigned char* QCELPDeinterleavingBuffer::fInputBuffer [private] |
Definition at line 300 of file QCELPAudioRTPSource.cpp.
Referenced by deliverIncomingFrame(), QCELPDeinterleavingBuffer(), and ~QCELPDeinterleavingBuffer().
struct timeval QCELPDeinterleavingBuffer::fLastRetrievedPresentationTime [read, private] |
1.5.2