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; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 37 | // SSRC to be used by this encoding. |
| 38 | // Can't be changed between getParameters/setParameters. |
deadbeef | 8014c75 | 2017-01-06 16:53:00 -0800 | [diff] [blame] | 39 | public Long ssrc; |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 40 | |
| 41 | @CalledByNative("Encoding") |
| 42 | Encoding(boolean active, Integer maxBitrateBps, Long ssrc) { |
| 43 | this.active = active; |
| 44 | this.maxBitrateBps = maxBitrateBps; |
| 45 | this.ssrc = ssrc; |
| 46 | } |
| 47 | |
| 48 | @CalledByNative("Encoding") |
| 49 | boolean getActive() { |
| 50 | return active; |
| 51 | } |
| 52 | |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 53 | @Nullable |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 54 | @CalledByNative("Encoding") |
| 55 | Integer getMaxBitrateBps() { |
| 56 | return maxBitrateBps; |
| 57 | } |
| 58 | |
| 59 | @CalledByNative("Encoding") |
| 60 | Long getSsrc() { |
| 61 | return ssrc; |
| 62 | } |
Taylor Brandstetter | f8711c0 | 2016-03-29 17:21:29 -0700 | [diff] [blame] | 63 | } |
skvlad | 303b3c2 | 2016-03-24 19:36:46 -0700 | [diff] [blame] | 64 | |
Taylor Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 65 | public static class Codec { |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 66 | // Payload type used to identify this codec in RTP packets. |
| 67 | public int payloadType; |
| 68 | // Name used to identify the codec. Equivalent to MIME subtype. |
| 69 | public String name; |
| 70 | // The media type of this codec. Equivalent to MIME top-level type. |
| 71 | MediaStreamTrack.MediaType kind; |
| 72 | // Clock rate in Hertz. |
| 73 | public Integer clockRate; |
| 74 | // The number of audio channels used. Set to null for video codecs. |
| 75 | public Integer numChannels; |
Florent Castelli | b7d9d83 | 2018-05-15 18:14:14 +0200 | [diff] [blame] | 76 | // The "format specific parameters" field from the "a=fmtp" line in the SDP |
| 77 | public Map<String, String> parameters; |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 78 | |
| 79 | @CalledByNative("Codec") |
| 80 | Codec(int payloadType, String name, MediaStreamTrack.MediaType kind, Integer clockRate, |
Florent Castelli | b7d9d83 | 2018-05-15 18:14:14 +0200 | [diff] [blame] | 81 | Integer numChannels, Map<String, String> parameters) { |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 82 | this.payloadType = payloadType; |
| 83 | this.name = name; |
| 84 | this.kind = kind; |
| 85 | this.clockRate = clockRate; |
| 86 | this.numChannels = numChannels; |
Florent Castelli | b7d9d83 | 2018-05-15 18:14:14 +0200 | [diff] [blame] | 87 | this.parameters = parameters; |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | @CalledByNative("Codec") |
| 91 | int getPayloadType() { |
| 92 | return payloadType; |
| 93 | } |
| 94 | |
| 95 | @CalledByNative("Codec") |
| 96 | String getName() { |
| 97 | return name; |
| 98 | } |
| 99 | |
| 100 | @CalledByNative("Codec") |
| 101 | MediaStreamTrack.MediaType getKind() { |
| 102 | return kind; |
| 103 | } |
| 104 | |
| 105 | @CalledByNative("Codec") |
| 106 | Integer getClockRate() { |
| 107 | return clockRate; |
| 108 | } |
| 109 | |
| 110 | @CalledByNative("Codec") |
| 111 | Integer getNumChannels() { |
| 112 | return numChannels; |
| 113 | } |
Florent Castelli | b7d9d83 | 2018-05-15 18:14:14 +0200 | [diff] [blame] | 114 | |
| 115 | @CalledByNative("Codec") |
| 116 | Map getParameters() { |
| 117 | return parameters; |
| 118 | } |
Taylor Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 119 | } |
| 120 | |
Florent Castelli | dacec71 | 2018-05-24 16:24:21 +0200 | [diff] [blame] | 121 | public static class Rtcp { |
| 122 | /** The Canonical Name used by RTCP */ |
| 123 | private final String cname; |
| 124 | /** Whether reduced size RTCP is configured or compound RTCP */ |
| 125 | private final boolean reducedSize; |
| 126 | |
| 127 | @CalledByNative("Rtcp") |
| 128 | Rtcp(String cname, boolean reducedSize) { |
| 129 | this.cname = cname; |
| 130 | this.reducedSize = reducedSize; |
| 131 | } |
| 132 | |
| 133 | @CalledByNative("Rtcp") |
| 134 | public String getCname() { |
| 135 | return cname; |
| 136 | } |
| 137 | |
| 138 | @CalledByNative("Rtcp") |
| 139 | public boolean getReducedSize() { |
| 140 | return reducedSize; |
| 141 | } |
| 142 | } |
| 143 | |
Florent Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame] | 144 | public final String transactionId; |
| 145 | |
Florent Castelli | dacec71 | 2018-05-24 16:24:21 +0200 | [diff] [blame] | 146 | private final Rtcp rtcp; |
| 147 | |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 148 | public final List<Encoding> encodings; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 149 | // Codec parameters can't currently be changed between getParameters and |
| 150 | // setParameters. Though in the future it will be possible to reorder them or |
| 151 | // remove them. |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 152 | public final List<Codec> codecs; |
| 153 | |
Florent Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame] | 154 | @CalledByNative |
Florent Castelli | dacec71 | 2018-05-24 16:24:21 +0200 | [diff] [blame] | 155 | RtpParameters(String transactionId, Rtcp rtcp, List<Encoding> encodings, List<Codec> codecs) { |
Florent Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame] | 156 | this.transactionId = transactionId; |
Florent Castelli | dacec71 | 2018-05-24 16:24:21 +0200 | [diff] [blame] | 157 | this.rtcp = rtcp; |
Florent Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame] | 158 | this.encodings = encodings; |
| 159 | this.codecs = codecs; |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | @CalledByNative |
Florent Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame] | 163 | String getTransactionId() { |
| 164 | return transactionId; |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | @CalledByNative |
Florent Castelli | dacec71 | 2018-05-24 16:24:21 +0200 | [diff] [blame] | 168 | public Rtcp getRtcp() { |
| 169 | return rtcp; |
| 170 | } |
| 171 | |
| 172 | @CalledByNative |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 173 | List<Encoding> getEncodings() { |
| 174 | return encodings; |
| 175 | } |
| 176 | |
| 177 | @CalledByNative |
| 178 | List<Codec> getCodecs() { |
| 179 | return codecs; |
| 180 | } |
skvlad | 303b3c2 | 2016-03-24 19:36:46 -0700 | [diff] [blame] | 181 | } |