| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/app.h" | 11 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/app.h" |
| 12 | 12 |
| 13 #include <limits> | 13 #include <limits> |
| 14 | 14 |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" | 16 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" |
| 17 | 17 |
| 18 using webrtc::rtcp::App; | 18 using webrtc::rtcp::App; |
| 19 using webrtc::rtcp::RawPacket; | |
| 20 using webrtc::RTCPUtility::RtcpCommonHeader; | 19 using webrtc::RTCPUtility::RtcpCommonHeader; |
| 21 using webrtc::RTCPUtility::RtcpParseCommonHeader; | 20 using webrtc::RTCPUtility::RtcpParseCommonHeader; |
| 22 | 21 |
| 23 namespace webrtc { | 22 namespace webrtc { |
| 24 namespace { | 23 namespace { |
| 25 | 24 |
| 26 const uint32_t kName = ((uint32_t)'n' << 24) | ((uint32_t)'a' << 16) | | 25 const uint32_t kName = ((uint32_t)'n' << 24) | ((uint32_t)'a' << 16) | |
| 27 ((uint32_t)'m' << 8) | (uint32_t)'e'; | 26 ((uint32_t)'m' << 8) | (uint32_t)'e'; |
| 28 const uint32_t kSenderSsrc = 0x12345678; | 27 const uint32_t kSenderSsrc = 0x12345678; |
| 29 | 28 |
| 30 class RtcpPacketAppTest : public ::testing::Test { | 29 class RtcpPacketAppTest : public ::testing::Test { |
| 31 protected: | 30 protected: |
| 32 void BuildPacket() { packet = app.Build(); } | 31 void BuildPacket() { packet = app.Build(); } |
| 33 void ParsePacket() { | 32 void ParsePacket() { |
| 34 RtcpCommonHeader header; | 33 RtcpCommonHeader header; |
| 35 EXPECT_TRUE( | 34 EXPECT_TRUE(RtcpParseCommonHeader(packet.data(), packet.size(), &header)); |
| 36 RtcpParseCommonHeader(packet->Buffer(), packet->Length(), &header)); | |
| 37 // Check there is exactly one RTCP packet in the buffer. | 35 // Check there is exactly one RTCP packet in the buffer. |
| 38 EXPECT_EQ(header.BlockSize(), packet->Length()); | 36 EXPECT_EQ(header.BlockSize(), packet.size()); |
| 39 EXPECT_TRUE(parsed_.Parse( | 37 EXPECT_TRUE(parsed_.Parse( |
| 40 header, packet->Buffer() + RtcpCommonHeader::kHeaderSizeBytes)); | 38 header, packet.data() + RtcpCommonHeader::kHeaderSizeBytes)); |
| 41 } | 39 } |
| 42 | 40 |
| 43 App app; | 41 App app; |
| 44 rtc::scoped_ptr<RawPacket> packet; | 42 rtc::Buffer packet; |
| 45 const App& parsed() { return parsed_; } | 43 const App& parsed() { return parsed_; } |
| 46 | 44 |
| 47 private: | 45 private: |
| 48 App parsed_; | 46 App parsed_; |
| 49 }; | 47 }; |
| 50 | 48 |
| 51 TEST_F(RtcpPacketAppTest, WithNoData) { | 49 TEST_F(RtcpPacketAppTest, WithNoData) { |
| 52 app.WithSubType(30); | 50 app.WithSubType(30); |
| 53 app.WithName(kName); | 51 app.WithName(kName); |
| 54 | 52 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 72 ParsePacket(); | 70 ParsePacket(); |
| 73 | 71 |
| 74 EXPECT_EQ(30U, parsed().sub_type()); | 72 EXPECT_EQ(30U, parsed().sub_type()); |
| 75 EXPECT_EQ(kName, parsed().name()); | 73 EXPECT_EQ(kName, parsed().name()); |
| 76 EXPECT_EQ(kDataLength, parsed().data_size()); | 74 EXPECT_EQ(kDataLength, parsed().data_size()); |
| 77 EXPECT_EQ(0, memcmp(kData, parsed().data(), kDataLength)); | 75 EXPECT_EQ(0, memcmp(kData, parsed().data(), kDataLength)); |
| 78 } | 76 } |
| 79 | 77 |
| 80 } // namespace | 78 } // namespace |
| 81 } // namespace webrtc | 79 } // namespace webrtc |
| OLD | NEW |