LCOV - code coverage report
Current view: top level - media/webrtc/trunk/webrtc/modules/rtp_rtcp/source/rtcp_packet - dlrr.cc (source / functions) Hit Total Coverage
Test: output.info Lines: 0 36 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  *  Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
       3             :  *
       4             :  *  Use of this source code is governed by a BSD-style license
       5             :  *  that can be found in the LICENSE file in the root of the source
       6             :  *  tree. An additional intellectual property rights grant can be found
       7             :  *  in the file PATENTS.  All contributing project authors may
       8             :  *  be found in the AUTHORS file in the root of the source tree.
       9             :  */
      10             : 
      11             : #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/dlrr.h"
      12             : 
      13             : #include "webrtc/base/checks.h"
      14             : #include "webrtc/base/logging.h"
      15             : #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
      16             : 
      17             : namespace webrtc {
      18             : namespace rtcp {
      19             : // DLRR Report Block (RFC 3611).
      20             : //
      21             : //   0                   1                   2                   3
      22             : //   0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
      23             : //  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      24             : //  |     BT=5      |   reserved    |         block length          |
      25             : //  +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
      26             : //  |                 SSRC_1 (SSRC of first receiver)               | sub-
      27             : //  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ block
      28             : //  |                         last RR (LRR)                         |   1
      29             : //  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      30             : //  |                   delay since last RR (DLRR)                  |
      31             : //  +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
      32             : //  |                 SSRC_2 (SSRC of second receiver)              | sub-
      33             : //  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ block
      34             : //  :                               ...                             :   2
      35             : 
      36           0 : bool Dlrr::Parse(const uint8_t* buffer, uint16_t block_length_32bits) {
      37           0 :   RTC_DCHECK(buffer[0] == kBlockType);
      38             :   // kReserved = buffer[1];
      39           0 :   RTC_DCHECK_EQ(block_length_32bits,
      40           0 :                 ByteReader<uint16_t>::ReadBigEndian(&buffer[2]));
      41           0 :   if (block_length_32bits % 3 != 0) {
      42           0 :     LOG(LS_WARNING) << "Invalid size for dlrr block.";
      43           0 :     return false;
      44             :   }
      45             : 
      46           0 :   size_t blocks_count = block_length_32bits / 3;
      47           0 :   const uint8_t* read_at = buffer + kBlockHeaderLength;
      48           0 :   sub_blocks_.resize(blocks_count);
      49           0 :   for (ReceiveTimeInfo& sub_block : sub_blocks_) {
      50           0 :     sub_block.ssrc = ByteReader<uint32_t>::ReadBigEndian(&read_at[0]);
      51           0 :     sub_block.last_rr = ByteReader<uint32_t>::ReadBigEndian(&read_at[4]);
      52           0 :     sub_block.delay_since_last_rr =
      53           0 :         ByteReader<uint32_t>::ReadBigEndian(&read_at[8]);
      54           0 :     read_at += kSubBlockLength;
      55             :   }
      56           0 :   return true;
      57             : }
      58             : 
      59           0 : size_t Dlrr::BlockLength() const {
      60           0 :   if (sub_blocks_.empty())
      61           0 :     return 0;
      62           0 :   return kBlockHeaderLength + kSubBlockLength * sub_blocks_.size();
      63             : }
      64             : 
      65           0 : void Dlrr::Create(uint8_t* buffer) const {
      66           0 :   if (sub_blocks_.empty())  // No subblocks, no need to write header either.
      67           0 :     return;
      68             :   // Create block header.
      69           0 :   const uint8_t kReserved = 0;
      70           0 :   buffer[0] = kBlockType;
      71           0 :   buffer[1] = kReserved;
      72           0 :   ByteWriter<uint16_t>::WriteBigEndian(&buffer[2], 3 * sub_blocks_.size());
      73             :   // Create sub blocks.
      74           0 :   uint8_t* write_at = buffer + kBlockHeaderLength;
      75           0 :   for (const ReceiveTimeInfo& sub_block : sub_blocks_) {
      76           0 :     ByteWriter<uint32_t>::WriteBigEndian(&write_at[0], sub_block.ssrc);
      77           0 :     ByteWriter<uint32_t>::WriteBigEndian(&write_at[4], sub_block.last_rr);
      78           0 :     ByteWriter<uint32_t>::WriteBigEndian(&write_at[8],
      79           0 :                                          sub_block.delay_since_last_rr);
      80           0 :     write_at += kSubBlockLength;
      81             :   }
      82           0 :   RTC_DCHECK_EQ(buffer + BlockLength(), write_at);
      83             : }
      84             : 
      85             : }  // namespace rtcp
      86             : }  // namespace webrtc

Generated by: LCOV version 1.13