niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
stefan@webrtc.org | 8fe03af | 2012-01-23 14:56:14 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 14 | #include <string> |
solenberg@webrtc.org | 56b5f77 | 2013-04-16 10:31:56 +0000 | [diff] [blame] | 15 | #include <vector> |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 16 | |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 17 | #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 18 | #include "webrtc/modules/video_coding/include/video_coding_defines.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 19 | |
solenberg@webrtc.org | 56b5f77 | 2013-04-16 10:31:56 +0000 | [diff] [blame] | 20 | namespace webrtc { |
| 21 | class Clock; |
stefan@webrtc.org | 8fe03af | 2012-01-23 14:56:14 +0000 | [diff] [blame] | 22 | |
solenberg@webrtc.org | 56b5f77 | 2013-04-16 10:31:56 +0000 | [diff] [blame] | 23 | namespace rtpplayer { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 24 | |
solenberg@webrtc.org | 56b5f77 | 2013-04-16 10:31:56 +0000 | [diff] [blame] | 25 | class PayloadCodecTuple { |
stefan@webrtc.org | 8fe03af | 2012-01-23 14:56:14 +0000 | [diff] [blame] | 26 | public: |
philipel | 5908c71 | 2015-12-21 08:23:20 -0800 | [diff] [blame] | 27 | PayloadCodecTuple(uint8_t payload_type, |
| 28 | const std::string& codec_name, |
solenberg@webrtc.org | 56b5f77 | 2013-04-16 10:31:56 +0000 | [diff] [blame] | 29 | VideoCodecType codec_type) |
| 30 | : name_(codec_name), |
| 31 | payload_type_(payload_type), |
philipel | 5908c71 | 2015-12-21 08:23:20 -0800 | [diff] [blame] | 32 | codec_type_(codec_type) {} |
stefan@webrtc.org | 8fe03af | 2012-01-23 14:56:14 +0000 | [diff] [blame] | 33 | |
solenberg@webrtc.org | 56b5f77 | 2013-04-16 10:31:56 +0000 | [diff] [blame] | 34 | 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.org | 8fe03af | 2012-01-23 14:56:14 +0000 | [diff] [blame] | 37 | |
| 38 | private: |
solenberg@webrtc.org | 56b5f77 | 2013-04-16 10:31:56 +0000 | [diff] [blame] | 39 | std::string name_; |
| 40 | uint8_t payload_type_; |
| 41 | VideoCodecType codec_type_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 42 | }; |
| 43 | |
solenberg@webrtc.org | 56b5f77 | 2013-04-16 10:31:56 +0000 | [diff] [blame] | 44 | typedef std::vector<PayloadCodecTuple> PayloadTypes; |
| 45 | typedef std::vector<PayloadCodecTuple>::const_iterator PayloadTypesIterator; |
| 46 | |
solenberg@webrtc.org | 56b5f77 | 2013-04-16 10:31:56 +0000 | [diff] [blame] | 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: |
| 51 | virtual ~RtpStreamInterface() {} |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 52 | |
solenberg@webrtc.org | 56b5f77 | 2013-04-16 10:31:56 +0000 | [diff] [blame] | 53 | // Ask for missing packets to be resent. |
| 54 | virtual void ResendPackets(const uint16_t* sequence_numbers, |
| 55 | uint16_t length) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 56 | |
solenberg@webrtc.org | 56b5f77 | 2013-04-16 10:31:56 +0000 | [diff] [blame] | 57 | virtual uint32_t ssrc() const = 0; |
| 58 | virtual const PayloadTypes& payload_types() const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 59 | }; |
| 60 | |
solenberg@webrtc.org | 56b5f77 | 2013-04-16 10:31:56 +0000 | [diff] [blame] | 61 | // Implemented by a sink. Wraps RtpData because its d-tor is protected. |
| 62 | class 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. |
| 69 | class 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. |
| 80 | class 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 | |
| 89 | RtpPlayerInterface* Create(const std::string& inputFilename, |
philipel | 5908c71 | 2015-12-21 08:23:20 -0800 | [diff] [blame] | 90 | PayloadSinkFactoryInterface* payloadSinkFactory, |
| 91 | Clock* clock, |
| 92 | const PayloadTypes& payload_types, |
| 93 | float lossRate, |
| 94 | int64_t rttMs, |
| 95 | bool reordering); |
solenberg@webrtc.org | 56b5f77 | 2013-04-16 10:31:56 +0000 | [diff] [blame] | 96 | |
| 97 | } // namespace rtpplayer |
| 98 | } // namespace webrtc |
| 99 | |
philipel | 5908c71 | 2015-12-21 08:23:20 -0800 | [diff] [blame] | 100 | #endif // WEBRTC_MODULES_VIDEO_CODING_TEST_RTP_PLAYER_H_ |