Skip to content

Commit 80c8abb

Browse files
authored
Merge pull request #233 from GetStream/migrate/m125
Patch to m125
2 parents 83836b7 + 7841703 commit 80c8abb

35 files changed

+915
-464
lines changed

stream-webrtc-android/api/stream-webrtc-android.api

Lines changed: 74 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,16 @@ public class org/webrtc/AudioSource : org/webrtc/MediaSource {
2121

2222
public class org/webrtc/AudioTrack : org/webrtc/MediaStreamTrack {
2323
public fun <init> (J)V
24+
public fun addSink (Lorg/webrtc/AudioTrackSink;)V
25+
public fun dispose ()V
26+
public fun removeSink (Lorg/webrtc/AudioTrackSink;)V
2427
public fun setVolume (D)V
2528
}
2629

30+
public abstract interface class org/webrtc/AudioTrackSink {
31+
public abstract fun onData (Ljava/nio/ByteBuffer;IIIIJ)V
32+
}
33+
2734
public class org/webrtc/BuiltinAudioDecoderFactoryFactory : org/webrtc/AudioDecoderFactoryFactory {
2835
public fun <init> ()V
2936
public fun createNativeAudioDecoderFactory ()J
@@ -450,6 +457,59 @@ public class org/webrtc/FileVideoCapturer : org/webrtc/VideoCapturer {
450457
public fun tick ()V
451458
}
452459

460+
public class org/webrtc/FrameCryptor {
461+
public fun <init> (J)V
462+
public fun dispose ()V
463+
public fun getKeyIndex ()I
464+
public fun getNativeFrameCryptor ()J
465+
public fun isEnabled ()Z
466+
public fun setEnabled (Z)V
467+
public fun setKeyIndex (I)V
468+
public fun setObserver (Lorg/webrtc/FrameCryptor$Observer;)V
469+
}
470+
471+
public final class org/webrtc/FrameCryptor$FrameCryptionState : java/lang/Enum {
472+
public static final field DECRYPTIONFAILED Lorg/webrtc/FrameCryptor$FrameCryptionState;
473+
public static final field ENCRYPTIONFAILED Lorg/webrtc/FrameCryptor$FrameCryptionState;
474+
public static final field INTERNALERROR Lorg/webrtc/FrameCryptor$FrameCryptionState;
475+
public static final field KEYRATCHETED Lorg/webrtc/FrameCryptor$FrameCryptionState;
476+
public static final field MISSINGKEY Lorg/webrtc/FrameCryptor$FrameCryptionState;
477+
public static final field NEW Lorg/webrtc/FrameCryptor$FrameCryptionState;
478+
public static final field OK Lorg/webrtc/FrameCryptor$FrameCryptionState;
479+
public static fun valueOf (Ljava/lang/String;)Lorg/webrtc/FrameCryptor$FrameCryptionState;
480+
public static fun values ()[Lorg/webrtc/FrameCryptor$FrameCryptionState;
481+
}
482+
483+
public abstract interface class org/webrtc/FrameCryptor$Observer {
484+
public abstract fun onFrameCryptionStateChanged (Ljava/lang/String;Lorg/webrtc/FrameCryptor$FrameCryptionState;)V
485+
}
486+
487+
public final class org/webrtc/FrameCryptorAlgorithm : java/lang/Enum {
488+
public static final field AES_GCM Lorg/webrtc/FrameCryptorAlgorithm;
489+
public static fun valueOf (Ljava/lang/String;)Lorg/webrtc/FrameCryptorAlgorithm;
490+
public static fun values ()[Lorg/webrtc/FrameCryptorAlgorithm;
491+
}
492+
493+
public class org/webrtc/FrameCryptorFactory {
494+
public fun <init> ()V
495+
public static fun createFrameCryptorForRtpReceiver (Lorg/webrtc/PeerConnectionFactory;Lorg/webrtc/RtpReceiver;Ljava/lang/String;Lorg/webrtc/FrameCryptorAlgorithm;Lorg/webrtc/FrameCryptorKeyProvider;)Lorg/webrtc/FrameCryptor;
496+
public static fun createFrameCryptorForRtpSender (Lorg/webrtc/PeerConnectionFactory;Lorg/webrtc/RtpSender;Ljava/lang/String;Lorg/webrtc/FrameCryptorAlgorithm;Lorg/webrtc/FrameCryptorKeyProvider;)Lorg/webrtc/FrameCryptor;
497+
public static fun createFrameCryptorKeyProvider (Z[BI[BIIZ)Lorg/webrtc/FrameCryptorKeyProvider;
498+
}
499+
500+
public class org/webrtc/FrameCryptorKeyProvider {
501+
public fun <init> (J)V
502+
public fun dispose ()V
503+
public fun exportKey (Ljava/lang/String;I)[B
504+
public fun exportSharedKey (I)[B
505+
public fun getNativeKeyProvider ()J
506+
public fun ratchetKey (Ljava/lang/String;I)[B
507+
public fun ratchetSharedKey (I)[B
508+
public fun setKey (Ljava/lang/String;I[B)Z
509+
public fun setSharedKey (I[B)Z
510+
public fun setSifTrailer ([B)V
511+
}
512+
453513
public abstract interface class org/webrtc/FrameDecryptor {
454514
public abstract fun getNativeFrameDecryptor ()J
455515
}
@@ -566,7 +626,7 @@ public class org/webrtc/LibaomAv1Decoder : org/webrtc/WrappedNativeVideoDecoder
566626

567627
public class org/webrtc/LibaomAv1Encoder : org/webrtc/WrappedNativeVideoEncoder {
568628
public fun <init> ()V
569-
public fun createNativeVideoEncoder ()J
629+
public fun createNative (J)J
570630
public fun isHardwareEncoder ()Z
571631
}
572632

@@ -577,7 +637,7 @@ public class org/webrtc/LibvpxVp8Decoder : org/webrtc/WrappedNativeVideoDecoder
577637

578638
public class org/webrtc/LibvpxVp8Encoder : org/webrtc/WrappedNativeVideoEncoder {
579639
public fun <init> ()V
580-
public fun createNativeVideoEncoder ()J
640+
public fun createNative (J)J
581641
public fun isHardwareEncoder ()Z
582642
}
583643

@@ -588,7 +648,7 @@ public class org/webrtc/LibvpxVp9Decoder : org/webrtc/WrappedNativeVideoDecoder
588648

589649
public class org/webrtc/LibvpxVp9Encoder : org/webrtc/WrappedNativeVideoEncoder {
590650
public fun <init> ()V
591-
public fun createNativeVideoEncoder ()J
651+
public fun createNative (J)J
592652
public fun isHardwareEncoder ()Z
593653
}
594654

@@ -702,6 +762,7 @@ public class org/webrtc/MediaStreamTrack {
702762
public fun dispose ()V
703763
public fun enabled ()Z
704764
public fun id ()Ljava/lang/String;
765+
public fun isDisposed ()Z
705766
public fun kind ()Ljava/lang/String;
706767
public fun setEnabled (Z)Z
707768
public fun state ()Lorg/webrtc/MediaStreamTrack$State;
@@ -1057,18 +1118,17 @@ public final class org/webrtc/PeerConnection$PortPrunePolicy : java/lang/Enum {
10571118

10581119
public class org/webrtc/PeerConnection$RTCConfiguration {
10591120
public field activeResetSrtpParams Z
1060-
public field allowCodecSwitching Ljava/lang/Boolean;
10611121
public field audioJitterBufferFastAccelerate Z
10621122
public field audioJitterBufferMaxPackets I
10631123
public field bundlePolicy Lorg/webrtc/PeerConnection$BundlePolicy;
10641124
public field candidateNetworkPolicy Lorg/webrtc/PeerConnection$CandidateNetworkPolicy;
10651125
public field certificate Lorg/webrtc/RtcCertificatePem;
1066-
public field combinedAudioVideoBwe Ljava/lang/Boolean;
10671126
public field continualGatheringPolicy Lorg/webrtc/PeerConnection$ContinualGatheringPolicy;
10681127
public field cryptoOptions Lorg/webrtc/CryptoOptions;
10691128
public field disableIPv6OnWifi Z
10701129
public field enableCpuOveruseDetection Z
10711130
public field enableDscp Z
1131+
public field enableIceGatheringOnAnyAddressPorts Z
10721132
public field enableImplicitRollback Z
10731133
public field iceBackupCandidatePairPingInterval I
10741134
public field iceCandidatePoolSize I
@@ -1514,7 +1574,7 @@ public final class org/webrtc/SimulcastAlignedVideoEncoderFactory : org/webrtc/V
15141574

15151575
public class org/webrtc/SimulcastVideoEncoder : org/webrtc/WrappedNativeVideoEncoder {
15161576
public fun <init> (Lorg/webrtc/VideoEncoderFactory;Lorg/webrtc/VideoEncoderFactory;Lorg/webrtc/VideoCodecInfo;)V
1517-
public fun createNativeVideoEncoder ()J
1577+
public fun createNative (J)J
15181578
public fun isHardwareEncoder ()Z
15191579
}
15201580

@@ -1703,9 +1763,9 @@ public class org/webrtc/VideoCodecInfo {
17031763
public final field name Ljava/lang/String;
17041764
public final field params Ljava/util/Map;
17051765
public final field payload I
1706-
public field scalabilityModes [I
1766+
public final field scalabilityModes Ljava/util/List;
17071767
public fun <init> (ILjava/lang/String;Ljava/util/Map;)V
1708-
public fun <init> (Ljava/lang/String;Ljava/util/Map;)V
1768+
public fun <init> (Ljava/lang/String;Ljava/util/Map;Ljava/util/List;)V
17091769
public fun equals (Ljava/lang/Object;)Z
17101770
public fun hashCode ()I
17111771
public fun toString ()Ljava/lang/String;
@@ -1766,7 +1826,7 @@ public class org/webrtc/VideoDecoderFallback : org/webrtc/WrappedNativeVideoDeco
17661826
}
17671827

17681828
public abstract interface class org/webrtc/VideoEncoder {
1769-
public fun createNativeVideoEncoder ()J
1829+
public fun createNative (J)J
17701830
public abstract fun encode (Lorg/webrtc/VideoFrame;Lorg/webrtc/VideoEncoder$EncodeInfo;)Lorg/webrtc/VideoCodecStatus;
17711831
public fun getEncoderInfo ()Lorg/webrtc/VideoEncoder$EncoderInfo;
17721832
public abstract fun getImplementationName ()Ljava/lang/String;
@@ -1885,7 +1945,7 @@ public abstract interface class org/webrtc/VideoEncoderFactory$VideoEncoderSelec
18851945

18861946
public class org/webrtc/VideoEncoderFallback : org/webrtc/WrappedNativeVideoEncoder {
18871947
public fun <init> (Lorg/webrtc/VideoEncoder;Lorg/webrtc/VideoEncoder;)V
1888-
public fun createNativeVideoEncoder ()J
1948+
public fun createNative (J)J
18891949
public fun isHardwareEncoder ()Z
18901950
}
18911951

@@ -2028,7 +2088,7 @@ public abstract class org/webrtc/WrappedNativeVideoDecoder : org/webrtc/VideoDec
20282088

20292089
public abstract class org/webrtc/WrappedNativeVideoEncoder : org/webrtc/VideoEncoder {
20302090
public fun <init> ()V
2031-
public abstract fun createNativeVideoEncoder ()J
2091+
public abstract fun createNative (J)J
20322092
public final fun encode (Lorg/webrtc/VideoFrame;Lorg/webrtc/VideoEncoder$EncodeInfo;)Lorg/webrtc/VideoCodecStatus;
20332093
public final fun getImplementationName ()Ljava/lang/String;
20342094
public final fun getScalingSettings ()Lorg/webrtc/VideoEncoder$ScalingSettings;
@@ -2070,6 +2130,8 @@ public abstract interface class org/webrtc/audio/AudioDeviceModule {
20702130
public abstract fun getNativeAudioDeviceModulePointer ()J
20712131
public abstract fun release ()V
20722132
public abstract fun setMicrophoneMute (Z)V
2133+
public fun setNoiseSuppressorEnabled (Z)Z
2134+
public fun setPreferredMicrophoneFieldDimension (F)Z
20732135
public abstract fun setSpeakerMute (Z)V
20742136
}
20752137

@@ -2084,6 +2146,7 @@ public class org/webrtc/audio/JavaAudioDeviceModule : org/webrtc/audio/AudioDevi
20842146
public static fun isBuiltInNoiseSuppressorSupported ()Z
20852147
public fun release ()V
20862148
public fun setMicrophoneMute (Z)V
2149+
public fun setNoiseSuppressorEnabled (Z)Z
20872150
public fun setPreferredInputDevice (Landroid/media/AudioDeviceInfo;)V
20882151
public fun setSpeakerMute (Z)V
20892152
}
@@ -2136,7 +2199,6 @@ public class org/webrtc/audio/JavaAudioDeviceModule$Builder {
21362199
public fun createAudioDeviceModule ()Lorg/webrtc/audio/JavaAudioDeviceModule;
21372200
public fun setAudioAttributes (Landroid/media/AudioAttributes;)Lorg/webrtc/audio/JavaAudioDeviceModule$Builder;
21382201
public fun setAudioFormat (I)Lorg/webrtc/audio/JavaAudioDeviceModule$Builder;
2139-
public fun setAudioRecordDataCallback (Lorg/webrtc/audio/AudioRecordDataCallback;)Lorg/webrtc/audio/JavaAudioDeviceModule$Builder;
21402202
public fun setAudioRecordErrorCallback (Lorg/webrtc/audio/JavaAudioDeviceModule$AudioRecordErrorCallback;)Lorg/webrtc/audio/JavaAudioDeviceModule$Builder;
21412203
public fun setAudioRecordStateCallback (Lorg/webrtc/audio/JavaAudioDeviceModule$AudioRecordStateCallback;)Lorg/webrtc/audio/JavaAudioDeviceModule$Builder;
21422204
public fun setAudioSource (I)Lorg/webrtc/audio/JavaAudioDeviceModule$Builder;
Binary file not shown.
Binary file not shown.
261 KB
Binary file not shown.
35.7 KB
Binary file not shown.

stream-webrtc-android/src/main/java/org/webrtc/AudioTrack.java

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@
1010

1111
package org.webrtc;
1212

13+
import java.util.IdentityHashMap;
14+
1315
/** Java wrapper for a C++ AudioTrackInterface */
1416
public class AudioTrack extends MediaStreamTrack {
17+
private final IdentityHashMap<AudioTrackSink, Long> sinks = new IdentityHashMap<AudioTrackSink, Long>();
18+
1519
public AudioTrack(long nativeTrack) {
1620
super(nativeTrack);
1721
}
@@ -23,10 +27,54 @@ public void setVolume(double volume) {
2327
nativeSetVolume(getNativeAudioTrack(), volume);
2428
}
2529

30+
/**
31+
* Adds an AudioTrackSink to the track. This callback is only
32+
* called for remote audio tracks.
33+
*
34+
* Repeated addSink calls will not add the sink multiple times.
35+
*/
36+
public void addSink(AudioTrackSink sink) {
37+
if (sink == null) {
38+
throw new IllegalArgumentException("The AudioTrackSink is not allowed to be null");
39+
}
40+
if (!sinks.containsKey(sink)) {
41+
final long nativeSink = nativeWrapSink(sink);
42+
sinks.put(sink, nativeSink);
43+
nativeAddSink(getNativeMediaStreamTrack(), nativeSink);
44+
}
45+
}
46+
47+
/**
48+
* Removes an AudioTrackSink from the track.
49+
*
50+
* If the AudioTrackSink was not attached to the track, this is a no-op.
51+
*/
52+
public void removeSink(AudioTrackSink sink) {
53+
final Long nativeSink = sinks.remove(sink);
54+
if (nativeSink != null) {
55+
nativeRemoveSink(getNativeMediaStreamTrack(), nativeSink);
56+
nativeFreeSink(nativeSink);
57+
}
58+
}
59+
60+
@Override
61+
public void dispose() {
62+
for (long nativeSink : sinks.values()) {
63+
nativeRemoveSink(getNativeMediaStreamTrack(), nativeSink);
64+
nativeFreeSink(nativeSink);
65+
}
66+
sinks.clear();
67+
super.dispose();
68+
}
69+
2670
/** Returns a pointer to webrtc::AudioTrackInterface. */
2771
long getNativeAudioTrack() {
2872
return getNativeMediaStreamTrack();
2973
}
3074

3175
private static native void nativeSetVolume(long track, double volume);
32-
}
76+
private static native void nativeAddSink(long track, long nativeSink);
77+
private static native void nativeRemoveSink(long track, long nativeSink);
78+
private static native long nativeWrapSink(AudioTrackSink sink);
79+
private static native void nativeFreeSink(long sink);
80+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright 2023 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+
13+
import java.nio.ByteBuffer;
14+
15+
/**
16+
* Java version of rtc::AudioTrackSinkInterface.
17+
*/
18+
public interface AudioTrackSink {
19+
/**
20+
* Implementations should copy the audio data into a local copy if they wish
21+
* to use the data after this function returns.
22+
*/
23+
@CalledByNative
24+
void onData(ByteBuffer audioData, int bitsPerSample, int sampleRate,
25+
int numberOfChannels, int numberOfFrames,
26+
long absoluteCaptureTimestampMs);
27+
}

0 commit comments

Comments
 (0)