blob: 634f3b30172a9467727d7fd2a2dd83cfe7a42a43 [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.List;
15import java.util.ArrayList;
Magnus Jedvert9060eb12017-12-12 12:52:54 +010016import org.webrtc.MediaStreamTrack;
skvlad303b3c22016-03-24 19:36:46 -070017
18/**
19 * The parameters for an {@code RtpSender}, as defined in
20 * http://w3c.github.io/webrtc-pc/#rtcrtpsender-interface.
deadbeefe702b302017-02-04 12:09:01 -080021 *
22 * Note: These structures use nullable Integer/etc. types because in the
23 * future, they may be used to construct ORTC RtpSender/RtpReceivers, in
24 * which case "null" will be used to represent "choose the implementation
25 * default value".
skvlad303b3c22016-03-24 19:36:46 -070026 */
27public class RtpParameters {
Taylor Brandstetterf8711c02016-03-29 17:21:29 -070028 public static class Encoding {
deadbeefe702b302017-02-04 12:09:01 -080029 // Set to true to cause this encoding to be sent, and false for it not to
30 // be sent.
Taylor Brandstetterf8711c02016-03-29 17:21:29 -070031 public boolean active = true;
deadbeefe702b302017-02-04 12:09:01 -080032 // If non-null, this represents the Transport Independent Application
33 // Specific maximum bandwidth defined in RFC3890. If null, there is no
34 // maximum bitrate.
Sami Kalliomäkie7592d82018-03-22 13:32:44 +010035 @Nullable public Integer maxBitrateBps;
deadbeefe702b302017-02-04 12:09:01 -080036 // SSRC to be used by this encoding.
37 // Can't be changed between getParameters/setParameters.
deadbeef8014c752017-01-06 16:53:00 -080038 public Long ssrc;
Magnus Jedvert9060eb12017-12-12 12:52:54 +010039
40 @CalledByNative("Encoding")
41 Encoding(boolean active, Integer maxBitrateBps, Long ssrc) {
42 this.active = active;
43 this.maxBitrateBps = maxBitrateBps;
44 this.ssrc = ssrc;
45 }
46
47 @CalledByNative("Encoding")
48 boolean getActive() {
49 return active;
50 }
51
Sami Kalliomäkie7592d82018-03-22 13:32:44 +010052 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +010053 @CalledByNative("Encoding")
54 Integer getMaxBitrateBps() {
55 return maxBitrateBps;
56 }
57
58 @CalledByNative("Encoding")
59 Long getSsrc() {
60 return ssrc;
61 }
Taylor Brandstetterf8711c02016-03-29 17:21:29 -070062 }
skvlad303b3c22016-03-24 19:36:46 -070063
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -070064 public static class Codec {
deadbeefe702b302017-02-04 12:09:01 -080065 // Payload type used to identify this codec in RTP packets.
66 public int payloadType;
67 // Name used to identify the codec. Equivalent to MIME subtype.
68 public String name;
69 // The media type of this codec. Equivalent to MIME top-level type.
70 MediaStreamTrack.MediaType kind;
71 // Clock rate in Hertz.
72 public Integer clockRate;
73 // The number of audio channels used. Set to null for video codecs.
74 public Integer numChannels;
Magnus Jedvert9060eb12017-12-12 12:52:54 +010075
76 @CalledByNative("Codec")
77 Codec(int payloadType, String name, MediaStreamTrack.MediaType kind, Integer clockRate,
78 Integer numChannels) {
79 this.payloadType = payloadType;
80 this.name = name;
81 this.kind = kind;
82 this.clockRate = clockRate;
83 this.numChannels = numChannels;
84 }
85
86 @CalledByNative("Codec")
87 int getPayloadType() {
88 return payloadType;
89 }
90
91 @CalledByNative("Codec")
92 String getName() {
93 return name;
94 }
95
96 @CalledByNative("Codec")
97 MediaStreamTrack.MediaType getKind() {
98 return kind;
99 }
100
101 @CalledByNative("Codec")
102 Integer getClockRate() {
103 return clockRate;
104 }
105
106 @CalledByNative("Codec")
107 Integer getNumChannels() {
108 return numChannels;
109 }
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700110 }
111
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100112 public final List<Encoding> encodings;
deadbeefe702b302017-02-04 12:09:01 -0800113 // Codec parameters can't currently be changed between getParameters and
114 // setParameters. Though in the future it will be possible to reorder them or
115 // remove them.
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100116 public final List<Codec> codecs;
117
118 public RtpParameters() {
119 this.encodings = new ArrayList<>();
120 this.codecs = new ArrayList<>();
121 }
122
123 @CalledByNative
124 RtpParameters(List<Encoding> encodings, List<Codec> codecs) {
125 this.encodings = encodings;
126 this.codecs = codecs;
127 }
128
129 @CalledByNative
130 List<Encoding> getEncodings() {
131 return encodings;
132 }
133
134 @CalledByNative
135 List<Codec> getCodecs() {
136 return codecs;
137 }
skvlad303b3c22016-03-24 19:36:46 -0700138}