blob: 9303f548e7299d857447970f0208d2e476665a76 [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"
sprang@webrtc.orgccd42842014-01-07 09:54:34 +000020#include "webrtc/common_types.h"
pbos@webrtc.orgce90eff2013-11-20 11:48:56 +000021#include "webrtc/typedefs.h"
22
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +000023namespace webrtc {
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +000024
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +000025// Settings for NACK, see RFC 4585 for details.
26struct NackConfig {
pbos@webrtc.orgeceb5322013-05-28 08:04:45 +000027 NackConfig() : rtp_history_ms(0) {}
solenberg971cab02016-06-14 10:02:41 -070028 std::string ToString() const;
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +000029 // Send side: the time RTP packets are stored for retransmissions.
30 // Receive side: the time the receiver is prepared to wait for
31 // retransmissions.
pbos@webrtc.orgeceb5322013-05-28 08:04:45 +000032 // Set to '0' to disable.
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +000033 int rtp_history_ms;
34};
35
36// Settings for forward error correction, see RFC 5109 for details. Set the
37// payload types to '-1' to disable.
38struct FecConfig {
Shao Changbine62202f2015-04-21 20:24:50 +080039 FecConfig()
40 : ulpfec_payload_type(-1),
41 red_payload_type(-1),
42 red_rtx_payload_type(-1) {}
pbos@webrtc.org1e92b0a2014-05-15 09:35:06 +000043 std::string ToString() const;
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +000044 // Payload type used for ULPFEC packets.
45 int ulpfec_payload_type;
46
47 // Payload type used for RED packets.
48 int red_payload_type;
Shao Changbine62202f2015-04-21 20:24:50 +080049
50 // RTX payload type for RED payload.
51 int red_rtx_payload_type;
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +000052};
53
solenberg3a941542015-11-16 07:34:50 -080054// RTP header extension, see RFC 5285.
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +000055struct RtpExtension {
isheriff6f8d6862016-05-26 11:24:55 -070056 RtpExtension() : id(0) {}
57 RtpExtension(const std::string& uri, int id) : uri(uri), id(id) {}
pbos@webrtc.org1e92b0a2014-05-15 09:35:06 +000058 std::string ToString() const;
solenberg3a941542015-11-16 07:34:50 -080059 bool operator==(const RtpExtension& rhs) const {
isheriff6f8d6862016-05-26 11:24:55 -070060 return uri == rhs.uri && id == rhs.id;
solenberg3a941542015-11-16 07:34:50 -080061 }
isheriff6f8d6862016-05-26 11:24:55 -070062 static bool IsSupportedForAudio(const std::string& uri);
63 static bool IsSupportedForVideo(const std::string& uri);
pbos@webrtc.org3c107582014-07-20 15:27:35 +000064
isheriff6f8d6862016-05-26 11:24:55 -070065 // Header extension for audio levels, as defined in:
66 // http://tools.ietf.org/html/draft-ietf-avtext-client-to-mixer-audio-level-03
67 static const char* kAudioLevelUri;
68 static const int kAudioLevelDefaultId;
69
70 // Header extension for RTP timestamp offset, see RFC 5450 for details:
71 // http://tools.ietf.org/html/rfc5450
72 static const char* kTimestampOffsetUri;
73 static const int kTimestampOffsetDefaultId;
74
75 // Header extension for absolute send time, see url for details:
76 // http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
77 static const char* kAbsSendTimeUri;
78 static const int kAbsSendTimeDefaultId;
79
80 // Header extension for coordination of video orientation, see url for
81 // details:
82 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ts_126114v120700p.pdf
83 static const char* kVideoRotationUri;
84 static const int kVideoRotationDefaultId;
85
86 // Header extension for transport sequence number, see url for details:
87 // http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions
88 static const char* kTransportSequenceNumberUri;
89 static const int kTransportSequenceNumberDefaultId;
90
isheriff6b4b5f32016-06-08 00:24:21 -070091 static const char* kPlayoutDelayUri;
92 static const int kPlayoutDelayDefaultId;
93
isheriff6f8d6862016-05-26 11:24:55 -070094 std::string uri;
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +000095 int id;
96};
pbos@webrtc.org1e92b0a2014-05-15 09:35:06 +000097
98struct VideoStream {
kwiberg@webrtc.orgac2d27d2015-02-26 13:59:22 +000099 VideoStream();
100 ~VideoStream();
pbos@webrtc.org1e92b0a2014-05-15 09:35:06 +0000101 std::string ToString() const;
102
103 size_t width;
104 size_t height;
105 int max_framerate;
106
107 int min_bitrate_bps;
108 int target_bitrate_bps;
109 int max_bitrate_bps;
110
111 int max_qp;
112
pbos@webrtc.orgb7ed7792014-10-31 13:08:10 +0000113 // Bitrate thresholds for enabling additional temporal layers. Since these are
114 // thresholds in between layers, we have one additional layer. One threshold
115 // gives two temporal layers, one below the threshold and one above, two give
116 // three, and so on.
117 // The VideoEncoder may redistribute bitrates over the temporal layers so a
118 // bitrate threshold of 100k and an estimate of 105k does not imply that we
119 // get 100k in one temporal layer and 5k in the other, just that the bitrate
120 // in the first temporal layer should not exceed 100k.
121 // TODO(pbos): Apart from a special case for two-layer screencast these
122 // thresholds are not propagated to the VideoEncoder. To be implemented.
123 std::vector<int> temporal_layer_thresholds_bps;
pbos@webrtc.org1e92b0a2014-05-15 09:35:06 +0000124};
125
pbos@webrtc.orgbbe0a852014-09-19 12:30:25 +0000126struct VideoEncoderConfig {
perkj26091b12016-09-01 01:17:40 -0700127 public:
Erik Språng143cec12015-04-28 10:01:41 +0200128 enum class ContentType {
pbos@webrtc.orgbbe0a852014-09-19 12:30:25 +0000129 kRealtimeVideo,
Erik Språng143cec12015-04-28 10:01:41 +0200130 kScreen,
pbos@webrtc.orgbbe0a852014-09-19 12:30:25 +0000131 };
132
perkj26091b12016-09-01 01:17:40 -0700133 VideoEncoderConfig& operator=(VideoEncoderConfig&&) = default;
134 VideoEncoderConfig& operator=(const VideoEncoderConfig&) = delete;
135
136 // Mostly used by tests. Avoid creating copies if you can.
137 VideoEncoderConfig Copy() const { return VideoEncoderConfig(*this); }
138
kwiberg@webrtc.orgac2d27d2015-02-26 13:59:22 +0000139 VideoEncoderConfig();
perkj26091b12016-09-01 01:17:40 -0700140 VideoEncoderConfig(VideoEncoderConfig&&) = default;
kwiberg@webrtc.orgac2d27d2015-02-26 13:59:22 +0000141 ~VideoEncoderConfig();
pbos@webrtc.orgad3b5a52014-10-24 09:23:21 +0000142 std::string ToString() const;
pbos@webrtc.orgbbe0a852014-09-19 12:30:25 +0000143
144 std::vector<VideoStream> streams;
sprangce4aef12015-11-02 07:23:20 -0800145 std::vector<SpatialLayer> spatial_layers;
pbos@webrtc.orgbbe0a852014-09-19 12:30:25 +0000146 ContentType content_type;
147 void* encoder_specific_settings;
pbos@webrtc.orgad3b5a52014-10-24 09:23:21 +0000148
149 // Padding will be used up to this bitrate regardless of the bitrate produced
150 // by the encoder. Padding above what's actually produced by the encoder helps
151 // maintaining a higher bitrate estimate. Padding will however not be sent
152 // unless the estimated bandwidth indicates that the link can handle it.
153 int min_transmit_bitrate_bps;
skvlad3abb7642016-06-16 12:08:03 -0700154 bool expect_encode_from_texture;
perkj26091b12016-09-01 01:17:40 -0700155
156 private:
157 // Access to the copy constructor is private to force use of the Copy()
158 // method for those exceptional cases where we do use it.
159 VideoEncoderConfig(const VideoEncoderConfig&) = default;
pbos@webrtc.orgbbe0a852014-09-19 12:30:25 +0000160};
161
johan3859c892016-08-05 09:19:25 -0700162struct VideoDecoderH264Settings {
163 std::string sprop_parameter_sets;
164};
165
166class DecoderSpecificSettings {
167 public:
168 virtual ~DecoderSpecificSettings() {}
169 rtc::Optional<VideoDecoderH264Settings> h264_extra_settings;
170};
171
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +0000172} // namespace webrtc
173
pbos@webrtc.org3c107582014-07-20 15:27:35 +0000174#endif // WEBRTC_CONFIG_H_