skvlad | 303b3c2 | 2016-03-24 19:36:46 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 11 | package org.webrtc; |
| 12 | |
Artem Titarenko | 69540f4 | 2018-12-10 12:30:46 +0100 | [diff] [blame] | 13 | import android.support.annotation.Nullable; |
Mirta Dvornicic | d8b9804 | 2019-02-04 16:38:46 +0100 | [diff] [blame] | 14 | import java.lang.Double; |
Amit Hilbuch | 177670a | 2019-03-25 12:53:58 -0700 | [diff] [blame^] | 15 | import java.lang.String; |
Magnus Jedvert | 6062f37 | 2017-11-16 16:53:12 +0100 | [diff] [blame] | 16 | import java.util.ArrayList; |
Florent Castelli | b7d9d83 | 2018-05-15 18:14:14 +0200 | [diff] [blame] | 17 | import java.util.List; |
| 18 | import java.util.Map; |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 19 | import org.webrtc.MediaStreamTrack; |
skvlad | 303b3c2 | 2016-03-24 19:36:46 -0700 | [diff] [blame] | 20 | |
| 21 | /** |
| 22 | * The parameters for an {@code RtpSender}, as defined in |
| 23 | * http://w3c.github.io/webrtc-pc/#rtcrtpsender-interface. |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 24 | * |
| 25 | * Note: These structures use nullable Integer/etc. types because in the |
| 26 | * future, they may be used to construct ORTC RtpSender/RtpReceivers, in |
| 27 | * which case "null" will be used to represent "choose the implementation |
| 28 | * default value". |
skvlad | 303b3c2 | 2016-03-24 19:36:46 -0700 | [diff] [blame] | 29 | */ |
| 30 | public class RtpParameters { |
Taylor Brandstetter | f8711c0 | 2016-03-29 17:21:29 -0700 | [diff] [blame] | 31 | public static class Encoding { |
Amit Hilbuch | 177670a | 2019-03-25 12:53:58 -0700 | [diff] [blame^] | 32 | // If non-null, this represents the RID that identifies this encoding layer. |
| 33 | // RIDs are used to identify layers in simulcast. |
| 34 | @Nullable public String rid; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 35 | // Set to true to cause this encoding to be sent, and false for it not to |
| 36 | // be sent. |
Taylor Brandstetter | f8711c0 | 2016-03-29 17:21:29 -0700 | [diff] [blame] | 37 | public boolean active = true; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 38 | // If non-null, this represents the Transport Independent Application |
| 39 | // Specific maximum bandwidth defined in RFC3890. If null, there is no |
| 40 | // maximum bitrate. |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 41 | @Nullable public Integer maxBitrateBps; |
Åsa Persson | 4e5342f | 2018-08-13 16:46:57 +0200 | [diff] [blame] | 42 | // The minimum bitrate in bps for video. |
Åsa Persson | 613591a | 2018-05-29 09:21:31 +0200 | [diff] [blame] | 43 | @Nullable public Integer minBitrateBps; |
Åsa Persson | 4e5342f | 2018-08-13 16:46:57 +0200 | [diff] [blame] | 44 | // The max framerate in fps for video. |
| 45 | @Nullable public Integer maxFramerate; |
Åsa Persson | 23eba22 | 2018-10-02 14:47:06 +0200 | [diff] [blame] | 46 | // The number of temporal layers for video. |
| 47 | @Nullable public Integer numTemporalLayers; |
Mirta Dvornicic | d8b9804 | 2019-02-04 16:38:46 +0100 | [diff] [blame] | 48 | // If non-null, scale the width and height down by this factor for video. If null, |
| 49 | // implementation default scaling factor will be used. |
| 50 | @Nullable public Double scaleResolutionDownBy; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 51 | // SSRC to be used by this encoding. |
| 52 | // Can't be changed between getParameters/setParameters. |
deadbeef | 8014c75 | 2017-01-06 16:53:00 -0800 | [diff] [blame] | 53 | public Long ssrc; |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 54 | |
Amit Hilbuch | 177670a | 2019-03-25 12:53:58 -0700 | [diff] [blame^] | 55 | // This constructor is useful for creating simulcast layers. |
| 56 | Encoding(String rid, boolean active, Double scaleResolutionDownBy) { |
| 57 | this.rid = rid; |
| 58 | this.active = active; |
| 59 | this.scaleResolutionDownBy = scaleResolutionDownBy; |
| 60 | } |
| 61 | |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 62 | @CalledByNative("Encoding") |
Amit Hilbuch | 177670a | 2019-03-25 12:53:58 -0700 | [diff] [blame^] | 63 | Encoding(String rid, boolean active, Integer maxBitrateBps, Integer minBitrateBps, |
| 64 | Integer maxFramerate, Integer numTemporalLayers, Double scaleResolutionDownBy, Long ssrc) { |
| 65 | this.rid = rid; |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 66 | this.active = active; |
| 67 | this.maxBitrateBps = maxBitrateBps; |
Åsa Persson | 613591a | 2018-05-29 09:21:31 +0200 | [diff] [blame] | 68 | this.minBitrateBps = minBitrateBps; |
Åsa Persson | 4e5342f | 2018-08-13 16:46:57 +0200 | [diff] [blame] | 69 | this.maxFramerate = maxFramerate; |
Åsa Persson | 23eba22 | 2018-10-02 14:47:06 +0200 | [diff] [blame] | 70 | this.numTemporalLayers = numTemporalLayers; |
Mirta Dvornicic | d8b9804 | 2019-02-04 16:38:46 +0100 | [diff] [blame] | 71 | this.scaleResolutionDownBy = scaleResolutionDownBy; |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 72 | this.ssrc = ssrc; |
| 73 | } |
| 74 | |
Amit Hilbuch | 177670a | 2019-03-25 12:53:58 -0700 | [diff] [blame^] | 75 | @Nullable |
| 76 | @CalledByNative("Encoding") |
| 77 | String getRid() { |
| 78 | return rid; |
| 79 | } |
| 80 | |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 81 | @CalledByNative("Encoding") |
| 82 | boolean getActive() { |
| 83 | return active; |
| 84 | } |
| 85 | |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 86 | @Nullable |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 87 | @CalledByNative("Encoding") |
| 88 | Integer getMaxBitrateBps() { |
| 89 | return maxBitrateBps; |
| 90 | } |
| 91 | |
Åsa Persson | 613591a | 2018-05-29 09:21:31 +0200 | [diff] [blame] | 92 | @Nullable |
| 93 | @CalledByNative("Encoding") |
| 94 | Integer getMinBitrateBps() { |
| 95 | return minBitrateBps; |
| 96 | } |
| 97 | |
Åsa Persson | 4e5342f | 2018-08-13 16:46:57 +0200 | [diff] [blame] | 98 | @Nullable |
| 99 | @CalledByNative("Encoding") |
| 100 | Integer getMaxFramerate() { |
| 101 | return maxFramerate; |
| 102 | } |
| 103 | |
Åsa Persson | 23eba22 | 2018-10-02 14:47:06 +0200 | [diff] [blame] | 104 | @Nullable |
| 105 | @CalledByNative("Encoding") |
| 106 | Integer getNumTemporalLayers() { |
| 107 | return numTemporalLayers; |
| 108 | } |
| 109 | |
Mirta Dvornicic | d8b9804 | 2019-02-04 16:38:46 +0100 | [diff] [blame] | 110 | @Nullable |
| 111 | @CalledByNative("Encoding") |
| 112 | Double getScaleResolutionDownBy() { |
| 113 | return scaleResolutionDownBy; |
| 114 | } |
| 115 | |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 116 | @CalledByNative("Encoding") |
| 117 | Long getSsrc() { |
| 118 | return ssrc; |
| 119 | } |
Taylor Brandstetter | f8711c0 | 2016-03-29 17:21:29 -0700 | [diff] [blame] | 120 | } |
skvlad | 303b3c2 | 2016-03-24 19:36:46 -0700 | [diff] [blame] | 121 | |
Taylor Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 122 | public static class Codec { |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 123 | // Payload type used to identify this codec in RTP packets. |
| 124 | public int payloadType; |
| 125 | // Name used to identify the codec. Equivalent to MIME subtype. |
| 126 | public String name; |
| 127 | // The media type of this codec. Equivalent to MIME top-level type. |
| 128 | MediaStreamTrack.MediaType kind; |
| 129 | // Clock rate in Hertz. |
| 130 | public Integer clockRate; |
| 131 | // The number of audio channels used. Set to null for video codecs. |
| 132 | public Integer numChannels; |
Florent Castelli | b7d9d83 | 2018-05-15 18:14:14 +0200 | [diff] [blame] | 133 | // The "format specific parameters" field from the "a=fmtp" line in the SDP |
| 134 | public Map<String, String> parameters; |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 135 | |
| 136 | @CalledByNative("Codec") |
| 137 | Codec(int payloadType, String name, MediaStreamTrack.MediaType kind, Integer clockRate, |
Florent Castelli | b7d9d83 | 2018-05-15 18:14:14 +0200 | [diff] [blame] | 138 | Integer numChannels, Map<String, String> parameters) { |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 139 | this.payloadType = payloadType; |
| 140 | this.name = name; |
| 141 | this.kind = kind; |
| 142 | this.clockRate = clockRate; |
| 143 | this.numChannels = numChannels; |
Florent Castelli | b7d9d83 | 2018-05-15 18:14:14 +0200 | [diff] [blame] | 144 | this.parameters = parameters; |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | @CalledByNative("Codec") |
| 148 | int getPayloadType() { |
| 149 | return payloadType; |
| 150 | } |
| 151 | |
| 152 | @CalledByNative("Codec") |
| 153 | String getName() { |
| 154 | return name; |
| 155 | } |
| 156 | |
| 157 | @CalledByNative("Codec") |
| 158 | MediaStreamTrack.MediaType getKind() { |
| 159 | return kind; |
| 160 | } |
| 161 | |
| 162 | @CalledByNative("Codec") |
| 163 | Integer getClockRate() { |
| 164 | return clockRate; |
| 165 | } |
| 166 | |
| 167 | @CalledByNative("Codec") |
| 168 | Integer getNumChannels() { |
| 169 | return numChannels; |
| 170 | } |
Florent Castelli | b7d9d83 | 2018-05-15 18:14:14 +0200 | [diff] [blame] | 171 | |
| 172 | @CalledByNative("Codec") |
| 173 | Map getParameters() { |
| 174 | return parameters; |
| 175 | } |
Taylor Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 176 | } |
| 177 | |
Florent Castelli | dacec71 | 2018-05-24 16:24:21 +0200 | [diff] [blame] | 178 | public static class Rtcp { |
| 179 | /** The Canonical Name used by RTCP */ |
| 180 | private final String cname; |
| 181 | /** Whether reduced size RTCP is configured or compound RTCP */ |
| 182 | private final boolean reducedSize; |
| 183 | |
| 184 | @CalledByNative("Rtcp") |
| 185 | Rtcp(String cname, boolean reducedSize) { |
| 186 | this.cname = cname; |
| 187 | this.reducedSize = reducedSize; |
| 188 | } |
| 189 | |
| 190 | @CalledByNative("Rtcp") |
| 191 | public String getCname() { |
| 192 | return cname; |
| 193 | } |
| 194 | |
| 195 | @CalledByNative("Rtcp") |
| 196 | public boolean getReducedSize() { |
| 197 | return reducedSize; |
| 198 | } |
| 199 | } |
| 200 | |
Florent Castelli | abe301f | 2018-06-12 18:33:49 +0200 | [diff] [blame] | 201 | public static class HeaderExtension { |
| 202 | /** The URI of the RTP header extension, as defined in RFC5285. */ |
| 203 | private final String uri; |
| 204 | /** The value put in the RTP packet to identify the header extension. */ |
| 205 | private final int id; |
| 206 | /** Whether the header extension is encrypted or not. */ |
| 207 | private final boolean encrypted; |
| 208 | |
| 209 | @CalledByNative("HeaderExtension") |
| 210 | HeaderExtension(String uri, int id, boolean encrypted) { |
| 211 | this.uri = uri; |
| 212 | this.id = id; |
| 213 | this.encrypted = encrypted; |
| 214 | } |
| 215 | |
| 216 | @CalledByNative("HeaderExtension") |
| 217 | public String getUri() { |
| 218 | return uri; |
| 219 | } |
| 220 | |
| 221 | @CalledByNative("HeaderExtension") |
| 222 | public int getId() { |
| 223 | return id; |
| 224 | } |
| 225 | |
| 226 | @CalledByNative("HeaderExtension") |
| 227 | public boolean getEncrypted() { |
| 228 | return encrypted; |
| 229 | } |
| 230 | } |
| 231 | |
Florent Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame] | 232 | public final String transactionId; |
| 233 | |
Florent Castelli | dacec71 | 2018-05-24 16:24:21 +0200 | [diff] [blame] | 234 | private final Rtcp rtcp; |
| 235 | |
Florent Castelli | abe301f | 2018-06-12 18:33:49 +0200 | [diff] [blame] | 236 | private final List<HeaderExtension> headerExtensions; |
| 237 | |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 238 | public final List<Encoding> encodings; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 239 | // Codec parameters can't currently be changed between getParameters and |
| 240 | // setParameters. Though in the future it will be possible to reorder them or |
| 241 | // remove them. |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 242 | public final List<Codec> codecs; |
| 243 | |
Florent Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame] | 244 | @CalledByNative |
Florent Castelli | abe301f | 2018-06-12 18:33:49 +0200 | [diff] [blame] | 245 | RtpParameters(String transactionId, Rtcp rtcp, List<HeaderExtension> headerExtensions, |
| 246 | List<Encoding> encodings, List<Codec> codecs) { |
Florent Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame] | 247 | this.transactionId = transactionId; |
Florent Castelli | dacec71 | 2018-05-24 16:24:21 +0200 | [diff] [blame] | 248 | this.rtcp = rtcp; |
Florent Castelli | abe301f | 2018-06-12 18:33:49 +0200 | [diff] [blame] | 249 | this.headerExtensions = headerExtensions; |
Florent Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame] | 250 | this.encodings = encodings; |
| 251 | this.codecs = codecs; |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | @CalledByNative |
Florent Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame] | 255 | String getTransactionId() { |
| 256 | return transactionId; |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | @CalledByNative |
Florent Castelli | dacec71 | 2018-05-24 16:24:21 +0200 | [diff] [blame] | 260 | public Rtcp getRtcp() { |
| 261 | return rtcp; |
| 262 | } |
| 263 | |
| 264 | @CalledByNative |
Florent Castelli | abe301f | 2018-06-12 18:33:49 +0200 | [diff] [blame] | 265 | public List<HeaderExtension> getHeaderExtensions() { |
| 266 | return headerExtensions; |
| 267 | } |
| 268 | |
| 269 | @CalledByNative |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 270 | List<Encoding> getEncodings() { |
| 271 | return encodings; |
| 272 | } |
| 273 | |
| 274 | @CalledByNative |
| 275 | List<Codec> getCodecs() { |
| 276 | return codecs; |
| 277 | } |
skvlad | 303b3c2 | 2016-03-24 19:36:46 -0700 | [diff] [blame] | 278 | } |