Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #ifndef WEBRTC_TEST_DIRECT_TRANSPORT_H_ | 10 #ifndef WEBRTC_TEST_DIRECT_TRANSPORT_H_ |
| 11 #define WEBRTC_TEST_DIRECT_TRANSPORT_H_ | 11 #define WEBRTC_TEST_DIRECT_TRANSPORT_H_ |
| 12 | 12 |
| 13 #include <assert.h> | 13 #include <assert.h> |
| 14 | 14 |
| 15 #include <deque> | 15 #include <memory> |
| 16 | 16 |
| 17 #include "webrtc/api/call/transport.h" | 17 #include "webrtc/api/call/transport.h" |
| 18 #include "webrtc/call/call.h" | 18 #include "webrtc/call/call.h" |
| 19 #include "webrtc/rtc_base/criticalsection.h" | 19 #include "webrtc/rtc_base/sequenced_task_checker.h" |
| 20 #include "webrtc/rtc_base/event.h" | |
| 21 #include "webrtc/rtc_base/platform_thread.h" | |
| 22 #include "webrtc/test/fake_network_pipe.h" | 20 #include "webrtc/test/fake_network_pipe.h" |
| 21 #include "webrtc/test/single_threaded_task_queue.h" | |
| 23 | 22 |
| 24 namespace webrtc { | 23 namespace webrtc { |
| 25 | 24 |
| 26 class Clock; | 25 class Clock; |
| 27 class PacketReceiver; | 26 class PacketReceiver; |
| 28 | 27 |
| 29 namespace test { | 28 namespace test { |
| 30 | 29 |
| 31 class DirectTransport : public Transport { | 30 class DirectTransport : public Transport { |
| 32 public: | 31 public: |
| 33 DirectTransport(Call* send_call, | 32 RTC_DEPRECATED DirectTransport( |
| 34 const std::map<uint8_t, MediaType>& payload_type_map); | 33 Call* send_call, |
| 35 DirectTransport(const FakeNetworkPipe::Config& config, | 34 const std::map<uint8_t, MediaType>& payload_type_map); |
| 36 Call* send_call, | 35 RTC_DEPRECATED DirectTransport( |
| 37 const std::map<uint8_t, MediaType>& payload_type_map); | 36 const FakeNetworkPipe::Config& config, |
| 38 DirectTransport(const FakeNetworkPipe::Config& config, | 37 Call* send_call, |
| 39 Call* send_call, | 38 const std::map<uint8_t, MediaType>& payload_type_map); |
| 40 std::unique_ptr<Demuxer> demuxer); | 39 RTC_DEPRECATED DirectTransport( |
| 40 const FakeNetworkPipe::Config& config, | |
| 41 Call* send_call, | |
| 42 std::unique_ptr<Demuxer> demuxer); | |
| 41 | 43 |
| 42 // This deprecated variant always uses MediaType::VIDEO. | 44 // This deprecated variant always uses MediaType::VIDEO. |
| 43 RTC_DEPRECATED explicit DirectTransport(Call* send_call) | 45 RTC_DEPRECATED explicit DirectTransport(Call* send_call) |
| 44 : DirectTransport( | 46 : DirectTransport( |
| 45 FakeNetworkPipe::Config(), | 47 FakeNetworkPipe::Config(), |
| 46 send_call, | 48 send_call, |
| 47 std::unique_ptr<Demuxer>(new ForceDemuxer(MediaType::VIDEO))) {} | 49 std::unique_ptr<Demuxer>(new ForceDemuxer(MediaType::VIDEO))) {} |
| 48 | 50 |
| 51 DirectTransport(SingleThreadedTaskQueueForTesting* task_queue, | |
| 52 Call* send_call, | |
| 53 const std::map<uint8_t, MediaType>& payload_type_map); | |
| 54 | |
| 55 DirectTransport(SingleThreadedTaskQueueForTesting* task_queue, | |
| 56 const FakeNetworkPipe::Config& config, | |
| 57 Call* send_call, | |
| 58 const std::map<uint8_t, MediaType>& payload_type_map); | |
| 59 | |
| 60 DirectTransport(SingleThreadedTaskQueueForTesting* task_queue, | |
| 61 const FakeNetworkPipe::Config& config, | |
| 62 Call* send_call, | |
| 63 std::unique_ptr<Demuxer> demuxer); | |
| 64 | |
| 49 ~DirectTransport() override; | 65 ~DirectTransport() override; |
| 50 | 66 |
| 51 void SetConfig(const FakeNetworkPipe::Config& config); | 67 void SetConfig(const FakeNetworkPipe::Config& config); |
| 52 | 68 |
| 53 virtual void StopSending(); | 69 RTC_DEPRECATED void StopSending(); |
| 70 | |
| 54 // TODO(holmer): Look into moving this to the constructor. | 71 // TODO(holmer): Look into moving this to the constructor. |
| 55 virtual void SetReceiver(PacketReceiver* receiver); | 72 virtual void SetReceiver(PacketReceiver* receiver); |
| 56 | 73 |
| 57 bool SendRtp(const uint8_t* data, | 74 bool SendRtp(const uint8_t* data, |
| 58 size_t length, | 75 size_t length, |
| 59 const PacketOptions& options) override; | 76 const PacketOptions& options) override; |
| 60 bool SendRtcp(const uint8_t* data, size_t length) override; | 77 bool SendRtcp(const uint8_t* data, size_t length) override; |
| 61 | 78 |
| 62 int GetAverageDelayMs(); | 79 int GetAverageDelayMs(); |
| 63 | 80 |
| 64 private: | 81 private: |
| 65 // TODO(minyue): remove when the deprecated ctors of DirectTransport that | 82 // TODO(minyue): remove when the deprecated ctors of DirectTransport that |
| 66 // create ForceDemuxer are removed. | 83 // create ForceDemuxer are removed. |
| 67 class ForceDemuxer : public Demuxer { | 84 class ForceDemuxer : public Demuxer { |
| 68 public: | 85 public: |
| 69 explicit ForceDemuxer(MediaType media_type); | 86 explicit ForceDemuxer(MediaType media_type); |
| 70 void SetReceiver(PacketReceiver* receiver) override; | 87 void SetReceiver(PacketReceiver* receiver) override; |
| 71 void DeliverPacket(const NetworkPacket* packet, | 88 void DeliverPacket(const NetworkPacket* packet, |
| 72 const PacketTime& packet_time) override; | 89 const PacketTime& packet_time) override; |
| 73 | 90 |
| 74 private: | 91 private: |
| 75 const MediaType media_type_; | 92 const MediaType media_type_; |
| 76 PacketReceiver* packet_receiver_; | 93 PacketReceiver* packet_receiver_; |
| 77 RTC_DISALLOW_COPY_AND_ASSIGN(ForceDemuxer); | 94 RTC_DISALLOW_COPY_AND_ASSIGN(ForceDemuxer); |
| 78 }; | 95 }; |
| 79 | 96 |
| 80 static bool NetworkProcess(void* transport); | 97 void SendPackets(); |
| 81 bool SendPackets(); | |
| 82 | 98 |
| 83 rtc::CriticalSection lock_; | |
| 84 Call* const send_call_; | 99 Call* const send_call_; |
| 85 rtc::Event packet_event_; | |
| 86 rtc::PlatformThread thread_; | |
| 87 Clock* const clock_; | 100 Clock* const clock_; |
| 88 | 101 |
| 89 bool shutting_down_; | 102 // TODO(eladalon): Make |task_queue_| const. |
| 103 // https://bugs.chromium.org/p/webrtc/issues/detail?id=8125 | |
| 104 SingleThreadedTaskQueueForTesting* task_queue_; | |
| 105 SingleThreadedTaskQueueForTesting::TaskId next_scheduled_task_; | |
|
danilchap
2017/08/23 15:49:23
why this member is unguarded? access to it seems r
eladalon
2017/08/24 07:56:51
The *deprecated* version is racy, because it runs
| |
| 90 | 106 |
| 91 FakeNetworkPipe fake_network_; | 107 FakeNetworkPipe fake_network_; |
| 108 | |
| 109 rtc::SequencedTaskChecker sequence_checker_; | |
| 110 | |
| 111 // TODO(eladalon): https://bugs.chromium.org/p/webrtc/issues/detail?id=8125 | |
| 112 // Deprecated versions of the ctor don't get the task queue passed in from | |
| 113 // outside. We'll create one locally for them. This is deprecated, and will | |
| 114 // be removed as soon as the need for those ctors is removed. | |
| 115 std::unique_ptr<SingleThreadedTaskQueueForTesting> deprecated_task_queue_; | |
| 92 }; | 116 }; |
| 93 } // namespace test | 117 } // namespace test |
| 94 } // namespace webrtc | 118 } // namespace webrtc |
| 95 | 119 |
| 96 #endif // WEBRTC_TEST_DIRECT_TRANSPORT_H_ | 120 #endif // WEBRTC_TEST_DIRECT_TRANSPORT_H_ |
| OLD | NEW |