skvlad | 303b3c2 | 2016-03-24 19:36:46 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 11 | package org.webrtc; |
| 12 | |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 13 | import javax.annotation.Nullable; |
Magnus Jedvert | 6062f37 | 2017-11-16 16:53:12 +0100 | [diff] [blame] | 14 | import java.util.List; |
| 15 | import java.util.ArrayList; |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 16 | import org.webrtc.MediaStreamTrack; |
skvlad | 303b3c2 | 2016-03-24 19:36:46 -0700 | [diff] [blame] | 17 | |
| 18 | /** |
| 19 | * The parameters for an {@code RtpSender}, as defined in |
| 20 | * http://w3c.github.io/webrtc-pc/#rtcrtpsender-interface. |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 21 | * |
| 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". |
skvlad | 303b3c2 | 2016-03-24 19:36:46 -0700 | [diff] [blame] | 26 | */ |
| 27 | public class RtpParameters { |
Taylor Brandstetter | f8711c0 | 2016-03-29 17:21:29 -0700 | [diff] [blame] | 28 | public static class Encoding { |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 29 | // Set to true to cause this encoding to be sent, and false for it not to |
| 30 | // be sent. |
Taylor Brandstetter | f8711c0 | 2016-03-29 17:21:29 -0700 | [diff] [blame] | 31 | public boolean active = true; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 32 | // 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äki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 35 | @Nullable public Integer maxBitrateBps; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 36 | // SSRC to be used by this encoding. |
| 37 | // Can't be changed between getParameters/setParameters. |
deadbeef | 8014c75 | 2017-01-06 16:53:00 -0800 | [diff] [blame] | 38 | public Long ssrc; |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 39 | |
| 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äki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 52 | @Nullable |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 53 | @CalledByNative("Encoding") |
| 54 | Integer getMaxBitrateBps() { |
| 55 | return maxBitrateBps; |
| 56 | } |
| 57 | |
| 58 | @CalledByNative("Encoding") |
| 59 | Long getSsrc() { |
| 60 | return ssrc; |
| 61 | } |
Taylor Brandstetter | f8711c0 | 2016-03-29 17:21:29 -0700 | [diff] [blame] | 62 | } |
skvlad | 303b3c2 | 2016-03-24 19:36:46 -0700 | [diff] [blame] | 63 | |
Taylor Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 64 | public static class Codec { |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 65 | // 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 Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 75 | |
| 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 Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 110 | } |
| 111 | |
Florent Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame] | 112 | public final String transactionId; |
| 113 | |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 114 | public final List<Encoding> encodings; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 115 | // Codec parameters can't currently be changed between getParameters and |
| 116 | // setParameters. Though in the future it will be possible to reorder them or |
| 117 | // remove them. |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 118 | public final List<Codec> codecs; |
| 119 | |
Florent Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame] | 120 | @CalledByNative |
| 121 | RtpParameters(String transactionId, List<Encoding> encodings, List<Codec> codecs) { |
| 122 | this.transactionId = transactionId; |
| 123 | this.encodings = encodings; |
| 124 | this.codecs = codecs; |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | @CalledByNative |
Florent Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame] | 128 | String getTransactionId() { |
| 129 | return transactionId; |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | @CalledByNative |
| 133 | List<Encoding> getEncodings() { |
| 134 | return encodings; |
| 135 | } |
| 136 | |
| 137 | @CalledByNative |
| 138 | List<Codec> getCodecs() { |
| 139 | return codecs; |
| 140 | } |
skvlad | 303b3c2 | 2016-03-24 19:36:46 -0700 | [diff] [blame] | 141 | } |