blob: 1c6f937401dac9012f80b7e8342269541117c018 [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
stefan@webrtc.orgb082ade2013-11-18 11:45:11 +000026class Clock;
pbos@webrtc.org96684672013-08-12 12:59:04 +000027class PacketReceiver;
pbos@webrtc.org96684672013-08-12 12:59:04 +000028
pbos@webrtc.org29d58392013-05-16 12:08:03 +000029namespace test {
30
pbos2d566682015-09-28 09:59:31 -070031class DirectTransport : public Transport {
pbos@webrtc.org29d58392013-05-16 12:08:03 +000032 public:
pbos@webrtc.org96684672013-08-12 12:59:04 +000033 DirectTransport();
stefan@webrtc.orgfaada6e2013-12-18 20:28:25 +000034 explicit DirectTransport(const FakeNetworkPipe::Config& config);
pbos@webrtc.org96684672013-08-12 12:59:04 +000035 ~DirectTransport();
pbos@webrtc.org29d58392013-05-16 12:08:03 +000036
henrik.lundin@webrtc.orgc0e9aeb2014-02-26 13:34:52 +000037 void SetConfig(const FakeNetworkPipe::Config& config);
38
pbos@webrtc.org96684672013-08-12 12:59:04 +000039 virtual void StopSending();
pbos@webrtc.org74fa4892013-08-23 09:19:30 +000040 virtual void SetReceiver(PacketReceiver* receiver);
pbos@webrtc.org29d58392013-05-16 12:08:03 +000041
stefan1d8a5062015-10-02 03:39:33 -070042 bool SendRtp(const uint8_t* data,
43 size_t length,
44 const PacketOptions& options) override;
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000045 bool SendRtcp(const uint8_t* data, size_t length) override;
pbos@webrtc.org29d58392013-05-16 12:08:03 +000046
47 private:
pbos@webrtc.org96684672013-08-12 12:59:04 +000048 static bool NetworkProcess(void* transport);
49 bool SendPackets();
50
Peter Boströmf2f82832015-05-01 13:00:41 +020051 rtc::CriticalSection lock_;
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +000052 rtc::scoped_ptr<EventWrapper> packet_event_;
53 rtc::scoped_ptr<ThreadWrapper> thread_;
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +000054 Clock* const clock_;
pbos@webrtc.org96684672013-08-12 12:59:04 +000055
pbos@webrtc.org468e19a2013-08-12 14:28:00 +000056 bool shutting_down_;
57
stefan@webrtc.orgfaada6e2013-12-18 20:28:25 +000058 FakeNetworkPipe fake_network_;
pbos@webrtc.org29d58392013-05-16 12:08:03 +000059};
pbos@webrtc.org96684672013-08-12 12:59:04 +000060} // namespace test
61} // namespace webrtc
pbos@webrtc.org29d58392013-05-16 12:08:03 +000062
63#endif // WEBRTC_VIDEO_ENGINE_TEST_COMMON_DIRECT_TRANSPORT_H_