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 | 613591a | 2018-05-29 09:21:31 +0200 | [diff] [blame] | 37 | // Not implemented. |
| 38 | @Nullable public Integer minBitrateBps; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 39 | // SSRC to be used by this encoding. |
| 40 | // Can't be changed between getParameters/setParameters. |
deadbeef | 8014c75 | 2017-01-06 16:53:00 -0800 | [diff] [blame] | 41 | public Long ssrc; |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 42 | |
| 43 | @CalledByNative("Encoding") |
Åsa Persson | 613591a | 2018-05-29 09:21:31 +0200 | [diff] [blame] | 44 | Encoding(boolean active, Integer maxBitrateBps, Integer minBitrateBps, Long ssrc) { |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 45 | this.active = active; |
| 46 | this.maxBitrateBps = maxBitrateBps; |
Åsa Persson | 613591a | 2018-05-29 09:21:31 +0200 | [diff] [blame] | 47 | this.minBitrateBps = minBitrateBps; |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 48 | this.ssrc = ssrc; |
| 49 | } |
| 50 | |
| 51 | @CalledByNative("Encoding") |
| 52 | boolean getActive() { |
| 53 | return active; |
| 54 | } |
| 55 | |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 56 | @Nullable |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 57 | @CalledByNative("Encoding") |
| 58 | Integer getMaxBitrateBps() { |
| 59 | return maxBitrateBps; |
| 60 | } |
| 61 | |
Åsa Persson | 613591a | 2018-05-29 09:21:31 +0200 | [diff] [blame] | 62 | @Nullable |
| 63 | @CalledByNative("Encoding") |
| 64 | Integer getMinBitrateBps() { |
| 65 | return minBitrateBps; |
| 66 | } |
| 67 | |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 68 | @CalledByNative("Encoding") |
| 69 | Long getSsrc() { |
| 70 | return ssrc; |
| 71 | } |
Taylor Brandstetter | f8711c0 | 2016-03-29 17:21:29 -0700 | [diff] [blame] | 72 | } |
skvlad | 303b3c2 | 2016-03-24 19:36:46 -0700 | [diff] [blame] | 73 | |
Taylor Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 74 | public static class Codec { |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 75 | // 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 Castelli | b7d9d83 | 2018-05-15 18:14:14 +0200 | [diff] [blame] | 85 | // The "format specific parameters" field from the "a=fmtp" line in the SDP |
| 86 | public Map<String, String> parameters; |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 87 | |
| 88 | @CalledByNative("Codec") |
| 89 | Codec(int payloadType, String name, MediaStreamTrack.MediaType kind, Integer clockRate, |
Florent Castelli | b7d9d83 | 2018-05-15 18:14:14 +0200 | [diff] [blame] | 90 | Integer numChannels, Map<String, String> parameters) { |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 91 | this.payloadType = payloadType; |
| 92 | this.name = name; |
| 93 | this.kind = kind; |
| 94 | this.clockRate = clockRate; |
| 95 | this.numChannels = numChannels; |
Florent Castelli | b7d9d83 | 2018-05-15 18:14:14 +0200 | [diff] [blame] | 96 | this.parameters = parameters; |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 97 | } |
| 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 Castelli | b7d9d83 | 2018-05-15 18:14:14 +0200 | [diff] [blame] | 123 | |
| 124 | @CalledByNative("Codec") |
| 125 | Map getParameters() { |
| 126 | return parameters; |
| 127 | } |
Taylor Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 128 | } |
| 129 | |
Florent Castelli | dacec71 | 2018-05-24 16:24:21 +0200 | [diff] [blame] | 130 | 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 Castelli | abe301f | 2018-06-12 18:33:49 +0200 | [diff] [blame^] | 153 | 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 Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame] | 184 | public final String transactionId; |
| 185 | |
Florent Castelli | dacec71 | 2018-05-24 16:24:21 +0200 | [diff] [blame] | 186 | private final Rtcp rtcp; |
| 187 | |
Florent Castelli | abe301f | 2018-06-12 18:33:49 +0200 | [diff] [blame^] | 188 | private final List<HeaderExtension> headerExtensions; |
| 189 | |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 190 | public final List<Encoding> encodings; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 191 | // 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 Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 194 | public final List<Codec> codecs; |
| 195 | |
Florent Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame] | 196 | @CalledByNative |
Florent Castelli | abe301f | 2018-06-12 18:33:49 +0200 | [diff] [blame^] | 197 | RtpParameters(String transactionId, Rtcp rtcp, List<HeaderExtension> headerExtensions, |
| 198 | List<Encoding> encodings, List<Codec> codecs) { |
Florent Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame] | 199 | this.transactionId = transactionId; |
Florent Castelli | dacec71 | 2018-05-24 16:24:21 +0200 | [diff] [blame] | 200 | this.rtcp = rtcp; |
Florent Castelli | abe301f | 2018-06-12 18:33:49 +0200 | [diff] [blame^] | 201 | this.headerExtensions = headerExtensions; |
Florent Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame] | 202 | this.encodings = encodings; |
| 203 | this.codecs = codecs; |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | @CalledByNative |
Florent Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame] | 207 | String getTransactionId() { |
| 208 | return transactionId; |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | @CalledByNative |
Florent Castelli | dacec71 | 2018-05-24 16:24:21 +0200 | [diff] [blame] | 212 | public Rtcp getRtcp() { |
| 213 | return rtcp; |
| 214 | } |
| 215 | |
| 216 | @CalledByNative |
Florent Castelli | abe301f | 2018-06-12 18:33:49 +0200 | [diff] [blame^] | 217 | public List<HeaderExtension> getHeaderExtensions() { |
| 218 | return headerExtensions; |
| 219 | } |
| 220 | |
| 221 | @CalledByNative |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 222 | List<Encoding> getEncodings() { |
| 223 | return encodings; |
| 224 | } |
| 225 | |
| 226 | @CalledByNative |
| 227 | List<Codec> getCodecs() { |
| 228 | return codecs; |
| 229 | } |
skvlad | 303b3c2 | 2016-03-24 19:36:46 -0700 | [diff] [blame] | 230 | } |