• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2012 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 
11 #ifndef WEBRTC_MODULES_VIDEO_CODING_TEST_RTP_PLAYER_H_
12 #define WEBRTC_MODULES_VIDEO_CODING_TEST_RTP_PLAYER_H_
13 
14 #include <string>
15 #include <vector>
16 
17 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
18 #include "webrtc/modules/video_coding/main/interface/video_coding_defines.h"
19 
20 namespace webrtc {
21 class Clock;
22 
23 namespace rtpplayer {
24 
25 class PayloadCodecTuple {
26  public:
PayloadCodecTuple(uint8_t payload_type,const std::string & codec_name,VideoCodecType codec_type)27   PayloadCodecTuple(uint8_t payload_type, const std::string& codec_name,
28                     VideoCodecType codec_type)
29       : name_(codec_name),
30         payload_type_(payload_type),
31         codec_type_(codec_type) {
32   }
33 
name()34   const std::string& name() const { return name_; }
payload_type()35   uint8_t payload_type() const { return payload_type_; }
codec_type()36   VideoCodecType codec_type() const { return codec_type_; }
37 
38  private:
39   std::string name_;
40   uint8_t payload_type_;
41   VideoCodecType codec_type_;
42 };
43 
44 typedef std::vector<PayloadCodecTuple> PayloadTypes;
45 typedef std::vector<PayloadCodecTuple>::const_iterator PayloadTypesIterator;
46 
47 // Implemented by something that can provide RTP packets, for instance a file
48 // format parser such as the rtp_file_reader or the pcap_file_reader.
49 class RtpPacketSourceInterface {
50  public:
~RtpPacketSourceInterface()51   virtual ~RtpPacketSourceInterface() {}
52 
53   // Read next RTP packet into buffer pointed to by rtp_data. On call, 'length'
54   // field must be filled in with the size of the buffer. The actual size of
55   // the packet is available in 'length' upon returning. Time in milliseconds
56   // from start of stream is returned in 'time_ms'.
57   virtual int NextPacket(uint8_t* rtp_data, uint32_t* length,
58                          uint32_t* time_ms) = 0;
59 };
60 
61 // Implemented by RtpPlayer and given to client as a means to retrieve
62 // information about a specific RTP stream.
63 class RtpStreamInterface {
64  public:
~RtpStreamInterface()65   virtual ~RtpStreamInterface() {}
66 
67   // Ask for missing packets to be resent.
68   virtual void ResendPackets(const uint16_t* sequence_numbers,
69                              uint16_t length) = 0;
70 
71   virtual uint32_t ssrc() const = 0;
72   virtual const PayloadTypes& payload_types() const = 0;
73 };
74 
75 // Implemented by a sink. Wraps RtpData because its d-tor is protected.
76 class PayloadSinkInterface : public RtpData {
77  public:
~PayloadSinkInterface()78   virtual ~PayloadSinkInterface() {}
79 };
80 
81 // Implemented to provide a sink for RTP data, such as hooking up a VCM to
82 // the incoming RTP stream.
83 class PayloadSinkFactoryInterface {
84  public:
~PayloadSinkFactoryInterface()85   virtual ~PayloadSinkFactoryInterface() {}
86 
87   // Return NULL if failed to create sink. 'stream' is guaranteed to be
88   // around for as long as the RtpData. The returned object is owned by
89   // the caller (RtpPlayer).
90   virtual PayloadSinkInterface* Create(RtpStreamInterface* stream) = 0;
91 };
92 
93 // The client's view of an RtpPlayer.
94 class RtpPlayerInterface {
95  public:
~RtpPlayerInterface()96   virtual ~RtpPlayerInterface() {}
97 
98   virtual int NextPacket(int64_t timeNow) = 0;
99   virtual uint32_t TimeUntilNextPacket() const = 0;
100   virtual void Print() const = 0;
101 };
102 
103 RtpPlayerInterface* Create(const std::string& inputFilename,
104     PayloadSinkFactoryInterface* payloadSinkFactory, Clock* clock,
105     const PayloadTypes& payload_types, float lossRate, uint32_t rttMs,
106     bool reordering);
107 
108 }  // namespace rtpplayer
109 }  // namespace webrtc
110 
111 #endif // WEBRTC_MODULES_VIDEO_CODING_TEST_RTP_PLAYER_H_
112