blob: d4cb45aad97a88bf4e1e7ecb40b266ab9e45189b [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"
pbos@webrtc.org16e03b72013-10-28 16:32:01 +000021#include "webrtc/transport.h"
pbos@webrtc.org29d58392013-05-16 12:08:03 +000022
23namespace webrtc {
pbos@webrtc.org96684672013-08-12 12:59:04 +000024
pbos@webrtc.org96684672013-08-12 12:59:04 +000025class PacketReceiver;
pbos@webrtc.org96684672013-08-12 12:59:04 +000026
pbos@webrtc.org29d58392013-05-16 12:08:03 +000027namespace test {
28
29class DirectTransport : public newapi::Transport {
30 public:
pbos@webrtc.org96684672013-08-12 12:59:04 +000031 DirectTransport();
32 ~DirectTransport();
pbos@webrtc.org29d58392013-05-16 12:08:03 +000033
pbos@webrtc.org96684672013-08-12 12:59:04 +000034 virtual void StopSending();
pbos@webrtc.org74fa4892013-08-23 09:19:30 +000035 virtual void SetReceiver(PacketReceiver* receiver);
pbos@webrtc.org29d58392013-05-16 12:08:03 +000036
pbos@webrtc.org96684672013-08-12 12:59:04 +000037 virtual bool SendRTP(const uint8_t* data, size_t length) OVERRIDE;
38 virtual bool SendRTCP(const uint8_t* data, size_t length) OVERRIDE;
pbos@webrtc.org29d58392013-05-16 12:08:03 +000039
40 private:
pbos@webrtc.org96684672013-08-12 12:59:04 +000041 struct Packet {
42 Packet();
43 Packet(const uint8_t* data, size_t length);
44
45 uint8_t data[1500];
46 size_t length;
47 };
48
49 void QueuePacket(const uint8_t* data, size_t length);
50
51 static bool NetworkProcess(void* transport);
52 bool SendPackets();
53
54 scoped_ptr<CriticalSectionWrapper> lock_;
55 scoped_ptr<EventWrapper> packet_event_;
56 scoped_ptr<ThreadWrapper> thread_;
57
pbos@webrtc.org468e19a2013-08-12 14:28:00 +000058 bool shutting_down_;
59
pbos@webrtc.org96684672013-08-12 12:59:04 +000060 std::deque<Packet> packet_queue_;
pbos@webrtc.org74fa4892013-08-23 09:19:30 +000061 PacketReceiver* receiver_;
pbos@webrtc.org29d58392013-05-16 12:08:03 +000062};
pbos@webrtc.org96684672013-08-12 12:59:04 +000063} // namespace test
64} // namespace webrtc
pbos@webrtc.org29d58392013-05-16 12:08:03 +000065
66#endif // WEBRTC_VIDEO_ENGINE_TEST_COMMON_DIRECT_TRANSPORT_H_