1 /* 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 3 * 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 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 #ifndef WEBRTC_TEST_DIRECT_TRANSPORT_H_ 11 #define WEBRTC_TEST_DIRECT_TRANSPORT_H_ 12 13 #include <assert.h> 14 15 #include <deque> 16 17 #include "webrtc/base/criticalsection.h" 18 #include "webrtc/base/event.h" 19 #include "webrtc/base/platform_thread.h" 20 #include "webrtc/base/scoped_ptr.h" 21 #include "webrtc/test/fake_network_pipe.h" 22 #include "webrtc/transport.h" 23 24 namespace webrtc { 25 26 class Call; 27 class Clock; 28 class PacketReceiver; 29 30 namespace test { 31 32 class DirectTransport : public Transport { 33 public: 34 explicit DirectTransport(Call* send_call); 35 DirectTransport(const FakeNetworkPipe::Config& config, Call* send_call); 36 ~DirectTransport(); 37 38 void SetConfig(const FakeNetworkPipe::Config& config); 39 40 virtual void StopSending(); 41 // TODO(holmer): Look into moving this to the constructor. 42 virtual void SetReceiver(PacketReceiver* receiver); 43 44 bool SendRtp(const uint8_t* data, 45 size_t length, 46 const PacketOptions& options) override; 47 bool SendRtcp(const uint8_t* data, size_t length) override; 48 49 int GetAverageDelayMs(); 50 51 private: 52 static bool NetworkProcess(void* transport); 53 bool SendPackets(); 54 55 rtc::CriticalSection lock_; 56 Call* const send_call_; 57 rtc::Event packet_event_; 58 rtc::PlatformThread thread_; 59 Clock* const clock_; 60 61 bool shutting_down_; 62 63 FakeNetworkPipe fake_network_; 64 }; 65 } // namespace test 66 } // namespace webrtc 67 68 #endif // WEBRTC_TEST_DIRECT_TRANSPORT_H_ 69