void RTPPacket::Dump() { int i; printf("Payload type: %d\n",(int)GetPayloadType()); printf("Extended sequence number: 0x%08x\n",GetExtendedSequenceNumber()); printf("Timestamp: 0x%08x\n",GetTimestamp()); printf("SSRC: 0x%08x\n",GetSSRC()); printf("Marker: %s\n",HasMarker()?"yes":"no"); printf("CSRC count: %d\n",GetCSRCCount()); for (i = 0 ; i < GetCSRCCount() ; i++) printf(" CSRC[%02d]: 0x%08x\n",i,GetCSRC(i)); printf("Payload: %s\n",GetPayloadData()); printf("Payload length: %d\n",GetPayloadLength()); printf("Packet length: %d\n",GetPacketLength()); printf("Extension: %s\n",HasExtension()?"yes":"no"); if (HasExtension()) { printf(" Extension ID: 0x%04x\n",GetExtensionID()); printf(" Extension data: %s\n",GetExtensionData()); printf(" Extension length: %d\n",GetExtensionLength()); } }
void CRTCPSource::ProcessPacket(unsigned char *puchDataBuffer, unsigned long ulBufferLength, int verbose) { unsigned char *SAVEpuchDataBuffer = puchDataBuffer; unsigned long SAVEulBufferLength = ulBufferLength; #ifdef DEBUG_RTCP_PACKETS /* [ */ if (0 < numPacketsToDump--) { verbose = 1; } if (verbose) { unsigned char *tp = puchDataBuffer; unsigned long tl = ulBufferLength; int i = 0; osPrintf("CRTCPSource::ProcessPacket(%8p, %lu)\n", puchDataBuffer, ulBufferLength); while(tl > 0) { osPrintf(" %02X", *tp++); if (0xf == (0xf & i++)) osPrintf("\n"); tl--; } if (0 != (0xf & i)) osPrintf("\n"); } #endif /* DEBUG_RTCP_PACKETS ] */ // This could be either a simple or composite report. Let's process the // buffer until there is nothing more to process. while(ulBufferLength > 0) { unsigned long ulBytesProcessed = 0; // Let's peek into the RTCP header to determine the payload type of an // RTCP report and route it to the appropriate handler. switch(GetPayloadType(puchDataBuffer)) { // Process Sender Report case etSenderReport: ulBytesProcessed = ProcessSenderReport(puchDataBuffer); #ifdef DEBUG_RTCP_PACKETS /* [ */ if (verbose) { osPrintf(" Sender Report (%lu bytes)\n", ulBytesProcessed); } #endif /* DEBUG_RTCP_PACKETS ] */ break; // Process Receiver Report case etReceiverReport: ulBytesProcessed = ProcessReceiverReport(puchDataBuffer); #ifdef DEBUG_RTCP_PACKETS /* [ */ if (verbose) { osPrintf(" Recvr Report (%lu bytes)\n", ulBytesProcessed); } #endif /* DEBUG_RTCP_PACKETS ] */ break; // Process Source Description Report case etSDESReport: ulBytesProcessed = ProcessSDESReport(puchDataBuffer); #ifdef DEBUG_RTCP_PACKETS /* [ */ if (verbose) { osPrintf(" SDES Report (%lu bytes)\n", ulBytesProcessed); } #endif /* DEBUG_RTCP_PACKETS ] */ break; // Process Bye Report case etByeReport: ulBytesProcessed = ProcessByeReport(puchDataBuffer); #ifdef DEBUG_RTCP_PACKETS /* [ */ if (verbose) { osPrintf(" Bye Report (%lu bytes)\n", ulBytesProcessed); } #endif /* DEBUG_RTCP_PACKETS ] */ break; // Process Application Report case etAppReport: ulBytesProcessed = ProcessAppReport(puchDataBuffer); #ifdef DEBUG_RTCP_PACKETS /* [ */ if (verbose) { osPrintf(" App Report (%lu bytes)\n", ulBytesProcessed); } #endif /* DEBUG_RTCP_PACKETS ] */ break; // Unrecognized Report default: { int count, i; osPrintf("** TROUBLE ** CRTCPSource::ProcessPacket()" " - Unrecognized RTCP Report Type of %d\n", GetPayloadType(puchDataBuffer)); osPrintf(" - Remaining buffer length of %lu", ulBufferLength); count = ulBufferLength > 0 ? ulBufferLength : 0; count = count < 100 ? count : 100; if (count > 0) osPrintf(" containing\n==>"); for (i=0; i<count; i++) { if (15 == (15 & i)) osPrintf(" %02X\n ", *puchDataBuffer); else osPrintf(" %02X", *puchDataBuffer); puchDataBuffer++; } osPrintf("\n"); } if (!verbose) { ProcessPacket(SAVEpuchDataBuffer, SAVEulBufferLength, 1); } return; } #ifdef DEBUG_RTCP_PACKETS /* [ */ if (verbose) { unsigned char *tp = puchDataBuffer; unsigned long tl = ulBytesProcessed; int i = 0; while(tl > 0) { osPrintf(" %02X", *tp++); if (0xf == (0xf & i++)) osPrintf("\n"); tl--; } if (0 != (0xf & i)) osPrintf("\n"); } #endif /* DEBUG_RTCP_PACKETS ] */ // Adjust length remaining and the buffer pointer so that we are // prepared to recognize and process other reports. puchDataBuffer += ulBytesProcessed; ulBufferLength -= ulBytesProcessed; } }