2016-03-24 19:36:46 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright 2013 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package org.webrtc;
|
|
|
|
|
|
2018-03-22 13:32:44 +01:00
|
|
|
import javax.annotation.Nullable;
|
2017-11-16 16:53:12 +01:00
|
|
|
import java.util.ArrayList;
|
2018-05-15 18:14:14 +02:00
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
2017-12-12 12:52:54 +01:00
|
|
|
import org.webrtc.MediaStreamTrack;
|
2016-03-24 19:36:46 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The parameters for an {@code RtpSender}, as defined in
|
|
|
|
|
* http://w3c.github.io/webrtc-pc/#rtcrtpsender-interface.
|
2017-02-04 12:09:01 -08:00
|
|
|
*
|
|
|
|
|
* Note: These structures use nullable Integer/etc. types because in the
|
|
|
|
|
* future, they may be used to construct ORTC RtpSender/RtpReceivers, in
|
|
|
|
|
* which case "null" will be used to represent "choose the implementation
|
|
|
|
|
* default value".
|
2016-03-24 19:36:46 -07:00
|
|
|
*/
|
|
|
|
|
public class RtpParameters {
|
2016-03-29 17:21:29 -07:00
|
|
|
public static class Encoding {
|
2017-02-04 12:09:01 -08:00
|
|
|
// Set to true to cause this encoding to be sent, and false for it not to
|
|
|
|
|
// be sent.
|
2016-03-29 17:21:29 -07:00
|
|
|
public boolean active = true;
|
2017-02-04 12:09:01 -08:00
|
|
|
// If non-null, this represents the Transport Independent Application
|
|
|
|
|
// Specific maximum bandwidth defined in RFC3890. If null, there is no
|
|
|
|
|
// maximum bitrate.
|
2018-03-22 13:32:44 +01:00
|
|
|
@Nullable public Integer maxBitrateBps;
|
2018-08-13 16:46:57 +02:00
|
|
|
// The minimum bitrate in bps for video.
|
2018-05-29 09:21:31 +02:00
|
|
|
@Nullable public Integer minBitrateBps;
|
2018-08-13 16:46:57 +02:00
|
|
|
// The max framerate in fps for video.
|
|
|
|
|
@Nullable public Integer maxFramerate;
|
2017-02-04 12:09:01 -08:00
|
|
|
// SSRC to be used by this encoding.
|
|
|
|
|
// Can't be changed between getParameters/setParameters.
|
2017-01-06 16:53:00 -08:00
|
|
|
public Long ssrc;
|
2017-12-12 12:52:54 +01:00
|
|
|
|
|
|
|
|
@CalledByNative("Encoding")
|
2018-08-13 16:46:57 +02:00
|
|
|
Encoding(boolean active, Integer maxBitrateBps, Integer minBitrateBps, Integer maxFramerate,
|
|
|
|
|
Long ssrc) {
|
2017-12-12 12:52:54 +01:00
|
|
|
this.active = active;
|
|
|
|
|
this.maxBitrateBps = maxBitrateBps;
|
2018-05-29 09:21:31 +02:00
|
|
|
this.minBitrateBps = minBitrateBps;
|
2018-08-13 16:46:57 +02:00
|
|
|
this.maxFramerate = maxFramerate;
|
2017-12-12 12:52:54 +01:00
|
|
|
this.ssrc = ssrc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@CalledByNative("Encoding")
|
|
|
|
|
boolean getActive() {
|
|
|
|
|
return active;
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-22 13:32:44 +01:00
|
|
|
@Nullable
|
2017-12-12 12:52:54 +01:00
|
|
|
@CalledByNative("Encoding")
|
|
|
|
|
Integer getMaxBitrateBps() {
|
|
|
|
|
return maxBitrateBps;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-29 09:21:31 +02:00
|
|
|
@Nullable
|
|
|
|
|
@CalledByNative("Encoding")
|
|
|
|
|
Integer getMinBitrateBps() {
|
|
|
|
|
return minBitrateBps;
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-13 16:46:57 +02:00
|
|
|
@Nullable
|
|
|
|
|
@CalledByNative("Encoding")
|
|
|
|
|
Integer getMaxFramerate() {
|
|
|
|
|
return maxFramerate;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-12 12:52:54 +01:00
|
|
|
@CalledByNative("Encoding")
|
|
|
|
|
Long getSsrc() {
|
|
|
|
|
return ssrc;
|
|
|
|
|
}
|
2016-03-29 17:21:29 -07:00
|
|
|
}
|
2016-03-24 19:36:46 -07:00
|
|
|
|
2016-04-20 16:23:10 -07:00
|
|
|
public static class Codec {
|
2017-02-04 12:09:01 -08:00
|
|
|
// Payload type used to identify this codec in RTP packets.
|
|
|
|
|
public int payloadType;
|
|
|
|
|
// Name used to identify the codec. Equivalent to MIME subtype.
|
|
|
|
|
public String name;
|
|
|
|
|
// The media type of this codec. Equivalent to MIME top-level type.
|
|
|
|
|
MediaStreamTrack.MediaType kind;
|
|
|
|
|
// Clock rate in Hertz.
|
|
|
|
|
public Integer clockRate;
|
|
|
|
|
// The number of audio channels used. Set to null for video codecs.
|
|
|
|
|
public Integer numChannels;
|
2018-05-15 18:14:14 +02:00
|
|
|
// The "format specific parameters" field from the "a=fmtp" line in the SDP
|
|
|
|
|
public Map<String, String> parameters;
|
2017-12-12 12:52:54 +01:00
|
|
|
|
|
|
|
|
@CalledByNative("Codec")
|
|
|
|
|
Codec(int payloadType, String name, MediaStreamTrack.MediaType kind, Integer clockRate,
|
2018-05-15 18:14:14 +02:00
|
|
|
Integer numChannels, Map<String, String> parameters) {
|
2017-12-12 12:52:54 +01:00
|
|
|
this.payloadType = payloadType;
|
|
|
|
|
this.name = name;
|
|
|
|
|
this.kind = kind;
|
|
|
|
|
this.clockRate = clockRate;
|
|
|
|
|
this.numChannels = numChannels;
|
2018-05-15 18:14:14 +02:00
|
|
|
this.parameters = parameters;
|
2017-12-12 12:52:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@CalledByNative("Codec")
|
|
|
|
|
int getPayloadType() {
|
|
|
|
|
return payloadType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@CalledByNative("Codec")
|
|
|
|
|
String getName() {
|
|
|
|
|
return name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@CalledByNative("Codec")
|
|
|
|
|
MediaStreamTrack.MediaType getKind() {
|
|
|
|
|
return kind;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@CalledByNative("Codec")
|
|
|
|
|
Integer getClockRate() {
|
|
|
|
|
return clockRate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@CalledByNative("Codec")
|
|
|
|
|
Integer getNumChannels() {
|
|
|
|
|
return numChannels;
|
|
|
|
|
}
|
2018-05-15 18:14:14 +02:00
|
|
|
|
|
|
|
|
@CalledByNative("Codec")
|
|
|
|
|
Map getParameters() {
|
|
|
|
|
return parameters;
|
|
|
|
|
}
|
2016-04-20 16:23:10 -07:00
|
|
|
}
|
|
|
|
|
|
2018-05-24 16:24:21 +02:00
|
|
|
public static class Rtcp {
|
|
|
|
|
/** The Canonical Name used by RTCP */
|
|
|
|
|
private final String cname;
|
|
|
|
|
/** Whether reduced size RTCP is configured or compound RTCP */
|
|
|
|
|
private final boolean reducedSize;
|
|
|
|
|
|
|
|
|
|
@CalledByNative("Rtcp")
|
|
|
|
|
Rtcp(String cname, boolean reducedSize) {
|
|
|
|
|
this.cname = cname;
|
|
|
|
|
this.reducedSize = reducedSize;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@CalledByNative("Rtcp")
|
|
|
|
|
public String getCname() {
|
|
|
|
|
return cname;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@CalledByNative("Rtcp")
|
|
|
|
|
public boolean getReducedSize() {
|
|
|
|
|
return reducedSize;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-12 18:33:49 +02:00
|
|
|
public static class HeaderExtension {
|
|
|
|
|
/** The URI of the RTP header extension, as defined in RFC5285. */
|
|
|
|
|
private final String uri;
|
|
|
|
|
/** The value put in the RTP packet to identify the header extension. */
|
|
|
|
|
private final int id;
|
|
|
|
|
/** Whether the header extension is encrypted or not. */
|
|
|
|
|
private final boolean encrypted;
|
|
|
|
|
|
|
|
|
|
@CalledByNative("HeaderExtension")
|
|
|
|
|
HeaderExtension(String uri, int id, boolean encrypted) {
|
|
|
|
|
this.uri = uri;
|
|
|
|
|
this.id = id;
|
|
|
|
|
this.encrypted = encrypted;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@CalledByNative("HeaderExtension")
|
|
|
|
|
public String getUri() {
|
|
|
|
|
return uri;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@CalledByNative("HeaderExtension")
|
|
|
|
|
public int getId() {
|
|
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@CalledByNative("HeaderExtension")
|
|
|
|
|
public boolean getEncrypted() {
|
|
|
|
|
return encrypted;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-03 15:31:53 +02:00
|
|
|
public final String transactionId;
|
|
|
|
|
|
2018-05-24 16:24:21 +02:00
|
|
|
private final Rtcp rtcp;
|
|
|
|
|
|
2018-06-12 18:33:49 +02:00
|
|
|
private final List<HeaderExtension> headerExtensions;
|
|
|
|
|
|
2017-12-12 12:52:54 +01:00
|
|
|
public final List<Encoding> encodings;
|
2017-02-04 12:09:01 -08:00
|
|
|
// Codec parameters can't currently be changed between getParameters and
|
|
|
|
|
// setParameters. Though in the future it will be possible to reorder them or
|
|
|
|
|
// remove them.
|
2017-12-12 12:52:54 +01:00
|
|
|
public final List<Codec> codecs;
|
|
|
|
|
|
2018-05-03 15:31:53 +02:00
|
|
|
@CalledByNative
|
2018-06-12 18:33:49 +02:00
|
|
|
RtpParameters(String transactionId, Rtcp rtcp, List<HeaderExtension> headerExtensions,
|
|
|
|
|
List<Encoding> encodings, List<Codec> codecs) {
|
2018-05-03 15:31:53 +02:00
|
|
|
this.transactionId = transactionId;
|
2018-05-24 16:24:21 +02:00
|
|
|
this.rtcp = rtcp;
|
2018-06-12 18:33:49 +02:00
|
|
|
this.headerExtensions = headerExtensions;
|
2018-05-07 06:09:37 +00:00
|
|
|
this.encodings = encodings;
|
|
|
|
|
this.codecs = codecs;
|
2018-05-03 15:31:53 +02:00
|
|
|
}
|
|
|
|
|
|
2018-05-03 15:31:53 +02:00
|
|
|
@CalledByNative
|
|
|
|
|
String getTransactionId() {
|
|
|
|
|
return transactionId;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-24 16:24:21 +02:00
|
|
|
@CalledByNative
|
|
|
|
|
public Rtcp getRtcp() {
|
|
|
|
|
return rtcp;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-12 18:33:49 +02:00
|
|
|
@CalledByNative
|
|
|
|
|
public List<HeaderExtension> getHeaderExtensions() {
|
|
|
|
|
return headerExtensions;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-12 12:52:54 +01:00
|
|
|
@CalledByNative
|
|
|
|
|
List<Encoding> getEncodings() {
|
|
|
|
|
return encodings;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@CalledByNative
|
|
|
|
|
List<Codec> getCodecs() {
|
|
|
|
|
return codecs;
|
|
|
|
|
}
|
2016-03-24 19:36:46 -07:00
|
|
|
}
|