mflodman@webrtc.org | 06e8026 | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2013 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_VIDEO_ENGINE_NEW_INCLUDE_VIDEO_RECEIVE_STREAM_H_ |
| 12 | #define WEBRTC_VIDEO_ENGINE_NEW_INCLUDE_VIDEO_RECEIVE_STREAM_H_ |
| 13 | |
| 14 | #include <string> |
| 15 | #include <vector> |
| 16 | |
| 17 | #include "webrtc/common_types.h" |
pbos@webrtc.org | 24e2089 | 2013-10-28 16:32:01 +0000 | [diff] [blame] | 18 | #include "webrtc/config.h" |
| 19 | #include "webrtc/frame_callback.h" |
| 20 | #include "webrtc/transport.h" |
| 21 | #include "webrtc/video_renderer.h" |
mflodman@webrtc.org | 06e8026 | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 22 | |
| 23 | namespace webrtc { |
| 24 | |
pbos@webrtc.org | 51e0101 | 2013-10-17 14:14:42 +0000 | [diff] [blame] | 25 | namespace newapi { |
| 26 | // RTCP mode to use. Compound mode is described by RFC 4585 and reduced-size |
| 27 | // RTCP mode is described by RFC 5506. |
| 28 | enum RtcpMode { |
| 29 | kRtcpCompound, |
| 30 | kRtcpReducedSize |
| 31 | }; |
| 32 | } // namespace newapi |
| 33 | |
mflodman@webrtc.org | 06e8026 | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 34 | class VideoDecoder; |
| 35 | |
mflodman@webrtc.org | 06e8026 | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 36 | // TODO(mflodman) Move all these settings to VideoDecoder and move the |
| 37 | // declaration to common_types.h. |
| 38 | struct ExternalVideoDecoder { |
pbos@webrtc.org | b2d1a40 | 2013-05-28 08:04:45 +0000 | [diff] [blame] | 39 | ExternalVideoDecoder() |
| 40 | : decoder(NULL), payload_type(0), renderer(false), expected_delay_ms(0) {} |
mflodman@webrtc.org | 06e8026 | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 41 | // The actual decoder. |
| 42 | VideoDecoder* decoder; |
| 43 | |
| 44 | // Received RTP packets with this payload type will be sent to this decoder |
| 45 | // instance. |
| 46 | int payload_type; |
| 47 | |
| 48 | // 'true' if the decoder handles rendering as well. |
| 49 | bool renderer; |
| 50 | |
| 51 | // The expected delay for decoding and rendering, i.e. the frame will be |
| 52 | // delivered this many milliseconds, if possible, earlier than the ideal |
| 53 | // render time. |
| 54 | // Note: Ignored if 'renderer' is false. |
| 55 | int expected_delay_ms; |
| 56 | }; |
| 57 | |
mflodman@webrtc.org | 06e8026 | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 58 | class VideoReceiveStream { |
| 59 | public: |
pbos@webrtc.org | 6f1c3ef | 2013-06-05 11:33:21 +0000 | [diff] [blame] | 60 | struct Stats { |
| 61 | Stats() |
| 62 | : network_frame_rate(0), |
| 63 | decode_frame_rate(0), |
| 64 | render_frame_rate(0), |
| 65 | key_frames(0), |
| 66 | delta_frames(0), |
| 67 | video_packets(0), |
| 68 | retransmitted_packets(0), |
| 69 | fec_packets(0), |
| 70 | padding_packets(0), |
| 71 | discarded_packets(0), |
| 72 | received_bitrate_bps(0), |
| 73 | receive_side_delay_ms(0) {} |
| 74 | RtpStatistics rtp_stats; |
| 75 | int network_frame_rate; |
| 76 | int decode_frame_rate; |
| 77 | int render_frame_rate; |
| 78 | uint32_t key_frames; |
| 79 | uint32_t delta_frames; |
| 80 | uint32_t video_packets; |
| 81 | uint32_t retransmitted_packets; |
| 82 | uint32_t fec_packets; |
| 83 | uint32_t padding_packets; |
| 84 | uint32_t discarded_packets; |
| 85 | int32_t received_bitrate_bps; |
| 86 | int receive_side_delay_ms; |
| 87 | }; |
| 88 | |
| 89 | class StatsCallback { |
| 90 | public: |
| 91 | virtual ~StatsCallback() {} |
| 92 | virtual void ReceiveStats(const Stats& stats) = 0; |
| 93 | }; |
| 94 | |
| 95 | struct Config { |
| 96 | Config() |
| 97 | : renderer(NULL), |
| 98 | render_delay_ms(0), |
| 99 | audio_channel_id(0), |
| 100 | pre_decode_callback(NULL), |
pbos@webrtc.org | 63301bd | 2013-10-21 10:34:43 +0000 | [diff] [blame] | 101 | pre_render_callback(NULL), |
pbos@webrtc.org | 6f1c3ef | 2013-06-05 11:33:21 +0000 | [diff] [blame] | 102 | target_delay_ms(0) {} |
pbos@webrtc.org | ce85109 | 2013-08-05 12:01:36 +0000 | [diff] [blame] | 103 | // Codecs the receive stream can receive. |
pbos@webrtc.org | 6f1c3ef | 2013-06-05 11:33:21 +0000 | [diff] [blame] | 104 | std::vector<VideoCodec> codecs; |
| 105 | |
| 106 | // Receive-stream specific RTP settings. |
| 107 | struct Rtp { |
pbos@webrtc.org | 51e0101 | 2013-10-17 14:14:42 +0000 | [diff] [blame] | 108 | Rtp() : ssrc(0), rtcp_mode(newapi::kRtcpReducedSize) {} |
| 109 | |
pbos@webrtc.org | 6f1c3ef | 2013-06-05 11:33:21 +0000 | [diff] [blame] | 110 | // TODO(mflodman) Do we require a set ssrc? What happens if the ssrc |
| 111 | // changes? |
| 112 | uint32_t ssrc; |
| 113 | |
pbos@webrtc.org | 51e0101 | 2013-10-17 14:14:42 +0000 | [diff] [blame] | 114 | // See RtcpMode for description. |
| 115 | newapi::RtcpMode rtcp_mode; |
| 116 | |
pbos@webrtc.org | 6f1c3ef | 2013-06-05 11:33:21 +0000 | [diff] [blame] | 117 | // See NackConfig for description. |
| 118 | NackConfig nack; |
| 119 | |
| 120 | // See FecConfig for description. |
| 121 | FecConfig fec; |
| 122 | |
| 123 | // RTX settings for possible payloads. RTX is disabled if the vector is |
| 124 | // empty. |
| 125 | std::vector<RtxConfig> rtx; |
| 126 | |
| 127 | // RTP header extensions used for the received stream. |
| 128 | std::vector<RtpExtension> extensions; |
| 129 | } rtp; |
| 130 | |
| 131 | // VideoRenderer will be called for each decoded frame. 'NULL' disables |
| 132 | // rendering of this stream. |
| 133 | VideoRenderer* renderer; |
| 134 | |
| 135 | // Expected delay needed by the renderer, i.e. the frame will be delivered |
| 136 | // this many milliseconds, if possible, earlier than the ideal render time. |
| 137 | // Only valid if 'renderer' is set. |
| 138 | int render_delay_ms; |
| 139 | |
| 140 | // Audio channel corresponding to this video stream, used for audio/video |
| 141 | // synchronization. 'audio_channel_id' is ignored if no VoiceEngine is set |
| 142 | // when creating the VideoEngine instance. '-1' disables a/v sync. |
| 143 | int audio_channel_id; |
| 144 | |
| 145 | // Called for each incoming video frame, i.e. in encoded state. E.g. used |
| 146 | // when |
| 147 | // saving the stream to a file. 'NULL' disables the callback. |
| 148 | EncodedFrameObserver* pre_decode_callback; |
| 149 | |
| 150 | // Called for each decoded frame. E.g. used when adding effects to the |
| 151 | // decoded |
| 152 | // stream. 'NULL' disables the callback. |
pbos@webrtc.org | 63301bd | 2013-10-21 10:34:43 +0000 | [diff] [blame] | 153 | I420FrameCallback* pre_render_callback; |
pbos@webrtc.org | 6f1c3ef | 2013-06-05 11:33:21 +0000 | [diff] [blame] | 154 | |
| 155 | // External video decoders to be used if incoming payload type matches the |
| 156 | // registered type for an external decoder. |
| 157 | std::vector<ExternalVideoDecoder> external_decoders; |
| 158 | |
| 159 | // Target delay in milliseconds. A positive value indicates this stream is |
| 160 | // used for streaming instead of a real-time call. |
| 161 | int target_delay_ms; |
| 162 | |
| 163 | // Callback for periodically receiving receiver stats. |
| 164 | StatsCallback* stats_callback; |
| 165 | }; |
| 166 | |
pbos@webrtc.org | 7f9f840 | 2013-11-20 11:36:47 +0000 | [diff] [blame] | 167 | virtual void StartReceiving() = 0; |
| 168 | virtual void StopReceiving() = 0; |
mflodman@webrtc.org | 06e8026 | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 169 | |
| 170 | // TODO(mflodman) Replace this with callback. |
| 171 | virtual void GetCurrentReceiveCodec(VideoCodec* receive_codec) = 0; |
| 172 | |
mflodman@webrtc.org | 06e8026 | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 173 | protected: |
| 174 | virtual ~VideoReceiveStream() {} |
| 175 | }; |
| 176 | |
mflodman@webrtc.org | 06e8026 | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 177 | } // namespace webrtc |
| 178 | |
| 179 | #endif // WEBRTC_VIDEO_ENGINE_NEW_INCLUDE_VIDEO_RECEIVE_STREAM_H_ |