blob: e376c082ac175e8b6a948c8885fe62481ce29fec [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;
deadbeefe702b302017-02-04 12:09:01 -080037 // SSRC to be used by this encoding.
38 // Can't be changed between getParameters/setParameters.
deadbeef8014c752017-01-06 16:53:00 -080039 public Long ssrc;
Magnus Jedvert9060eb12017-12-12 12:52:54 +010040
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äkie7592d82018-03-22 13:32:44 +010053 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +010054 @CalledByNative("Encoding")
55 Integer getMaxBitrateBps() {
56 return maxBitrateBps;
57 }
58
59 @CalledByNative("Encoding")
60 Long getSsrc() {
61 return ssrc;
62 }
Taylor Brandstetterf8711c02016-03-29 17:21:29 -070063 }
skvlad303b3c22016-03-24 19:36:46 -070064
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -070065 public static class Codec {
deadbeefe702b302017-02-04 12:09:01 -080066 // 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 Castellib7d9d832018-05-15 18:14:14 +020076 // The "format specific parameters" field from the "a=fmtp" line in the SDP
77 public Map<String, String> parameters;
Magnus Jedvert9060eb12017-12-12 12:52:54 +010078
79 @CalledByNative("Codec")
80 Codec(int payloadType, String name, MediaStreamTrack.MediaType kind, Integer clockRate,
Florent Castellib7d9d832018-05-15 18:14:14 +020081 Integer numChannels, Map<String, String> parameters) {
Magnus Jedvert9060eb12017-12-12 12:52:54 +010082 this.payloadType = payloadType;
83 this.name = name;
84 this.kind = kind;
85 this.clockRate = clockRate;
86 this.numChannels = numChannels;
Florent Castellib7d9d832018-05-15 18:14:14 +020087 this.parameters = parameters;
Magnus Jedvert9060eb12017-12-12 12:52:54 +010088 }
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 Castellib7d9d832018-05-15 18:14:14 +0200114
115 @CalledByNative("Codec")
116 Map getParameters() {
117 return parameters;
118 }
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700119 }
120
Florent Castellidacec712018-05-24 16:24:21 +0200121 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 Castellicebf50f2018-05-03 15:31:53 +0200144 public final String transactionId;
145
Florent Castellidacec712018-05-24 16:24:21 +0200146 private final Rtcp rtcp;
147
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100148 public final List<Encoding> encodings;
deadbeefe702b302017-02-04 12:09:01 -0800149 // 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 Jedvert9060eb12017-12-12 12:52:54 +0100152 public final List<Codec> codecs;
153
Florent Castellicebf50f2018-05-03 15:31:53 +0200154 @CalledByNative
Florent Castellidacec712018-05-24 16:24:21 +0200155 RtpParameters(String transactionId, Rtcp rtcp, List<Encoding> encodings, List<Codec> codecs) {
Florent Castellicebf50f2018-05-03 15:31:53 +0200156 this.transactionId = transactionId;
Florent Castellidacec712018-05-24 16:24:21 +0200157 this.rtcp = rtcp;
Florent Castellicebf50f2018-05-03 15:31:53 +0200158 this.encodings = encodings;
159 this.codecs = codecs;
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100160 }
161
162 @CalledByNative
Florent Castellicebf50f2018-05-03 15:31:53 +0200163 String getTransactionId() {
164 return transactionId;
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100165 }
166
167 @CalledByNative
Florent Castellidacec712018-05-24 16:24:21 +0200168 public Rtcp getRtcp() {
169 return rtcp;
170 }
171
172 @CalledByNative
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100173 List<Encoding> getEncodings() {
174 return encodings;
175 }
176
177 @CalledByNative
178 List<Codec> getCodecs() {
179 return codecs;
180 }
skvlad303b3c22016-03-24 19:36:46 -0700181}