コード例 #1
0
ファイル: SenderReport.cpp プロジェクト: Konnekt/lib-sipx
/**
 *
 * Method Name:  FormatSenderReport
 *
 *
 * Inputs:   unsigned long  ulBufferSize     - length allocated for the buffer
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 *
 * Outputs:  unsigned char *puchReportBuffer
 *                                    - Buffer used to store the Sender Report
 *
 * Returns:  unsigned long - number of octets written into the buffer.
 *
 * Description: Constructs a Sender report using the buffer passed in by the
 *              caller.  The Sender Report object shall keep track of the
 *              reporting periods that have passed an which information should
 *              be used to populate the report.
 *
 * Usage Notes: The header of the RTCP Report shall be formatted by delegating
 *              to the base class.
 *
 *
 */
unsigned long CSenderReport::FormatSenderReport(
                  unsigned char *puchReportBuffer, unsigned long ulBufferSize)
{

    unsigned long ulReportLength=0;

    // Let's offset into the Formatting buffer enough to
    //  start depositing payload
    unsigned char *puchPayloadBuffer = puchReportBuffer + GetHeaderLength();

    // Let's load the NTP and RTP timestamps into the Sender Report
    puchPayloadBuffer += LoadTimestamps((unsigned long *)puchPayloadBuffer);

    // Let's load the Sender Statistics
    puchPayloadBuffer += LoadSenderStats((unsigned long *)puchPayloadBuffer);

    // Set the sender report length
    ulReportLength = puchPayloadBuffer - puchReportBuffer;

    // Let's slap a header on this report
    FormatRTCPHeader( puchReportBuffer,  // RTCP Report Buffer
          FALSE,                         // No Padding
          1,                             // Receiver Count set to 1 for now
          ulReportLength + RR_LENGTH);   // Report Length

    return(ulReportLength);

}
コード例 #2
0
ファイル: ByeReport.cpp プロジェクト: John-Chan/sipXtapi
/**
 *
 * Method Name:  FormatByeReport
 *
 *
 * Inputs:      unsigned long  ulBufferSize - length allocated for the buffer
 *
 * Outputs:     unsigned char *puchReportBuffer
 *                       - Buffer to receive the contents of the Sender Report
 *
 * Returns:     unsigned long  - number of octets written into the buffer.
 *
 * Description: Constructs a Bye report using the buffer passed in by the
 *              caller.
 *
 * Usage Notes: The header of the RTCP Report shall be formatted by
 *              delegating to the base class.
 *
 *
 */
unsigned long CByeReport::FormatByeReport(unsigned char *puchReportBuffer,
        unsigned long ulBufferSize)
{
    unsigned long  ulReportLength, ulCSRCCount = 0;
    unsigned char *puchPayloadBuffer;
    unsigned long l = GetHeaderLength();

    // Let's offset into the Formatting buffer enough to
    // start depositing payload
    puchPayloadBuffer = puchReportBuffer + l;
    // OsSysLog::add(FAC_MP, PRI_DEBUG, "CByeReport::FormatByeReport: GetHeaderLength() = %ld", l);

    // Let's load the field information based upon the period.
    // Conversion to NBO done in GetCSRC().
    ulCSRCCount = GetCSRC((ssrc_t *)puchPayloadBuffer, TRUE);
    puchPayloadBuffer += (ulCSRCCount * sizeof(ssrc_t));

    // Let's load the field information based upon the period
    unsigned long ulReasonLength = GetReason(puchPayloadBuffer+1);
    bool bPadded = FALSE;
    if(ulReasonLength > 0)
    {
        // Adjust the count and payload pointer
        *puchPayloadBuffer++ = (unsigned char)ulReasonLength;
        puchPayloadBuffer += ulReasonLength;

        // Let's load padding onto the end of the packet to
        // ensure 4 byte alignment
        puchPayloadBuffer += LoadPadding(puchPayloadBuffer, &bPadded);
    }

    // Set the report length
    ulReportLength = puchPayloadBuffer - puchReportBuffer;

    // Let's call the RTCP Header base class's formatter so we can prepend
    // a header to this Bye Payload
    FormatRTCPHeader(puchReportBuffer,      // RTCP Report Buffer
                     bPadded,               // Padding Flag
                     ulCSRCCount+1,         // SSRC/CSRC Count
                     ulReportLength);       // Report Length

    return(ulReportLength);
}