blob: d932eda1df8eee81a3d004518fcc9396a495d2c2 [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
pbos@webrtc.org16e03b72013-10-28 16:32:01 +000011// TODO(pbos): Move Config from common.h to here.
12
pbos@webrtc.org3c107582014-07-20 15:27:35 +000013#ifndef WEBRTC_CONFIG_H_
14#define WEBRTC_CONFIG_H_
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +000015
16#include <string>
pbos@webrtc.org5860de02013-09-16 13:01:47 +000017#include <vector>
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +000018
johan3859c892016-08-05 09:19:25 -070019#include "webrtc/base/optional.h"
aluebs688e3082016-01-14 04:32:46 -080020#include "webrtc/common.h"
sprang@webrtc.orgccd42842014-01-07 09:54:34 +000021#include "webrtc/common_types.h"
pbos@webrtc.orgce90eff2013-11-20 11:48:56 +000022#include "webrtc/typedefs.h"
23
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +000024namespace webrtc {
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +000025
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +000026// Settings for NACK, see RFC 4585 for details.
27struct NackConfig {
pbos@webrtc.orgeceb5322013-05-28 08:04:45 +000028 NackConfig() : rtp_history_ms(0) {}
solenberg971cab02016-06-14 10:02:41 -070029 std::string ToString() const;
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +000030 // Send side: the time RTP packets are stored for retransmissions.
31 // Receive side: the time the receiver is prepared to wait for
32 // retransmissions.
pbos@webrtc.orgeceb5322013-05-28 08:04:45 +000033 // Set to '0' to disable.
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +000034 int rtp_history_ms;
35};
36
37// Settings for forward error correction, see RFC 5109 for details. Set the
38// payload types to '-1' to disable.
39struct FecConfig {
Shao Changbine62202f2015-04-21 20:24:50 +080040 FecConfig()
41 : ulpfec_payload_type(-1),
42 red_payload_type(-1),
43 red_rtx_payload_type(-1) {}
pbos@webrtc.org1e92b0a2014-05-15 09:35:06 +000044 std::string ToString() const;
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +000045 // Payload type used for ULPFEC packets.
46 int ulpfec_payload_type;
47
48 // Payload type used for RED packets.
49 int red_payload_type;
Shao Changbine62202f2015-04-21 20:24:50 +080050
51 // RTX payload type for RED payload.
52 int red_rtx_payload_type;
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +000053};
54
solenberg3a941542015-11-16 07:34:50 -080055// RTP header extension, see RFC 5285.
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +000056struct RtpExtension {
isheriff6f8d6862016-05-26 11:24:55 -070057 RtpExtension() : id(0) {}
58 RtpExtension(const std::string& uri, int id) : uri(uri), id(id) {}
pbos@webrtc.org1e92b0a2014-05-15 09:35:06 +000059 std::string ToString() const;
solenberg3a941542015-11-16 07:34:50 -080060 bool operator==(const RtpExtension& rhs) const {
isheriff6f8d6862016-05-26 11:24:55 -070061 return uri == rhs.uri && id == rhs.id;
solenberg3a941542015-11-16 07:34:50 -080062 }
isheriff6f8d6862016-05-26 11:24:55 -070063 static bool IsSupportedForAudio(const std::string& uri);
64 static bool IsSupportedForVideo(const std::string& uri);
pbos@webrtc.org3c107582014-07-20 15:27:35 +000065
isheriff6f8d6862016-05-26 11:24:55 -070066 // Header extension for audio levels, as defined in:
67 // http://tools.ietf.org/html/draft-ietf-avtext-client-to-mixer-audio-level-03
68 static const char* kAudioLevelUri;
69 static const int kAudioLevelDefaultId;
70
71 // Header extension for RTP timestamp offset, see RFC 5450 for details:
72 // http://tools.ietf.org/html/rfc5450
73 static const char* kTimestampOffsetUri;
74 static const int kTimestampOffsetDefaultId;
75
76 // Header extension for absolute send time, see url for details:
77 // http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
78 static const char* kAbsSendTimeUri;
79 static const int kAbsSendTimeDefaultId;
80
81 // Header extension for coordination of video orientation, see url for
82 // details:
83 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ts_126114v120700p.pdf
84 static const char* kVideoRotationUri;
85 static const int kVideoRotationDefaultId;
86
87 // Header extension for transport sequence number, see url for details:
88 // http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions
89 static const char* kTransportSequenceNumberUri;
90 static const int kTransportSequenceNumberDefaultId;
91
isheriff6b4b5f32016-06-08 00:24:21 -070092 static const char* kPlayoutDelayUri;
93 static const int kPlayoutDelayDefaultId;
94
isheriff6f8d6862016-05-26 11:24:55 -070095 std::string uri;
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +000096 int id;
97};
pbos@webrtc.org1e92b0a2014-05-15 09:35:06 +000098
99struct VideoStream {
kwiberg@webrtc.orgac2d27d2015-02-26 13:59:22 +0000100 VideoStream();
101 ~VideoStream();
pbos@webrtc.org1e92b0a2014-05-15 09:35:06 +0000102 std::string ToString() const;
103
104 size_t width;
105 size_t height;
106 int max_framerate;
107
108 int min_bitrate_bps;
109 int target_bitrate_bps;
110 int max_bitrate_bps;
111
112 int max_qp;
113
pbos@webrtc.orgb7ed7792014-10-31 13:08:10 +0000114 // Bitrate thresholds for enabling additional temporal layers. Since these are
115 // thresholds in between layers, we have one additional layer. One threshold
116 // gives two temporal layers, one below the threshold and one above, two give
117 // three, and so on.
118 // The VideoEncoder may redistribute bitrates over the temporal layers so a
119 // bitrate threshold of 100k and an estimate of 105k does not imply that we
120 // get 100k in one temporal layer and 5k in the other, just that the bitrate
121 // in the first temporal layer should not exceed 100k.
122 // TODO(pbos): Apart from a special case for two-layer screencast these
123 // thresholds are not propagated to the VideoEncoder. To be implemented.
124 std::vector<int> temporal_layer_thresholds_bps;
pbos@webrtc.org1e92b0a2014-05-15 09:35:06 +0000125};
126
pbos@webrtc.orgbbe0a852014-09-19 12:30:25 +0000127struct VideoEncoderConfig {
perkj26091b12016-09-01 01:17:40 -0700128 public:
Erik Språng143cec12015-04-28 10:01:41 +0200129 enum class ContentType {
pbos@webrtc.orgbbe0a852014-09-19 12:30:25 +0000130 kRealtimeVideo,
Erik Språng143cec12015-04-28 10:01:41 +0200131 kScreen,
pbos@webrtc.orgbbe0a852014-09-19 12:30:25 +0000132 };
133
perkj26091b12016-09-01 01:17:40 -0700134 VideoEncoderConfig& operator=(VideoEncoderConfig&&) = default;
135 VideoEncoderConfig& operator=(const VideoEncoderConfig&) = delete;
136
137 // Mostly used by tests. Avoid creating copies if you can.
138 VideoEncoderConfig Copy() const { return VideoEncoderConfig(*this); }
139
kwiberg@webrtc.orgac2d27d2015-02-26 13:59:22 +0000140 VideoEncoderConfig();
perkj26091b12016-09-01 01:17:40 -0700141 VideoEncoderConfig(VideoEncoderConfig&&) = default;
kwiberg@webrtc.orgac2d27d2015-02-26 13:59:22 +0000142 ~VideoEncoderConfig();
pbos@webrtc.orgad3b5a52014-10-24 09:23:21 +0000143 std::string ToString() const;
pbos@webrtc.orgbbe0a852014-09-19 12:30:25 +0000144
145 std::vector<VideoStream> streams;
sprangce4aef12015-11-02 07:23:20 -0800146 std::vector<SpatialLayer> spatial_layers;
pbos@webrtc.orgbbe0a852014-09-19 12:30:25 +0000147 ContentType content_type;
148 void* encoder_specific_settings;
pbos@webrtc.orgad3b5a52014-10-24 09:23:21 +0000149
150 // Padding will be used up to this bitrate regardless of the bitrate produced
151 // by the encoder. Padding above what's actually produced by the encoder helps
152 // maintaining a higher bitrate estimate. Padding will however not be sent
153 // unless the estimated bandwidth indicates that the link can handle it.
154 int min_transmit_bitrate_bps;
skvlad3abb7642016-06-16 12:08:03 -0700155 bool expect_encode_from_texture;
perkj26091b12016-09-01 01:17:40 -0700156
157 private:
158 // Access to the copy constructor is private to force use of the Copy()
159 // method for those exceptional cases where we do use it.
160 VideoEncoderConfig(const VideoEncoderConfig&) = default;
pbos@webrtc.orgbbe0a852014-09-19 12:30:25 +0000161};
162
johan3859c892016-08-05 09:19:25 -0700163struct VideoDecoderH264Settings {
164 std::string sprop_parameter_sets;
165};
166
167class DecoderSpecificSettings {
168 public:
169 virtual ~DecoderSpecificSettings() {}
170 rtc::Optional<VideoDecoderH264Settings> h264_extra_settings;
171};
172
Henrik Lundin64dad832015-05-11 12:44:23 +0200173// Controls the capacity of the packet buffer in NetEq. The capacity is the
174// maximum number of packets that the buffer can contain. If the limit is
175// exceeded, the buffer will be flushed. The capacity does not affect the actual
176// audio delay in the general case, since this is governed by the target buffer
177// level (calculated from the jitter profile). It is only in the rare case of
178// severe network freezes that a higher capacity will lead to a (transient)
179// increase in audio delay.
180struct NetEqCapacityConfig {
181 NetEqCapacityConfig() : enabled(false), capacity(0) {}
182 explicit NetEqCapacityConfig(int value) : enabled(true), capacity(value) {}
aluebs688e3082016-01-14 04:32:46 -0800183 static const ConfigOptionID identifier = ConfigOptionID::kNetEqCapacityConfig;
Henrik Lundin64dad832015-05-11 12:44:23 +0200184 bool enabled;
185 int capacity;
186};
187
Henrik Lundin5263b3c2015-06-01 10:29:41 +0200188struct NetEqFastAccelerate {
189 NetEqFastAccelerate() : enabled(false) {}
190 explicit NetEqFastAccelerate(bool value) : enabled(value) {}
aluebs688e3082016-01-14 04:32:46 -0800191 static const ConfigOptionID identifier = ConfigOptionID::kNetEqFastAccelerate;
Henrik Lundin5263b3c2015-06-01 10:29:41 +0200192 bool enabled;
193};
194
Stefan Holmerb86d4e42015-12-07 10:26:18 +0100195struct VoicePacing {
196 VoicePacing() : enabled(false) {}
197 explicit VoicePacing(bool value) : enabled(value) {}
aluebs688e3082016-01-14 04:32:46 -0800198 static const ConfigOptionID identifier = ConfigOptionID::kVoicePacing;
Stefan Holmerb86d4e42015-12-07 10:26:18 +0100199 bool enabled;
200};
201
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +0000202} // namespace webrtc
203
pbos@webrtc.org3c107582014-07-20 15:27:35 +0000204#endif // WEBRTC_CONFIG_H_