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 <deque> |
| 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/thread_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 DirectTransport(SingleThreadedTaskQueueForTesting* task_queue, |
| 34 const std::map<uint8_t, MediaType>& payload_type_map); | |
| 35 DirectTransport(const FakeNetworkPipe::Config& config, | |
| 36 Call* send_call, | 33 Call* send_call, |
| 37 const std::map<uint8_t, MediaType>& payload_type_map); | 34 const std::map<uint8_t, MediaType>& payload_type_map); |
| 38 DirectTransport(const FakeNetworkPipe::Config& config, | 35 |
| 36 DirectTransport(SingleThreadedTaskQueueForTesting* task_queue, | |
| 37 const FakeNetworkPipe::Config& config, | |
| 38 Call* send_call, | |
| 39 const std::map<uint8_t, MediaType>& payload_type_map); | |
| 40 | |
| 41 DirectTransport(SingleThreadedTaskQueueForTesting* task_queue, | |
| 42 const FakeNetworkPipe::Config& config, | |
| 39 Call* send_call, | 43 Call* send_call, |
| 40 std::unique_ptr<Demuxer> demuxer); | 44 std::unique_ptr<Demuxer> demuxer); |
| 41 | 45 |
| 42 // This deprecated variant always uses MediaType::VIDEO. | 46 // This deprecated variant always uses MediaType::VIDEO. |
| 43 RTC_DEPRECATED explicit DirectTransport(Call* send_call) | 47 RTC_DEPRECATED explicit DirectTransport(Call* send_call) |
| 44 : DirectTransport( | 48 : DirectTransport( |
| 49 // TODO(eladalon): !!! Deprecate older APIs gently. (Before landing.) | |
| 50 nullptr, | |
| 45 FakeNetworkPipe::Config(), | 51 FakeNetworkPipe::Config(), |
| 46 send_call, | 52 send_call, |
| 47 std::unique_ptr<Demuxer>(new ForceDemuxer(MediaType::VIDEO))) {} | 53 std::unique_ptr<Demuxer>(new ForceDemuxer(MediaType::VIDEO))) {} |
| 48 | 54 |
| 49 ~DirectTransport() override; | 55 ~DirectTransport() override; |
| 50 | 56 |
| 51 void SetConfig(const FakeNetworkPipe::Config& config); | 57 void SetConfig(const FakeNetworkPipe::Config& config); |
| 52 | 58 |
| 53 virtual void StopSending(); | |
|
nisse-webrtc
2017/08/21 09:07:07
Ok, so you're deleting this method? Worth mentioni
eladalon
2017/08/21 10:56:53
Done.
| |
| 54 // TODO(holmer): Look into moving this to the constructor. | 59 // TODO(holmer): Look into moving this to the constructor. |
| 55 virtual void SetReceiver(PacketReceiver* receiver); | 60 virtual void SetReceiver(PacketReceiver* receiver); |
| 56 | 61 |
| 57 bool SendRtp(const uint8_t* data, | 62 bool SendRtp(const uint8_t* data, |
| 58 size_t length, | 63 size_t length, |
| 59 const PacketOptions& options) override; | 64 const PacketOptions& options) override; |
| 60 bool SendRtcp(const uint8_t* data, size_t length) override; | 65 bool SendRtcp(const uint8_t* data, size_t length) override; |
| 61 | 66 |
| 62 int GetAverageDelayMs(); | 67 int GetAverageDelayMs(); |
| 63 | 68 |
| 64 private: | 69 private: |
| 65 // TODO(minyue): remove when the deprecated ctors of DirectTransport that | 70 // TODO(minyue): remove when the deprecated ctors of DirectTransport that |
| 66 // create ForceDemuxer are removed. | 71 // create ForceDemuxer are removed. |
| 67 class ForceDemuxer : public Demuxer { | 72 class ForceDemuxer : public Demuxer { |
| 68 public: | 73 public: |
| 69 explicit ForceDemuxer(MediaType media_type); | 74 explicit ForceDemuxer(MediaType media_type); |
| 70 void SetReceiver(PacketReceiver* receiver) override; | 75 void SetReceiver(PacketReceiver* receiver) override; |
| 71 void DeliverPacket(const NetworkPacket* packet, | 76 void DeliverPacket(const NetworkPacket* packet, |
| 72 const PacketTime& packet_time) override; | 77 const PacketTime& packet_time) override; |
| 73 | 78 |
| 74 private: | 79 private: |
| 75 const MediaType media_type_; | 80 const MediaType media_type_; |
| 76 PacketReceiver* packet_receiver_; | 81 PacketReceiver* packet_receiver_; |
| 77 RTC_DISALLOW_COPY_AND_ASSIGN(ForceDemuxer); | 82 RTC_DISALLOW_COPY_AND_ASSIGN(ForceDemuxer); |
| 78 }; | 83 }; |
| 79 | 84 |
| 80 static bool NetworkProcess(void* transport); | 85 void SendPackets(); |
| 81 bool SendPackets(); | |
| 82 | 86 |
| 83 rtc::CriticalSection lock_; | |
| 84 Call* const send_call_; | 87 Call* const send_call_; |
| 85 rtc::Event packet_event_; | |
| 86 rtc::PlatformThread thread_; | |
| 87 Clock* const clock_; | 88 Clock* const clock_; |
| 88 | 89 |
| 89 bool shutting_down_; | 90 SingleThreadedTaskQueueForTesting* const task_queue_; |
| 91 SingleThreadedTaskQueueForTesting::TaskId next_scheduled_task_; | |
| 90 | 92 |
| 91 FakeNetworkPipe fake_network_; | 93 FakeNetworkPipe fake_network_; |
| 94 | |
| 95 rtc::ThreadChecker thread_checker_; | |
| 92 }; | 96 }; |
| 93 } // namespace test | 97 } // namespace test |
| 94 } // namespace webrtc | 98 } // namespace webrtc |
| 95 | 99 |
| 96 #endif // WEBRTC_TEST_DIRECT_TRANSPORT_H_ | 100 #endif // WEBRTC_TEST_DIRECT_TRANSPORT_H_ |
| OLD | NEW |