blob: 087936e49175f473825c4035abdab9f7207efc65 [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
Sami Kalliomäkie7592d82018-03-22 13:32:44 +010013import javax.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 Persson613591a2018-05-29 09:21:31 +020037 // Not implemented.
38 @Nullable public Integer minBitrateBps;
deadbeefe702b302017-02-04 12:09:01 -080039 // SSRC to be used by this encoding.
40 // Can't be changed between getParameters/setParameters.
deadbeef8014c752017-01-06 16:53:00 -080041 public Long ssrc;
Magnus Jedvert9060eb12017-12-12 12:52:54 +010042
43 @CalledByNative("Encoding")
Åsa Persson613591a2018-05-29 09:21:31 +020044 Encoding(boolean active, Integer maxBitrateBps, Integer minBitrateBps, Long ssrc) {
Magnus Jedvert9060eb12017-12-12 12:52:54 +010045 this.active = active;
46 this.maxBitrateBps = maxBitrateBps;
Åsa Persson613591a2018-05-29 09:21:31 +020047 this.minBitrateBps = minBitrateBps;
Magnus Jedvert9060eb12017-12-12 12:52:54 +010048 this.ssrc = ssrc;
49 }
50
51 @CalledByNative("Encoding")
52 boolean getActive() {
53 return active;
54 }
55
Sami Kalliomäkie7592d82018-03-22 13:32:44 +010056 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +010057 @CalledByNative("Encoding")
58 Integer getMaxBitrateBps() {
59 return maxBitrateBps;
60 }
61
Åsa Persson613591a2018-05-29 09:21:31 +020062 @Nullable
63 @CalledByNative("Encoding")
64 Integer getMinBitrateBps() {
65 return minBitrateBps;
66 }
67
Magnus Jedvert9060eb12017-12-12 12:52:54 +010068 @CalledByNative("Encoding")
69 Long getSsrc() {
70 return ssrc;
71 }
Taylor Brandstetterf8711c02016-03-29 17:21:29 -070072 }
skvlad303b3c22016-03-24 19:36:46 -070073
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -070074 public static class Codec {
deadbeefe702b302017-02-04 12:09:01 -080075 // Payload type used to identify this codec in RTP packets.
76 public int payloadType;
77 // Name used to identify the codec. Equivalent to MIME subtype.
78 public String name;
79 // The media type of this codec. Equivalent to MIME top-level type.
80 MediaStreamTrack.MediaType kind;
81 // Clock rate in Hertz.
82 public Integer clockRate;
83 // The number of audio channels used. Set to null for video codecs.
84 public Integer numChannels;
Florent Castellib7d9d832018-05-15 18:14:14 +020085 // The "format specific parameters" field from the "a=fmtp" line in the SDP
86 public Map<String, String> parameters;
Magnus Jedvert9060eb12017-12-12 12:52:54 +010087
88 @CalledByNative("Codec")
89 Codec(int payloadType, String name, MediaStreamTrack.MediaType kind, Integer clockRate,
Florent Castellib7d9d832018-05-15 18:14:14 +020090 Integer numChannels, Map<String, String> parameters) {
Magnus Jedvert9060eb12017-12-12 12:52:54 +010091 this.payloadType = payloadType;
92 this.name = name;
93 this.kind = kind;
94 this.clockRate = clockRate;
95 this.numChannels = numChannels;
Florent Castellib7d9d832018-05-15 18:14:14 +020096 this.parameters = parameters;
Magnus Jedvert9060eb12017-12-12 12:52:54 +010097 }
98
99 @CalledByNative("Codec")
100 int getPayloadType() {
101 return payloadType;
102 }
103
104 @CalledByNative("Codec")
105 String getName() {
106 return name;
107 }
108
109 @CalledByNative("Codec")
110 MediaStreamTrack.MediaType getKind() {
111 return kind;
112 }
113
114 @CalledByNative("Codec")
115 Integer getClockRate() {
116 return clockRate;
117 }
118
119 @CalledByNative("Codec")
120 Integer getNumChannels() {
121 return numChannels;
122 }
Florent Castellib7d9d832018-05-15 18:14:14 +0200123
124 @CalledByNative("Codec")
125 Map getParameters() {
126 return parameters;
127 }
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700128 }
129
Florent Castellidacec712018-05-24 16:24:21 +0200130 public static class Rtcp {
131 /** The Canonical Name used by RTCP */
132 private final String cname;
133 /** Whether reduced size RTCP is configured or compound RTCP */
134 private final boolean reducedSize;
135
136 @CalledByNative("Rtcp")
137 Rtcp(String cname, boolean reducedSize) {
138 this.cname = cname;
139 this.reducedSize = reducedSize;
140 }
141
142 @CalledByNative("Rtcp")
143 public String getCname() {
144 return cname;
145 }
146
147 @CalledByNative("Rtcp")
148 public boolean getReducedSize() {
149 return reducedSize;
150 }
151 }
152
Florent Castelliabe301f2018-06-12 18:33:49 +0200153 public static class HeaderExtension {
154 /** The URI of the RTP header extension, as defined in RFC5285. */
155 private final String uri;
156 /** The value put in the RTP packet to identify the header extension. */
157 private final int id;
158 /** Whether the header extension is encrypted or not. */
159 private final boolean encrypted;
160
161 @CalledByNative("HeaderExtension")
162 HeaderExtension(String uri, int id, boolean encrypted) {
163 this.uri = uri;
164 this.id = id;
165 this.encrypted = encrypted;
166 }
167
168 @CalledByNative("HeaderExtension")
169 public String getUri() {
170 return uri;
171 }
172
173 @CalledByNative("HeaderExtension")
174 public int getId() {
175 return id;
176 }
177
178 @CalledByNative("HeaderExtension")
179 public boolean getEncrypted() {
180 return encrypted;
181 }
182 }
183
Florent Castellicebf50f2018-05-03 15:31:53 +0200184 public final String transactionId;
185
Florent Castellidacec712018-05-24 16:24:21 +0200186 private final Rtcp rtcp;
187
Florent Castelliabe301f2018-06-12 18:33:49 +0200188 private final List<HeaderExtension> headerExtensions;
189
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100190 public final List<Encoding> encodings;
deadbeefe702b302017-02-04 12:09:01 -0800191 // Codec parameters can't currently be changed between getParameters and
192 // setParameters. Though in the future it will be possible to reorder them or
193 // remove them.
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100194 public final List<Codec> codecs;
195
Florent Castellicebf50f2018-05-03 15:31:53 +0200196 @CalledByNative
Florent Castelliabe301f2018-06-12 18:33:49 +0200197 RtpParameters(String transactionId, Rtcp rtcp, List<HeaderExtension> headerExtensions,
198 List<Encoding> encodings, List<Codec> codecs) {
Florent Castellicebf50f2018-05-03 15:31:53 +0200199 this.transactionId = transactionId;
Florent Castellidacec712018-05-24 16:24:21 +0200200 this.rtcp = rtcp;
Florent Castelliabe301f2018-06-12 18:33:49 +0200201 this.headerExtensions = headerExtensions;
Florent Castellicebf50f2018-05-03 15:31:53 +0200202 this.encodings = encodings;
203 this.codecs = codecs;
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100204 }
205
206 @CalledByNative
Florent Castellicebf50f2018-05-03 15:31:53 +0200207 String getTransactionId() {
208 return transactionId;
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100209 }
210
211 @CalledByNative
Florent Castellidacec712018-05-24 16:24:21 +0200212 public Rtcp getRtcp() {
213 return rtcp;
214 }
215
216 @CalledByNative
Florent Castelliabe301f2018-06-12 18:33:49 +0200217 public List<HeaderExtension> getHeaderExtensions() {
218 return headerExtensions;
219 }
220
221 @CalledByNative
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100222 List<Encoding> getEncodings() {
223 return encodings;
224 }
225
226 @CalledByNative
227 List<Codec> getCodecs() {
228 return codecs;
229 }
skvlad303b3c22016-03-24 19:36:46 -0700230}