blob: 5fe36ef7ec27faf61933f43a034c57b5033bae11 [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;
Magnus Jedvert6062f372017-11-16 16:53:12 +010015import java.util.ArrayList;
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 {
deadbeefe702b302017-02-04 12:09:01 -080031 // Set to true to cause this encoding to be sent, and false for it not to
32 // be sent.
Taylor Brandstetterf8711c02016-03-29 17:21:29 -070033 public boolean active = true;
deadbeefe702b302017-02-04 12:09:01 -080034 // If non-null, this represents the Transport Independent Application
35 // Specific maximum bandwidth defined in RFC3890. If null, there is no
36 // maximum bitrate.
Sami Kalliomäkie7592d82018-03-22 13:32:44 +010037 @Nullable public Integer maxBitrateBps;
Åsa Persson4e5342f2018-08-13 16:46:57 +020038 // The minimum bitrate in bps for video.
Åsa Persson613591a2018-05-29 09:21:31 +020039 @Nullable public Integer minBitrateBps;
Åsa Persson4e5342f2018-08-13 16:46:57 +020040 // The max framerate in fps for video.
41 @Nullable public Integer maxFramerate;
Åsa Persson23eba222018-10-02 14:47:06 +020042 // The number of temporal layers for video.
43 @Nullable public Integer numTemporalLayers;
Mirta Dvornicicd8b98042019-02-04 16:38:46 +010044 // If non-null, scale the width and height down by this factor for video. If null,
45 // implementation default scaling factor will be used.
46 @Nullable public Double scaleResolutionDownBy;
deadbeefe702b302017-02-04 12:09:01 -080047 // SSRC to be used by this encoding.
48 // Can't be changed between getParameters/setParameters.
deadbeef8014c752017-01-06 16:53:00 -080049 public Long ssrc;
Magnus Jedvert9060eb12017-12-12 12:52:54 +010050
51 @CalledByNative("Encoding")
Oleh Prypine8bc3a02019-03-29 15:29:51 +000052 Encoding(boolean active, Integer maxBitrateBps, Integer minBitrateBps, Integer maxFramerate,
53 Integer numTemporalLayers, Double scaleResolutionDownBy, Long ssrc) {
Magnus Jedvert9060eb12017-12-12 12:52:54 +010054 this.active = active;
55 this.maxBitrateBps = maxBitrateBps;
Åsa Persson613591a2018-05-29 09:21:31 +020056 this.minBitrateBps = minBitrateBps;
Åsa Persson4e5342f2018-08-13 16:46:57 +020057 this.maxFramerate = maxFramerate;
Åsa Persson23eba222018-10-02 14:47:06 +020058 this.numTemporalLayers = numTemporalLayers;
Mirta Dvornicicd8b98042019-02-04 16:38:46 +010059 this.scaleResolutionDownBy = scaleResolutionDownBy;
Magnus Jedvert9060eb12017-12-12 12:52:54 +010060 this.ssrc = ssrc;
61 }
62
63 @CalledByNative("Encoding")
64 boolean getActive() {
65 return active;
66 }
67
Sami Kalliomäkie7592d82018-03-22 13:32:44 +010068 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +010069 @CalledByNative("Encoding")
70 Integer getMaxBitrateBps() {
71 return maxBitrateBps;
72 }
73
Åsa Persson613591a2018-05-29 09:21:31 +020074 @Nullable
75 @CalledByNative("Encoding")
76 Integer getMinBitrateBps() {
77 return minBitrateBps;
78 }
79
Åsa Persson4e5342f2018-08-13 16:46:57 +020080 @Nullable
81 @CalledByNative("Encoding")
82 Integer getMaxFramerate() {
83 return maxFramerate;
84 }
85
Åsa Persson23eba222018-10-02 14:47:06 +020086 @Nullable
87 @CalledByNative("Encoding")
88 Integer getNumTemporalLayers() {
89 return numTemporalLayers;
90 }
91
Mirta Dvornicicd8b98042019-02-04 16:38:46 +010092 @Nullable
93 @CalledByNative("Encoding")
94 Double getScaleResolutionDownBy() {
95 return scaleResolutionDownBy;
96 }
97
Magnus Jedvert9060eb12017-12-12 12:52:54 +010098 @CalledByNative("Encoding")
99 Long getSsrc() {
100 return ssrc;
101 }
Taylor Brandstetterf8711c02016-03-29 17:21:29 -0700102 }
skvlad303b3c22016-03-24 19:36:46 -0700103
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700104 public static class Codec {
deadbeefe702b302017-02-04 12:09:01 -0800105 // Payload type used to identify this codec in RTP packets.
106 public int payloadType;
107 // Name used to identify the codec. Equivalent to MIME subtype.
108 public String name;
109 // The media type of this codec. Equivalent to MIME top-level type.
110 MediaStreamTrack.MediaType kind;
111 // Clock rate in Hertz.
112 public Integer clockRate;
113 // The number of audio channels used. Set to null for video codecs.
114 public Integer numChannels;
Florent Castellib7d9d832018-05-15 18:14:14 +0200115 // The "format specific parameters" field from the "a=fmtp" line in the SDP
116 public Map<String, String> parameters;
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100117
118 @CalledByNative("Codec")
119 Codec(int payloadType, String name, MediaStreamTrack.MediaType kind, Integer clockRate,
Florent Castellib7d9d832018-05-15 18:14:14 +0200120 Integer numChannels, Map<String, String> parameters) {
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100121 this.payloadType = payloadType;
122 this.name = name;
123 this.kind = kind;
124 this.clockRate = clockRate;
125 this.numChannels = numChannels;
Florent Castellib7d9d832018-05-15 18:14:14 +0200126 this.parameters = parameters;
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100127 }
128
129 @CalledByNative("Codec")
130 int getPayloadType() {
131 return payloadType;
132 }
133
134 @CalledByNative("Codec")
135 String getName() {
136 return name;
137 }
138
139 @CalledByNative("Codec")
140 MediaStreamTrack.MediaType getKind() {
141 return kind;
142 }
143
144 @CalledByNative("Codec")
145 Integer getClockRate() {
146 return clockRate;
147 }
148
149 @CalledByNative("Codec")
150 Integer getNumChannels() {
151 return numChannels;
152 }
Florent Castellib7d9d832018-05-15 18:14:14 +0200153
154 @CalledByNative("Codec")
155 Map getParameters() {
156 return parameters;
157 }
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700158 }
159
Florent Castellidacec712018-05-24 16:24:21 +0200160 public static class Rtcp {
161 /** The Canonical Name used by RTCP */
162 private final String cname;
163 /** Whether reduced size RTCP is configured or compound RTCP */
164 private final boolean reducedSize;
165
166 @CalledByNative("Rtcp")
167 Rtcp(String cname, boolean reducedSize) {
168 this.cname = cname;
169 this.reducedSize = reducedSize;
170 }
171
172 @CalledByNative("Rtcp")
173 public String getCname() {
174 return cname;
175 }
176
177 @CalledByNative("Rtcp")
178 public boolean getReducedSize() {
179 return reducedSize;
180 }
181 }
182
Florent Castelliabe301f2018-06-12 18:33:49 +0200183 public static class HeaderExtension {
184 /** The URI of the RTP header extension, as defined in RFC5285. */
185 private final String uri;
186 /** The value put in the RTP packet to identify the header extension. */
187 private final int id;
188 /** Whether the header extension is encrypted or not. */
189 private final boolean encrypted;
190
191 @CalledByNative("HeaderExtension")
192 HeaderExtension(String uri, int id, boolean encrypted) {
193 this.uri = uri;
194 this.id = id;
195 this.encrypted = encrypted;
196 }
197
198 @CalledByNative("HeaderExtension")
199 public String getUri() {
200 return uri;
201 }
202
203 @CalledByNative("HeaderExtension")
204 public int getId() {
205 return id;
206 }
207
208 @CalledByNative("HeaderExtension")
209 public boolean getEncrypted() {
210 return encrypted;
211 }
212 }
213
Florent Castellicebf50f2018-05-03 15:31:53 +0200214 public final String transactionId;
215
Florent Castellidacec712018-05-24 16:24:21 +0200216 private final Rtcp rtcp;
217
Florent Castelliabe301f2018-06-12 18:33:49 +0200218 private final List<HeaderExtension> headerExtensions;
219
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100220 public final List<Encoding> encodings;
deadbeefe702b302017-02-04 12:09:01 -0800221 // Codec parameters can't currently be changed between getParameters and
222 // setParameters. Though in the future it will be possible to reorder them or
223 // remove them.
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100224 public final List<Codec> codecs;
225
Florent Castellicebf50f2018-05-03 15:31:53 +0200226 @CalledByNative
Florent Castelliabe301f2018-06-12 18:33:49 +0200227 RtpParameters(String transactionId, Rtcp rtcp, List<HeaderExtension> headerExtensions,
228 List<Encoding> encodings, List<Codec> codecs) {
Florent Castellicebf50f2018-05-03 15:31:53 +0200229 this.transactionId = transactionId;
Florent Castellidacec712018-05-24 16:24:21 +0200230 this.rtcp = rtcp;
Florent Castelliabe301f2018-06-12 18:33:49 +0200231 this.headerExtensions = headerExtensions;
Florent Castellicebf50f2018-05-03 15:31:53 +0200232 this.encodings = encodings;
233 this.codecs = codecs;
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100234 }
235
236 @CalledByNative
Florent Castellicebf50f2018-05-03 15:31:53 +0200237 String getTransactionId() {
238 return transactionId;
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100239 }
240
241 @CalledByNative
Florent Castellidacec712018-05-24 16:24:21 +0200242 public Rtcp getRtcp() {
243 return rtcp;
244 }
245
246 @CalledByNative
Florent Castelliabe301f2018-06-12 18:33:49 +0200247 public List<HeaderExtension> getHeaderExtensions() {
248 return headerExtensions;
249 }
250
251 @CalledByNative
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100252 List<Encoding> getEncodings() {
253 return encodings;
254 }
255
256 @CalledByNative
257 List<Codec> getCodecs() {
258 return codecs;
259 }
skvlad303b3c22016-03-24 19:36:46 -0700260}