| 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_ |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 namespace webrtc { | 24 namespace webrtc { |
| 25 | 25 |
| 26 class Clock; | 26 class Clock; |
| 27 class PacketReceiver; | 27 class PacketReceiver; |
| 28 | 28 |
| 29 namespace test { | 29 namespace test { |
| 30 | 30 |
| 31 class DirectTransport : public Transport { | 31 class DirectTransport : public Transport { |
| 32 public: | 32 public: |
| 33 DirectTransport(Call* send_call, MediaType media_type); | 33 DirectTransport(Call* send_call, |
| 34 DirectTransport(const FakeNetworkPipe::Config& config, Call* send_call, | 34 const std::map<uint8_t, MediaType>& payload_type_map); |
| 35 MediaType media_type); | 35 DirectTransport(const FakeNetworkPipe::Config& config, |
| 36 Call* send_call, |
| 37 const std::map<uint8_t, MediaType>& payload_type_map); |
| 38 DirectTransport(const FakeNetworkPipe::Config& config, |
| 39 Call* send_call, |
| 40 std::unique_ptr<Demuxer> demuxer); |
| 41 |
| 42 // These deprecated variants always use ForceDemuxer. |
| 43 RTC_DEPRECATED DirectTransport(Call* send_call, MediaType media_type) |
| 44 : DirectTransport(FakeNetworkPipe::Config(), send_call, media_type) {} |
| 45 RTC_DEPRECATED DirectTransport(const FakeNetworkPipe::Config& config, |
| 46 Call* send_call, |
| 47 MediaType media_type) |
| 48 : DirectTransport( |
| 49 config, |
| 50 send_call, |
| 51 std::unique_ptr<Demuxer>(new ForceDemuxer(media_type))) {} |
| 52 |
| 36 // These deprecated variants always use MediaType::VIDEO. | 53 // These deprecated variants always use MediaType::VIDEO. |
| 37 RTC_DEPRECATED explicit DirectTransport(Call* send_call) | 54 RTC_DEPRECATED explicit DirectTransport(Call* send_call) |
| 38 : DirectTransport(send_call, MediaType::VIDEO) {} | 55 : DirectTransport(send_call, MediaType::VIDEO) {} |
| 39 | 56 |
| 40 RTC_DEPRECATED DirectTransport(const FakeNetworkPipe::Config& config, | 57 RTC_DEPRECATED DirectTransport(const FakeNetworkPipe::Config& config, |
| 41 Call* send_call) | 58 Call* send_call) |
| 42 : DirectTransport(config, send_call, MediaType::VIDEO) {} | 59 : DirectTransport(config, send_call, MediaType::VIDEO) {} |
| 43 | 60 |
| 44 ~DirectTransport(); | 61 ~DirectTransport(); |
| 45 | 62 |
| 46 void SetConfig(const FakeNetworkPipe::Config& config); | 63 void SetConfig(const FakeNetworkPipe::Config& config); |
| 47 | 64 |
| 48 virtual void StopSending(); | 65 virtual void StopSending(); |
| 49 // TODO(holmer): Look into moving this to the constructor. | 66 // TODO(holmer): Look into moving this to the constructor. |
| 50 virtual void SetReceiver(PacketReceiver* receiver); | 67 virtual void SetReceiver(PacketReceiver* receiver); |
| 51 | 68 |
| 52 bool SendRtp(const uint8_t* data, | 69 bool SendRtp(const uint8_t* data, |
| 53 size_t length, | 70 size_t length, |
| 54 const PacketOptions& options) override; | 71 const PacketOptions& options) override; |
| 55 bool SendRtcp(const uint8_t* data, size_t length) override; | 72 bool SendRtcp(const uint8_t* data, size_t length) override; |
| 56 | 73 |
| 57 int GetAverageDelayMs(); | 74 int GetAverageDelayMs(); |
| 58 | 75 |
| 59 private: | 76 private: |
| 77 // TODO(minyue): remove when the deprecated ctors of DirectTransport that |
| 78 // create ForceDemuxer are removed. |
| 79 class ForceDemuxer : public Demuxer { |
| 80 public: |
| 81 explicit ForceDemuxer(MediaType media_type); |
| 82 void SetReceiver(PacketReceiver* receiver) override; |
| 83 void DeliverPacket(const NetworkPacket* packet, |
| 84 const PacketTime& packet_time) override; |
| 85 |
| 86 private: |
| 87 const MediaType media_type_; |
| 88 PacketReceiver* packet_receiver_; |
| 89 RTC_DISALLOW_COPY_AND_ASSIGN(ForceDemuxer); |
| 90 }; |
| 91 |
| 60 static bool NetworkProcess(void* transport); | 92 static bool NetworkProcess(void* transport); |
| 61 bool SendPackets(); | 93 bool SendPackets(); |
| 62 | 94 |
| 63 rtc::CriticalSection lock_; | 95 rtc::CriticalSection lock_; |
| 64 Call* const send_call_; | 96 Call* const send_call_; |
| 65 rtc::Event packet_event_; | 97 rtc::Event packet_event_; |
| 66 rtc::PlatformThread thread_; | 98 rtc::PlatformThread thread_; |
| 67 Clock* const clock_; | 99 Clock* const clock_; |
| 68 | 100 |
| 69 bool shutting_down_; | 101 bool shutting_down_; |
| 70 | 102 |
| 71 FakeNetworkPipe fake_network_; | 103 FakeNetworkPipe fake_network_; |
| 72 }; | 104 }; |
| 73 } // namespace test | 105 } // namespace test |
| 74 } // namespace webrtc | 106 } // namespace webrtc |
| 75 | 107 |
| 76 #endif // WEBRTC_TEST_DIRECT_TRANSPORT_H_ | 108 #endif // WEBRTC_TEST_DIRECT_TRANSPORT_H_ |
| OLD | NEW |