blob: 20a6857182b71d545b0d742df3aea61aa31138df [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 */
Peter Boström7623ce42015-12-09 12:13:30 +010010#ifndef WEBRTC_TEST_DIRECT_TRANSPORT_H_
11#define WEBRTC_TEST_DIRECT_TRANSPORT_H_
pbos@webrtc.org29d58392013-05-16 12:08:03 +000012
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
aleloia8eb7562016-11-28 07:02:13 -080017#include "webrtc/api/call/transport.h"
Peter Boströmf2f82832015-05-01 13:00:41 +020018#include "webrtc/base/criticalsection.h"
Peter Boström5811a392015-12-10 13:02:50 +010019#include "webrtc/base/event.h"
pbos12411ef2015-11-23 14:47:56 -080020#include "webrtc/base/platform_thread.h"
nissee5ad5ca2017-03-29 23:57:43 -070021#include "webrtc/call/call.h"
stefan@webrtc.orgfaada6e2013-12-18 20:28:25 +000022#include "webrtc/test/fake_network_pipe.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:
nissee5ad5ca2017-03-29 23:57:43 -070033 DirectTransport(Call* send_call, MediaType media_type);
34 DirectTransport(const FakeNetworkPipe::Config& config, Call* send_call,
35 MediaType media_type);
36 // These deprecated variants always use MediaType::VIDEO.
37 RTC_DEPRECATED explicit DirectTransport(Call* send_call)
38 : DirectTransport(send_call, MediaType::VIDEO) {}
39
40 RTC_DEPRECATED DirectTransport(const FakeNetworkPipe::Config& config,
41 Call* send_call)
42 : DirectTransport(config, send_call, MediaType::VIDEO) {}
43
pbos@webrtc.org96684672013-08-12 12:59:04 +000044 ~DirectTransport();
pbos@webrtc.org29d58392013-05-16 12:08:03 +000045
henrik.lundin@webrtc.orgc0e9aeb2014-02-26 13:34:52 +000046 void SetConfig(const FakeNetworkPipe::Config& config);
47
pbos@webrtc.org96684672013-08-12 12:59:04 +000048 virtual void StopSending();
stefanf116bd02015-10-27 08:29:42 -070049 // TODO(holmer): Look into moving this to the constructor.
pbos@webrtc.org74fa4892013-08-23 09:19:30 +000050 virtual void SetReceiver(PacketReceiver* receiver);
pbos@webrtc.org29d58392013-05-16 12:08:03 +000051
stefan1d8a5062015-10-02 03:39:33 -070052 bool SendRtp(const uint8_t* data,
53 size_t length,
54 const PacketOptions& options) override;
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000055 bool SendRtcp(const uint8_t* data, size_t length) override;
pbos@webrtc.org29d58392013-05-16 12:08:03 +000056
Stefan Holmerff2a6352016-01-14 10:00:21 +010057 int GetAverageDelayMs();
58
pbos@webrtc.org29d58392013-05-16 12:08:03 +000059 private:
pbos@webrtc.org96684672013-08-12 12:59:04 +000060 static bool NetworkProcess(void* transport);
61 bool SendPackets();
62
Peter Boströmf2f82832015-05-01 13:00:41 +020063 rtc::CriticalSection lock_;
stefanf116bd02015-10-27 08:29:42 -070064 Call* const send_call_;
Peter Boström5811a392015-12-10 13:02:50 +010065 rtc::Event packet_event_;
Peter Boström8c38e8b2015-11-26 17:45:47 +010066 rtc::PlatformThread thread_;
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +000067 Clock* const clock_;
pbos@webrtc.org96684672013-08-12 12:59:04 +000068
pbos@webrtc.org468e19a2013-08-12 14:28:00 +000069 bool shutting_down_;
70
stefan@webrtc.orgfaada6e2013-12-18 20:28:25 +000071 FakeNetworkPipe fake_network_;
pbos@webrtc.org29d58392013-05-16 12:08:03 +000072};
pbos@webrtc.org96684672013-08-12 12:59:04 +000073} // namespace test
74} // namespace webrtc
pbos@webrtc.org29d58392013-05-16 12:08:03 +000075
Peter Boström7623ce42015-12-09 12:13:30 +010076#endif // WEBRTC_TEST_DIRECT_TRANSPORT_H_