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.
29 enum RtcpMode { kRtcpCompound, kRtcpReducedSize };
34 // TODO(mflodman) Move all these settings to VideoDecoder and move the
35 // declaration to common_types.h.
36 struct ExternalVideoDecoder {
37 ExternalVideoDecoder()
38 : decoder(NULL), payload_type(0), renderer(false), expected_delay_ms(0) {}
39 // The actual decoder.
40 VideoDecoder* decoder;
42 // Received RTP packets with this payload type will be sent to this decoder
46 // 'true' if the decoder handles rendering as well.
49 // The expected delay for decoding and rendering, i.e. the frame will be
50 // delivered this many milliseconds, if possible, earlier than the ideal
52 // Note: Ignored if 'renderer' is false.
53 int expected_delay_ms;
56 class VideoReceiveStream {
58 struct Stats : public StreamStats {
60 : network_frame_rate(0),
67 int network_frame_rate;
68 int decode_frame_rate;
69 int render_frame_rate;
71 uint32_t discarded_packets;
81 pre_decode_callback(NULL),
82 pre_render_callback(NULL),
84 // Codecs the receive stream can receive.
85 std::vector<VideoCodec> codecs;
87 // Receive-stream specific RTP settings.
92 rtcp_mode(newapi::kRtcpReducedSize),
95 // Synchronization source (stream identifier) to be received.
97 // Sender SSRC used for sending RTCP (such as receiver reports).
100 // See RtcpMode for description.
101 newapi::RtcpMode rtcp_mode;
103 // Extended RTCP settings.
105 RtcpXr() : receiver_reference_time_report(false) {}
107 // True if RTCP Receiver Reference Time Report Block extension
108 // (RFC 3611) should be enabled.
109 bool receiver_reference_time_report;
112 // See draft-alvestrand-rmcat-remb for information.
115 // See NackConfig for description.
118 // See FecConfig for description.
121 // RTX settings for incoming video payloads that may be received. RTX is
122 // disabled if there's no config present.
124 Rtx() : ssrc(0), payload_type(0) {}
126 // SSRCs to use for the RTX streams.
129 // Payload type to use for the RTX stream.
133 // Map from video RTP payload type -> RTX config.
134 typedef std::map<int, Rtx> RtxMap;
137 // RTP header extensions used for the received stream.
138 std::vector<RtpExtension> extensions;
141 // VideoRenderer will be called for each decoded frame. 'NULL' disables
142 // rendering of this stream.
143 VideoRenderer* renderer;
145 // Expected delay needed by the renderer, i.e. the frame will be delivered
146 // this many milliseconds, if possible, earlier than the ideal render time.
147 // Only valid if 'renderer' is set.
150 // Audio channel corresponding to this video stream, used for audio/video
151 // synchronization. 'audio_channel_id' is ignored if no VoiceEngine is set
152 // when creating the VideoEngine instance. '-1' disables a/v sync.
153 int audio_channel_id;
155 // Called for each incoming video frame, i.e. in encoded state. E.g. used
157 // saving the stream to a file. 'NULL' disables the callback.
158 EncodedFrameObserver* pre_decode_callback;
160 // Called for each decoded frame. E.g. used when adding effects to the
162 // stream. 'NULL' disables the callback.
163 I420FrameCallback* pre_render_callback;
165 // External video decoders to be used if incoming payload type matches the
166 // registered type for an external decoder.
167 std::vector<ExternalVideoDecoder> external_decoders;
169 // Target delay in milliseconds. A positive value indicates this stream is
170 // used for streaming instead of a real-time call.
174 virtual void Start() = 0;
175 virtual void Stop() = 0;
176 virtual Stats GetStats() const = 0;
178 // TODO(mflodman) Replace this with callback.
179 virtual void GetCurrentReceiveCodec(VideoCodec* receive_codec) = 0;
182 virtual ~VideoReceiveStream() {}
185 } // namespace webrtc
187 #endif // WEBRTC_VIDEO_RECEIVE_STREAM_H_