blob: a3982353385a3e527c97e5ddb69b2a02ec33021e [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 Persson613591a2018-05-29 09:21:31 +020037 // Not implemented.
38 @Nullable public Integer minBitrateBps;
deadbeefe702b302017-02-04 12:09:01 -080039 // SSRC to be used by this encoding.
40 // Can't be changed between getParameters/setParameters.
deadbeef8014c752017-01-06 16:53:00 -080041 public Long ssrc;
Magnus Jedvert9060eb12017-12-12 12:52:54 +010042
43 @CalledByNative("Encoding")
Åsa Persson613591a2018-05-29 09:21:31 +020044 Encoding(boolean active, Integer maxBitrateBps, Integer minBitrateBps, Long ssrc) {
Magnus Jedvert9060eb12017-12-12 12:52:54 +010045 this.active = active;
46 this.maxBitrateBps = maxBitrateBps;
Åsa Persson613591a2018-05-29 09:21:31 +020047 this.minBitrateBps = minBitrateBps;
Magnus Jedvert9060eb12017-12-12 12:52:54 +010048 this.ssrc = ssrc;
49 }
50
51 @CalledByNative("Encoding")
52 boolean getActive() {
53 return active;
54 }
55
Sami Kalliomäkie7592d82018-03-22 13:32:44 +010056 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +010057 @CalledByNative("Encoding")
58 Integer getMaxBitrateBps() {
59 return maxBitrateBps;
60 }
61
Åsa Persson613591a2018-05-29 09:21:31 +020062 @Nullable
63 @CalledByNative("Encoding")
64 Integer getMinBitrateBps() {
65 return minBitrateBps;
66 }
67
Magnus Jedvert9060eb12017-12-12 12:52:54 +010068 @CalledByNative("Encoding")
69 Long getSsrc() {
70 return ssrc;
71 }
Taylor Brandstetterf8711c02016-03-29 17:21:29 -070072 }
skvlad303b3c22016-03-24 19:36:46 -070073
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -070074 public static class Codec {
deadbeefe702b302017-02-04 12:09:01 -080075 // 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 Castellib7d9d832018-05-15 18:14:14 +020085 // The "format specific parameters" field from the "a=fmtp" line in the SDP
86 public Map<String, String> parameters;
Magnus Jedvert9060eb12017-12-12 12:52:54 +010087
88 @CalledByNative("Codec")
89 Codec(int payloadType, String name, MediaStreamTrack.MediaType kind, Integer clockRate,
Florent Castellib7d9d832018-05-15 18:14:14 +020090 Integer numChannels, Map<String, String> parameters) {
Magnus Jedvert9060eb12017-12-12 12:52:54 +010091 this.payloadType = payloadType;
92 this.name = name;
93 this.kind = kind;
94 this.clockRate = clockRate;
95 this.numChannels = numChannels;
Florent Castellib7d9d832018-05-15 18:14:14 +020096 this.parameters = parameters;
Magnus Jedvert9060eb12017-12-12 12:52:54 +010097 }
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 Castellib7d9d832018-05-15 18:14:14 +0200123
124 @CalledByNative("Codec")
125 Map getParameters() {
126 return parameters;
127 }
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700128 }
129
Florent Castellidacec712018-05-24 16:24:21 +0200130 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 Castellicebf50f2018-05-03 15:31:53 +0200153 public final String transactionId;
154
Florent Castellidacec712018-05-24 16:24:21 +0200155 private final Rtcp rtcp;
156
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100157 public final List<Encoding> encodings;
deadbeefe702b302017-02-04 12:09:01 -0800158 // Codec parameters can't currently be changed between getParameters and
159 // setParameters. Though in the future it will be possible to reorder them or
160 // remove them.
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100161 public final List<Codec> codecs;
162
Florent Castellicebf50f2018-05-03 15:31:53 +0200163 @CalledByNative
Florent Castellidacec712018-05-24 16:24:21 +0200164 RtpParameters(String transactionId, Rtcp rtcp, List<Encoding> encodings, List<Codec> codecs) {
Florent Castellicebf50f2018-05-03 15:31:53 +0200165 this.transactionId = transactionId;
Florent Castellidacec712018-05-24 16:24:21 +0200166 this.rtcp = rtcp;
Florent Castellicebf50f2018-05-03 15:31:53 +0200167 this.encodings = encodings;
168 this.codecs = codecs;
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100169 }
170
171 @CalledByNative
Florent Castellicebf50f2018-05-03 15:31:53 +0200172 String getTransactionId() {
173 return transactionId;
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100174 }
175
176 @CalledByNative
Florent Castellidacec712018-05-24 16:24:21 +0200177 public Rtcp getRtcp() {
178 return rtcp;
179 }
180
181 @CalledByNative
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100182 List<Encoding> getEncodings() {
183 return encodings;
184 }
185
186 @CalledByNative
187 List<Codec> getCodecs() {
188 return codecs;
189 }
skvlad303b3c22016-03-24 19:36:46 -0700190}