blob: cd1434caeefb2bb3533559ed53c50c67b32f0bbe [file] [log] [blame]
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +00001/*
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
mflodman@webrtc.orgb429e512013-12-18 09:46:22 +000011#ifndef WEBRTC_VIDEO_RECEIVE_STREAM_H_
12#define WEBRTC_VIDEO_RECEIVE_STREAM_H_
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +000013
pbos@webrtc.orge02d4752014-01-20 14:43:55 +000014#include <map>
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +000015#include <string>
16#include <vector>
17
18#include "webrtc/common_types.h"
pbos@webrtc.org16e03b72013-10-28 16:32:01 +000019#include "webrtc/config.h"
20#include "webrtc/frame_callback.h"
Jelena Marusiccd670222015-07-16 09:30:09 +020021#include "webrtc/stream.h"
pbos@webrtc.org16e03b72013-10-28 16:32:01 +000022#include "webrtc/transport.h"
23#include "webrtc/video_renderer.h"
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +000024
25namespace webrtc {
26
27class VideoDecoder;
28
Jelena Marusiccd670222015-07-16 09:30:09 +020029class VideoReceiveStream : public ReceiveStream {
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +000030 public:
pbos@webrtc.org776e6f22014-10-29 15:28:39 +000031 // TODO(mflodman) Move all these settings to VideoDecoder and move the
32 // declaration to common_types.h.
33 struct Decoder {
pbos@webrtc.org32e85282015-01-15 10:09:39 +000034 std::string ToString() const;
pbos@webrtc.org776e6f22014-10-29 15:28:39 +000035
36 // The actual decoder instance.
Fredrik Solenberg78fb3b32015-06-11 12:38:38 +020037 VideoDecoder* decoder = nullptr;
pbos@webrtc.org776e6f22014-10-29 15:28:39 +000038
39 // Received RTP packets with this payload type will be sent to this decoder
40 // instance.
Fredrik Solenberg78fb3b32015-06-11 12:38:38 +020041 int payload_type = 0;
pbos@webrtc.org776e6f22014-10-29 15:28:39 +000042
43 // Name of the decoded payload (such as VP8). Maps back to the depacketizer
44 // used to unpack incoming packets.
45 std::string payload_name;
pbos@webrtc.org776e6f22014-10-29 15:28:39 +000046 };
47
pbos@webrtc.org09c77b92015-02-25 10:42:16 +000048 struct Stats {
49 int network_frame_rate = 0;
50 int decode_frame_rate = 0;
51 int render_frame_rate = 0;
sprang@webrtc.org09315702014-02-07 12:06:29 +000052
pbos@webrtc.org09c77b92015-02-25 10:42:16 +000053 // Decoder stats.
54 FrameCounts frame_counts;
55 int decode_ms = 0;
56 int max_decode_ms = 0;
57 int current_delay_ms = 0;
58 int target_delay_ms = 0;
59 int jitter_buffer_ms = 0;
60 int min_playout_delay_ms = 0;
Peter Boströmc4188fd2015-04-24 15:16:03 +020061 int render_delay_ms = 10;
pbos@webrtc.org09c77b92015-02-25 10:42:16 +000062
pbosf42376c2015-08-28 07:35:32 -070063 int current_payload_type = -1;
64
pbos@webrtc.org09c77b92015-02-25 10:42:16 +000065 int total_bitrate_bps = 0;
66 int discarded_packets = 0;
67
68 uint32_t ssrc = 0;
sprang@webrtc.org09315702014-02-07 12:06:29 +000069 std::string c_name;
pbos@webrtc.org09c77b92015-02-25 10:42:16 +000070 StreamDataCounters rtp_stats;
71 RtcpPacketTypeCounter rtcp_packet_type_counts;
72 RtcpStatistics rtcp_stats;
pbos@webrtc.org025f4f12013-06-05 11:33:21 +000073 };
74
75 struct Config {
solenberg4fbae2b2015-08-28 04:07:10 -070076 Config() = delete;
pbos2d566682015-09-28 09:59:31 -070077 explicit Config(Transport* rtcp_send_transport)
solenberg4fbae2b2015-08-28 04:07:10 -070078 : rtcp_send_transport(rtcp_send_transport) {}
79
pbos@webrtc.org32e85282015-01-15 10:09:39 +000080 std::string ToString() const;
pbos@webrtc.org776e6f22014-10-29 15:28:39 +000081
82 // Decoders for every payload that we can receive.
83 std::vector<Decoder> decoders;
pbos@webrtc.org025f4f12013-06-05 11:33:21 +000084
85 // Receive-stream specific RTP settings.
86 struct Rtp {
pbos@webrtc.org32e85282015-01-15 10:09:39 +000087 std::string ToString() const;
pbos@webrtc.orgc11148b2013-10-17 14:14:42 +000088
pbos@webrtc.orgb613b5a2013-12-03 10:13:04 +000089 // Synchronization source (stream identifier) to be received.
Fredrik Solenberg78fb3b32015-06-11 12:38:38 +020090 uint32_t remote_ssrc = 0;
pbos@webrtc.orgb613b5a2013-12-03 10:13:04 +000091 // Sender SSRC used for sending RTCP (such as receiver reports).
Fredrik Solenberg78fb3b32015-06-11 12:38:38 +020092 uint32_t local_ssrc = 0;
pbos@webrtc.org025f4f12013-06-05 11:33:21 +000093
pbos@webrtc.orgc11148b2013-10-17 14:14:42 +000094 // See RtcpMode for description.
pbosda903ea2015-10-02 02:36:56 -070095 RtcpMode rtcp_mode = RtcpMode::kCompound;
pbos@webrtc.orgc11148b2013-10-17 14:14:42 +000096
asapersson@webrtc.orgefaeda02014-01-20 08:34:49 +000097 // Extended RTCP settings.
98 struct RtcpXr {
asapersson@webrtc.orgefaeda02014-01-20 08:34:49 +000099 // True if RTCP Receiver Reference Time Report Block extension
100 // (RFC 3611) should be enabled.
Fredrik Solenberg78fb3b32015-06-11 12:38:38 +0200101 bool receiver_reference_time_report = false;
asapersson@webrtc.orgefaeda02014-01-20 08:34:49 +0000102 } rtcp_xr;
103
mflodman@webrtc.org92c27932013-12-13 16:36:28 +0000104 // See draft-alvestrand-rmcat-remb for information.
Fredrik Solenberg78fb3b32015-06-11 12:38:38 +0200105 bool remb = false;
mflodman@webrtc.org92c27932013-12-13 16:36:28 +0000106
stefan43edf0f2015-11-20 18:05:48 -0800107 // See draft-holmer-rmcat-transport-wide-cc-extensions for details.
108 bool transport_cc = false;
109
pbos@webrtc.org025f4f12013-06-05 11:33:21 +0000110 // See NackConfig for description.
111 NackConfig nack;
112
113 // See FecConfig for description.
114 FecConfig fec;
115
pbos@webrtc.orgc279a5d2014-01-24 09:30:53 +0000116 // RTX settings for incoming video payloads that may be received. RTX is
117 // disabled if there's no config present.
118 struct Rtx {
pbos@webrtc.orgc279a5d2014-01-24 09:30:53 +0000119 // SSRCs to use for the RTX streams.
Fredrik Solenberg78fb3b32015-06-11 12:38:38 +0200120 uint32_t ssrc = 0;
pbos@webrtc.orgc279a5d2014-01-24 09:30:53 +0000121
122 // Payload type to use for the RTX stream.
Fredrik Solenberg78fb3b32015-06-11 12:38:38 +0200123 int payload_type = 0;
pbos@webrtc.orgc279a5d2014-01-24 09:30:53 +0000124 };
125
126 // Map from video RTP payload type -> RTX config.
127 typedef std::map<int, Rtx> RtxMap;
128 RtxMap rtx;
pbos@webrtc.org025f4f12013-06-05 11:33:21 +0000129
noahric65220a72015-10-14 11:29:49 -0700130 // If set to true, the RTX payload type mapping supplied in |rtx| will be
131 // used when restoring RTX packets. Without it, RTX packets will always be
132 // restored to the last non-RTX packet payload type received.
133 bool use_rtx_payload_mapping_on_restore = false;
134
pbos@webrtc.org025f4f12013-06-05 11:33:21 +0000135 // RTP header extensions used for the received stream.
136 std::vector<RtpExtension> extensions;
137 } rtp;
138
solenberg4fbae2b2015-08-28 04:07:10 -0700139 // Transport for outgoing packets (RTCP).
pbos2d566682015-09-28 09:59:31 -0700140 Transport* rtcp_send_transport = nullptr;
solenberg4fbae2b2015-08-28 04:07:10 -0700141
Fredrik Solenberg78fb3b32015-06-11 12:38:38 +0200142 // VideoRenderer will be called for each decoded frame. 'nullptr' disables
pbos@webrtc.org025f4f12013-06-05 11:33:21 +0000143 // rendering of this stream.
Fredrik Solenberg78fb3b32015-06-11 12:38:38 +0200144 VideoRenderer* renderer = nullptr;
pbos@webrtc.org025f4f12013-06-05 11:33:21 +0000145
146 // Expected delay needed by the renderer, i.e. the frame will be delivered
147 // this many milliseconds, if possible, earlier than the ideal render time.
148 // Only valid if 'renderer' is set.
Fredrik Solenberg78fb3b32015-06-11 12:38:38 +0200149 int render_delay_ms = 10;
pbos@webrtc.org025f4f12013-06-05 11:33:21 +0000150
pbos8fc7fa72015-07-15 08:02:58 -0700151 // Identifier for an A/V synchronization group. Empty string to disable.
152 // TODO(pbos): Synchronize streams in a sync group, not just video streams
153 // to one of the audio streams.
154 std::string sync_group;
pbos@webrtc.org025f4f12013-06-05 11:33:21 +0000155
156 // Called for each incoming video frame, i.e. in encoded state. E.g. used
157 // when
Fredrik Solenberg78fb3b32015-06-11 12:38:38 +0200158 // saving the stream to a file. 'nullptr' disables the callback.
159 EncodedFrameObserver* pre_decode_callback = nullptr;
pbos@webrtc.org025f4f12013-06-05 11:33:21 +0000160
161 // Called for each decoded frame. E.g. used when adding effects to the
162 // decoded
Fredrik Solenberg78fb3b32015-06-11 12:38:38 +0200163 // stream. 'nullptr' disables the callback.
164 I420FrameCallback* pre_render_callback = nullptr;
pbos@webrtc.org025f4f12013-06-05 11:33:21 +0000165
pbos@webrtc.org025f4f12013-06-05 11:33:21 +0000166 // Target delay in milliseconds. A positive value indicates this stream is
167 // used for streaming instead of a real-time call.
Fredrik Solenberg78fb3b32015-06-11 12:38:38 +0200168 int target_delay_ms = 0;
pbos@webrtc.org025f4f12013-06-05 11:33:21 +0000169 };
170
pbos@webrtc.org776e6f22014-10-29 15:28:39 +0000171 // TODO(pbos): Add info on currently-received codec to Stats.
172 virtual Stats GetStats() const = 0;
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +0000173};
174
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +0000175} // namespace webrtc
176
mflodman@webrtc.orgb429e512013-12-18 09:46:22 +0000177#endif // WEBRTC_VIDEO_RECEIVE_STREAM_H_