18281e7dd4a8ac4b00aededd8ebf52e93f1d980e8pwestin@webrtc.org/*
22853dde5201d9ddc284ce5efb9688f6340487acepwestin@webrtc.org *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
38281e7dd4a8ac4b00aededd8ebf52e93f1d980e8pwestin@webrtc.org *
48281e7dd4a8ac4b00aededd8ebf52e93f1d980e8pwestin@webrtc.org *  Use of this source code is governed by a BSD-style license
58281e7dd4a8ac4b00aededd8ebf52e93f1d980e8pwestin@webrtc.org *  that can be found in the LICENSE file in the root of the source
68281e7dd4a8ac4b00aededd8ebf52e93f1d980e8pwestin@webrtc.org *  tree. An additional intellectual property rights grant can be found
78281e7dd4a8ac4b00aededd8ebf52e93f1d980e8pwestin@webrtc.org *  in the file PATENTS.  All contributing project authors may
88281e7dd4a8ac4b00aededd8ebf52e93f1d980e8pwestin@webrtc.org *  be found in the AUTHORS file in the root of the source tree.
98281e7dd4a8ac4b00aededd8ebf52e93f1d980e8pwestin@webrtc.org */
105eb4988c0ac0665701e9bccba0fad3dcadfcfcd0danilchap#ifndef WEBRTC_MODULES_RTP_RTCP_TEST_TESTAPI_TEST_API_H_
115eb4988c0ac0665701e9bccba0fad3dcadfcfcd0danilchap#define WEBRTC_MODULES_RTP_RTCP_TEST_TESTAPI_TEST_API_H_
128281e7dd4a8ac4b00aededd8ebf52e93f1d980e8pwestin@webrtc.org
13bda7f305c5d7d675f1c35813bd2b2a5732775bb9mikhal@webrtc.org#include "testing/gtest/include/gtest/gtest.h"
1400b8f6b3643332cce1ee711715f7fbb824d793cakwiberg@webrtc.org#include "webrtc/base/scoped_ptr.h"
15bda7f305c5d7d675f1c35813bd2b2a5732775bb9mikhal@webrtc.org#include "webrtc/common_types.h"
16ff761fba8274d93bd73e76c8b8a1f2d0776dd840Henrik Kjellander#include "webrtc/modules/rtp_rtcp/include/receive_statistics.h"
17ff761fba8274d93bd73e76c8b8a1f2d0776dd840Henrik Kjellander#include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"
18ff761fba8274d93bd73e76c8b8a1f2d0776dd840Henrik Kjellander#include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h"
19ff761fba8274d93bd73e76c8b8a1f2d0776dd840Henrik Kjellander#include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h"
20ff761fba8274d93bd73e76c8b8a1f2d0776dd840Henrik Kjellander#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
21ff761fba8274d93bd73e76c8b8a1f2d0776dd840Henrik Kjellander#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
222d566686a23fe93ada58f1c38a0d4b9a0d68556epbos#include "webrtc/transport.h"
238281e7dd4a8ac4b00aededd8ebf52e93f1d980e8pwestin@webrtc.org
24a1783598a78b2cd583408d97372fb4c0ba0fde91pwestin@webrtc.orgnamespace webrtc {
258281e7dd4a8ac4b00aededd8ebf52e93f1d980e8pwestin@webrtc.org
268281e7dd4a8ac4b00aededd8ebf52e93f1d980e8pwestin@webrtc.org// This class sends all its packet straight to the provided RtpRtcp module.
278281e7dd4a8ac4b00aededd8ebf52e93f1d980e8pwestin@webrtc.org// with optional packet loss.
282d566686a23fe93ada58f1c38a0d4b9a0d68556epbosclass LoopBackTransport : public Transport {
298281e7dd4a8ac4b00aededd8ebf52e93f1d980e8pwestin@webrtc.org public:
302853dde5201d9ddc284ce5efb9688f6340487acepwestin@webrtc.org  LoopBackTransport()
319691b369951d8406b32bda2fb40667d55a3da96achangbin.shao@intel.com      : count_(0),
329691b369951d8406b32bda2fb40667d55a3da96achangbin.shao@intel.com        packet_loss_(0),
339691b369951d8406b32bda2fb40667d55a3da96achangbin.shao@intel.com        rtp_payload_registry_(NULL),
349691b369951d8406b32bda2fb40667d55a3da96achangbin.shao@intel.com        rtp_receiver_(NULL),
359691b369951d8406b32bda2fb40667d55a3da96achangbin.shao@intel.com        rtp_rtcp_module_(NULL) {}
369691b369951d8406b32bda2fb40667d55a3da96achangbin.shao@intel.com  void SetSendModule(RtpRtcp* rtp_rtcp_module,
37822fbd8b68ffdb481b9557e2950ae8d6657c8ce6wu@webrtc.org                     RTPPayloadRegistry* payload_registry,
38822fbd8b68ffdb481b9557e2950ae8d6657c8ce6wu@webrtc.org                     RtpReceiver* receiver,
399691b369951d8406b32bda2fb40667d55a3da96achangbin.shao@intel.com                     ReceiveStatistics* receive_statistics);
409691b369951d8406b32bda2fb40667d55a3da96achangbin.shao@intel.com  void DropEveryNthPacket(int n);
411d8a506405734d0cef9653704b036ca4f1388960stefan  bool SendRtp(const uint8_t* data,
421d8a506405734d0cef9653704b036ca4f1388960stefan               size_t len,
431d8a506405734d0cef9653704b036ca4f1388960stefan               const PacketOptions& options) override;
442d566686a23fe93ada58f1c38a0d4b9a0d68556epbos  bool SendRtcp(const uint8_t* data, size_t len) override;
459691b369951d8406b32bda2fb40667d55a3da96achangbin.shao@intel.com
468281e7dd4a8ac4b00aededd8ebf52e93f1d980e8pwestin@webrtc.org private:
479691b369951d8406b32bda2fb40667d55a3da96achangbin.shao@intel.com  int count_;
489691b369951d8406b32bda2fb40667d55a3da96achangbin.shao@intel.com  int packet_loss_;
49822fbd8b68ffdb481b9557e2950ae8d6657c8ce6wu@webrtc.org  ReceiveStatistics* receive_statistics_;
50822fbd8b68ffdb481b9557e2950ae8d6657c8ce6wu@webrtc.org  RTPPayloadRegistry* rtp_payload_registry_;
51822fbd8b68ffdb481b9557e2950ae8d6657c8ce6wu@webrtc.org  RtpReceiver* rtp_receiver_;
529691b369951d8406b32bda2fb40667d55a3da96achangbin.shao@intel.com  RtpRtcp* rtp_rtcp_module_;
538281e7dd4a8ac4b00aededd8ebf52e93f1d980e8pwestin@webrtc.org};
548281e7dd4a8ac4b00aededd8ebf52e93f1d980e8pwestin@webrtc.org
55822fbd8b68ffdb481b9557e2950ae8d6657c8ce6wu@webrtc.orgclass TestRtpReceiver : public NullRtpData {
568281e7dd4a8ac4b00aededd8ebf52e93f1d980e8pwestin@webrtc.org public:
5714665ff7d4024d07e58622f498b23fd980001871kjellander@webrtc.org  int32_t OnReceivedPayloadData(
589691b369951d8406b32bda2fb40667d55a3da96achangbin.shao@intel.com      const uint8_t* payload_data,
599691b369951d8406b32bda2fb40667d55a3da96achangbin.shao@intel.com      const size_t payload_size,
6014665ff7d4024d07e58622f498b23fd980001871kjellander@webrtc.org      const webrtc::WebRtcRTPHeader* rtp_header) override;
618d0cd07d0c5e30eacaac4c118f9fd624b11e67abstefan@webrtc.org
629691b369951d8406b32bda2fb40667d55a3da96achangbin.shao@intel.com  const uint8_t* payload_data() const { return payload_data_; }
639691b369951d8406b32bda2fb40667d55a3da96achangbin.shao@intel.com  size_t payload_size() const { return payload_size_; }
649691b369951d8406b32bda2fb40667d55a3da96achangbin.shao@intel.com  webrtc::WebRtcRTPHeader rtp_header() const { return rtp_header_; }
658d0cd07d0c5e30eacaac4c118f9fd624b11e67abstefan@webrtc.org
668d0cd07d0c5e30eacaac4c118f9fd624b11e67abstefan@webrtc.org private:
679691b369951d8406b32bda2fb40667d55a3da96achangbin.shao@intel.com  uint8_t payload_data_[1500];
689691b369951d8406b32bda2fb40667d55a3da96achangbin.shao@intel.com  size_t payload_size_;
699691b369951d8406b32bda2fb40667d55a3da96achangbin.shao@intel.com  webrtc::WebRtcRTPHeader rtp_header_;
708281e7dd4a8ac4b00aededd8ebf52e93f1d980e8pwestin@webrtc.org};
718281e7dd4a8ac4b00aededd8ebf52e93f1d980e8pwestin@webrtc.org
72a1783598a78b2cd583408d97372fb4c0ba0fde91pwestin@webrtc.org}  // namespace webrtc
735eb4988c0ac0665701e9bccba0fad3dcadfcfcd0danilchap#endif  // WEBRTC_MODULES_RTP_RTCP_TEST_TESTAPI_TEST_API_H_
74