blob: 28ce6aa511249ca82a4e318f922158c4feac2c97 [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
Magnus Jedvert6062f372017-11-16 16:53:12 +010013import java.util.List;
14import java.util.ArrayList;
Magnus Jedvert9060eb12017-12-12 12:52:54 +010015import org.webrtc.MediaStreamTrack;
skvlad303b3c22016-03-24 19:36:46 -070016
17/**
18 * The parameters for an {@code RtpSender}, as defined in
19 * http://w3c.github.io/webrtc-pc/#rtcrtpsender-interface.
deadbeefe702b302017-02-04 12:09:01 -080020 *
21 * Note: These structures use nullable Integer/etc. types because in the
22 * future, they may be used to construct ORTC RtpSender/RtpReceivers, in
23 * which case "null" will be used to represent "choose the implementation
24 * default value".
skvlad303b3c22016-03-24 19:36:46 -070025 */
26public class RtpParameters {
Taylor Brandstetterf8711c02016-03-29 17:21:29 -070027 public static class Encoding {
deadbeefe702b302017-02-04 12:09:01 -080028 // Set to true to cause this encoding to be sent, and false for it not to
29 // be sent.
Taylor Brandstetterf8711c02016-03-29 17:21:29 -070030 public boolean active = true;
deadbeefe702b302017-02-04 12:09:01 -080031 // If non-null, this represents the Transport Independent Application
32 // Specific maximum bandwidth defined in RFC3890. If null, there is no
33 // maximum bitrate.
Taylor Brandstetterf8711c02016-03-29 17:21:29 -070034 public Integer maxBitrateBps;
deadbeefe702b302017-02-04 12:09:01 -080035 // SSRC to be used by this encoding.
36 // Can't be changed between getParameters/setParameters.
deadbeef8014c752017-01-06 16:53:00 -080037 public Long ssrc;
Magnus Jedvert9060eb12017-12-12 12:52:54 +010038
39 @CalledByNative("Encoding")
40 Encoding(boolean active, Integer maxBitrateBps, Long ssrc) {
41 this.active = active;
42 this.maxBitrateBps = maxBitrateBps;
43 this.ssrc = ssrc;
44 }
45
46 @CalledByNative("Encoding")
47 boolean getActive() {
48 return active;
49 }
50
51 @CalledByNative("Encoding")
52 Integer getMaxBitrateBps() {
53 return maxBitrateBps;
54 }
55
56 @CalledByNative("Encoding")
57 Long getSsrc() {
58 return ssrc;
59 }
Taylor Brandstetterf8711c02016-03-29 17:21:29 -070060 }
skvlad303b3c22016-03-24 19:36:46 -070061
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -070062 public static class Codec {
deadbeefe702b302017-02-04 12:09:01 -080063 // Payload type used to identify this codec in RTP packets.
64 public int payloadType;
65 // Name used to identify the codec. Equivalent to MIME subtype.
66 public String name;
67 // The media type of this codec. Equivalent to MIME top-level type.
68 MediaStreamTrack.MediaType kind;
69 // Clock rate in Hertz.
70 public Integer clockRate;
71 // The number of audio channels used. Set to null for video codecs.
72 public Integer numChannels;
Magnus Jedvert9060eb12017-12-12 12:52:54 +010073
74 @CalledByNative("Codec")
75 Codec(int payloadType, String name, MediaStreamTrack.MediaType kind, Integer clockRate,
76 Integer numChannels) {
77 this.payloadType = payloadType;
78 this.name = name;
79 this.kind = kind;
80 this.clockRate = clockRate;
81 this.numChannels = numChannels;
82 }
83
84 @CalledByNative("Codec")
85 int getPayloadType() {
86 return payloadType;
87 }
88
89 @CalledByNative("Codec")
90 String getName() {
91 return name;
92 }
93
94 @CalledByNative("Codec")
95 MediaStreamTrack.MediaType getKind() {
96 return kind;
97 }
98
99 @CalledByNative("Codec")
100 Integer getClockRate() {
101 return clockRate;
102 }
103
104 @CalledByNative("Codec")
105 Integer getNumChannels() {
106 return numChannels;
107 }
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700108 }
109
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100110 public final List<Encoding> encodings;
deadbeefe702b302017-02-04 12:09:01 -0800111 // Codec parameters can't currently be changed between getParameters and
112 // setParameters. Though in the future it will be possible to reorder them or
113 // remove them.
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100114 public final List<Codec> codecs;
115
116 public RtpParameters() {
117 this.encodings = new ArrayList<>();
118 this.codecs = new ArrayList<>();
119 }
120
121 @CalledByNative
122 RtpParameters(List<Encoding> encodings, List<Codec> codecs) {
123 this.encodings = encodings;
124 this.codecs = codecs;
125 }
126
127 @CalledByNative
128 List<Encoding> getEncodings() {
129 return encodings;
130 }
131
132 @CalledByNative
133 List<Codec> getCodecs() {
134 return codecs;
135 }
skvlad303b3c22016-03-24 19:36:46 -0700136}