1 /*
2  *  Copyright (c) 2016 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/tmmbr.h"
12 
13 #include "testing/gtest/include/gtest/gtest.h"
14 
15 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
16 #include "webrtc/test/rtcp_packet_parser.h"
17 
18 using webrtc::rtcp::RawPacket;
19 using webrtc::rtcp::Tmmbr;
20 using webrtc::test::RtcpPacketParser;
21 
22 namespace webrtc {
23 const uint32_t kSenderSsrc = 0x12345678;
24 const uint32_t kRemoteSsrc = 0x23456789;
25 
TEST(RtcpPacketTest,Tmmbr)26 TEST(RtcpPacketTest, Tmmbr) {
27   Tmmbr tmmbr;
28   tmmbr.From(kSenderSsrc);
29   tmmbr.To(kRemoteSsrc);
30   tmmbr.WithBitrateKbps(312);
31   tmmbr.WithOverhead(60);
32 
33   rtc::scoped_ptr<RawPacket> packet(tmmbr.Build());
34   RtcpPacketParser parser;
35   parser.Parse(packet->Buffer(), packet->Length());
36   EXPECT_EQ(1, parser.tmmbr()->num_packets());
37   EXPECT_EQ(kSenderSsrc, parser.tmmbr()->Ssrc());
38   EXPECT_EQ(1, parser.tmmbr_item()->num_packets());
39   EXPECT_EQ(312U, parser.tmmbr_item()->BitrateKbps());
40   EXPECT_EQ(60U, parser.tmmbr_item()->Overhead());
41 }
42 
43 }  // namespace webrtc
44