blob: c60157dc22573155631ba6faa2e7b67cabf9119f [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
eladalon413ee9a2017-08-22 04:02:52 -070015#include <memory>
pbos@webrtc.org96684672013-08-12 12:59:04 +000016
aleloia8eb7562016-11-28 07:02:13 -080017#include "webrtc/api/call/transport.h"
nissee5ad5ca2017-03-29 23:57:43 -070018#include "webrtc/call/call.h"
eladalon413ee9a2017-08-22 04:02:52 -070019#include "webrtc/rtc_base/sequenced_task_checker.h"
eladaloncff98dc2017-08-24 05:04:56 -070020#include "webrtc/rtc_base/thread_annotations.h"
stefan@webrtc.orgfaada6e2013-12-18 20:28:25 +000021#include "webrtc/test/fake_network_pipe.h"
eladalon413ee9a2017-08-22 04:02:52 -070022#include "webrtc/test/single_threaded_task_queue.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
eladaloncff98dc2017-08-24 05:04:56 -070031// Objects of this class are expected to be allocated and destroyed on the
32// same task-queue - the one that's passed in via the constructor.
pbos2d566682015-09-28 09:59:31 -070033class DirectTransport : public Transport {
pbos@webrtc.org29d58392013-05-16 12:08:03 +000034 public:
eladalon413ee9a2017-08-22 04:02:52 -070035 DirectTransport(SingleThreadedTaskQueueForTesting* task_queue,
36 Call* send_call,
37 const std::map<uint8_t, MediaType>& payload_type_map);
38
39 DirectTransport(SingleThreadedTaskQueueForTesting* task_queue,
40 const FakeNetworkPipe::Config& config,
41 Call* send_call,
42 const std::map<uint8_t, MediaType>& payload_type_map);
43
44 DirectTransport(SingleThreadedTaskQueueForTesting* task_queue,
45 const FakeNetworkPipe::Config& config,
46 Call* send_call,
47 std::unique_ptr<Demuxer> demuxer);
48
eladalon8435e552017-08-03 07:44:08 -070049 ~DirectTransport() override;
pbos@webrtc.org29d58392013-05-16 12:08:03 +000050
henrik.lundin@webrtc.orgc0e9aeb2014-02-26 13:34:52 +000051 void SetConfig(const FakeNetworkPipe::Config& config);
52
eladalon413ee9a2017-08-22 04:02:52 -070053 RTC_DEPRECATED void StopSending();
54
stefanf116bd02015-10-27 08:29:42 -070055 // TODO(holmer): Look into moving this to the constructor.
pbos@webrtc.org74fa4892013-08-23 09:19:30 +000056 virtual void SetReceiver(PacketReceiver* receiver);
pbos@webrtc.org29d58392013-05-16 12:08:03 +000057
stefan1d8a5062015-10-02 03:39:33 -070058 bool SendRtp(const uint8_t* data,
59 size_t length,
60 const PacketOptions& options) override;
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000061 bool SendRtcp(const uint8_t* data, size_t length) override;
pbos@webrtc.org29d58392013-05-16 12:08:03 +000062
Stefan Holmerff2a6352016-01-14 10:00:21 +010063 int GetAverageDelayMs();
64
pbos@webrtc.org29d58392013-05-16 12:08:03 +000065 private:
eladalon413ee9a2017-08-22 04:02:52 -070066 void SendPackets();
pbos@webrtc.org96684672013-08-12 12:59:04 +000067
stefanf116bd02015-10-27 08:29:42 -070068 Call* const send_call_;
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +000069 Clock* const clock_;
pbos@webrtc.org96684672013-08-12 12:59:04 +000070
eladalon8a6241e2017-08-29 06:53:21 -070071 SingleThreadedTaskQueueForTesting* const task_queue_;
eladaloncff98dc2017-08-24 05:04:56 -070072 SingleThreadedTaskQueueForTesting::TaskId next_scheduled_task_
danilchapa37de392017-09-09 04:17:22 -070073 RTC_GUARDED_BY(&sequence_checker_);
pbos@webrtc.org468e19a2013-08-12 14:28:00 +000074
stefan@webrtc.orgfaada6e2013-12-18 20:28:25 +000075 FakeNetworkPipe fake_network_;
eladalon413ee9a2017-08-22 04:02:52 -070076
77 rtc::SequencedTaskChecker sequence_checker_;
pbos@webrtc.org29d58392013-05-16 12:08:03 +000078};
pbos@webrtc.org96684672013-08-12 12:59:04 +000079} // namespace test
80} // namespace webrtc
pbos@webrtc.org29d58392013-05-16 12:08:03 +000081
Peter Boström7623ce42015-12-09 12:13:30 +010082#endif // WEBRTC_TEST_DIRECT_TRANSPORT_H_