blob: eb552c57c8e29b52bcb1f562d6f36bd98d4266dd [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"
stefan@webrtc.orgfaada6e2013-12-18 20:28:25 +000021#include "webrtc/test/fake_network_pipe.h"
pbos@webrtc.org29d58392013-05-16 12:08:03 +000022
23namespace webrtc {
pbos@webrtc.org96684672013-08-12 12:59:04 +000024
stefanf116bd02015-10-27 08:29:42 -070025class Call;
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:
stefanf116bd02015-10-27 08:29:42 -070033 explicit DirectTransport(Call* send_call);
34 DirectTransport(const FakeNetworkPipe::Config& config, Call* send_call);
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();
stefanf116bd02015-10-27 08:29:42 -070040 // TODO(holmer): Look into moving this to the constructor.
pbos@webrtc.org74fa4892013-08-23 09:19:30 +000041 virtual void SetReceiver(PacketReceiver* receiver);
pbos@webrtc.org29d58392013-05-16 12:08:03 +000042
stefan1d8a5062015-10-02 03:39:33 -070043 bool SendRtp(const uint8_t* data,
44 size_t length,
45 const PacketOptions& options) override;
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000046 bool SendRtcp(const uint8_t* data, size_t length) override;
pbos@webrtc.org29d58392013-05-16 12:08:03 +000047
Stefan Holmerff2a6352016-01-14 10:00:21 +010048 int GetAverageDelayMs();
49
pbos@webrtc.org29d58392013-05-16 12:08:03 +000050 private:
pbos@webrtc.org96684672013-08-12 12:59:04 +000051 static bool NetworkProcess(void* transport);
52 bool SendPackets();
53
Peter Boströmf2f82832015-05-01 13:00:41 +020054 rtc::CriticalSection lock_;
stefanf116bd02015-10-27 08:29:42 -070055 Call* const send_call_;
Peter Boström5811a392015-12-10 13:02:50 +010056 rtc::Event packet_event_;
Peter Boström8c38e8b2015-11-26 17:45:47 +010057 rtc::PlatformThread thread_;
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +000058 Clock* const clock_;
pbos@webrtc.org96684672013-08-12 12:59:04 +000059
pbos@webrtc.org468e19a2013-08-12 14:28:00 +000060 bool shutting_down_;
61
stefan@webrtc.orgfaada6e2013-12-18 20:28:25 +000062 FakeNetworkPipe fake_network_;
pbos@webrtc.org29d58392013-05-16 12:08:03 +000063};
pbos@webrtc.org96684672013-08-12 12:59:04 +000064} // namespace test
65} // namespace webrtc
pbos@webrtc.org29d58392013-05-16 12:08:03 +000066
Peter Boström7623ce42015-12-09 12:13:30 +010067#endif // WEBRTC_TEST_DIRECT_TRANSPORT_H_