From d845dd1b33964eb335474d60f13ffe6c7e179202 Mon Sep 17 00:00:00 2001 From: cloudwebrtc Date: Mon, 30 Jan 2023 23:38:02 +0800 Subject: [PATCH 1/3] feat: Expose setCodecPreferences/getCapabilities. --- sdk/android/BUILD.gn | 4 + .../api/org/webrtc/PeerConnectionFactory.java | 13 +++ .../api/org/webrtc/RtpCapabilities.java | 110 ++++++++++++++++++ .../api/org/webrtc/RtpTransceiver.java | 6 + .../src/jni/pc/peer_connection_factory.cc | 18 +++ sdk/android/src/jni/pc/rtp_capabilities.cc | 107 +++++++++++++++++ sdk/android/src/jni/pc/rtp_capabilities.h | 35 ++++++ sdk/android/src/jni/pc/rtp_transceiver.cc | 11 ++ 8 files changed, 304 insertions(+) create mode 100644 sdk/android/api/org/webrtc/RtpCapabilities.java create mode 100644 sdk/android/src/jni/pc/rtp_capabilities.cc create mode 100644 sdk/android/src/jni/pc/rtp_capabilities.h diff --git a/sdk/android/BUILD.gn b/sdk/android/BUILD.gn index 5ba4a539fd..9f941a8811 100644 --- a/sdk/android/BUILD.gn +++ b/sdk/android/BUILD.gn @@ -287,6 +287,7 @@ if (is_android) { "api/org/webrtc/RTCStatsCollectorCallback.java", "api/org/webrtc/RTCStatsReport.java", "api/org/webrtc/RtcCertificatePem.java", + "api/org/webrtc/RtpCapabilities.java", "api/org/webrtc/RtpParameters.java", "api/org/webrtc/RtpReceiver.java", "api/org/webrtc/RtpSender.java", @@ -754,6 +755,8 @@ if (current_os == "linux" || is_android) { "src/jni/pc/rtc_certificate.h", "src/jni/pc/rtc_stats_collector_callback_wrapper.cc", "src/jni/pc/rtc_stats_collector_callback_wrapper.h", + "src/jni/pc/rtp_capabilities.cc", + "src/jni/pc/rtp_capabilities.h", "src/jni/pc/rtp_parameters.cc", "src/jni/pc/rtp_parameters.h", "src/jni/pc/rtp_receiver.cc", @@ -1423,6 +1426,7 @@ if (current_os == "linux" || is_android) { "api/org/webrtc/RTCStatsCollectorCallback.java", "api/org/webrtc/RTCStatsReport.java", "api/org/webrtc/RtcCertificatePem.java", + "api/org/webrtc/RtpCapabilities.java", "api/org/webrtc/RtpParameters.java", "api/org/webrtc/RtpReceiver.java", "api/org/webrtc/RtpSender.java", diff --git a/sdk/android/api/org/webrtc/PeerConnectionFactory.java b/sdk/android/api/org/webrtc/PeerConnectionFactory.java index ca67b3afc1..e093056b55 100644 --- a/sdk/android/api/org/webrtc/PeerConnectionFactory.java +++ b/sdk/android/api/org/webrtc/PeerConnectionFactory.java @@ -18,6 +18,7 @@ import org.webrtc.PeerConnection; import org.webrtc.audio.AudioDeviceModule; import org.webrtc.audio.JavaAudioDeviceModule; +import org.webrtc.RtpCapabilities; /** * Java wrapper for a C++ PeerConnectionFactoryInterface. Main entry point to @@ -471,6 +472,16 @@ public AudioTrack createAudioTrack(String id, AudioSource source) { return new AudioTrack(nativeCreateAudioTrack(nativeFactory, id, source.getNativeAudioSource())); } + public RtpCapabilities getRtpReceiverCapabilities(MediaStreamTrack.MediaType mediaType) { + checkPeerConnectionFactoryExists(); + return nativeGetRtpReceiverCapabilities(nativeFactory, mediaType); + } + + public RtpCapabilities getRtpSenderCapabilities(MediaStreamTrack.MediaType mediaType) { + checkPeerConnectionFactoryExists(); + return nativeGetRtpSenderCapabilities(nativeFactory, mediaType); + } + // Starts recording an AEC dump. Ownership of the file is transfered to the // native code. If an AEC dump is already in progress, it will be stopped and // a new one will start using the provided file. @@ -615,4 +626,6 @@ private static native boolean nativeStartAecDump( private static native void nativeInjectLoggable(JNILogging jniLogging, int severity); private static native void nativeDeleteLoggable(); private static native void nativePrintStackTrace(int tid); + private static native RtpCapabilities nativeGetRtpSenderCapabilities(long factory, MediaStreamTrack.MediaType mediaType); + private static native RtpCapabilities nativeGetRtpReceiverCapabilities(long factory, MediaStreamTrack.MediaType mediaType); } diff --git a/sdk/android/api/org/webrtc/RtpCapabilities.java b/sdk/android/api/org/webrtc/RtpCapabilities.java new file mode 100644 index 0000000000..c8a38a2ea7 --- /dev/null +++ b/sdk/android/api/org/webrtc/RtpCapabilities.java @@ -0,0 +1,110 @@ +package org.webrtc; + +import androidx.annotation.Nullable; +import java.util.List; +import java.util.Map; +import org.webrtc.MediaStreamTrack; + +public class RtpCapabilities { + public static class CodecCapability { + public int preferredPayloadType; + // 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; + // The "format specific parameters" field from the "a=fmtp" line in the SDP + public Map parameters; + + @CalledByNative("CodecCapability") + CodecCapability(int preferredPayloadType, String name, MediaStreamTrack.MediaType kind, + Integer clockRate, Integer numChannels, Map parameters) { + this.preferredPayloadType = preferredPayloadType; + this.name = name; + this.kind = kind; + this.clockRate = clockRate; + this.numChannels = numChannels; + this.parameters = parameters; + } + + @CalledByNative("CodecCapability") + int getPreferredPayloadType() { + return preferredPayloadType; + } + + @CalledByNative("CodecCapability") + String getName() { + return name; + } + + @CalledByNative("CodecCapability") + MediaStreamTrack.MediaType getKind() { + return kind; + } + + @CalledByNative("CodecCapability") + Integer getClockRate() { + return clockRate; + } + + @CalledByNative("CodecCapability") + Integer getNumChannels() { + return numChannels; + } + + @CalledByNative("CodecCapability") + Map getParameters() { + return parameters; + } + } + + public static class HeaderExtensionCapability { + private final String uri; + private final int preferredId; + private final boolean preferredEncrypted; + + @CalledByNative("HeaderExtensionCapability") + HeaderExtensionCapability(String uri, int preferredId, boolean preferredEncrypted) { + this.uri = uri; + this.preferredId = preferredId; + this.preferredEncrypted = preferredEncrypted; + } + + @CalledByNative("HeaderExtensionCapability") + public String getUri() { + return uri; + } + + @CalledByNative("HeaderExtensionCapability") + public int getPreferredId() { + return preferredId; + } + + @CalledByNative("HeaderExtensionCapability") + public boolean getPreferredEncrypted() { + return preferredEncrypted; + } + } + + public List codecs; + public List headerExtensions; + + @CalledByNative + RtpCapabilities(List codecs, List headerExtensions) { + this.headerExtensions = headerExtensions; + this.codecs = codecs; + } + + @CalledByNative + public List getHeaderExtensions() { + return headerExtensions; + } + + @CalledByNative + List getCodecs() { + return codecs; + } +} \ No newline at end of file diff --git a/sdk/android/api/org/webrtc/RtpTransceiver.java b/sdk/android/api/org/webrtc/RtpTransceiver.java index 1102bd7eb1..17b78b6186 100644 --- a/sdk/android/api/org/webrtc/RtpTransceiver.java +++ b/sdk/android/api/org/webrtc/RtpTransceiver.java @@ -215,6 +215,11 @@ public void stop() { nativeStopInternal(nativeRtpTransceiver); } + public void setCodecPreferences(List codecs) { + checkRtpTransceiverExists(); + nativeSetCodecPreferences(nativeRtpTransceiver, codecs); + } + /** * The StopInternal method stops the RtpTransceiver, like Stop, but goes * immediately to Stopped state. @@ -263,4 +268,5 @@ private void checkRtpTransceiverExists() { private static native void nativeStopStandard(long rtpTransceiver); private static native boolean nativeSetDirection( long rtpTransceiver, RtpTransceiverDirection rtpTransceiverDirection); + private static native void nativeSetCodecPreferences(long rtpTransceiver, List codecs); } diff --git a/sdk/android/src/jni/pc/peer_connection_factory.cc b/sdk/android/src/jni/pc/peer_connection_factory.cc index fafcad3caf..c6c9b76edf 100644 --- a/sdk/android/src/jni/pc/peer_connection_factory.cc +++ b/sdk/android/src/jni/pc/peer_connection_factory.cc @@ -39,7 +39,9 @@ #include "sdk/android/src/jni/logging/log_sink.h" #include "sdk/android/src/jni/pc/android_network_monitor.h" #include "sdk/android/src/jni/pc/audio.h" +#include "sdk/android/src/jni/pc/rtp_capabilities.h" #include "sdk/android/src/jni/pc/ice_candidate.h" +#include "sdk/android/src/jni/pc/media_stream_track.h" #include "sdk/android/src/jni/pc/owned_factory_and_threads.h" #include "sdk/android/src/jni/pc/peer_connection.h" #include "sdk/android/src/jni/pc/ssl_certificate_verifier_wrapper.h" @@ -413,6 +415,22 @@ jlong JNI_PeerConnectionFactory_CreateAudioTrack( return jlongFromPointer(track.release()); } +ScopedJavaLocalRef JNI_PeerConnectionFactory_GetRtpSenderCapabilities( + JNIEnv* jni, + jlong native_factory, + const JavaParamRef& media_type) { + auto factory = PeerConnectionFactoryFromJava(native_factory); + return NativeToJavaRtpCapabilities(jni, factory->GetRtpSenderCapabilities(JavaToNativeMediaType(jni, media_type))); +} + +ScopedJavaLocalRef JNI_PeerConnectionFactory_GetRtpReceiverCapabilities( + JNIEnv* jni, + jlong native_factory, + const JavaParamRef& media_type) { + auto factory = PeerConnectionFactoryFromJava(native_factory); + return NativeToJavaRtpCapabilities(jni, factory->GetRtpReceiverCapabilities(JavaToNativeMediaType(jni, media_type))); +} + static jboolean JNI_PeerConnectionFactory_StartAecDump( JNIEnv* jni, jlong native_factory, diff --git a/sdk/android/src/jni/pc/rtp_capabilities.cc b/sdk/android/src/jni/pc/rtp_capabilities.cc new file mode 100644 index 0000000000..f729bed3d5 --- /dev/null +++ b/sdk/android/src/jni/pc/rtp_capabilities.cc @@ -0,0 +1,107 @@ +/* + * Copyright 2017 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. + */ + +#include "sdk/android/src/jni/pc/rtp_capabilities.h" + +#include "sdk/android/generated_peerconnection_jni/RtpCapabilities_jni.h" +#include "sdk/android/native_api/jni/java_types.h" +#include "sdk/android/src/jni/jni_helpers.h" +#include "sdk/android/src/jni/pc/media_stream_track.h" + +namespace webrtc { +namespace jni { + +namespace { + +ScopedJavaLocalRef NativeToJavaRtpCodecParameter( + JNIEnv* env, + const RtpCodecCapability& codec) { + return Java_CodecCapability_Constructor(env, codec.preferred_payload_type.value(), + NativeToJavaString(env, codec.name), + NativeToJavaMediaType(env, codec.kind), + NativeToJavaInteger(env, codec.clock_rate), + NativeToJavaInteger(env, codec.num_channels), + NativeToJavaStringMap(env, codec.parameters)); +} + +ScopedJavaLocalRef NativeToJavaRtpHeaderExtensionParameter( + JNIEnv* env, + const RtpHeaderExtensionCapability& extension) { + return Java_HeaderExtensionCapability_Constructor( + env, NativeToJavaString(env, extension.uri), extension.preferred_id.value(), + extension.preferred_encrypt); +} +} // namespace + +RtpCapabilities JavaToNativeRtpCapabilities(JNIEnv* jni, + const JavaRef& j_capabilities) { + RtpCapabilities capabilities; + + ScopedJavaLocalRef j_header_extensions = + Java_RtpCapabilities_getHeaderExtensions(jni, j_capabilities); + for (const JavaRef& j_header_extension : + Iterable(jni, j_header_extensions)) { + RtpHeaderExtensionCapability header_extension; + header_extension.uri = JavaToStdString( + jni, Java_HeaderExtensionCapability_getUri(jni, j_header_extension)); + header_extension.preferred_id = Java_HeaderExtensionCapability_getPreferredId(jni, j_header_extension); + header_extension.preferred_encrypt = + Java_HeaderExtensionCapability_getPreferredEncrypted(jni, j_header_extension); + capabilities.header_extensions.push_back(header_extension); + } + + // Convert codecs. + ScopedJavaLocalRef j_codecs = + Java_RtpCapabilities_getCodecs(jni, j_capabilities); + for (const JavaRef& j_codec : Iterable(jni, j_codecs)) { + RtpCodecCapability codec; + codec.preferred_payload_type = Java_CodecCapability_getPreferredPayloadType(jni, j_codec); + codec.name = JavaToStdString(jni, Java_CodecCapability_getName(jni, j_codec)); + codec.kind = JavaToNativeMediaType(jni, Java_CodecCapability_getKind(jni, j_codec)); + codec.clock_rate = + JavaToNativeOptionalInt(jni, Java_CodecCapability_getClockRate(jni, j_codec)); + codec.num_channels = + JavaToNativeOptionalInt(jni, Java_CodecCapability_getNumChannels(jni, j_codec)); + auto parameters_map = + JavaToNativeStringMap(jni, Java_CodecCapability_getParameters(jni, j_codec)); + codec.parameters.insert(parameters_map.begin(), parameters_map.end()); + capabilities.codecs.push_back(codec); + } + return capabilities; +} + +ScopedJavaLocalRef NativeToJavaRtpCapabilities( + JNIEnv* env, + const RtpCapabilities& capabilities) { + return Java_RtpCapabilities_Constructor( + env, NativeToJavaList(env, capabilities.codecs, &NativeToJavaRtpCodecParameter), + NativeToJavaList(env, capabilities.header_extensions, + &NativeToJavaRtpHeaderExtensionParameter) + ); +} + +RtpCodecCapability JavaToNativeRtpCodecCapability(JNIEnv* jni, + const JavaRef& j_codec) { + RtpCodecCapability codec; + codec.preferred_payload_type = Java_CodecCapability_getPreferredPayloadType(jni, j_codec); + codec.name = JavaToStdString(jni, Java_CodecCapability_getName(jni, j_codec)); + codec.kind = JavaToNativeMediaType(jni, Java_CodecCapability_getKind(jni, j_codec)); + codec.clock_rate = + JavaToNativeOptionalInt(jni, Java_CodecCapability_getClockRate(jni, j_codec)); + codec.num_channels = + JavaToNativeOptionalInt(jni, Java_CodecCapability_getNumChannels(jni, j_codec)); + auto parameters_map = + JavaToNativeStringMap(jni, Java_CodecCapability_getParameters(jni, j_codec)); + codec.parameters.insert(parameters_map.begin(), parameters_map.end()); + return codec; +} + +} // namespace jni +} // namespace webrtc diff --git a/sdk/android/src/jni/pc/rtp_capabilities.h b/sdk/android/src/jni/pc/rtp_capabilities.h new file mode 100644 index 0000000000..f510383046 --- /dev/null +++ b/sdk/android/src/jni/pc/rtp_capabilities.h @@ -0,0 +1,35 @@ +/* + * Copyright 2017 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. + */ + +#ifndef SDK_ANDROID_SRC_JNI_PC_RTP_CAPABLILITES_H_ +#define SDK_ANDROID_SRC_JNI_PC_RTP_CAPABLILITES_H_ + +#include + +#include "api/rtp_parameters.h" +#include "sdk/android/native_api/jni/scoped_java_ref.h" + +namespace webrtc { +namespace jni { + +RtpCapabilities JavaToNativeRtpCapabilities(JNIEnv* jni, + const JavaRef& j_capabilities); + +ScopedJavaLocalRef NativeToJavaRtpCapabilities( + JNIEnv* jni, + const RtpCapabilities& capabilities); + +RtpCodecCapability JavaToNativeRtpCodecCapability(JNIEnv* jni, + const JavaRef& j_codec_capability); + +} // namespace jni +} // namespace webrtc + +#endif // SDK_ANDROID_SRC_JNI_PC_RTP_CAPABLILITES_H_ diff --git a/sdk/android/src/jni/pc/rtp_transceiver.cc b/sdk/android/src/jni/pc/rtp_transceiver.cc index 1d468461f1..34cba6ab5f 100644 --- a/sdk/android/src/jni/pc/rtp_transceiver.cc +++ b/sdk/android/src/jni/pc/rtp_transceiver.cc @@ -16,6 +16,7 @@ #include "sdk/android/native_api/jni/java_types.h" #include "sdk/android/src/jni/jni_helpers.h" #include "sdk/android/src/jni/pc/media_stream_track.h" +#include "sdk/android/src/jni/pc/rtp_capabilities.h" #include "sdk/android/src/jni/pc/rtp_parameters.h" #include "sdk/android/src/jni/pc/rtp_receiver.h" #include "sdk/android/src/jni/pc/rtp_sender.h" @@ -139,6 +140,16 @@ ScopedJavaLocalRef JNI_RtpTransceiver_CurrentDirection( : nullptr; } + +void JNI_RtpTransceiver_SetCodecPreferences(JNIEnv* jni, + jlong j_rtp_transceiver_pointer, + const JavaParamRef& j_codecs) { + std::vector codecs = + JavaListToNativeVector( + jni, j_codecs, &JavaToNativeRtpCodecCapability); + reinterpret_cast(j_rtp_transceiver_pointer)->SetCodecPreferences(codecs); +} + void JNI_RtpTransceiver_StopInternal(JNIEnv* jni, jlong j_rtp_transceiver_pointer) { reinterpret_cast(j_rtp_transceiver_pointer) From a64b257dcad689e7d2d951188e850d9c7691952b Mon Sep 17 00:00:00 2001 From: cloudwebrtc Date: Mon, 30 Jan 2023 23:46:23 +0800 Subject: [PATCH 2/3] chore: update license. --- .../api/org/webrtc/RtpCapabilities.java | 21 ++++++++++++++++++- sdk/android/src/jni/pc/rtp_capabilities.cc | 19 +++++++++++------ sdk/android/src/jni/pc/rtp_capabilities.h | 18 ++++++++++------ 3 files changed, 45 insertions(+), 13 deletions(-) diff --git a/sdk/android/api/org/webrtc/RtpCapabilities.java b/sdk/android/api/org/webrtc/RtpCapabilities.java index c8a38a2ea7..8170799e21 100644 --- a/sdk/android/api/org/webrtc/RtpCapabilities.java +++ b/sdk/android/api/org/webrtc/RtpCapabilities.java @@ -1,3 +1,19 @@ +/* + * Copyright 2023 LiveKit + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.webrtc; import androidx.annotation.Nullable; @@ -18,16 +34,19 @@ public static class CodecCapability { public Integer numChannels; // The "format specific parameters" field from the "a=fmtp" line in the SDP public Map parameters; + // The MIME type of the codec. This is a convenience field. + public String mimeType; @CalledByNative("CodecCapability") CodecCapability(int preferredPayloadType, String name, MediaStreamTrack.MediaType kind, - Integer clockRate, Integer numChannels, Map parameters) { + Integer clockRate, Integer numChannels, String mimeType, Map parameters) { this.preferredPayloadType = preferredPayloadType; this.name = name; this.kind = kind; this.clockRate = clockRate; this.numChannels = numChannels; this.parameters = parameters; + this.mimeType = mimeType; } @CalledByNative("CodecCapability") diff --git a/sdk/android/src/jni/pc/rtp_capabilities.cc b/sdk/android/src/jni/pc/rtp_capabilities.cc index f729bed3d5..fb71491ee1 100644 --- a/sdk/android/src/jni/pc/rtp_capabilities.cc +++ b/sdk/android/src/jni/pc/rtp_capabilities.cc @@ -1,11 +1,17 @@ /* - * Copyright 2017 The WebRTC project authors. All Rights Reserved. + * Copyright 2023 LiveKit * - * 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. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #include "sdk/android/src/jni/pc/rtp_capabilities.h" @@ -28,6 +34,7 @@ ScopedJavaLocalRef NativeToJavaRtpCodecParameter( NativeToJavaMediaType(env, codec.kind), NativeToJavaInteger(env, codec.clock_rate), NativeToJavaInteger(env, codec.num_channels), + NativeToJavaString(env, codec.mime_type()), NativeToJavaStringMap(env, codec.parameters)); } diff --git a/sdk/android/src/jni/pc/rtp_capabilities.h b/sdk/android/src/jni/pc/rtp_capabilities.h index f510383046..4acf611c82 100644 --- a/sdk/android/src/jni/pc/rtp_capabilities.h +++ b/sdk/android/src/jni/pc/rtp_capabilities.h @@ -1,11 +1,17 @@ /* - * Copyright 2017 The WebRTC project authors. All Rights Reserved. + * Copyright 2023 LiveKit * - * 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. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #ifndef SDK_ANDROID_SRC_JNI_PC_RTP_CAPABLILITES_H_ From e69a48f816effed48478645ad62872d31be7fbe9 Mon Sep 17 00:00:00 2001 From: cloudwebrtc Date: Tue, 31 Jan 2023 14:16:51 +0800 Subject: [PATCH 3/3] fix bugs. --- sdk/android/api/org/webrtc/RtpCapabilities.java | 4 +++- sdk/android/api/org/webrtc/RtpTransceiver.java | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/sdk/android/api/org/webrtc/RtpCapabilities.java b/sdk/android/api/org/webrtc/RtpCapabilities.java index 8170799e21..612acb8cf6 100644 --- a/sdk/android/api/org/webrtc/RtpCapabilities.java +++ b/sdk/android/api/org/webrtc/RtpCapabilities.java @@ -27,7 +27,7 @@ public static class CodecCapability { // 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; + public MediaStreamTrack.MediaType kind; // Clock rate in Hertz. public Integer clockRate; // The number of audio channels used. Set to null for video codecs. @@ -37,6 +37,8 @@ public static class CodecCapability { // The MIME type of the codec. This is a convenience field. public String mimeType; + public CodecCapability() {} + @CalledByNative("CodecCapability") CodecCapability(int preferredPayloadType, String name, MediaStreamTrack.MediaType kind, Integer clockRate, Integer numChannels, String mimeType, Map parameters) { diff --git a/sdk/android/api/org/webrtc/RtpTransceiver.java b/sdk/android/api/org/webrtc/RtpTransceiver.java index 17b78b6186..b60ac6450a 100644 --- a/sdk/android/api/org/webrtc/RtpTransceiver.java +++ b/sdk/android/api/org/webrtc/RtpTransceiver.java @@ -215,7 +215,7 @@ public void stop() { nativeStopInternal(nativeRtpTransceiver); } - public void setCodecPreferences(List codecs) { + public void setCodecPreferences(List codecs) { checkRtpTransceiverExists(); nativeSetCodecPreferences(nativeRtpTransceiver, codecs); } @@ -268,5 +268,5 @@ private void checkRtpTransceiverExists() { private static native void nativeStopStandard(long rtpTransceiver); private static native boolean nativeSetDirection( long rtpTransceiver, RtpTransceiverDirection rtpTransceiverDirection); - private static native void nativeSetCodecPreferences(long rtpTransceiver, List codecs); + private static native void nativeSetCodecPreferences(long rtpTransceiver, List codecs); }