• 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/include/rtp_rtcp_defines.h"
18 #include "webrtc/modules/video_coding/include/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,
28                     const std::string& codec_name,
29                     VideoCodecType codec_type)
30       : name_(codec_name),
31         payload_type_(payload_type),
32         codec_type_(codec_type) {}
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 RtpPlayer and given to client as a means to retrieve
48 // information about a specific RTP stream.
49 class RtpStreamInterface {
50  public:
~RtpStreamInterface()51   virtual ~RtpStreamInterface() {}
52 
53   // Ask for missing packets to be resent.
54   virtual void ResendPackets(const uint16_t* sequence_numbers,
55                              uint16_t length) = 0;
56 
57   virtual uint32_t ssrc() const = 0;
58   virtual const PayloadTypes& payload_types() const = 0;
59 };
60 
61 // Implemented by a sink. Wraps RtpData because its d-tor is protected.
62 class PayloadSinkInterface : public RtpData {
63  public:
~PayloadSinkInterface()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.
69 class PayloadSinkFactoryInterface {
70  public:
~PayloadSinkFactoryInterface()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.
80 class RtpPlayerInterface {
81  public:
~RtpPlayerInterface()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 
89 RtpPlayerInterface* Create(const std::string& inputFilename,
90                            PayloadSinkFactoryInterface* payloadSinkFactory,
91                            Clock* clock,
92                            const PayloadTypes& payload_types,
93                            float lossRate,
94                            int64_t rttMs,
95                            bool reordering);
96 
97 }  // namespace rtpplayer
98 }  // namespace webrtc
99 
100 #endif  // WEBRTC_MODULES_VIDEO_CODING_TEST_RTP_PLAYER_H_
101