blob: 5c8c657bb36b742c19ae896e52716f1933826b3d [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 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;
deadbeefe702b302017-02-04 12:09:01 -080041 // SSRC to be used by this encoding.
42 // Can't be changed between getParameters/setParameters.
deadbeef8014c752017-01-06 16:53:00 -080043 public Long ssrc;
Magnus Jedvert9060eb12017-12-12 12:52:54 +010044
45 @CalledByNative("Encoding")
Åsa Persson4e5342f2018-08-13 16:46:57 +020046 Encoding(boolean active, Integer maxBitrateBps, Integer minBitrateBps, Integer maxFramerate,
47 Long ssrc) {
Magnus Jedvert9060eb12017-12-12 12:52:54 +010048 this.active = active;
49 this.maxBitrateBps = maxBitrateBps;
Åsa Persson613591a2018-05-29 09:21:31 +020050 this.minBitrateBps = minBitrateBps;
Åsa Persson4e5342f2018-08-13 16:46:57 +020051 this.maxFramerate = maxFramerate;
Magnus Jedvert9060eb12017-12-12 12:52:54 +010052 this.ssrc = ssrc;
53 }
54
55 @CalledByNative("Encoding")
56 boolean getActive() {
57 return active;
58 }
59
Sami Kalliomäkie7592d82018-03-22 13:32:44 +010060 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +010061 @CalledByNative("Encoding")
62 Integer getMaxBitrateBps() {
63 return maxBitrateBps;
64 }
65
Åsa Persson613591a2018-05-29 09:21:31 +020066 @Nullable
67 @CalledByNative("Encoding")
68 Integer getMinBitrateBps() {
69 return minBitrateBps;
70 }
71
Åsa Persson4e5342f2018-08-13 16:46:57 +020072 @Nullable
73 @CalledByNative("Encoding")
74 Integer getMaxFramerate() {
75 return maxFramerate;
76 }
77
Magnus Jedvert9060eb12017-12-12 12:52:54 +010078 @CalledByNative("Encoding")
79 Long getSsrc() {
80 return ssrc;
81 }
Taylor Brandstetterf8711c02016-03-29 17:21:29 -070082 }
skvlad303b3c22016-03-24 19:36:46 -070083
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -070084 public static class Codec {
deadbeefe702b302017-02-04 12:09:01 -080085 // Payload type used to identify this codec in RTP packets.
86 public int payloadType;
87 // Name used to identify the codec. Equivalent to MIME subtype.
88 public String name;
89 // The media type of this codec. Equivalent to MIME top-level type.
90 MediaStreamTrack.MediaType kind;
91 // Clock rate in Hertz.
92 public Integer clockRate;
93 // The number of audio channels used. Set to null for video codecs.
94 public Integer numChannels;
Florent Castellib7d9d832018-05-15 18:14:14 +020095 // The "format specific parameters" field from the "a=fmtp" line in the SDP
96 public Map<String, String> parameters;
Magnus Jedvert9060eb12017-12-12 12:52:54 +010097
98 @CalledByNative("Codec")
99 Codec(int payloadType, String name, MediaStreamTrack.MediaType kind, Integer clockRate,
Florent Castellib7d9d832018-05-15 18:14:14 +0200100 Integer numChannels, Map<String, String> parameters) {
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100101 this.payloadType = payloadType;
102 this.name = name;
103 this.kind = kind;
104 this.clockRate = clockRate;
105 this.numChannels = numChannels;
Florent Castellib7d9d832018-05-15 18:14:14 +0200106 this.parameters = parameters;
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100107 }
108
109 @CalledByNative("Codec")
110 int getPayloadType() {
111 return payloadType;
112 }
113
114 @CalledByNative("Codec")
115 String getName() {
116 return name;
117 }
118
119 @CalledByNative("Codec")
120 MediaStreamTrack.MediaType getKind() {
121 return kind;
122 }
123
124 @CalledByNative("Codec")
125 Integer getClockRate() {
126 return clockRate;
127 }
128
129 @CalledByNative("Codec")
130 Integer getNumChannels() {
131 return numChannels;
132 }
Florent Castellib7d9d832018-05-15 18:14:14 +0200133
134 @CalledByNative("Codec")
135 Map getParameters() {
136 return parameters;
137 }
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700138 }
139
Florent Castellidacec712018-05-24 16:24:21 +0200140 public static class Rtcp {
141 /** The Canonical Name used by RTCP */
142 private final String cname;
143 /** Whether reduced size RTCP is configured or compound RTCP */
144 private final boolean reducedSize;
145
146 @CalledByNative("Rtcp")
147 Rtcp(String cname, boolean reducedSize) {
148 this.cname = cname;
149 this.reducedSize = reducedSize;
150 }
151
152 @CalledByNative("Rtcp")
153 public String getCname() {
154 return cname;
155 }
156
157 @CalledByNative("Rtcp")
158 public boolean getReducedSize() {
159 return reducedSize;
160 }
161 }
162
Florent Castelliabe301f2018-06-12 18:33:49 +0200163 public static class HeaderExtension {
164 /** The URI of the RTP header extension, as defined in RFC5285. */
165 private final String uri;
166 /** The value put in the RTP packet to identify the header extension. */
167 private final int id;
168 /** Whether the header extension is encrypted or not. */
169 private final boolean encrypted;
170
171 @CalledByNative("HeaderExtension")
172 HeaderExtension(String uri, int id, boolean encrypted) {
173 this.uri = uri;
174 this.id = id;
175 this.encrypted = encrypted;
176 }
177
178 @CalledByNative("HeaderExtension")
179 public String getUri() {
180 return uri;
181 }
182
183 @CalledByNative("HeaderExtension")
184 public int getId() {
185 return id;
186 }
187
188 @CalledByNative("HeaderExtension")
189 public boolean getEncrypted() {
190 return encrypted;
191 }
192 }
193
Florent Castellicebf50f2018-05-03 15:31:53 +0200194 public final String transactionId;
195
Florent Castellidacec712018-05-24 16:24:21 +0200196 private final Rtcp rtcp;
197
Florent Castelliabe301f2018-06-12 18:33:49 +0200198 private final List<HeaderExtension> headerExtensions;
199
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100200 public final List<Encoding> encodings;
deadbeefe702b302017-02-04 12:09:01 -0800201 // Codec parameters can't currently be changed between getParameters and
202 // setParameters. Though in the future it will be possible to reorder them or
203 // remove them.
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100204 public final List<Codec> codecs;
205
Florent Castellicebf50f2018-05-03 15:31:53 +0200206 @CalledByNative
Florent Castelliabe301f2018-06-12 18:33:49 +0200207 RtpParameters(String transactionId, Rtcp rtcp, List<HeaderExtension> headerExtensions,
208 List<Encoding> encodings, List<Codec> codecs) {
Florent Castellicebf50f2018-05-03 15:31:53 +0200209 this.transactionId = transactionId;
Florent Castellidacec712018-05-24 16:24:21 +0200210 this.rtcp = rtcp;
Florent Castelliabe301f2018-06-12 18:33:49 +0200211 this.headerExtensions = headerExtensions;
Florent Castellicebf50f2018-05-03 15:31:53 +0200212 this.encodings = encodings;
213 this.codecs = codecs;
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100214 }
215
216 @CalledByNative
Florent Castellicebf50f2018-05-03 15:31:53 +0200217 String getTransactionId() {
218 return transactionId;
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100219 }
220
221 @CalledByNative
Florent Castellidacec712018-05-24 16:24:21 +0200222 public Rtcp getRtcp() {
223 return rtcp;
224 }
225
226 @CalledByNative
Florent Castelliabe301f2018-06-12 18:33:49 +0200227 public List<HeaderExtension> getHeaderExtensions() {
228 return headerExtensions;
229 }
230
231 @CalledByNative
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100232 List<Encoding> getEncodings() {
233 return encodings;
234 }
235
236 @CalledByNative
237 List<Codec> getCodecs() {
238 return codecs;
239 }
skvlad303b3c22016-03-24 19:36:46 -0700240}