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 | |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 13 | import javax.annotation.Nullable; |
Magnus Jedvert | 6062f37 | 2017-11-16 16:53:12 +0100 | [diff] [blame] | 14 | import java.util.ArrayList; |
Florent Castelli | b7d9d83 | 2018-05-15 18:14:14 +0200 | [diff] [blame] | 15 | import java.util.List; |
| 16 | import java.util.Map; |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 17 | import org.webrtc.MediaStreamTrack; |
skvlad | 303b3c2 | 2016-03-24 19:36:46 -0700 | [diff] [blame] | 18 | |
| 19 | /** |
| 20 | * The parameters for an {@code RtpSender}, as defined in |
| 21 | * http://w3c.github.io/webrtc-pc/#rtcrtpsender-interface. |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 22 | * |
| 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". |
skvlad | 303b3c2 | 2016-03-24 19:36:46 -0700 | [diff] [blame] | 27 | */ |
| 28 | public class RtpParameters { |
Taylor Brandstetter | f8711c0 | 2016-03-29 17:21:29 -0700 | [diff] [blame] | 29 | public static class Encoding { |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 30 | // Set to true to cause this encoding to be sent, and false for it not to |
| 31 | // be sent. |
Taylor Brandstetter | f8711c0 | 2016-03-29 17:21:29 -0700 | [diff] [blame] | 32 | public boolean active = true; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 33 | // 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äki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 36 | @Nullable public Integer maxBitrateBps; |
Åsa Persson | 4e5342f | 2018-08-13 16:46:57 +0200 | [diff] [blame] | 37 | // The minimum bitrate in bps for video. |
Åsa Persson | 613591a | 2018-05-29 09:21:31 +0200 | [diff] [blame] | 38 | @Nullable public Integer minBitrateBps; |
Åsa Persson | 4e5342f | 2018-08-13 16:46:57 +0200 | [diff] [blame] | 39 | // The max framerate in fps for video. |
| 40 | @Nullable public Integer maxFramerate; |
Åsa Persson | 23eba22 | 2018-10-02 14:47:06 +0200 | [diff] [blame^] | 41 | // The number of temporal layers for video. |
| 42 | @Nullable public Integer numTemporalLayers; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 43 | // SSRC to be used by this encoding. |
| 44 | // Can't be changed between getParameters/setParameters. |
deadbeef | 8014c75 | 2017-01-06 16:53:00 -0800 | [diff] [blame] | 45 | public Long ssrc; |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 46 | |
| 47 | @CalledByNative("Encoding") |
Åsa Persson | 4e5342f | 2018-08-13 16:46:57 +0200 | [diff] [blame] | 48 | Encoding(boolean active, Integer maxBitrateBps, Integer minBitrateBps, Integer maxFramerate, |
Åsa Persson | 23eba22 | 2018-10-02 14:47:06 +0200 | [diff] [blame^] | 49 | Integer numTemporalLayers, Long ssrc) { |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 50 | this.active = active; |
| 51 | this.maxBitrateBps = maxBitrateBps; |
Åsa Persson | 613591a | 2018-05-29 09:21:31 +0200 | [diff] [blame] | 52 | this.minBitrateBps = minBitrateBps; |
Åsa Persson | 4e5342f | 2018-08-13 16:46:57 +0200 | [diff] [blame] | 53 | this.maxFramerate = maxFramerate; |
Åsa Persson | 23eba22 | 2018-10-02 14:47:06 +0200 | [diff] [blame^] | 54 | this.numTemporalLayers = numTemporalLayers; |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 55 | this.ssrc = ssrc; |
| 56 | } |
| 57 | |
| 58 | @CalledByNative("Encoding") |
| 59 | boolean getActive() { |
| 60 | return active; |
| 61 | } |
| 62 | |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 63 | @Nullable |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 64 | @CalledByNative("Encoding") |
| 65 | Integer getMaxBitrateBps() { |
| 66 | return maxBitrateBps; |
| 67 | } |
| 68 | |
Åsa Persson | 613591a | 2018-05-29 09:21:31 +0200 | [diff] [blame] | 69 | @Nullable |
| 70 | @CalledByNative("Encoding") |
| 71 | Integer getMinBitrateBps() { |
| 72 | return minBitrateBps; |
| 73 | } |
| 74 | |
Åsa Persson | 4e5342f | 2018-08-13 16:46:57 +0200 | [diff] [blame] | 75 | @Nullable |
| 76 | @CalledByNative("Encoding") |
| 77 | Integer getMaxFramerate() { |
| 78 | return maxFramerate; |
| 79 | } |
| 80 | |
Åsa Persson | 23eba22 | 2018-10-02 14:47:06 +0200 | [diff] [blame^] | 81 | @Nullable |
| 82 | @CalledByNative("Encoding") |
| 83 | Integer getNumTemporalLayers() { |
| 84 | return numTemporalLayers; |
| 85 | } |
| 86 | |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 87 | @CalledByNative("Encoding") |
| 88 | Long getSsrc() { |
| 89 | return ssrc; |
| 90 | } |
Taylor Brandstetter | f8711c0 | 2016-03-29 17:21:29 -0700 | [diff] [blame] | 91 | } |
skvlad | 303b3c2 | 2016-03-24 19:36:46 -0700 | [diff] [blame] | 92 | |
Taylor Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 93 | public static class Codec { |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 94 | // 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 Castelli | b7d9d83 | 2018-05-15 18:14:14 +0200 | [diff] [blame] | 104 | // The "format specific parameters" field from the "a=fmtp" line in the SDP |
| 105 | public Map<String, String> parameters; |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 106 | |
| 107 | @CalledByNative("Codec") |
| 108 | Codec(int payloadType, String name, MediaStreamTrack.MediaType kind, Integer clockRate, |
Florent Castelli | b7d9d83 | 2018-05-15 18:14:14 +0200 | [diff] [blame] | 109 | Integer numChannels, Map<String, String> parameters) { |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 110 | this.payloadType = payloadType; |
| 111 | this.name = name; |
| 112 | this.kind = kind; |
| 113 | this.clockRate = clockRate; |
| 114 | this.numChannels = numChannels; |
Florent Castelli | b7d9d83 | 2018-05-15 18:14:14 +0200 | [diff] [blame] | 115 | this.parameters = parameters; |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 116 | } |
| 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 Castelli | b7d9d83 | 2018-05-15 18:14:14 +0200 | [diff] [blame] | 142 | |
| 143 | @CalledByNative("Codec") |
| 144 | Map getParameters() { |
| 145 | return parameters; |
| 146 | } |
Taylor Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 147 | } |
| 148 | |
Florent Castelli | dacec71 | 2018-05-24 16:24:21 +0200 | [diff] [blame] | 149 | 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 Castelli | abe301f | 2018-06-12 18:33:49 +0200 | [diff] [blame] | 172 | 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 Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame] | 203 | public final String transactionId; |
| 204 | |
Florent Castelli | dacec71 | 2018-05-24 16:24:21 +0200 | [diff] [blame] | 205 | private final Rtcp rtcp; |
| 206 | |
Florent Castelli | abe301f | 2018-06-12 18:33:49 +0200 | [diff] [blame] | 207 | private final List<HeaderExtension> headerExtensions; |
| 208 | |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 209 | public final List<Encoding> encodings; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 210 | // 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 Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 213 | public final List<Codec> codecs; |
| 214 | |
Florent Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame] | 215 | @CalledByNative |
Florent Castelli | abe301f | 2018-06-12 18:33:49 +0200 | [diff] [blame] | 216 | RtpParameters(String transactionId, Rtcp rtcp, List<HeaderExtension> headerExtensions, |
| 217 | List<Encoding> encodings, List<Codec> codecs) { |
Florent Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame] | 218 | this.transactionId = transactionId; |
Florent Castelli | dacec71 | 2018-05-24 16:24:21 +0200 | [diff] [blame] | 219 | this.rtcp = rtcp; |
Florent Castelli | abe301f | 2018-06-12 18:33:49 +0200 | [diff] [blame] | 220 | this.headerExtensions = headerExtensions; |
Florent Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame] | 221 | this.encodings = encodings; |
| 222 | this.codecs = codecs; |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | @CalledByNative |
Florent Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame] | 226 | String getTransactionId() { |
| 227 | return transactionId; |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | @CalledByNative |
Florent Castelli | dacec71 | 2018-05-24 16:24:21 +0200 | [diff] [blame] | 231 | public Rtcp getRtcp() { |
| 232 | return rtcp; |
| 233 | } |
| 234 | |
| 235 | @CalledByNative |
Florent Castelli | abe301f | 2018-06-12 18:33:49 +0200 | [diff] [blame] | 236 | public List<HeaderExtension> getHeaderExtensions() { |
| 237 | return headerExtensions; |
| 238 | } |
| 239 | |
| 240 | @CalledByNative |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 241 | List<Encoding> getEncodings() { |
| 242 | return encodings; |
| 243 | } |
| 244 | |
| 245 | @CalledByNative |
| 246 | List<Codec> getCodecs() { |
| 247 | return codecs; |
| 248 | } |
skvlad | 303b3c2 | 2016-03-24 19:36:46 -0700 | [diff] [blame] | 249 | } |