Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Side by Side Diff: webrtc/video/rtp_video_stream_receiver_unittest.cc

Issue 2974453002: Protected streams report RTP messages directly to the FlexFec streams (Closed)
Patch Set: Appease lint. Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/video/rtp_video_stream_receiver.cc ('k') | webrtc/video/video_quality_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2017 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2017 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/test/gtest.h" 11 #include "webrtc/test/gtest.h"
12 #include "webrtc/test/gmock.h" 12 #include "webrtc/test/gmock.h"
13 13
14 #include "webrtc/common_video/h264/h264_common.h" 14 #include "webrtc/common_video/h264/h264_common.h"
15 #include "webrtc/media/base/mediaconstants.h" 15 #include "webrtc/media/base/mediaconstants.h"
16 #include "webrtc/modules/pacing/packet_router.h" 16 #include "webrtc/modules/pacing/packet_router.h"
17 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h"
17 #include "webrtc/modules/utility/include/process_thread.h" 18 #include "webrtc/modules/utility/include/process_thread.h"
18 #include "webrtc/modules/video_coding/frame_object.h" 19 #include "webrtc/modules/video_coding/frame_object.h"
19 #include "webrtc/modules/video_coding/include/video_coding_defines.h" 20 #include "webrtc/modules/video_coding/include/video_coding_defines.h"
20 #include "webrtc/modules/video_coding/packet.h" 21 #include "webrtc/modules/video_coding/packet.h"
21 #include "webrtc/modules/video_coding/rtp_frame_reference_finder.h" 22 #include "webrtc/modules/video_coding/rtp_frame_reference_finder.h"
22 #include "webrtc/modules/video_coding/timing.h" 23 #include "webrtc/modules/video_coding/timing.h"
23 #include "webrtc/rtc_base/bytebuffer.h" 24 #include "webrtc/rtc_base/bytebuffer.h"
24 #include "webrtc/rtc_base/logging.h" 25 #include "webrtc/rtc_base/logging.h"
26 #include "webrtc/rtc_base/ptr_util.h"
25 #include "webrtc/system_wrappers/include/clock.h" 27 #include "webrtc/system_wrappers/include/clock.h"
26 #include "webrtc/system_wrappers/include/field_trial_default.h" 28 #include "webrtc/system_wrappers/include/field_trial_default.h"
27 #include "webrtc/test/field_trial.h" 29 #include "webrtc/test/field_trial.h"
28 #include "webrtc/video/rtp_video_stream_receiver.h" 30 #include "webrtc/video/rtp_video_stream_receiver.h"
29 31
30 using testing::_; 32 using testing::_;
31 33
32 namespace webrtc { 34 namespace webrtc {
33 35
34 namespace { 36 namespace {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 } 88 }
87 DoOnCompleteFrame(frame.get()); 89 DoOnCompleteFrame(frame.get());
88 } 90 }
89 void AppendExpectedBitstream(const uint8_t data[], size_t size_in_bytes) { 91 void AppendExpectedBitstream(const uint8_t data[], size_t size_in_bytes) {
90 // TODO(Johan): Let rtc::ByteBuffer handle uint8_t* instead of char*. 92 // TODO(Johan): Let rtc::ByteBuffer handle uint8_t* instead of char*.
91 buffer_.WriteBytes(reinterpret_cast<const char*>(data), size_in_bytes); 93 buffer_.WriteBytes(reinterpret_cast<const char*>(data), size_in_bytes);
92 } 94 }
93 rtc::ByteBufferWriter buffer_; 95 rtc::ByteBufferWriter buffer_;
94 }; 96 };
95 97
98 class MockRtpPacketSink : public RtpPacketSinkInterface {
99 public:
100 MOCK_METHOD1(OnRtpPacket, void(const RtpPacketReceived&));
101 };
102
103 constexpr uint32_t kSsrc = 111;
104 constexpr uint16_t kSequenceNumber = 222;
105 std::unique_ptr<RtpPacketReceived> CreateRtpPacketReceived(
106 uint32_t ssrc = kSsrc,
107 uint16_t sequence_number = kSequenceNumber) {
108 auto packet = rtc::MakeUnique<RtpPacketReceived>();
109 packet->SetSsrc(ssrc);
110 packet->SetSequenceNumber(sequence_number);
111 return packet;
112 }
113
114 MATCHER_P(SamePacketAs, other, "") {
115 return arg.Ssrc() == other.Ssrc() &&
116 arg.SequenceNumber() == other.SequenceNumber();
117 }
118
96 } // namespace 119 } // namespace
97 120
98 class RtpVideoStreamReceiverTest : public testing::Test { 121 class RtpVideoStreamReceiverTest : public testing::Test {
99 public: 122 public:
100 RtpVideoStreamReceiverTest() 123 RtpVideoStreamReceiverTest()
101 : config_(CreateConfig()), 124 : config_(CreateConfig()),
102 timing_(Clock::GetRealTimeClock()), 125 timing_(Clock::GetRealTimeClock()),
103 process_thread_(ProcessThread::Create("TestThread")) {} 126 process_thread_(ProcessThread::Create("TestThread")) {}
104 127
105 void SetUp() { 128 void SetUp() {
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 rtp_header.header.markerBit = 1; 360 rtp_header.header.markerBit = 1;
338 rtp_header.type.Video.is_first_packet_in_frame = true; 361 rtp_header.type.Video.is_first_packet_in_frame = true;
339 rtp_header.frameType = kVideoFrameDelta; 362 rtp_header.frameType = kVideoFrameDelta;
340 rtp_header.type.Video.codec = kRtpVideoGeneric; 363 rtp_header.type.Video.codec = kRtpVideoGeneric;
341 364
342 EXPECT_CALL(mock_key_frame_request_sender_, RequestKeyFrame()); 365 EXPECT_CALL(mock_key_frame_request_sender_, RequestKeyFrame());
343 rtp_video_stream_receiver_->OnReceivedPayloadData(data.data(), data.size(), 366 rtp_video_stream_receiver_->OnReceivedPayloadData(data.data(), data.size(),
344 &rtp_header); 367 &rtp_header);
345 } 368 }
346 369
370 TEST_F(RtpVideoStreamReceiverTest, SecondarySinksGetRtpNotifications) {
371 rtp_video_stream_receiver_->StartReceive();
372
373 MockRtpPacketSink secondary_sink_1;
374 MockRtpPacketSink secondary_sink_2;
375
376 rtp_video_stream_receiver_->AddSecondarySink(&secondary_sink_1);
377 rtp_video_stream_receiver_->AddSecondarySink(&secondary_sink_2);
378
379 auto rtp_packet = CreateRtpPacketReceived();
380 EXPECT_CALL(secondary_sink_1, OnRtpPacket(SamePacketAs(*rtp_packet)));
381 EXPECT_CALL(secondary_sink_2, OnRtpPacket(SamePacketAs(*rtp_packet)));
382
383 rtp_video_stream_receiver_->OnRtpPacket(*rtp_packet);
384
385 // Test tear-down.
386 rtp_video_stream_receiver_->StopReceive();
387 rtp_video_stream_receiver_->RemoveSecondarySink(&secondary_sink_1);
388 rtp_video_stream_receiver_->RemoveSecondarySink(&secondary_sink_2);
389 }
390
391 TEST_F(RtpVideoStreamReceiverTest, RemovedSecondarySinksGetNoRtpNotifications) {
392 rtp_video_stream_receiver_->StartReceive();
393
394 MockRtpPacketSink secondary_sink;
395
396 rtp_video_stream_receiver_->AddSecondarySink(&secondary_sink);
397 rtp_video_stream_receiver_->RemoveSecondarySink(&secondary_sink);
398
399 auto rtp_packet = CreateRtpPacketReceived();
400
401 EXPECT_CALL(secondary_sink, OnRtpPacket(_)).Times(0);
402
403 rtp_video_stream_receiver_->OnRtpPacket(*rtp_packet);
404
405 // Test tear-down.
406 rtp_video_stream_receiver_->StopReceive();
407 }
408
409 TEST_F(RtpVideoStreamReceiverTest,
410 OnlyRemovedSecondarySinksExcludedFromNotifications) {
411 rtp_video_stream_receiver_->StartReceive();
412
413 MockRtpPacketSink kept_secondary_sink;
414 MockRtpPacketSink removed_secondary_sink;
415
416 rtp_video_stream_receiver_->AddSecondarySink(&kept_secondary_sink);
417 rtp_video_stream_receiver_->AddSecondarySink(&removed_secondary_sink);
418 rtp_video_stream_receiver_->RemoveSecondarySink(&removed_secondary_sink);
419
420 auto rtp_packet = CreateRtpPacketReceived();
421 EXPECT_CALL(kept_secondary_sink, OnRtpPacket(SamePacketAs(*rtp_packet)));
422
423 rtp_video_stream_receiver_->OnRtpPacket(*rtp_packet);
424
425 // Test tear-down.
426 rtp_video_stream_receiver_->StopReceive();
427 rtp_video_stream_receiver_->RemoveSecondarySink(&kept_secondary_sink);
428 }
429
430 TEST_F(RtpVideoStreamReceiverTest,
431 SecondariesOfNonStartedStreamGetNoNotifications) {
432 // Explicitly showing that the stream is not in the |started| state,
433 // regardless of whether streams start out |started| or |stopped|.
434 rtp_video_stream_receiver_->StopReceive();
435
436 MockRtpPacketSink secondary_sink;
437 rtp_video_stream_receiver_->AddSecondarySink(&secondary_sink);
438
439 auto rtp_packet = CreateRtpPacketReceived();
440 EXPECT_CALL(secondary_sink, OnRtpPacket(_)).Times(0);
441
442 rtp_video_stream_receiver_->OnRtpPacket(*rtp_packet);
443
444 // Test tear-down.
445 rtp_video_stream_receiver_->RemoveSecondarySink(&secondary_sink);
446 }
447
448 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
449 TEST_F(RtpVideoStreamReceiverTest, RepeatedSecondarySinkDisallowed) {
450 MockRtpPacketSink secondary_sink;
451
452 rtp_video_stream_receiver_->AddSecondarySink(&secondary_sink);
453 EXPECT_DEATH(rtp_video_stream_receiver_->AddSecondarySink(&secondary_sink),
454 "");
455
456 // Test tear-down.
457 rtp_video_stream_receiver_->RemoveSecondarySink(&secondary_sink);
458 }
459 #endif
460
347 } // namespace webrtc 461 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/rtp_video_stream_receiver.cc ('k') | webrtc/video/video_quality_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698