| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/cast/net/rtcp/rtcp_builder.h" |
| 6 |
| 5 #include <stddef.h> | 7 #include <stddef.h> |
| 6 #include <stdint.h> | 8 #include <stdint.h> |
| 7 | 9 |
| 10 #include <memory> |
| 11 |
| 8 #include "base/macros.h" | 12 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/test/simple_test_tick_clock.h" | 13 #include "base/test/simple_test_tick_clock.h" |
| 11 #include "media/cast/cast_environment.h" | 14 #include "media/cast/cast_environment.h" |
| 12 #include "media/cast/net/cast_transport_config.h" | 15 #include "media/cast/net/cast_transport_config.h" |
| 13 #include "media/cast/net/cast_transport_defines.h" | 16 #include "media/cast/net/cast_transport_defines.h" |
| 14 #include "media/cast/net/pacing/paced_sender.h" | 17 #include "media/cast/net/pacing/paced_sender.h" |
| 15 #include "media/cast/net/rtcp/receiver_rtcp_event_subscriber.h" | 18 #include "media/cast/net/rtcp/receiver_rtcp_event_subscriber.h" |
| 16 #include "media/cast/net/rtcp/rtcp_builder.h" | |
| 17 #include "media/cast/net/rtcp/rtcp_utility.h" | 19 #include "media/cast/net/rtcp/rtcp_utility.h" |
| 18 #include "media/cast/net/rtcp/test_rtcp_packet_builder.h" | 20 #include "media/cast/net/rtcp/test_rtcp_packet_builder.h" |
| 19 #include "testing/gmock/include/gmock/gmock.h" | 21 #include "testing/gmock/include/gmock/gmock.h" |
| 20 | 22 |
| 21 namespace media { | 23 namespace media { |
| 22 namespace cast { | 24 namespace cast { |
| 23 | 25 |
| 24 namespace { | 26 namespace { |
| 25 static const uint32_t kSendingSsrc = 0x12345678; | 27 static const uint32_t kSendingSsrc = 0x12345678; |
| 26 static const uint32_t kMediaSsrc = 0x87654321; | 28 static const uint32_t kMediaSsrc = 0x87654321; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 42 } | 44 } |
| 43 | 45 |
| 44 } // namespace | 46 } // namespace |
| 45 | 47 |
| 46 | 48 |
| 47 class RtcpBuilderTest : public ::testing::Test { | 49 class RtcpBuilderTest : public ::testing::Test { |
| 48 protected: | 50 protected: |
| 49 RtcpBuilderTest() | 51 RtcpBuilderTest() |
| 50 : rtcp_builder_(new RtcpBuilder(kSendingSsrc)) {} | 52 : rtcp_builder_(new RtcpBuilder(kSendingSsrc)) {} |
| 51 | 53 |
| 52 void ExpectPacketEQ(scoped_ptr<Packet> golden_packet, | 54 void ExpectPacketEQ(std::unique_ptr<Packet> golden_packet, PacketRef packet) { |
| 53 PacketRef packet) { | |
| 54 int diffs = 0; | 55 int diffs = 0; |
| 55 EXPECT_EQ(golden_packet->size(), packet->data.size()); | 56 EXPECT_EQ(golden_packet->size(), packet->data.size()); |
| 56 if (golden_packet->size() == packet->data.size()) { | 57 if (golden_packet->size() == packet->data.size()) { |
| 57 for (size_t x = 0; x < golden_packet->size(); x++) { | 58 for (size_t x = 0; x < golden_packet->size(); x++) { |
| 58 EXPECT_EQ((*golden_packet)[x], packet->data[x]) << | 59 EXPECT_EQ((*golden_packet)[x], packet->data[x]) << |
| 59 "x = " << x << " / " << golden_packet->size(); | 60 "x = " << x << " / " << golden_packet->size(); |
| 60 if ((*golden_packet)[x] != packet->data[x]) { | 61 if ((*golden_packet)[x] != packet->data[x]) { |
| 61 if (++diffs > 5) | 62 if (++diffs > 5) |
| 62 break; | 63 break; |
| 63 } | 64 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 85 rtcp_builder_->AddRrtr(*rrtr); | 86 rtcp_builder_->AddRrtr(*rrtr); |
| 86 if (cast_message) | 87 if (cast_message) |
| 87 rtcp_builder_->AddCast(*cast_message, target_delay); | 88 rtcp_builder_->AddCast(*cast_message, target_delay); |
| 88 if (pli_message) | 89 if (pli_message) |
| 89 rtcp_builder_->AddPli(*pli_message); | 90 rtcp_builder_->AddPli(*pli_message); |
| 90 if (rtcp_events) | 91 if (rtcp_events) |
| 91 rtcp_builder_->AddReceiverLog(*rtcp_events); | 92 rtcp_builder_->AddReceiverLog(*rtcp_events); |
| 92 return rtcp_builder_->Finish(); | 93 return rtcp_builder_->Finish(); |
| 93 } | 94 } |
| 94 | 95 |
| 95 scoped_ptr<RtcpBuilder> rtcp_builder_; | 96 std::unique_ptr<RtcpBuilder> rtcp_builder_; |
| 96 | 97 |
| 97 DISALLOW_COPY_AND_ASSIGN(RtcpBuilderTest); | 98 DISALLOW_COPY_AND_ASSIGN(RtcpBuilderTest); |
| 98 }; | 99 }; |
| 99 | 100 |
| 100 TEST_F(RtcpBuilderTest, RtcpReceiverReport) { | 101 TEST_F(RtcpBuilderTest, RtcpReceiverReport) { |
| 101 // Receiver report with report block. | 102 // Receiver report with report block. |
| 102 TestRtcpPacketBuilder p2; | 103 TestRtcpPacketBuilder p2; |
| 103 p2.AddRr(kSendingSsrc, 1); | 104 p2.AddRr(kSendingSsrc, 1); |
| 104 p2.AddRb(kMediaSsrc); | 105 p2.AddRb(kMediaSsrc); |
| 105 | 106 |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 // Sender report. | 450 // Sender report. |
| 450 TestRtcpPacketBuilder p; | 451 TestRtcpPacketBuilder p; |
| 451 p.AddSr(kSendingSsrc, 0); | 452 p.AddSr(kSendingSsrc, 0); |
| 452 | 453 |
| 453 ExpectPacketEQ(p.GetPacket(), | 454 ExpectPacketEQ(p.GetPacket(), |
| 454 rtcp_builder_->BuildRtcpFromSender(sender_info)); | 455 rtcp_builder_->BuildRtcpFromSender(sender_info)); |
| 455 } | 456 } |
| 456 | 457 |
| 457 } // namespace cast | 458 } // namespace cast |
| 458 } // namespace media | 459 } // namespace media |
| OLD | NEW |