OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_VIDEO_RECEIVE_STREAM_H_ | 11 #ifndef WEBRTC_VIDEO_RECEIVE_STREAM_H_ |
12 #define WEBRTC_VIDEO_RECEIVE_STREAM_H_ | 12 #define WEBRTC_VIDEO_RECEIVE_STREAM_H_ |
13 | 13 |
14 #include <limits> | 14 #include "webrtc/call/video_receive_stream.h" |
15 #include <map> | 15 // The contents header have moved to webrtc/call/video_receive_stream.h. This |
16 #include <string> | 16 // file is deprecated. See http://bugs.webrtc.org/8107. |
17 #include <vector> | |
18 | |
19 #include "webrtc/api/call/transport.h" | |
20 #include "webrtc/common_types.h" | |
21 #include "webrtc/common_video/include/frame_callback.h" | |
22 #include "webrtc/config.h" | |
23 #include "webrtc/media/base/videosinkinterface.h" | |
24 #include "webrtc/rtc_base/platform_file.h" | |
25 | |
26 namespace webrtc { | |
27 | |
28 class RtpPacketSinkInterface; | |
29 class VideoDecoder; | |
30 | |
31 class VideoReceiveStream { | |
32 public: | |
33 // TODO(mflodman) Move all these settings to VideoDecoder and move the | |
34 // declaration to common_types.h. | |
35 struct Decoder { | |
36 std::string ToString() const; | |
37 | |
38 // The actual decoder instance. | |
39 VideoDecoder* decoder = nullptr; | |
40 | |
41 // Received RTP packets with this payload type will be sent to this decoder | |
42 // instance. | |
43 int payload_type = 0; | |
44 | |
45 // Name of the decoded payload (such as VP8). Maps back to the depacketizer | |
46 // used to unpack incoming packets. | |
47 std::string payload_name; | |
48 | |
49 // This map contains the codec specific parameters from SDP, i.e. the "fmtp" | |
50 // parameters. It is the same as cricket::CodecParameterMap used in | |
51 // cricket::VideoCodec. | |
52 std::map<std::string, std::string> codec_params; | |
53 }; | |
54 | |
55 struct Stats { | |
56 std::string ToString(int64_t time_ms) const; | |
57 | |
58 int network_frame_rate = 0; | |
59 int decode_frame_rate = 0; | |
60 int render_frame_rate = 0; | |
61 uint32_t frames_rendered = 0; | |
62 | |
63 // Decoder stats. | |
64 std::string decoder_implementation_name = "unknown"; | |
65 FrameCounts frame_counts; | |
66 int decode_ms = 0; | |
67 int max_decode_ms = 0; | |
68 int current_delay_ms = 0; | |
69 int target_delay_ms = 0; | |
70 int jitter_buffer_ms = 0; | |
71 int min_playout_delay_ms = 0; | |
72 int render_delay_ms = 10; | |
73 uint64_t interframe_delay_sum_ms = 0; | |
74 uint32_t frames_decoded = 0; | |
75 rtc::Optional<uint64_t> qp_sum; | |
76 | |
77 int current_payload_type = -1; | |
78 | |
79 int total_bitrate_bps = 0; | |
80 int discarded_packets = 0; | |
81 | |
82 int width = 0; | |
83 int height = 0; | |
84 | |
85 int sync_offset_ms = std::numeric_limits<int>::max(); | |
86 | |
87 uint32_t ssrc = 0; | |
88 std::string c_name; | |
89 StreamDataCounters rtp_stats; | |
90 RtcpPacketTypeCounter rtcp_packet_type_counts; | |
91 RtcpStatistics rtcp_stats; | |
92 }; | |
93 | |
94 struct Config { | |
95 private: | |
96 // Access to the copy constructor is private to force use of the Copy() | |
97 // method for those exceptional cases where we do use it. | |
98 Config(const Config&) = default; | |
99 | |
100 public: | |
101 Config() = delete; | |
102 Config(Config&&) = default; | |
103 explicit Config(Transport* rtcp_send_transport) | |
104 : rtcp_send_transport(rtcp_send_transport) {} | |
105 | |
106 Config& operator=(Config&&) = default; | |
107 Config& operator=(const Config&) = delete; | |
108 | |
109 // Mostly used by tests. Avoid creating copies if you can. | |
110 Config Copy() const { return Config(*this); } | |
111 | |
112 std::string ToString() const; | |
113 | |
114 // Decoders for every payload that we can receive. | |
115 std::vector<Decoder> decoders; | |
116 | |
117 // Receive-stream specific RTP settings. | |
118 struct Rtp { | |
119 std::string ToString() const; | |
120 | |
121 // Synchronization source (stream identifier) to be received. | |
122 uint32_t remote_ssrc = 0; | |
123 | |
124 // Sender SSRC used for sending RTCP (such as receiver reports). | |
125 uint32_t local_ssrc = 0; | |
126 | |
127 // See RtcpMode for description. | |
128 RtcpMode rtcp_mode = RtcpMode::kCompound; | |
129 | |
130 // Extended RTCP settings. | |
131 struct RtcpXr { | |
132 // True if RTCP Receiver Reference Time Report Block extension | |
133 // (RFC 3611) should be enabled. | |
134 bool receiver_reference_time_report = false; | |
135 } rtcp_xr; | |
136 | |
137 // TODO(nisse): This remb setting is currently set but never | |
138 // applied. REMB logic is now the responsibility of | |
139 // PacketRouter, and it will generate REMB feedback if | |
140 // OnReceiveBitrateChanged is used, which depends on how the | |
141 // estimators belonging to the ReceiveSideCongestionController | |
142 // are configured. Decide if this setting should be deleted, and | |
143 // if it needs to be replaced by a setting in PacketRouter to | |
144 // disable REMB feedback. | |
145 | |
146 // See draft-alvestrand-rmcat-remb for information. | |
147 bool remb = false; | |
148 | |
149 // See draft-holmer-rmcat-transport-wide-cc-extensions for details. | |
150 bool transport_cc = false; | |
151 | |
152 // See NackConfig for description. | |
153 NackConfig nack; | |
154 | |
155 // See UlpfecConfig for description. | |
156 UlpfecConfig ulpfec; | |
157 | |
158 // SSRC for retransmissions. | |
159 uint32_t rtx_ssrc = 0; | |
160 | |
161 // Set if the stream is protected using FlexFEC. | |
162 bool protected_by_flexfec = false; | |
163 | |
164 // Map from video payload type (apt) -> RTX payload type (pt). | |
165 // For RTX to be enabled, both an SSRC and this mapping are needed. | |
166 std::map<int, int> rtx_payload_types; | |
167 | |
168 // RTP header extensions used for the received stream. | |
169 std::vector<RtpExtension> extensions; | |
170 } rtp; | |
171 | |
172 // Transport for outgoing packets (RTCP). | |
173 Transport* rtcp_send_transport = nullptr; | |
174 | |
175 // Must not be 'nullptr' when the stream is started. | |
176 rtc::VideoSinkInterface<VideoFrame>* renderer = nullptr; | |
177 | |
178 // Expected delay needed by the renderer, i.e. the frame will be delivered | |
179 // this many milliseconds, if possible, earlier than the ideal render time. | |
180 // Only valid if 'renderer' is set. | |
181 int render_delay_ms = 10; | |
182 | |
183 // If set, pass frames on to the renderer as soon as they are | |
184 // available. | |
185 bool disable_prerenderer_smoothing = false; | |
186 | |
187 // Identifier for an A/V synchronization group. Empty string to disable. | |
188 // TODO(pbos): Synchronize streams in a sync group, not just video streams | |
189 // to one of the audio streams. | |
190 std::string sync_group; | |
191 | |
192 // Called for each incoming video frame, i.e. in encoded state. E.g. used | |
193 // when | |
194 // saving the stream to a file. 'nullptr' disables the callback. | |
195 EncodedFrameObserver* pre_decode_callback = nullptr; | |
196 | |
197 // Target delay in milliseconds. A positive value indicates this stream is | |
198 // used for streaming instead of a real-time call. | |
199 int target_delay_ms = 0; | |
200 }; | |
201 | |
202 // Starts stream activity. | |
203 // When a stream is active, it can receive, process and deliver packets. | |
204 virtual void Start() = 0; | |
205 // Stops stream activity. | |
206 // When a stream is stopped, it can't receive, process or deliver packets. | |
207 virtual void Stop() = 0; | |
208 | |
209 // TODO(pbos): Add info on currently-received codec to Stats. | |
210 virtual Stats GetStats() const = 0; | |
211 | |
212 virtual rtc::Optional<TimingFrameInfo> GetAndResetTimingFrameInfo() = 0; | |
213 | |
214 // Takes ownership of the file, is responsible for closing it later. | |
215 // Calling this method will close and finalize any current log. | |
216 // Giving rtc::kInvalidPlatformFileValue disables logging. | |
217 // If a frame to be written would make the log too large the write fails and | |
218 // the log is closed and finalized. A |byte_limit| of 0 means no limit. | |
219 virtual void EnableEncodedFrameRecording(rtc::PlatformFile file, | |
220 size_t byte_limit) = 0; | |
221 inline void DisableEncodedFrameRecording() { | |
222 EnableEncodedFrameRecording(rtc::kInvalidPlatformFileValue, 0); | |
223 } | |
224 | |
225 // RtpDemuxer only forwards a given RTP packet to one sink. However, some | |
226 // sinks, such as FlexFEC, might wish to be informed of all of the packets | |
227 // a given sink receives (or any set of sinks). They may do so by registering | |
228 // themselves as secondary sinks. | |
229 virtual void AddSecondarySink(RtpPacketSinkInterface* sink) = 0; | |
230 virtual void RemoveSecondarySink(const RtpPacketSinkInterface* sink) = 0; | |
231 | |
232 protected: | |
233 virtual ~VideoReceiveStream() {} | |
234 }; | |
235 | |
236 } // namespace webrtc | |
237 | 17 |
238 #endif // WEBRTC_VIDEO_RECEIVE_STREAM_H_ | 18 #endif // WEBRTC_VIDEO_RECEIVE_STREAM_H_ |
OLD | NEW |