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 | |
Magnus Jedvert | 6062f37 | 2017-11-16 16:53:12 +0100 | [diff] [blame] | 13 | import java.util.List; |
| 14 | import java.util.ArrayList; |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame^] | 15 | import org.webrtc.MediaStreamTrack; |
skvlad | 303b3c2 | 2016-03-24 19:36:46 -0700 | [diff] [blame] | 16 | |
| 17 | /** |
| 18 | * The parameters for an {@code RtpSender}, as defined in |
| 19 | * http://w3c.github.io/webrtc-pc/#rtcrtpsender-interface. |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 20 | * |
| 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". |
skvlad | 303b3c2 | 2016-03-24 19:36:46 -0700 | [diff] [blame] | 25 | */ |
| 26 | public class RtpParameters { |
Taylor Brandstetter | f8711c0 | 2016-03-29 17:21:29 -0700 | [diff] [blame] | 27 | public static class Encoding { |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 28 | // Set to true to cause this encoding to be sent, and false for it not to |
| 29 | // be sent. |
Taylor Brandstetter | f8711c0 | 2016-03-29 17:21:29 -0700 | [diff] [blame] | 30 | public boolean active = true; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 31 | // 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 Brandstetter | f8711c0 | 2016-03-29 17:21:29 -0700 | [diff] [blame] | 34 | public Integer maxBitrateBps; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 35 | // SSRC to be used by this encoding. |
| 36 | // Can't be changed between getParameters/setParameters. |
deadbeef | 8014c75 | 2017-01-06 16:53:00 -0800 | [diff] [blame] | 37 | public Long ssrc; |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame^] | 38 | |
| 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 Brandstetter | f8711c0 | 2016-03-29 17:21:29 -0700 | [diff] [blame] | 60 | } |
skvlad | 303b3c2 | 2016-03-24 19:36:46 -0700 | [diff] [blame] | 61 | |
Taylor Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 62 | public static class Codec { |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 63 | // 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 Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame^] | 73 | |
| 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 Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 108 | } |
| 109 | |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame^] | 110 | public final List<Encoding> encodings; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 111 | // 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 Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame^] | 114 | 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 | } |
skvlad | 303b3c2 | 2016-03-24 19:36:46 -0700 | [diff] [blame] | 136 | } |