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

Side by Side Diff: webrtc/test/direct_transport.cc

Issue 3006513002: Remove deprecated DirectTransport constructors (Closed)
Patch Set: Created 3 years, 3 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/test/direct_transport.h ('k') | no next file » | 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 (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 #include "webrtc/test/direct_transport.h" 10 #include "webrtc/test/direct_transport.h"
11 11
12 #include "webrtc/call/call.h" 12 #include "webrtc/call/call.h"
13 #include "webrtc/rtc_base/ptr_util.h" 13 #include "webrtc/rtc_base/ptr_util.h"
14 #include "webrtc/system_wrappers/include/clock.h" 14 #include "webrtc/system_wrappers/include/clock.h"
15 #include "webrtc/test/single_threaded_task_queue.h" 15 #include "webrtc/test/single_threaded_task_queue.h"
16 16
17 namespace webrtc { 17 namespace webrtc {
18 namespace test { 18 namespace test {
19 19
20 DirectTransport::DirectTransport( 20 DirectTransport::DirectTransport(
21 Call* send_call,
22 const std::map<uint8_t, MediaType>& payload_type_map)
23 : DirectTransport(FakeNetworkPipe::Config(), send_call, payload_type_map) {}
24
25 DirectTransport::DirectTransport(
26 const FakeNetworkPipe::Config& config,
27 Call* send_call,
28 const std::map<uint8_t, MediaType>& payload_type_map)
29 : DirectTransport(
30 config,
31 send_call,
32 std::unique_ptr<Demuxer>(new DemuxerImpl(payload_type_map))) {}
33
34 DirectTransport::DirectTransport(const FakeNetworkPipe::Config& config,
35 Call* send_call,
36 std::unique_ptr<Demuxer> demuxer)
37 : DirectTransport(nullptr, config, send_call, std::move(demuxer)) {}
38
39 DirectTransport::DirectTransport(
40 SingleThreadedTaskQueueForTesting* task_queue, 21 SingleThreadedTaskQueueForTesting* task_queue,
41 Call* send_call, 22 Call* send_call,
42 const std::map<uint8_t, MediaType>& payload_type_map) 23 const std::map<uint8_t, MediaType>& payload_type_map)
43 : DirectTransport(task_queue, 24 : DirectTransport(task_queue,
44 FakeNetworkPipe::Config(), 25 FakeNetworkPipe::Config(),
45 send_call, 26 send_call,
46 payload_type_map) { 27 payload_type_map) {
47 } 28 }
48 29
49 DirectTransport::DirectTransport( 30 DirectTransport::DirectTransport(
50 SingleThreadedTaskQueueForTesting* task_queue, 31 SingleThreadedTaskQueueForTesting* task_queue,
51 const FakeNetworkPipe::Config& config, 32 const FakeNetworkPipe::Config& config,
52 Call* send_call, 33 Call* send_call,
53 const std::map<uint8_t, MediaType>& payload_type_map) 34 const std::map<uint8_t, MediaType>& payload_type_map)
54 : DirectTransport( 35 : DirectTransport(
55 task_queue, 36 task_queue,
56 config, 37 config,
57 send_call, 38 send_call,
58 std::unique_ptr<Demuxer>(new DemuxerImpl(payload_type_map))) { 39 std::unique_ptr<Demuxer>(new DemuxerImpl(payload_type_map))) {
59 } 40 }
60 41
61 DirectTransport::DirectTransport(SingleThreadedTaskQueueForTesting* task_queue, 42 DirectTransport::DirectTransport(SingleThreadedTaskQueueForTesting* task_queue,
62 const FakeNetworkPipe::Config& config, 43 const FakeNetworkPipe::Config& config,
63 Call* send_call, 44 Call* send_call,
64 std::unique_ptr<Demuxer> demuxer) 45 std::unique_ptr<Demuxer> demuxer)
65 : send_call_(send_call), 46 : send_call_(send_call),
66 clock_(Clock::GetRealTimeClock()), 47 clock_(Clock::GetRealTimeClock()),
67 task_queue_(task_queue), 48 task_queue_(task_queue),
68 fake_network_(clock_, config, std::move(demuxer)) { 49 fake_network_(clock_, config, std::move(demuxer)) {
69 // TODO(eladalon): When the deprecated ctors are removed, this check 50 RTC_DCHECK(task_queue);
70 // can be restored. https://bugs.chromium.org/p/webrtc/issues/detail?id=8125
71 // RTC_DCHECK(task_queue);
72 if (!task_queue) {
73 deprecated_task_queue_ =
74 rtc::MakeUnique<SingleThreadedTaskQueueForTesting>("deprecated_queue");
75 task_queue_ = deprecated_task_queue_.get();
76 }
77
78 if (send_call_) { 51 if (send_call_) {
79 send_call_->SignalChannelNetworkState(MediaType::AUDIO, kNetworkUp); 52 send_call_->SignalChannelNetworkState(MediaType::AUDIO, kNetworkUp);
80 send_call_->SignalChannelNetworkState(MediaType::VIDEO, kNetworkUp); 53 send_call_->SignalChannelNetworkState(MediaType::VIDEO, kNetworkUp);
81 } 54 }
82 SendPackets(); 55 SendPackets();
83 } 56 }
84 57
85 DirectTransport::~DirectTransport() { 58 DirectTransport::~DirectTransport() {
86 RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_); 59 RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_);
87 // Constructor updates |next_scheduled_task_|, so it's guaranteed to 60 // Constructor updates |next_scheduled_task_|, so it's guaranteed to
(...skipping 29 matching lines...) Expand all
117 90
118 bool DirectTransport::SendRtcp(const uint8_t* data, size_t length) { 91 bool DirectTransport::SendRtcp(const uint8_t* data, size_t length) {
119 fake_network_.SendPacket(data, length); 92 fake_network_.SendPacket(data, length);
120 return true; 93 return true;
121 } 94 }
122 95
123 int DirectTransport::GetAverageDelayMs() { 96 int DirectTransport::GetAverageDelayMs() {
124 return fake_network_.AverageDelay(); 97 return fake_network_.AverageDelay();
125 } 98 }
126 99
127 DirectTransport::ForceDemuxer::ForceDemuxer(MediaType media_type)
128 : media_type_(media_type) {}
129
130 void DirectTransport::ForceDemuxer::SetReceiver(PacketReceiver* receiver) {
131 packet_receiver_ = receiver;
132 }
133
134 void DirectTransport::ForceDemuxer::DeliverPacket(
135 const NetworkPacket* packet,
136 const PacketTime& packet_time) {
137 if (!packet_receiver_)
138 return;
139 packet_receiver_->DeliverPacket(media_type_, packet->data(),
140 packet->data_length(), packet_time);
141 }
142
143 void DirectTransport::SendPackets() { 100 void DirectTransport::SendPackets() {
144 RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_); 101 RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_);
145 102
146 fake_network_.Process(); 103 fake_network_.Process();
147 104
148 int64_t delay_ms = fake_network_.TimeUntilNextProcess(); 105 int64_t delay_ms = fake_network_.TimeUntilNextProcess();
149 next_scheduled_task_ = task_queue_->PostDelayedTask([this]() { 106 next_scheduled_task_ = task_queue_->PostDelayedTask([this]() {
150 SendPackets(); 107 SendPackets();
151 }, delay_ms); 108 }, delay_ms);
152 } 109 }
153 } // namespace test 110 } // namespace test
154 } // namespace webrtc 111 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/test/direct_transport.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698