blob: 660ffecc2ee932690754f808e9ecdcaa1ed3fd68 [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
17#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
18#include "webrtc/system_wrappers/interface/event_wrapper.h"
19#include "webrtc/system_wrappers/interface/scoped_ptr.h"
20#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
31class DirectTransport : public newapi::Transport {
32 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
pbos@webrtc.org96684672013-08-12 12:59:04 +000037 virtual void StopSending();
pbos@webrtc.org74fa4892013-08-23 09:19:30 +000038 virtual void SetReceiver(PacketReceiver* receiver);
pbos@webrtc.org29d58392013-05-16 12:08:03 +000039
pbos@webrtc.org27326b62013-11-20 12:17:04 +000040 virtual bool SendRtp(const uint8_t* data, size_t length) OVERRIDE;
41 virtual bool SendRtcp(const uint8_t* data, size_t length) OVERRIDE;
pbos@webrtc.org29d58392013-05-16 12:08:03 +000042
43 private:
pbos@webrtc.org96684672013-08-12 12:59:04 +000044 static bool NetworkProcess(void* transport);
45 bool SendPackets();
46
47 scoped_ptr<CriticalSectionWrapper> lock_;
48 scoped_ptr<EventWrapper> packet_event_;
49 scoped_ptr<ThreadWrapper> thread_;
stefan@webrtc.orgb082ade2013-11-18 11:45:11 +000050 Clock* clock_;
pbos@webrtc.org96684672013-08-12 12:59:04 +000051
pbos@webrtc.org468e19a2013-08-12 14:28:00 +000052 bool shutting_down_;
53
stefan@webrtc.orgfaada6e2013-12-18 20:28:25 +000054 FakeNetworkPipe fake_network_;
pbos@webrtc.org29d58392013-05-16 12:08:03 +000055};
pbos@webrtc.org96684672013-08-12 12:59:04 +000056} // namespace test
57} // namespace webrtc
pbos@webrtc.org29d58392013-05-16 12:08:03 +000058
59#endif // WEBRTC_VIDEO_ENGINE_TEST_COMMON_DIRECT_TRANSPORT_H_