blob: e50fb9ac701c5017a76468364b0d96d25647fa84 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
stefan@webrtc.org8fe03af2012-01-23 14:56:14 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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
11#ifndef WEBRTC_MODULES_VIDEO_CODING_TEST_RTP_PLAYER_H_
12#define WEBRTC_MODULES_VIDEO_CODING_TEST_RTP_PLAYER_H_
13
niklase@google.com470e71d2011-07-07 08:21:25 +000014#include <string>
solenberg@webrtc.org56b5f772013-04-16 10:31:56 +000015#include <vector>
niklase@google.com470e71d2011-07-07 08:21:25 +000016
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010017#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
Henrik Kjellander2557b862015-11-18 22:00:21 +010018#include "webrtc/modules/video_coding/include/video_coding_defines.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000019
solenberg@webrtc.org56b5f772013-04-16 10:31:56 +000020namespace webrtc {
21class Clock;
stefan@webrtc.org8fe03af2012-01-23 14:56:14 +000022
solenberg@webrtc.org56b5f772013-04-16 10:31:56 +000023namespace rtpplayer {
niklase@google.com470e71d2011-07-07 08:21:25 +000024
solenberg@webrtc.org56b5f772013-04-16 10:31:56 +000025class PayloadCodecTuple {
stefan@webrtc.org8fe03af2012-01-23 14:56:14 +000026 public:
philipel5908c712015-12-21 08:23:20 -080027 PayloadCodecTuple(uint8_t payload_type,
28 const std::string& codec_name,
solenberg@webrtc.org56b5f772013-04-16 10:31:56 +000029 VideoCodecType codec_type)
30 : name_(codec_name),
31 payload_type_(payload_type),
philipel5908c712015-12-21 08:23:20 -080032 codec_type_(codec_type) {}
stefan@webrtc.org8fe03af2012-01-23 14:56:14 +000033
solenberg@webrtc.org56b5f772013-04-16 10:31:56 +000034 const std::string& name() const { return name_; }
35 uint8_t payload_type() const { return payload_type_; }
36 VideoCodecType codec_type() const { return codec_type_; }
stefan@webrtc.org8fe03af2012-01-23 14:56:14 +000037
38 private:
solenberg@webrtc.org56b5f772013-04-16 10:31:56 +000039 std::string name_;
40 uint8_t payload_type_;
41 VideoCodecType codec_type_;
niklase@google.com470e71d2011-07-07 08:21:25 +000042};
43
solenberg@webrtc.org56b5f772013-04-16 10:31:56 +000044typedef std::vector<PayloadCodecTuple> PayloadTypes;
45typedef std::vector<PayloadCodecTuple>::const_iterator PayloadTypesIterator;
46
solenberg@webrtc.org56b5f772013-04-16 10:31:56 +000047// Implemented by RtpPlayer and given to client as a means to retrieve
48// information about a specific RTP stream.
49class RtpStreamInterface {
50 public:
51 virtual ~RtpStreamInterface() {}
niklase@google.com470e71d2011-07-07 08:21:25 +000052
solenberg@webrtc.org56b5f772013-04-16 10:31:56 +000053 // Ask for missing packets to be resent.
54 virtual void ResendPackets(const uint16_t* sequence_numbers,
55 uint16_t length) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000056
solenberg@webrtc.org56b5f772013-04-16 10:31:56 +000057 virtual uint32_t ssrc() const = 0;
58 virtual const PayloadTypes& payload_types() const = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000059};
60
solenberg@webrtc.org56b5f772013-04-16 10:31:56 +000061// Implemented by a sink. Wraps RtpData because its d-tor is protected.
62class PayloadSinkInterface : public RtpData {
63 public:
64 virtual ~PayloadSinkInterface() {}
65};
66
67// Implemented to provide a sink for RTP data, such as hooking up a VCM to
68// the incoming RTP stream.
69class PayloadSinkFactoryInterface {
70 public:
71 virtual ~PayloadSinkFactoryInterface() {}
72
73 // Return NULL if failed to create sink. 'stream' is guaranteed to be
74 // around for as long as the RtpData. The returned object is owned by
75 // the caller (RtpPlayer).
76 virtual PayloadSinkInterface* Create(RtpStreamInterface* stream) = 0;
77};
78
79// The client's view of an RtpPlayer.
80class RtpPlayerInterface {
81 public:
82 virtual ~RtpPlayerInterface() {}
83
84 virtual int NextPacket(int64_t timeNow) = 0;
85 virtual uint32_t TimeUntilNextPacket() const = 0;
86 virtual void Print() const = 0;
87};
88
89RtpPlayerInterface* Create(const std::string& inputFilename,
philipel5908c712015-12-21 08:23:20 -080090 PayloadSinkFactoryInterface* payloadSinkFactory,
91 Clock* clock,
92 const PayloadTypes& payload_types,
93 float lossRate,
94 int64_t rttMs,
95 bool reordering);
solenberg@webrtc.org56b5f772013-04-16 10:31:56 +000096
97} // namespace rtpplayer
98} // namespace webrtc
99
philipel5908c712015-12-21 08:23:20 -0800100#endif // WEBRTC_MODULES_VIDEO_CODING_TEST_RTP_PLAYER_H_