blob: 5158c13aeb1554582703eb1574bc7d8f880f4f8e [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;
Magnus Jedvert6062f372017-11-16 16:53:12 +010014import java.util.ArrayList;
Florent Castellib7d9d832018-05-15 18:14:14 +020015import java.util.List;
16import java.util.Map;
Magnus Jedvert9060eb12017-12-12 12:52:54 +010017import org.webrtc.MediaStreamTrack;
skvlad303b3c22016-03-24 19:36:46 -070018
19/**
20 * The parameters for an {@code RtpSender}, as defined in
21 * http://w3c.github.io/webrtc-pc/#rtcrtpsender-interface.
deadbeefe702b302017-02-04 12:09:01 -080022 *
23 * Note: These structures use nullable Integer/etc. types because in the
24 * future, they may be used to construct ORTC RtpSender/RtpReceivers, in
25 * which case "null" will be used to represent "choose the implementation
26 * default value".
skvlad303b3c22016-03-24 19:36:46 -070027 */
28public class RtpParameters {
Taylor Brandstetterf8711c02016-03-29 17:21:29 -070029 public static class Encoding {
deadbeefe702b302017-02-04 12:09:01 -080030 // Set to true to cause this encoding to be sent, and false for it not to
31 // be sent.
Taylor Brandstetterf8711c02016-03-29 17:21:29 -070032 public boolean active = true;
deadbeefe702b302017-02-04 12:09:01 -080033 // If non-null, this represents the Transport Independent Application
34 // Specific maximum bandwidth defined in RFC3890. If null, there is no
35 // maximum bitrate.
Sami Kalliomäkie7592d82018-03-22 13:32:44 +010036 @Nullable public Integer maxBitrateBps;
Åsa Persson4e5342f2018-08-13 16:46:57 +020037 // The minimum bitrate in bps for video.
Åsa Persson613591a2018-05-29 09:21:31 +020038 @Nullable public Integer minBitrateBps;
Åsa Persson4e5342f2018-08-13 16:46:57 +020039 // The max framerate in fps for video.
40 @Nullable public Integer maxFramerate;
Åsa Persson23eba222018-10-02 14:47:06 +020041 // The number of temporal layers for video.
42 @Nullable public Integer numTemporalLayers;
deadbeefe702b302017-02-04 12:09:01 -080043 // SSRC to be used by this encoding.
44 // Can't be changed between getParameters/setParameters.
deadbeef8014c752017-01-06 16:53:00 -080045 public Long ssrc;
Magnus Jedvert9060eb12017-12-12 12:52:54 +010046
47 @CalledByNative("Encoding")
Åsa Persson4e5342f2018-08-13 16:46:57 +020048 Encoding(boolean active, Integer maxBitrateBps, Integer minBitrateBps, Integer maxFramerate,
Åsa Persson23eba222018-10-02 14:47:06 +020049 Integer numTemporalLayers, Long ssrc) {
Magnus Jedvert9060eb12017-12-12 12:52:54 +010050 this.active = active;
51 this.maxBitrateBps = maxBitrateBps;
Åsa Persson613591a2018-05-29 09:21:31 +020052 this.minBitrateBps = minBitrateBps;
Åsa Persson4e5342f2018-08-13 16:46:57 +020053 this.maxFramerate = maxFramerate;
Åsa Persson23eba222018-10-02 14:47:06 +020054 this.numTemporalLayers = numTemporalLayers;
Magnus Jedvert9060eb12017-12-12 12:52:54 +010055 this.ssrc = ssrc;
56 }
57
58 @CalledByNative("Encoding")
59 boolean getActive() {
60 return active;
61 }
62
Sami Kalliomäkie7592d82018-03-22 13:32:44 +010063 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +010064 @CalledByNative("Encoding")
65 Integer getMaxBitrateBps() {
66 return maxBitrateBps;
67 }
68
Åsa Persson613591a2018-05-29 09:21:31 +020069 @Nullable
70 @CalledByNative("Encoding")
71 Integer getMinBitrateBps() {
72 return minBitrateBps;
73 }
74
Åsa Persson4e5342f2018-08-13 16:46:57 +020075 @Nullable
76 @CalledByNative("Encoding")
77 Integer getMaxFramerate() {
78 return maxFramerate;
79 }
80
Åsa Persson23eba222018-10-02 14:47:06 +020081 @Nullable
82 @CalledByNative("Encoding")
83 Integer getNumTemporalLayers() {
84 return numTemporalLayers;
85 }
86
Magnus Jedvert9060eb12017-12-12 12:52:54 +010087 @CalledByNative("Encoding")
88 Long getSsrc() {
89 return ssrc;
90 }
Taylor Brandstetterf8711c02016-03-29 17:21:29 -070091 }
skvlad303b3c22016-03-24 19:36:46 -070092
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -070093 public static class Codec {
deadbeefe702b302017-02-04 12:09:01 -080094 // Payload type used to identify this codec in RTP packets.
95 public int payloadType;
96 // Name used to identify the codec. Equivalent to MIME subtype.
97 public String name;
98 // The media type of this codec. Equivalent to MIME top-level type.
99 MediaStreamTrack.MediaType kind;
100 // Clock rate in Hertz.
101 public Integer clockRate;
102 // The number of audio channels used. Set to null for video codecs.
103 public Integer numChannels;
Florent Castellib7d9d832018-05-15 18:14:14 +0200104 // The "format specific parameters" field from the "a=fmtp" line in the SDP
105 public Map<String, String> parameters;
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100106
107 @CalledByNative("Codec")
108 Codec(int payloadType, String name, MediaStreamTrack.MediaType kind, Integer clockRate,
Florent Castellib7d9d832018-05-15 18:14:14 +0200109 Integer numChannels, Map<String, String> parameters) {
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100110 this.payloadType = payloadType;
111 this.name = name;
112 this.kind = kind;
113 this.clockRate = clockRate;
114 this.numChannels = numChannels;
Florent Castellib7d9d832018-05-15 18:14:14 +0200115 this.parameters = parameters;
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100116 }
117
118 @CalledByNative("Codec")
119 int getPayloadType() {
120 return payloadType;
121 }
122
123 @CalledByNative("Codec")
124 String getName() {
125 return name;
126 }
127
128 @CalledByNative("Codec")
129 MediaStreamTrack.MediaType getKind() {
130 return kind;
131 }
132
133 @CalledByNative("Codec")
134 Integer getClockRate() {
135 return clockRate;
136 }
137
138 @CalledByNative("Codec")
139 Integer getNumChannels() {
140 return numChannels;
141 }
Florent Castellib7d9d832018-05-15 18:14:14 +0200142
143 @CalledByNative("Codec")
144 Map getParameters() {
145 return parameters;
146 }
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700147 }
148
Florent Castellidacec712018-05-24 16:24:21 +0200149 public static class Rtcp {
150 /** The Canonical Name used by RTCP */
151 private final String cname;
152 /** Whether reduced size RTCP is configured or compound RTCP */
153 private final boolean reducedSize;
154
155 @CalledByNative("Rtcp")
156 Rtcp(String cname, boolean reducedSize) {
157 this.cname = cname;
158 this.reducedSize = reducedSize;
159 }
160
161 @CalledByNative("Rtcp")
162 public String getCname() {
163 return cname;
164 }
165
166 @CalledByNative("Rtcp")
167 public boolean getReducedSize() {
168 return reducedSize;
169 }
170 }
171
Florent Castelliabe301f2018-06-12 18:33:49 +0200172 public static class HeaderExtension {
173 /** The URI of the RTP header extension, as defined in RFC5285. */
174 private final String uri;
175 /** The value put in the RTP packet to identify the header extension. */
176 private final int id;
177 /** Whether the header extension is encrypted or not. */
178 private final boolean encrypted;
179
180 @CalledByNative("HeaderExtension")
181 HeaderExtension(String uri, int id, boolean encrypted) {
182 this.uri = uri;
183 this.id = id;
184 this.encrypted = encrypted;
185 }
186
187 @CalledByNative("HeaderExtension")
188 public String getUri() {
189 return uri;
190 }
191
192 @CalledByNative("HeaderExtension")
193 public int getId() {
194 return id;
195 }
196
197 @CalledByNative("HeaderExtension")
198 public boolean getEncrypted() {
199 return encrypted;
200 }
201 }
202
Florent Castellicebf50f2018-05-03 15:31:53 +0200203 public final String transactionId;
204
Florent Castellidacec712018-05-24 16:24:21 +0200205 private final Rtcp rtcp;
206
Florent Castelliabe301f2018-06-12 18:33:49 +0200207 private final List<HeaderExtension> headerExtensions;
208
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100209 public final List<Encoding> encodings;
deadbeefe702b302017-02-04 12:09:01 -0800210 // Codec parameters can't currently be changed between getParameters and
211 // setParameters. Though in the future it will be possible to reorder them or
212 // remove them.
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100213 public final List<Codec> codecs;
214
Florent Castellicebf50f2018-05-03 15:31:53 +0200215 @CalledByNative
Florent Castelliabe301f2018-06-12 18:33:49 +0200216 RtpParameters(String transactionId, Rtcp rtcp, List<HeaderExtension> headerExtensions,
217 List<Encoding> encodings, List<Codec> codecs) {
Florent Castellicebf50f2018-05-03 15:31:53 +0200218 this.transactionId = transactionId;
Florent Castellidacec712018-05-24 16:24:21 +0200219 this.rtcp = rtcp;
Florent Castelliabe301f2018-06-12 18:33:49 +0200220 this.headerExtensions = headerExtensions;
Florent Castellicebf50f2018-05-03 15:31:53 +0200221 this.encodings = encodings;
222 this.codecs = codecs;
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100223 }
224
225 @CalledByNative
Florent Castellicebf50f2018-05-03 15:31:53 +0200226 String getTransactionId() {
227 return transactionId;
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100228 }
229
230 @CalledByNative
Florent Castellidacec712018-05-24 16:24:21 +0200231 public Rtcp getRtcp() {
232 return rtcp;
233 }
234
235 @CalledByNative
Florent Castelliabe301f2018-06-12 18:33:49 +0200236 public List<HeaderExtension> getHeaderExtensions() {
237 return headerExtensions;
238 }
239
240 @CalledByNative
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100241 List<Encoding> getEncodings() {
242 return encodings;
243 }
244
245 @CalledByNative
246 List<Codec> getCodecs() {
247 return codecs;
248 }
skvlad303b3c22016-03-24 19:36:46 -0700249}