blob: 56d39ee9f1d642dfa3981a6e996c719879399690 [file] [log] [blame]
skvlad303b3c22016-03-24 19:36:46 -07001/*
2 * Copyright 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
11package org.webrtc;
12
Artem Titarenko69540f42018-12-10 12:30:46 +010013import android.support.annotation.Nullable;
Mirta Dvornicicd8b98042019-02-04 16:38:46 +010014import java.lang.Double;
Amit Hilbuch177670a2019-03-25 12:53:58 -070015import java.lang.String;
Magnus Jedvert6062f372017-11-16 16:53:12 +010016import java.util.ArrayList;
Florent Castellib7d9d832018-05-15 18:14:14 +020017import java.util.List;
18import java.util.Map;
Magnus Jedvert9060eb12017-12-12 12:52:54 +010019import org.webrtc.MediaStreamTrack;
skvlad303b3c22016-03-24 19:36:46 -070020
21/**
22 * The parameters for an {@code RtpSender}, as defined in
23 * http://w3c.github.io/webrtc-pc/#rtcrtpsender-interface.
deadbeefe702b302017-02-04 12:09:01 -080024 *
25 * Note: These structures use nullable Integer/etc. types because in the
26 * future, they may be used to construct ORTC RtpSender/RtpReceivers, in
27 * which case "null" will be used to represent "choose the implementation
28 * default value".
skvlad303b3c22016-03-24 19:36:46 -070029 */
30public class RtpParameters {
Taylor Brandstetterf8711c02016-03-29 17:21:29 -070031 public static class Encoding {
Amit Hilbuch177670a2019-03-25 12:53:58 -070032 // If non-null, this represents the RID that identifies this encoding layer.
33 // RIDs are used to identify layers in simulcast.
34 @Nullable public String rid;
deadbeefe702b302017-02-04 12:09:01 -080035 // Set to true to cause this encoding to be sent, and false for it not to
36 // be sent.
Taylor Brandstetterf8711c02016-03-29 17:21:29 -070037 public boolean active = true;
deadbeefe702b302017-02-04 12:09:01 -080038 // If non-null, this represents the Transport Independent Application
39 // Specific maximum bandwidth defined in RFC3890. If null, there is no
40 // maximum bitrate.
Sami Kalliomäkie7592d82018-03-22 13:32:44 +010041 @Nullable public Integer maxBitrateBps;
Åsa Persson4e5342f2018-08-13 16:46:57 +020042 // The minimum bitrate in bps for video.
Åsa Persson613591a2018-05-29 09:21:31 +020043 @Nullable public Integer minBitrateBps;
Åsa Persson4e5342f2018-08-13 16:46:57 +020044 // The max framerate in fps for video.
45 @Nullable public Integer maxFramerate;
Åsa Persson23eba222018-10-02 14:47:06 +020046 // The number of temporal layers for video.
47 @Nullable public Integer numTemporalLayers;
Mirta Dvornicicd8b98042019-02-04 16:38:46 +010048 // If non-null, scale the width and height down by this factor for video. If null,
49 // implementation default scaling factor will be used.
50 @Nullable public Double scaleResolutionDownBy;
deadbeefe702b302017-02-04 12:09:01 -080051 // SSRC to be used by this encoding.
52 // Can't be changed between getParameters/setParameters.
deadbeef8014c752017-01-06 16:53:00 -080053 public Long ssrc;
Magnus Jedvert9060eb12017-12-12 12:52:54 +010054
Amit Hilbuch177670a2019-03-25 12:53:58 -070055 // This constructor is useful for creating simulcast layers.
56 Encoding(String rid, boolean active, Double scaleResolutionDownBy) {
57 this.rid = rid;
58 this.active = active;
59 this.scaleResolutionDownBy = scaleResolutionDownBy;
60 }
61
Magnus Jedvert9060eb12017-12-12 12:52:54 +010062 @CalledByNative("Encoding")
Amit Hilbuch177670a2019-03-25 12:53:58 -070063 Encoding(String rid, boolean active, Integer maxBitrateBps, Integer minBitrateBps,
64 Integer maxFramerate, Integer numTemporalLayers, Double scaleResolutionDownBy, Long ssrc) {
65 this.rid = rid;
Magnus Jedvert9060eb12017-12-12 12:52:54 +010066 this.active = active;
67 this.maxBitrateBps = maxBitrateBps;
Åsa Persson613591a2018-05-29 09:21:31 +020068 this.minBitrateBps = minBitrateBps;
Åsa Persson4e5342f2018-08-13 16:46:57 +020069 this.maxFramerate = maxFramerate;
Åsa Persson23eba222018-10-02 14:47:06 +020070 this.numTemporalLayers = numTemporalLayers;
Mirta Dvornicicd8b98042019-02-04 16:38:46 +010071 this.scaleResolutionDownBy = scaleResolutionDownBy;
Magnus Jedvert9060eb12017-12-12 12:52:54 +010072 this.ssrc = ssrc;
73 }
74
Amit Hilbuch177670a2019-03-25 12:53:58 -070075 @Nullable
76 @CalledByNative("Encoding")
77 String getRid() {
78 return rid;
79 }
80
Magnus Jedvert9060eb12017-12-12 12:52:54 +010081 @CalledByNative("Encoding")
82 boolean getActive() {
83 return active;
84 }
85
Sami Kalliomäkie7592d82018-03-22 13:32:44 +010086 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +010087 @CalledByNative("Encoding")
88 Integer getMaxBitrateBps() {
89 return maxBitrateBps;
90 }
91
Åsa Persson613591a2018-05-29 09:21:31 +020092 @Nullable
93 @CalledByNative("Encoding")
94 Integer getMinBitrateBps() {
95 return minBitrateBps;
96 }
97
Åsa Persson4e5342f2018-08-13 16:46:57 +020098 @Nullable
99 @CalledByNative("Encoding")
100 Integer getMaxFramerate() {
101 return maxFramerate;
102 }
103
Åsa Persson23eba222018-10-02 14:47:06 +0200104 @Nullable
105 @CalledByNative("Encoding")
106 Integer getNumTemporalLayers() {
107 return numTemporalLayers;
108 }
109
Mirta Dvornicicd8b98042019-02-04 16:38:46 +0100110 @Nullable
111 @CalledByNative("Encoding")
112 Double getScaleResolutionDownBy() {
113 return scaleResolutionDownBy;
114 }
115
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100116 @CalledByNative("Encoding")
117 Long getSsrc() {
118 return ssrc;
119 }
Taylor Brandstetterf8711c02016-03-29 17:21:29 -0700120 }
skvlad303b3c22016-03-24 19:36:46 -0700121
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700122 public static class Codec {
deadbeefe702b302017-02-04 12:09:01 -0800123 // Payload type used to identify this codec in RTP packets.
124 public int payloadType;
125 // Name used to identify the codec. Equivalent to MIME subtype.
126 public String name;
127 // The media type of this codec. Equivalent to MIME top-level type.
128 MediaStreamTrack.MediaType kind;
129 // Clock rate in Hertz.
130 public Integer clockRate;
131 // The number of audio channels used. Set to null for video codecs.
132 public Integer numChannels;
Florent Castellib7d9d832018-05-15 18:14:14 +0200133 // The "format specific parameters" field from the "a=fmtp" line in the SDP
134 public Map<String, String> parameters;
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100135
136 @CalledByNative("Codec")
137 Codec(int payloadType, String name, MediaStreamTrack.MediaType kind, Integer clockRate,
Florent Castellib7d9d832018-05-15 18:14:14 +0200138 Integer numChannels, Map<String, String> parameters) {
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100139 this.payloadType = payloadType;
140 this.name = name;
141 this.kind = kind;
142 this.clockRate = clockRate;
143 this.numChannels = numChannels;
Florent Castellib7d9d832018-05-15 18:14:14 +0200144 this.parameters = parameters;
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100145 }
146
147 @CalledByNative("Codec")
148 int getPayloadType() {
149 return payloadType;
150 }
151
152 @CalledByNative("Codec")
153 String getName() {
154 return name;
155 }
156
157 @CalledByNative("Codec")
158 MediaStreamTrack.MediaType getKind() {
159 return kind;
160 }
161
162 @CalledByNative("Codec")
163 Integer getClockRate() {
164 return clockRate;
165 }
166
167 @CalledByNative("Codec")
168 Integer getNumChannels() {
169 return numChannels;
170 }
Florent Castellib7d9d832018-05-15 18:14:14 +0200171
172 @CalledByNative("Codec")
173 Map getParameters() {
174 return parameters;
175 }
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700176 }
177
Florent Castellidacec712018-05-24 16:24:21 +0200178 public static class Rtcp {
179 /** The Canonical Name used by RTCP */
180 private final String cname;
181 /** Whether reduced size RTCP is configured or compound RTCP */
182 private final boolean reducedSize;
183
184 @CalledByNative("Rtcp")
185 Rtcp(String cname, boolean reducedSize) {
186 this.cname = cname;
187 this.reducedSize = reducedSize;
188 }
189
190 @CalledByNative("Rtcp")
191 public String getCname() {
192 return cname;
193 }
194
195 @CalledByNative("Rtcp")
196 public boolean getReducedSize() {
197 return reducedSize;
198 }
199 }
200
Florent Castelliabe301f2018-06-12 18:33:49 +0200201 public static class HeaderExtension {
202 /** The URI of the RTP header extension, as defined in RFC5285. */
203 private final String uri;
204 /** The value put in the RTP packet to identify the header extension. */
205 private final int id;
206 /** Whether the header extension is encrypted or not. */
207 private final boolean encrypted;
208
209 @CalledByNative("HeaderExtension")
210 HeaderExtension(String uri, int id, boolean encrypted) {
211 this.uri = uri;
212 this.id = id;
213 this.encrypted = encrypted;
214 }
215
216 @CalledByNative("HeaderExtension")
217 public String getUri() {
218 return uri;
219 }
220
221 @CalledByNative("HeaderExtension")
222 public int getId() {
223 return id;
224 }
225
226 @CalledByNative("HeaderExtension")
227 public boolean getEncrypted() {
228 return encrypted;
229 }
230 }
231
Florent Castellicebf50f2018-05-03 15:31:53 +0200232 public final String transactionId;
233
Florent Castellidacec712018-05-24 16:24:21 +0200234 private final Rtcp rtcp;
235
Florent Castelliabe301f2018-06-12 18:33:49 +0200236 private final List<HeaderExtension> headerExtensions;
237
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100238 public final List<Encoding> encodings;
deadbeefe702b302017-02-04 12:09:01 -0800239 // Codec parameters can't currently be changed between getParameters and
240 // setParameters. Though in the future it will be possible to reorder them or
241 // remove them.
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100242 public final List<Codec> codecs;
243
Florent Castellicebf50f2018-05-03 15:31:53 +0200244 @CalledByNative
Florent Castelliabe301f2018-06-12 18:33:49 +0200245 RtpParameters(String transactionId, Rtcp rtcp, List<HeaderExtension> headerExtensions,
246 List<Encoding> encodings, List<Codec> codecs) {
Florent Castellicebf50f2018-05-03 15:31:53 +0200247 this.transactionId = transactionId;
Florent Castellidacec712018-05-24 16:24:21 +0200248 this.rtcp = rtcp;
Florent Castelliabe301f2018-06-12 18:33:49 +0200249 this.headerExtensions = headerExtensions;
Florent Castellicebf50f2018-05-03 15:31:53 +0200250 this.encodings = encodings;
251 this.codecs = codecs;
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100252 }
253
254 @CalledByNative
Florent Castellicebf50f2018-05-03 15:31:53 +0200255 String getTransactionId() {
256 return transactionId;
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100257 }
258
259 @CalledByNative
Florent Castellidacec712018-05-24 16:24:21 +0200260 public Rtcp getRtcp() {
261 return rtcp;
262 }
263
264 @CalledByNative
Florent Castelliabe301f2018-06-12 18:33:49 +0200265 public List<HeaderExtension> getHeaderExtensions() {
266 return headerExtensions;
267 }
268
269 @CalledByNative
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100270 List<Encoding> getEncodings() {
271 return encodings;
272 }
273
274 @CalledByNative
275 List<Codec> getCodecs() {
276 return codecs;
277 }
skvlad303b3c22016-03-24 19:36:46 -0700278}