blob: f910efafaf3c0b020bf402dbff26d76a9a172f6b [file] [log] [blame]
pbos@webrtc.org29d58392013-05-16 12:08:03 +00001/*
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_VIDEO_ENGINE_TEST_COMMON_DIRECT_TRANSPORT_H_
11#define WEBRTC_VIDEO_ENGINE_TEST_COMMON_DIRECT_TRANSPORT_H_
12
pbos@webrtc.orgbbb07e62013-08-05 12:01:36 +000013#include <assert.h>
14
pbos@webrtc.org96684672013-08-12 12:59:04 +000015#include <deque>
16
Peter Boströmf2f82832015-05-01 13:00:41 +020017#include "webrtc/base/criticalsection.h"
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +000018#include "webrtc/base/scoped_ptr.h"
pbos@webrtc.org96684672013-08-12 12:59:04 +000019#include "webrtc/system_wrappers/interface/event_wrapper.h"
pbos@webrtc.org96684672013-08-12 12:59:04 +000020#include "webrtc/system_wrappers/interface/thread_wrapper.h"
stefan@webrtc.orgfaada6e2013-12-18 20:28:25 +000021#include "webrtc/test/fake_network_pipe.h"
pbos@webrtc.org16e03b72013-10-28 16:32:01 +000022#include "webrtc/transport.h"
pbos@webrtc.org29d58392013-05-16 12:08:03 +000023
24namespace webrtc {
pbos@webrtc.org96684672013-08-12 12:59:04 +000025
stefanf116bd02015-10-27 08:29:42 -070026class Call;
stefan@webrtc.orgb082ade2013-11-18 11:45:11 +000027class Clock;
pbos@webrtc.org96684672013-08-12 12:59:04 +000028class PacketReceiver;
pbos@webrtc.org96684672013-08-12 12:59:04 +000029
pbos@webrtc.org29d58392013-05-16 12:08:03 +000030namespace test {
31
pbos2d566682015-09-28 09:59:31 -070032class DirectTransport : public Transport {
pbos@webrtc.org29d58392013-05-16 12:08:03 +000033 public:
stefanf116bd02015-10-27 08:29:42 -070034 explicit DirectTransport(Call* send_call);
35 DirectTransport(const FakeNetworkPipe::Config& config, Call* send_call);
pbos@webrtc.org96684672013-08-12 12:59:04 +000036 ~DirectTransport();
pbos@webrtc.org29d58392013-05-16 12:08:03 +000037
henrik.lundin@webrtc.orgc0e9aeb2014-02-26 13:34:52 +000038 void SetConfig(const FakeNetworkPipe::Config& config);
39
pbos@webrtc.org96684672013-08-12 12:59:04 +000040 virtual void StopSending();
stefanf116bd02015-10-27 08:29:42 -070041 // TODO(holmer): Look into moving this to the constructor.
pbos@webrtc.org74fa4892013-08-23 09:19:30 +000042 virtual void SetReceiver(PacketReceiver* receiver);
pbos@webrtc.org29d58392013-05-16 12:08:03 +000043
stefan1d8a5062015-10-02 03:39:33 -070044 bool SendRtp(const uint8_t* data,
45 size_t length,
46 const PacketOptions& options) override;
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000047 bool SendRtcp(const uint8_t* data, size_t length) override;
pbos@webrtc.org29d58392013-05-16 12:08:03 +000048
49 private:
pbos@webrtc.org96684672013-08-12 12:59:04 +000050 static bool NetworkProcess(void* transport);
51 bool SendPackets();
52
Peter Boströmf2f82832015-05-01 13:00:41 +020053 rtc::CriticalSection lock_;
stefanf116bd02015-10-27 08:29:42 -070054 Call* const send_call_;
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +000055 rtc::scoped_ptr<EventWrapper> packet_event_;
56 rtc::scoped_ptr<ThreadWrapper> thread_;
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +000057 Clock* const clock_;
pbos@webrtc.org96684672013-08-12 12:59:04 +000058
pbos@webrtc.org468e19a2013-08-12 14:28:00 +000059 bool shutting_down_;
60
stefan@webrtc.orgfaada6e2013-12-18 20:28:25 +000061 FakeNetworkPipe fake_network_;
pbos@webrtc.org29d58392013-05-16 12:08:03 +000062};
pbos@webrtc.org96684672013-08-12 12:59:04 +000063} // namespace test
64} // namespace webrtc
pbos@webrtc.org29d58392013-05-16 12:08:03 +000065
66#endif // WEBRTC_VIDEO_ENGINE_TEST_COMMON_DIRECT_TRANSPORT_H_