2013-05-16 12:08:03 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef TEST_DIRECT_TRANSPORT_H_
|
|
|
|
|
#define TEST_DIRECT_TRANSPORT_H_
|
2013-05-16 12:08:03 +00:00
|
|
|
|
2013-08-05 12:01:36 +00:00
|
|
|
#include <assert.h>
|
|
|
|
|
|
2017-08-22 04:02:52 -07:00
|
|
|
#include <memory>
|
2013-08-12 12:59:04 +00:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "api/call/transport.h"
|
|
|
|
|
#include "call/call.h"
|
|
|
|
|
#include "rtc_base/sequenced_task_checker.h"
|
|
|
|
|
#include "rtc_base/thread_annotations.h"
|
|
|
|
|
#include "test/fake_network_pipe.h"
|
|
|
|
|
#include "test/single_threaded_task_queue.h"
|
2013-05-16 12:08:03 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
2013-08-12 12:59:04 +00:00
|
|
|
|
2013-11-18 11:45:11 +00:00
|
|
|
class Clock;
|
2013-08-12 12:59:04 +00:00
|
|
|
class PacketReceiver;
|
|
|
|
|
|
2013-05-16 12:08:03 +00:00
|
|
|
namespace test {
|
|
|
|
|
|
2017-08-24 05:04:56 -07:00
|
|
|
// Objects of this class are expected to be allocated and destroyed on the
|
|
|
|
|
// same task-queue - the one that's passed in via the constructor.
|
2015-09-28 09:59:31 -07:00
|
|
|
class DirectTransport : public Transport {
|
2013-05-16 12:08:03 +00:00
|
|
|
public:
|
2017-08-22 04:02:52 -07:00
|
|
|
DirectTransport(SingleThreadedTaskQueueForTesting* task_queue,
|
|
|
|
|
Call* send_call,
|
|
|
|
|
const std::map<uint8_t, MediaType>& payload_type_map);
|
|
|
|
|
|
|
|
|
|
DirectTransport(SingleThreadedTaskQueueForTesting* task_queue,
|
|
|
|
|
const FakeNetworkPipe::Config& config,
|
|
|
|
|
Call* send_call,
|
|
|
|
|
const std::map<uint8_t, MediaType>& payload_type_map);
|
|
|
|
|
|
|
|
|
|
DirectTransport(SingleThreadedTaskQueueForTesting* task_queue,
|
|
|
|
|
const FakeNetworkPipe::Config& config,
|
|
|
|
|
Call* send_call,
|
|
|
|
|
std::unique_ptr<Demuxer> demuxer);
|
|
|
|
|
|
2017-10-24 16:26:49 +02:00
|
|
|
DirectTransport(SingleThreadedTaskQueueForTesting* task_queue,
|
|
|
|
|
std::unique_ptr<FakeNetworkPipe> pipe, Call* send_call);
|
|
|
|
|
|
2017-08-03 07:44:08 -07:00
|
|
|
~DirectTransport() override;
|
2013-05-16 12:08:03 +00:00
|
|
|
|
2014-02-26 13:34:52 +00:00
|
|
|
void SetConfig(const FakeNetworkPipe::Config& config);
|
|
|
|
|
|
2017-08-22 04:02:52 -07:00
|
|
|
RTC_DEPRECATED void StopSending();
|
|
|
|
|
|
2015-10-27 08:29:42 -07:00
|
|
|
// TODO(holmer): Look into moving this to the constructor.
|
2013-08-23 09:19:30 +00:00
|
|
|
virtual void SetReceiver(PacketReceiver* receiver);
|
2013-05-16 12:08:03 +00:00
|
|
|
|
2015-10-02 03:39:33 -07:00
|
|
|
bool SendRtp(const uint8_t* data,
|
|
|
|
|
size_t length,
|
|
|
|
|
const PacketOptions& options) override;
|
2015-03-04 12:58:35 +00:00
|
|
|
bool SendRtcp(const uint8_t* data, size_t length) override;
|
2013-05-16 12:08:03 +00:00
|
|
|
|
2016-01-14 10:00:21 +01:00
|
|
|
int GetAverageDelayMs();
|
|
|
|
|
|
2013-05-16 12:08:03 +00:00
|
|
|
private:
|
2017-08-22 04:02:52 -07:00
|
|
|
void SendPackets();
|
2017-10-24 16:26:49 +02:00
|
|
|
void Start();
|
2013-08-12 12:59:04 +00:00
|
|
|
|
2015-10-27 08:29:42 -07:00
|
|
|
Call* const send_call_;
|
2014-04-28 13:00:21 +00:00
|
|
|
Clock* const clock_;
|
2013-08-12 12:59:04 +00:00
|
|
|
|
2017-08-29 06:53:21 -07:00
|
|
|
SingleThreadedTaskQueueForTesting* const task_queue_;
|
2017-08-24 05:04:56 -07:00
|
|
|
SingleThreadedTaskQueueForTesting::TaskId next_scheduled_task_
|
2017-09-09 04:17:22 -07:00
|
|
|
RTC_GUARDED_BY(&sequence_checker_);
|
2013-08-12 14:28:00 +00:00
|
|
|
|
2017-10-24 16:26:49 +02:00
|
|
|
std::unique_ptr<FakeNetworkPipe> fake_network_;
|
2017-08-22 04:02:52 -07:00
|
|
|
|
|
|
|
|
rtc::SequencedTaskChecker sequence_checker_;
|
2013-05-16 12:08:03 +00:00
|
|
|
};
|
2013-08-12 12:59:04 +00:00
|
|
|
} // namespace test
|
|
|
|
|
} // namespace webrtc
|
2013-05-16 12:08:03 +00:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // TEST_DIRECT_TRANSPORT_H_
|