blob: 109c2aa15b8bcc3920d426c676f61cf137362fd2 [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
asaperssonf8cdd182016-03-15 01:00:47 -070014#include <limits>
pbos@webrtc.orge02d4752014-01-20 14:43:55 +000015#include <map>
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +000016#include <string>
17#include <vector>
18
19#include "webrtc/common_types.h"
pbos@webrtc.org16e03b72013-10-28 16:32:01 +000020#include "webrtc/config.h"
21#include "webrtc/frame_callback.h"
Jelena Marusiccd670222015-07-16 09:30:09 +020022#include "webrtc/stream.h"
pbos@webrtc.org16e03b72013-10-28 16:32:01 +000023#include "webrtc/transport.h"
nisse7ade7b32016-03-23 04:48:10 -070024#include "webrtc/media/base/videosinkinterface.h"
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +000025
26namespace webrtc {
27
28class VideoDecoder;
29
Jelena Marusiccd670222015-07-16 09:30:09 +020030class VideoReceiveStream : public ReceiveStream {
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +000031 public:
pbos@webrtc.org776e6f22014-10-29 15:28:39 +000032 // TODO(mflodman) Move all these settings to VideoDecoder and move the
33 // declaration to common_types.h.
34 struct Decoder {
pbos@webrtc.org32e85282015-01-15 10:09:39 +000035 std::string ToString() const;
pbos@webrtc.org776e6f22014-10-29 15:28:39 +000036
37 // The actual decoder instance.
Fredrik Solenberg78fb3b32015-06-11 12:38:38 +020038 VideoDecoder* decoder = nullptr;
pbos@webrtc.org776e6f22014-10-29 15:28:39 +000039
40 // Received RTP packets with this payload type will be sent to this decoder
41 // instance.
Fredrik Solenberg78fb3b32015-06-11 12:38:38 +020042 int payload_type = 0;
pbos@webrtc.org776e6f22014-10-29 15:28:39 +000043
44 // Name of the decoded payload (such as VP8). Maps back to the depacketizer
45 // used to unpack incoming packets.
46 std::string payload_name;
pbos@webrtc.org776e6f22014-10-29 15:28:39 +000047 };
48
pbos@webrtc.org09c77b92015-02-25 10:42:16 +000049 struct Stats {
50 int network_frame_rate = 0;
51 int decode_frame_rate = 0;
52 int render_frame_rate = 0;
sprang@webrtc.org09315702014-02-07 12:06:29 +000053
pbos@webrtc.org09c77b92015-02-25 10:42:16 +000054 // Decoder stats.
Peter Boströmb7d9a972015-12-18 16:01:11 +010055 std::string decoder_implementation_name = "unknown";
pbos@webrtc.org09c77b92015-02-25 10:42:16 +000056 FrameCounts frame_counts;
57 int decode_ms = 0;
58 int max_decode_ms = 0;
59 int current_delay_ms = 0;
60 int target_delay_ms = 0;
61 int jitter_buffer_ms = 0;
62 int min_playout_delay_ms = 0;
Peter Boströmc4188fd2015-04-24 15:16:03 +020063 int render_delay_ms = 10;
pbos@webrtc.org09c77b92015-02-25 10:42:16 +000064
pbosf42376c2015-08-28 07:35:32 -070065 int current_payload_type = -1;
66
pbos@webrtc.org09c77b92015-02-25 10:42:16 +000067 int total_bitrate_bps = 0;
68 int discarded_packets = 0;
69
asaperssonf8cdd182016-03-15 01:00:47 -070070 int sync_offset_ms = std::numeric_limits<int>::max();
71
pbos@webrtc.org09c77b92015-02-25 10:42:16 +000072 uint32_t ssrc = 0;
sprang@webrtc.org09315702014-02-07 12:06:29 +000073 std::string c_name;
pbos@webrtc.org09c77b92015-02-25 10:42:16 +000074 StreamDataCounters rtp_stats;
75 RtcpPacketTypeCounter rtcp_packet_type_counts;
76 RtcpStatistics rtcp_stats;
pbos@webrtc.org025f4f12013-06-05 11:33:21 +000077 };
78
79 struct Config {
solenberg4fbae2b2015-08-28 04:07:10 -070080 Config() = delete;
pbos2d566682015-09-28 09:59:31 -070081 explicit Config(Transport* rtcp_send_transport)
solenberg4fbae2b2015-08-28 04:07:10 -070082 : rtcp_send_transport(rtcp_send_transport) {}
83
pbos@webrtc.org32e85282015-01-15 10:09:39 +000084 std::string ToString() const;
pbos@webrtc.org776e6f22014-10-29 15:28:39 +000085
86 // Decoders for every payload that we can receive.
87 std::vector<Decoder> decoders;
pbos@webrtc.org025f4f12013-06-05 11:33:21 +000088
89 // Receive-stream specific RTP settings.
90 struct Rtp {
pbos@webrtc.org32e85282015-01-15 10:09:39 +000091 std::string ToString() const;
pbos@webrtc.orgc11148b2013-10-17 14:14:42 +000092
pbos@webrtc.orgb613b5a2013-12-03 10:13:04 +000093 // Synchronization source (stream identifier) to be received.
Fredrik Solenberg78fb3b32015-06-11 12:38:38 +020094 uint32_t remote_ssrc = 0;
pbos@webrtc.orgb613b5a2013-12-03 10:13:04 +000095 // Sender SSRC used for sending RTCP (such as receiver reports).
Fredrik Solenberg78fb3b32015-06-11 12:38:38 +020096 uint32_t local_ssrc = 0;
pbos@webrtc.org025f4f12013-06-05 11:33:21 +000097
pbos@webrtc.orgc11148b2013-10-17 14:14:42 +000098 // See RtcpMode for description.
pbosda903ea2015-10-02 02:36:56 -070099 RtcpMode rtcp_mode = RtcpMode::kCompound;
pbos@webrtc.orgc11148b2013-10-17 14:14:42 +0000100
asapersson@webrtc.orgefaeda02014-01-20 08:34:49 +0000101 // Extended RTCP settings.
102 struct RtcpXr {
asapersson@webrtc.orgefaeda02014-01-20 08:34:49 +0000103 // True if RTCP Receiver Reference Time Report Block extension
104 // (RFC 3611) should be enabled.
Fredrik Solenberg78fb3b32015-06-11 12:38:38 +0200105 bool receiver_reference_time_report = false;
asapersson@webrtc.orgefaeda02014-01-20 08:34:49 +0000106 } rtcp_xr;
107
mflodman@webrtc.org92c27932013-12-13 16:36:28 +0000108 // See draft-alvestrand-rmcat-remb for information.
Fredrik Solenberg78fb3b32015-06-11 12:38:38 +0200109 bool remb = false;
mflodman@webrtc.org92c27932013-12-13 16:36:28 +0000110
stefan43edf0f2015-11-20 18:05:48 -0800111 // See draft-holmer-rmcat-transport-wide-cc-extensions for details.
112 bool transport_cc = false;
113
pbos@webrtc.org025f4f12013-06-05 11:33:21 +0000114 // See NackConfig for description.
115 NackConfig nack;
116
117 // See FecConfig for description.
118 FecConfig fec;
119
pbos@webrtc.orgc279a5d2014-01-24 09:30:53 +0000120 // RTX settings for incoming video payloads that may be received. RTX is
121 // disabled if there's no config present.
122 struct Rtx {
pbos@webrtc.orgc279a5d2014-01-24 09:30:53 +0000123 // SSRCs to use for the RTX streams.
Fredrik Solenberg78fb3b32015-06-11 12:38:38 +0200124 uint32_t ssrc = 0;
pbos@webrtc.orgc279a5d2014-01-24 09:30:53 +0000125
126 // Payload type to use for the RTX stream.
Fredrik Solenberg78fb3b32015-06-11 12:38:38 +0200127 int payload_type = 0;
pbos@webrtc.orgc279a5d2014-01-24 09:30:53 +0000128 };
129
130 // Map from video RTP payload type -> RTX config.
131 typedef std::map<int, Rtx> RtxMap;
132 RtxMap rtx;
pbos@webrtc.org025f4f12013-06-05 11:33:21 +0000133
noahric65220a72015-10-14 11:29:49 -0700134 // If set to true, the RTX payload type mapping supplied in |rtx| will be
135 // used when restoring RTX packets. Without it, RTX packets will always be
136 // restored to the last non-RTX packet payload type received.
137 bool use_rtx_payload_mapping_on_restore = false;
138
pbos@webrtc.org025f4f12013-06-05 11:33:21 +0000139 // RTP header extensions used for the received stream.
140 std::vector<RtpExtension> extensions;
141 } rtp;
142
solenberg4fbae2b2015-08-28 04:07:10 -0700143 // Transport for outgoing packets (RTCP).
pbos2d566682015-09-28 09:59:31 -0700144 Transport* rtcp_send_transport = nullptr;
solenberg4fbae2b2015-08-28 04:07:10 -0700145
Fredrik Solenberg78fb3b32015-06-11 12:38:38 +0200146 // VideoRenderer will be called for each decoded frame. 'nullptr' disables
pbos@webrtc.org025f4f12013-06-05 11:33:21 +0000147 // rendering of this stream.
nisse7ade7b32016-03-23 04:48:10 -0700148 rtc::VideoSinkInterface<VideoFrame>* renderer = nullptr;
pbos@webrtc.org025f4f12013-06-05 11:33:21 +0000149
150 // Expected delay needed by the renderer, i.e. the frame will be delivered
151 // this many milliseconds, if possible, earlier than the ideal render time.
152 // Only valid if 'renderer' is set.
Fredrik Solenberg78fb3b32015-06-11 12:38:38 +0200153 int render_delay_ms = 10;
pbos@webrtc.org025f4f12013-06-05 11:33:21 +0000154
nisse7ade7b32016-03-23 04:48:10 -0700155 // If set, pass frames on to the renderer as soon as they are
156 // available.
157 bool disable_prerenderer_smoothing = false;
158
pbos8fc7fa72015-07-15 08:02:58 -0700159 // Identifier for an A/V synchronization group. Empty string to disable.
160 // TODO(pbos): Synchronize streams in a sync group, not just video streams
161 // to one of the audio streams.
162 std::string sync_group;
pbos@webrtc.org025f4f12013-06-05 11:33:21 +0000163
164 // Called for each incoming video frame, i.e. in encoded state. E.g. used
165 // when
Fredrik Solenberg78fb3b32015-06-11 12:38:38 +0200166 // saving the stream to a file. 'nullptr' disables the callback.
167 EncodedFrameObserver* pre_decode_callback = nullptr;
pbos@webrtc.org025f4f12013-06-05 11:33:21 +0000168
169 // Called for each decoded frame. E.g. used when adding effects to the
170 // decoded
Fredrik Solenberg78fb3b32015-06-11 12:38:38 +0200171 // stream. 'nullptr' disables the callback.
172 I420FrameCallback* pre_render_callback = nullptr;
pbos@webrtc.org025f4f12013-06-05 11:33:21 +0000173
pbos@webrtc.org025f4f12013-06-05 11:33:21 +0000174 // Target delay in milliseconds. A positive value indicates this stream is
175 // used for streaming instead of a real-time call.
Fredrik Solenberg78fb3b32015-06-11 12:38:38 +0200176 int target_delay_ms = 0;
pbos@webrtc.org025f4f12013-06-05 11:33:21 +0000177 };
178
pbos@webrtc.org776e6f22014-10-29 15:28:39 +0000179 // TODO(pbos): Add info on currently-received codec to Stats.
180 virtual Stats GetStats() const = 0;
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +0000181};
182
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +0000183} // namespace webrtc
184
mflodman@webrtc.orgb429e512013-12-18 09:46:22 +0000185#endif // WEBRTC_VIDEO_RECEIVE_STREAM_H_