blob: 0e893bdc5f2a639cdd9aefe742a741eb34e6dceb [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 Castellicebf50f2018-05-03 15:31:53 +0200121 public final String transactionId;
122
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100123 public final List<Encoding> encodings;
deadbeefe702b302017-02-04 12:09:01 -0800124 // Codec parameters can't currently be changed between getParameters and
125 // setParameters. Though in the future it will be possible to reorder them or
126 // remove them.
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100127 public final List<Codec> codecs;
128
Florent Castellicebf50f2018-05-03 15:31:53 +0200129 @CalledByNative
130 RtpParameters(String transactionId, List<Encoding> encodings, List<Codec> codecs) {
131 this.transactionId = transactionId;
132 this.encodings = encodings;
133 this.codecs = codecs;
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100134 }
135
136 @CalledByNative
Florent Castellicebf50f2018-05-03 15:31:53 +0200137 String getTransactionId() {
138 return transactionId;
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100139 }
140
141 @CalledByNative
142 List<Encoding> getEncodings() {
143 return encodings;
144 }
145
146 @CalledByNative
147 List<Codec> getCodecs() {
148 return codecs;
149 }
skvlad303b3c22016-03-24 19:36:46 -0700150}