12a9108f911ae7a758f16061ba06bb73b270dd170pbos@webrtc.org/*
22a9108f911ae7a758f16061ba06bb73b270dd170pbos@webrtc.org *  Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
32a9108f911ae7a758f16061ba06bb73b270dd170pbos@webrtc.org *
42a9108f911ae7a758f16061ba06bb73b270dd170pbos@webrtc.org *  Use of this source code is governed by a BSD-style license
52a9108f911ae7a758f16061ba06bb73b270dd170pbos@webrtc.org *  that can be found in the LICENSE file in the root of the source
62a9108f911ae7a758f16061ba06bb73b270dd170pbos@webrtc.org *  tree. An additional intellectual property rights grant can be found
72a9108f911ae7a758f16061ba06bb73b270dd170pbos@webrtc.org *  in the file PATENTS.  All contributing project authors may
82a9108f911ae7a758f16061ba06bb73b270dd170pbos@webrtc.org *  be found in the AUTHORS file in the root of the source tree.
92a9108f911ae7a758f16061ba06bb73b270dd170pbos@webrtc.org */
102a9108f911ae7a758f16061ba06bb73b270dd170pbos@webrtc.org#ifndef WEBRTC_VIDEO_ENGINE_TEST_COMMON_DIRECT_TRANSPORT_H_
112a9108f911ae7a758f16061ba06bb73b270dd170pbos@webrtc.org#define WEBRTC_VIDEO_ENGINE_TEST_COMMON_DIRECT_TRANSPORT_H_
122a9108f911ae7a758f16061ba06bb73b270dd170pbos@webrtc.org
13ce8510901416e37afabb0a54c6e10bec6db63a42pbos@webrtc.org#include <assert.h>
14ce8510901416e37afabb0a54c6e10bec6db63a42pbos@webrtc.org
15fe881f62ea79a98b997af7d6fb0346dcb68acccepbos@webrtc.org#include <deque>
16fe881f62ea79a98b997af7d6fb0346dcb68acccepbos@webrtc.org
17fe881f62ea79a98b997af7d6fb0346dcb68acccepbos@webrtc.org#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
18fe881f62ea79a98b997af7d6fb0346dcb68acccepbos@webrtc.org#include "webrtc/system_wrappers/interface/event_wrapper.h"
19fe881f62ea79a98b997af7d6fb0346dcb68acccepbos@webrtc.org#include "webrtc/system_wrappers/interface/scoped_ptr.h"
20fe881f62ea79a98b997af7d6fb0346dcb68acccepbos@webrtc.org#include "webrtc/system_wrappers/interface/thread_wrapper.h"
21aacdb9f6eed4ceedc8db73865384e29444abcda2stefan@webrtc.org#include "webrtc/test/fake_network_pipe.h"
2224e2089750e9e51228b82d6c7ebf4fa064c797bapbos@webrtc.org#include "webrtc/transport.h"
232a9108f911ae7a758f16061ba06bb73b270dd170pbos@webrtc.org
242a9108f911ae7a758f16061ba06bb73b270dd170pbos@webrtc.orgnamespace webrtc {
25fe881f62ea79a98b997af7d6fb0346dcb68acccepbos@webrtc.org
26e028410838cd976c75e379b3c2e2eb0ac52b3c99stefan@webrtc.orgclass Clock;
27fe881f62ea79a98b997af7d6fb0346dcb68acccepbos@webrtc.orgclass PacketReceiver;
28fe881f62ea79a98b997af7d6fb0346dcb68acccepbos@webrtc.org
292a9108f911ae7a758f16061ba06bb73b270dd170pbos@webrtc.orgnamespace test {
302a9108f911ae7a758f16061ba06bb73b270dd170pbos@webrtc.org
312a9108f911ae7a758f16061ba06bb73b270dd170pbos@webrtc.orgclass DirectTransport : public newapi::Transport {
322a9108f911ae7a758f16061ba06bb73b270dd170pbos@webrtc.org public:
33fe881f62ea79a98b997af7d6fb0346dcb68acccepbos@webrtc.org  DirectTransport();
34aacdb9f6eed4ceedc8db73865384e29444abcda2stefan@webrtc.org  explicit DirectTransport(const FakeNetworkPipe::Config& config);
35fe881f62ea79a98b997af7d6fb0346dcb68acccepbos@webrtc.org  ~DirectTransport();
362a9108f911ae7a758f16061ba06bb73b270dd170pbos@webrtc.org
379900e37401509bbdcd8c7685a4471db42435ef8fhenrik.lundin@webrtc.org  void SetConfig(const FakeNetworkPipe::Config& config);
389900e37401509bbdcd8c7685a4471db42435ef8fhenrik.lundin@webrtc.org
39fe881f62ea79a98b997af7d6fb0346dcb68acccepbos@webrtc.org  virtual void StopSending();
40c1797061756f40b9b1f3f3e82fc040ce18ecd43cpbos@webrtc.org  virtual void SetReceiver(PacketReceiver* receiver);
412a9108f911ae7a758f16061ba06bb73b270dd170pbos@webrtc.org
423009c81bf29a814dfd68ec1faad81e70e3399636pbos@webrtc.org  virtual bool SendRtp(const uint8_t* data, size_t length) OVERRIDE;
433009c81bf29a814dfd68ec1faad81e70e3399636pbos@webrtc.org  virtual bool SendRtcp(const uint8_t* data, size_t length) OVERRIDE;
442a9108f911ae7a758f16061ba06bb73b270dd170pbos@webrtc.org
452a9108f911ae7a758f16061ba06bb73b270dd170pbos@webrtc.org private:
46fe881f62ea79a98b997af7d6fb0346dcb68acccepbos@webrtc.org  static bool NetworkProcess(void* transport);
47fe881f62ea79a98b997af7d6fb0346dcb68acccepbos@webrtc.org  bool SendPackets();
48fe881f62ea79a98b997af7d6fb0346dcb68acccepbos@webrtc.org
49fe881f62ea79a98b997af7d6fb0346dcb68acccepbos@webrtc.org  scoped_ptr<CriticalSectionWrapper> lock_;
50fe881f62ea79a98b997af7d6fb0346dcb68acccepbos@webrtc.org  scoped_ptr<EventWrapper> packet_event_;
51fe881f62ea79a98b997af7d6fb0346dcb68acccepbos@webrtc.org  scoped_ptr<ThreadWrapper> thread_;
52c476e64d056c5e342bc5b23eecd493abf6d85d7fpbos@webrtc.org  Clock* const clock_;
53fe881f62ea79a98b997af7d6fb0346dcb68acccepbos@webrtc.org
54823a888e7f4538d20974a537cc565513f3886658pbos@webrtc.org  bool shutting_down_;
55823a888e7f4538d20974a537cc565513f3886658pbos@webrtc.org
56aacdb9f6eed4ceedc8db73865384e29444abcda2stefan@webrtc.org  FakeNetworkPipe fake_network_;
572a9108f911ae7a758f16061ba06bb73b270dd170pbos@webrtc.org};
58fe881f62ea79a98b997af7d6fb0346dcb68acccepbos@webrtc.org}  // namespace test
59fe881f62ea79a98b997af7d6fb0346dcb68acccepbos@webrtc.org}  // namespace webrtc
602a9108f911ae7a758f16061ba06bb73b270dd170pbos@webrtc.org
612a9108f911ae7a758f16061ba06bb73b270dd170pbos@webrtc.org#endif  // WEBRTC_VIDEO_ENGINE_TEST_COMMON_DIRECT_TRANSPORT_H_
62