• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2019 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 "api/rtp_packet_infos.h"
12 #include "test/gmock.h"
13 #include "test/gtest.h"
14 
15 namespace webrtc {
16 
TEST(RtpPacketInfoTest,Ssrc)17 TEST(RtpPacketInfoTest, Ssrc) {
18   const uint32_t value = 4038189233;
19 
20   RtpPacketInfo lhs;
21   RtpPacketInfo rhs;
22 
23   EXPECT_TRUE(lhs == rhs);
24   EXPECT_FALSE(lhs != rhs);
25 
26   rhs.set_ssrc(value);
27   EXPECT_EQ(rhs.ssrc(), value);
28 
29   EXPECT_FALSE(lhs == rhs);
30   EXPECT_TRUE(lhs != rhs);
31 
32   lhs = rhs;
33 
34   EXPECT_TRUE(lhs == rhs);
35   EXPECT_FALSE(lhs != rhs);
36 
37   rhs = RtpPacketInfo();
38   EXPECT_NE(rhs.ssrc(), value);
39 
40   rhs = RtpPacketInfo(value, {}, {}, {}, {}, {});
41   EXPECT_EQ(rhs.ssrc(), value);
42 }
43 
TEST(RtpPacketInfoTest,Csrcs)44 TEST(RtpPacketInfoTest, Csrcs) {
45   const std::vector<uint32_t> value = {4038189233, 3016333617, 1207992985};
46 
47   RtpPacketInfo lhs;
48   RtpPacketInfo rhs;
49 
50   EXPECT_TRUE(lhs == rhs);
51   EXPECT_FALSE(lhs != rhs);
52 
53   rhs.set_csrcs(value);
54   EXPECT_EQ(rhs.csrcs(), value);
55 
56   EXPECT_FALSE(lhs == rhs);
57   EXPECT_TRUE(lhs != rhs);
58 
59   lhs = rhs;
60 
61   EXPECT_TRUE(lhs == rhs);
62   EXPECT_FALSE(lhs != rhs);
63 
64   rhs = RtpPacketInfo();
65   EXPECT_NE(rhs.csrcs(), value);
66 
67   rhs = RtpPacketInfo({}, value, {}, {}, {}, {});
68   EXPECT_EQ(rhs.csrcs(), value);
69 }
70 
TEST(RtpPacketInfoTest,RtpTimestamp)71 TEST(RtpPacketInfoTest, RtpTimestamp) {
72   const uint32_t value = 4038189233;
73 
74   RtpPacketInfo lhs;
75   RtpPacketInfo rhs;
76 
77   EXPECT_TRUE(lhs == rhs);
78   EXPECT_FALSE(lhs != rhs);
79 
80   rhs.set_rtp_timestamp(value);
81   EXPECT_EQ(rhs.rtp_timestamp(), value);
82 
83   EXPECT_FALSE(lhs == rhs);
84   EXPECT_TRUE(lhs != rhs);
85 
86   lhs = rhs;
87 
88   EXPECT_TRUE(lhs == rhs);
89   EXPECT_FALSE(lhs != rhs);
90 
91   rhs = RtpPacketInfo();
92   EXPECT_NE(rhs.rtp_timestamp(), value);
93 
94   rhs = RtpPacketInfo({}, {}, value, {}, {}, {});
95   EXPECT_EQ(rhs.rtp_timestamp(), value);
96 }
97 
TEST(RtpPacketInfoTest,AudioLevel)98 TEST(RtpPacketInfoTest, AudioLevel) {
99   const absl::optional<uint8_t> value = 31;
100 
101   RtpPacketInfo lhs;
102   RtpPacketInfo rhs;
103 
104   EXPECT_TRUE(lhs == rhs);
105   EXPECT_FALSE(lhs != rhs);
106 
107   rhs.set_audio_level(value);
108   EXPECT_EQ(rhs.audio_level(), value);
109 
110   EXPECT_FALSE(lhs == rhs);
111   EXPECT_TRUE(lhs != rhs);
112 
113   lhs = rhs;
114 
115   EXPECT_TRUE(lhs == rhs);
116   EXPECT_FALSE(lhs != rhs);
117 
118   rhs = RtpPacketInfo();
119   EXPECT_NE(rhs.audio_level(), value);
120 
121   rhs = RtpPacketInfo({}, {}, {}, value, {}, {});
122   EXPECT_EQ(rhs.audio_level(), value);
123 }
124 
TEST(RtpPacketInfoTest,AbsoluteCaptureTime)125 TEST(RtpPacketInfoTest, AbsoluteCaptureTime) {
126   const absl::optional<AbsoluteCaptureTime> value = AbsoluteCaptureTime{12, 34};
127 
128   RtpPacketInfo lhs;
129   RtpPacketInfo rhs;
130 
131   EXPECT_TRUE(lhs == rhs);
132   EXPECT_FALSE(lhs != rhs);
133 
134   rhs.set_absolute_capture_time(value);
135   EXPECT_EQ(rhs.absolute_capture_time(), value);
136 
137   EXPECT_FALSE(lhs == rhs);
138   EXPECT_TRUE(lhs != rhs);
139 
140   lhs = rhs;
141 
142   EXPECT_TRUE(lhs == rhs);
143   EXPECT_FALSE(lhs != rhs);
144 
145   rhs = RtpPacketInfo();
146   EXPECT_NE(rhs.absolute_capture_time(), value);
147 
148   rhs = RtpPacketInfo({}, {}, {}, {}, value, {});
149   EXPECT_EQ(rhs.absolute_capture_time(), value);
150 }
151 
TEST(RtpPacketInfoTest,ReceiveTimeMs)152 TEST(RtpPacketInfoTest, ReceiveTimeMs) {
153   const int64_t value = 8868963877546349045LL;
154 
155   RtpPacketInfo lhs;
156   RtpPacketInfo rhs;
157 
158   EXPECT_TRUE(lhs == rhs);
159   EXPECT_FALSE(lhs != rhs);
160 
161   rhs.set_receive_time_ms(value);
162   EXPECT_EQ(rhs.receive_time_ms(), value);
163 
164   EXPECT_FALSE(lhs == rhs);
165   EXPECT_TRUE(lhs != rhs);
166 
167   lhs = rhs;
168 
169   EXPECT_TRUE(lhs == rhs);
170   EXPECT_FALSE(lhs != rhs);
171 
172   rhs = RtpPacketInfo();
173   EXPECT_NE(rhs.receive_time_ms(), value);
174 
175   rhs = RtpPacketInfo({}, {}, {}, {}, {}, value);
176   EXPECT_EQ(rhs.receive_time_ms(), value);
177 }
178 
179 }  // namespace webrtc
180