2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
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.
11 #ifndef WEBRTC_VIDEO_RECEIVE_STREAM_H_
12 #define WEBRTC_VIDEO_RECEIVE_STREAM_H_
18 #include "webrtc/common_types.h"
19 #include "webrtc/config.h"
20 #include "webrtc/frame_callback.h"
21 #include "webrtc/transport.h"
22 #include "webrtc/video_renderer.h"
27 // RTCP mode to use. Compound mode is described by RFC 4585 and reduced-size
28 // RTCP mode is described by RFC 5506.
37 // TODO(mflodman) Move all these settings to VideoDecoder and move the
38 // declaration to common_types.h.
39 struct ExternalVideoDecoder {
40 ExternalVideoDecoder()
41 : decoder(NULL), payload_type(0), renderer(false), expected_delay_ms(0) {}
42 // The actual decoder.
43 VideoDecoder* decoder;
45 // Received RTP packets with this payload type will be sent to this decoder
49 // 'true' if the decoder handles rendering as well.
52 // The expected delay for decoding and rendering, i.e. the frame will be
53 // delivered this many milliseconds, if possible, earlier than the ideal
55 // Note: Ignored if 'renderer' is false.
56 int expected_delay_ms;
59 class VideoReceiveStream {
63 : network_frame_rate(0),
69 retransmitted_packets(0),
73 received_bitrate_bps(0),
74 receive_side_delay_ms(0) {}
75 RtpStatistics rtp_stats;
76 int network_frame_rate;
77 int decode_frame_rate;
78 int render_frame_rate;
80 uint32_t delta_frames;
81 uint32_t video_packets;
82 uint32_t retransmitted_packets;
84 uint32_t padding_packets;
85 uint32_t discarded_packets;
86 int32_t received_bitrate_bps;
87 int receive_side_delay_ms;
92 virtual ~StatsCallback() {}
93 virtual void ReceiveStats(const Stats& stats) = 0;
101 pre_decode_callback(NULL),
102 pre_render_callback(NULL),
103 target_delay_ms(0) {}
104 // Codecs the receive stream can receive.
105 std::vector<VideoCodec> codecs;
107 // Receive-stream specific RTP settings.
112 rtcp_mode(newapi::kRtcpReducedSize),
115 // Synchronization source (stream identifier) to be received.
116 uint32_t remote_ssrc;
117 // Sender SSRC used for sending RTCP (such as receiver reports).
120 // See RtcpMode for description.
121 newapi::RtcpMode rtcp_mode;
123 // Extended RTCP settings.
125 RtcpXr() : receiver_reference_time_report(false) {}
127 // True if RTCP Receiver Reference Time Report Block extension
128 // (RFC 3611) should be enabled.
129 bool receiver_reference_time_report;
132 // See draft-alvestrand-rmcat-remb for information.
135 // See NackConfig for description.
138 // See FecConfig for description.
141 // RTX settings for video payloads that may be received. RTX is disabled
142 // if there's no config present.
143 std::map<int, RtxConfig> rtx;
145 // RTP header extensions used for the received stream.
146 std::vector<RtpExtension> extensions;
149 // VideoRenderer will be called for each decoded frame. 'NULL' disables
150 // rendering of this stream.
151 VideoRenderer* renderer;
153 // Expected delay needed by the renderer, i.e. the frame will be delivered
154 // this many milliseconds, if possible, earlier than the ideal render time.
155 // Only valid if 'renderer' is set.
158 // Audio channel corresponding to this video stream, used for audio/video
159 // synchronization. 'audio_channel_id' is ignored if no VoiceEngine is set
160 // when creating the VideoEngine instance. '-1' disables a/v sync.
161 int audio_channel_id;
163 // Called for each incoming video frame, i.e. in encoded state. E.g. used
165 // saving the stream to a file. 'NULL' disables the callback.
166 EncodedFrameObserver* pre_decode_callback;
168 // Called for each decoded frame. E.g. used when adding effects to the
170 // stream. 'NULL' disables the callback.
171 I420FrameCallback* pre_render_callback;
173 // External video decoders to be used if incoming payload type matches the
174 // registered type for an external decoder.
175 std::vector<ExternalVideoDecoder> external_decoders;
177 // Target delay in milliseconds. A positive value indicates this stream is
178 // used for streaming instead of a real-time call.
181 // Callback for periodically receiving receiver stats.
182 StatsCallback* stats_callback;
185 virtual void StartReceiving() = 0;
186 virtual void StopReceiving() = 0;
188 // TODO(mflodman) Replace this with callback.
189 virtual void GetCurrentReceiveCodec(VideoCodec* receive_codec) = 0;
192 virtual ~VideoReceiveStream() {}
195 } // namespace webrtc
197 #endif // WEBRTC_VIDEO_RECEIVE_STREAM_H_