blob: ac42baab564d0910d611039ebc95dea706e4342f [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 Hilbuchae4b6232019-03-29 14:02:42 -070015import java.lang.String;
Florent Castellib7d9d832018-05-15 18:14:14 +020016import java.util.List;
17import java.util.Map;
Magnus Jedvert9060eb12017-12-12 12:52:54 +010018import org.webrtc.MediaStreamTrack;
skvlad303b3c22016-03-24 19:36:46 -070019
20/**
21 * The parameters for an {@code RtpSender}, as defined in
22 * http://w3c.github.io/webrtc-pc/#rtcrtpsender-interface.
deadbeefe702b302017-02-04 12:09:01 -080023 *
24 * Note: These structures use nullable Integer/etc. types because in the
25 * future, they may be used to construct ORTC RtpSender/RtpReceivers, in
26 * which case "null" will be used to represent "choose the implementation
27 * default value".
skvlad303b3c22016-03-24 19:36:46 -070028 */
29public class RtpParameters {
Taylor Brandstetterf8711c02016-03-29 17:21:29 -070030 public static class Encoding {
Amit Hilbuchae4b6232019-03-29 14:02:42 -070031 // If non-null, this represents the RID that identifies this encoding layer.
32 // RIDs are used to identify layers in simulcast.
33 @Nullable public String rid;
deadbeefe702b302017-02-04 12:09:01 -080034 // Set to true to cause this encoding to be sent, and false for it not to
35 // be sent.
Taylor Brandstetterf8711c02016-03-29 17:21:29 -070036 public boolean active = true;
deadbeefe702b302017-02-04 12:09:01 -080037 // If non-null, this represents the Transport Independent Application
38 // Specific maximum bandwidth defined in RFC3890. If null, there is no
39 // maximum bitrate.
Sami Kalliomäkie7592d82018-03-22 13:32:44 +010040 @Nullable public Integer maxBitrateBps;
Åsa Persson4e5342f2018-08-13 16:46:57 +020041 // The minimum bitrate in bps for video.
Åsa Persson613591a2018-05-29 09:21:31 +020042 @Nullable public Integer minBitrateBps;
Åsa Persson4e5342f2018-08-13 16:46:57 +020043 // The max framerate in fps for video.
44 @Nullable public Integer maxFramerate;
Åsa Persson23eba222018-10-02 14:47:06 +020045 // The number of temporal layers for video.
46 @Nullable public Integer numTemporalLayers;
Mirta Dvornicicd8b98042019-02-04 16:38:46 +010047 // If non-null, scale the width and height down by this factor for video. If null,
48 // implementation default scaling factor will be used.
49 @Nullable public Double scaleResolutionDownBy;
deadbeefe702b302017-02-04 12:09:01 -080050 // SSRC to be used by this encoding.
51 // Can't be changed between getParameters/setParameters.
deadbeef8014c752017-01-06 16:53:00 -080052 public Long ssrc;
Magnus Jedvert9060eb12017-12-12 12:52:54 +010053
Amit Hilbuchae4b6232019-03-29 14:02:42 -070054 // This constructor is useful for creating simulcast layers.
55 Encoding(String rid, boolean active, Double scaleResolutionDownBy) {
56 this.rid = rid;
57 this.active = active;
58 this.scaleResolutionDownBy = scaleResolutionDownBy;
59 }
60
Magnus Jedvert9060eb12017-12-12 12:52:54 +010061 @CalledByNative("Encoding")
Amit Hilbuchae4b6232019-03-29 14:02:42 -070062 Encoding(String rid, boolean active, Integer maxBitrateBps, Integer minBitrateBps,
63 Integer maxFramerate, Integer numTemporalLayers, Double scaleResolutionDownBy, Long ssrc) {
64 this.rid = rid;
Magnus Jedvert9060eb12017-12-12 12:52:54 +010065 this.active = active;
66 this.maxBitrateBps = maxBitrateBps;
Åsa Persson613591a2018-05-29 09:21:31 +020067 this.minBitrateBps = minBitrateBps;
Åsa Persson4e5342f2018-08-13 16:46:57 +020068 this.maxFramerate = maxFramerate;
Åsa Persson23eba222018-10-02 14:47:06 +020069 this.numTemporalLayers = numTemporalLayers;
Mirta Dvornicicd8b98042019-02-04 16:38:46 +010070 this.scaleResolutionDownBy = scaleResolutionDownBy;
Magnus Jedvert9060eb12017-12-12 12:52:54 +010071 this.ssrc = ssrc;
72 }
73
Amit Hilbuchae4b6232019-03-29 14:02:42 -070074 @Nullable
75 @CalledByNative("Encoding")
76 String getRid() {
77 return rid;
78 }
79
Magnus Jedvert9060eb12017-12-12 12:52:54 +010080 @CalledByNative("Encoding")
81 boolean getActive() {
82 return active;
83 }
84
Sami Kalliomäkie7592d82018-03-22 13:32:44 +010085 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +010086 @CalledByNative("Encoding")
87 Integer getMaxBitrateBps() {
88 return maxBitrateBps;
89 }
90
Åsa Persson613591a2018-05-29 09:21:31 +020091 @Nullable
92 @CalledByNative("Encoding")
93 Integer getMinBitrateBps() {
94 return minBitrateBps;
95 }
96
Åsa Persson4e5342f2018-08-13 16:46:57 +020097 @Nullable
98 @CalledByNative("Encoding")
99 Integer getMaxFramerate() {
100 return maxFramerate;
101 }
102
Åsa Persson23eba222018-10-02 14:47:06 +0200103 @Nullable
104 @CalledByNative("Encoding")
105 Integer getNumTemporalLayers() {
106 return numTemporalLayers;
107 }
108
Mirta Dvornicicd8b98042019-02-04 16:38:46 +0100109 @Nullable
110 @CalledByNative("Encoding")
111 Double getScaleResolutionDownBy() {
112 return scaleResolutionDownBy;
113 }
114
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100115 @CalledByNative("Encoding")
116 Long getSsrc() {
117 return ssrc;
118 }
Taylor Brandstetterf8711c02016-03-29 17:21:29 -0700119 }
skvlad303b3c22016-03-24 19:36:46 -0700120
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700121 public static class Codec {
deadbeefe702b302017-02-04 12:09:01 -0800122 // Payload type used to identify this codec in RTP packets.
123 public int payloadType;
124 // Name used to identify the codec. Equivalent to MIME subtype.
125 public String name;
126 // The media type of this codec. Equivalent to MIME top-level type.
127 MediaStreamTrack.MediaType kind;
128 // Clock rate in Hertz.
129 public Integer clockRate;
130 // The number of audio channels used. Set to null for video codecs.
131 public Integer numChannels;
Florent Castellib7d9d832018-05-15 18:14:14 +0200132 // The "format specific parameters" field from the "a=fmtp" line in the SDP
133 public Map<String, String> parameters;
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100134
135 @CalledByNative("Codec")
136 Codec(int payloadType, String name, MediaStreamTrack.MediaType kind, Integer clockRate,
Florent Castellib7d9d832018-05-15 18:14:14 +0200137 Integer numChannels, Map<String, String> parameters) {
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100138 this.payloadType = payloadType;
139 this.name = name;
140 this.kind = kind;
141 this.clockRate = clockRate;
142 this.numChannels = numChannels;
Florent Castellib7d9d832018-05-15 18:14:14 +0200143 this.parameters = parameters;
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100144 }
145
146 @CalledByNative("Codec")
147 int getPayloadType() {
148 return payloadType;
149 }
150
151 @CalledByNative("Codec")
152 String getName() {
153 return name;
154 }
155
156 @CalledByNative("Codec")
157 MediaStreamTrack.MediaType getKind() {
158 return kind;
159 }
160
161 @CalledByNative("Codec")
162 Integer getClockRate() {
163 return clockRate;
164 }
165
166 @CalledByNative("Codec")
167 Integer getNumChannels() {
168 return numChannels;
169 }
Florent Castellib7d9d832018-05-15 18:14:14 +0200170
171 @CalledByNative("Codec")
172 Map getParameters() {
173 return parameters;
174 }
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700175 }
176
Florent Castellidacec712018-05-24 16:24:21 +0200177 public static class Rtcp {
178 /** The Canonical Name used by RTCP */
179 private final String cname;
180 /** Whether reduced size RTCP is configured or compound RTCP */
181 private final boolean reducedSize;
182
183 @CalledByNative("Rtcp")
184 Rtcp(String cname, boolean reducedSize) {
185 this.cname = cname;
186 this.reducedSize = reducedSize;
187 }
188
189 @CalledByNative("Rtcp")
190 public String getCname() {
191 return cname;
192 }
193
194 @CalledByNative("Rtcp")
195 public boolean getReducedSize() {
196 return reducedSize;
197 }
198 }
199
Florent Castelliabe301f2018-06-12 18:33:49 +0200200 public static class HeaderExtension {
201 /** The URI of the RTP header extension, as defined in RFC5285. */
202 private final String uri;
203 /** The value put in the RTP packet to identify the header extension. */
204 private final int id;
205 /** Whether the header extension is encrypted or not. */
206 private final boolean encrypted;
207
208 @CalledByNative("HeaderExtension")
209 HeaderExtension(String uri, int id, boolean encrypted) {
210 this.uri = uri;
211 this.id = id;
212 this.encrypted = encrypted;
213 }
214
215 @CalledByNative("HeaderExtension")
216 public String getUri() {
217 return uri;
218 }
219
220 @CalledByNative("HeaderExtension")
221 public int getId() {
222 return id;
223 }
224
225 @CalledByNative("HeaderExtension")
226 public boolean getEncrypted() {
227 return encrypted;
228 }
229 }
230
Florent Castellicebf50f2018-05-03 15:31:53 +0200231 public final String transactionId;
232
Florent Castellidacec712018-05-24 16:24:21 +0200233 private final Rtcp rtcp;
234
Florent Castelliabe301f2018-06-12 18:33:49 +0200235 private final List<HeaderExtension> headerExtensions;
236
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100237 public final List<Encoding> encodings;
deadbeefe702b302017-02-04 12:09:01 -0800238 // Codec parameters can't currently be changed between getParameters and
239 // setParameters. Though in the future it will be possible to reorder them or
240 // remove them.
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100241 public final List<Codec> codecs;
242
Florent Castellicebf50f2018-05-03 15:31:53 +0200243 @CalledByNative
Florent Castelliabe301f2018-06-12 18:33:49 +0200244 RtpParameters(String transactionId, Rtcp rtcp, List<HeaderExtension> headerExtensions,
245 List<Encoding> encodings, List<Codec> codecs) {
Florent Castellicebf50f2018-05-03 15:31:53 +0200246 this.transactionId = transactionId;
Florent Castellidacec712018-05-24 16:24:21 +0200247 this.rtcp = rtcp;
Florent Castelliabe301f2018-06-12 18:33:49 +0200248 this.headerExtensions = headerExtensions;
Florent Castellicebf50f2018-05-03 15:31:53 +0200249 this.encodings = encodings;
250 this.codecs = codecs;
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100251 }
252
253 @CalledByNative
Florent Castellicebf50f2018-05-03 15:31:53 +0200254 String getTransactionId() {
255 return transactionId;
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100256 }
257
258 @CalledByNative
Florent Castellidacec712018-05-24 16:24:21 +0200259 public Rtcp getRtcp() {
260 return rtcp;
261 }
262
263 @CalledByNative
Florent Castelliabe301f2018-06-12 18:33:49 +0200264 public List<HeaderExtension> getHeaderExtensions() {
265 return headerExtensions;
266 }
267
268 @CalledByNative
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100269 List<Encoding> getEncodings() {
270 return encodings;
271 }
272
273 @CalledByNative
274 List<Codec> getCodecs() {
275 return codecs;
276 }
skvlad303b3c22016-03-24 19:36:46 -0700277}