Rabbit-R1/switch port/java/sources/org/webrtc/VideoTrack.java
2024-05-21 17:08:36 -04:00

59 lines
1.8 KiB
Java

package org.webrtc;
import java.util.IdentityHashMap;
import java.util.Iterator;
/* loaded from: classes3.dex */
public class VideoTrack extends MediaStreamTrack {
private final IdentityHashMap<VideoSink, Long> sinks;
private static native void nativeAddSink(long j, long j2);
private static native void nativeFreeSink(long j);
private static native void nativeRemoveSink(long j, long j2);
private static native long nativeWrapSink(VideoSink videoSink);
public VideoTrack(long j) {
super(j);
this.sinks = new IdentityHashMap<>();
}
public void addSink(VideoSink videoSink) {
if (videoSink == null) {
throw new IllegalArgumentException("The VideoSink is not allowed to be null");
}
if (this.sinks.containsKey(videoSink)) {
return;
}
long nativeWrapSink = nativeWrapSink(videoSink);
this.sinks.put(videoSink, Long.valueOf(nativeWrapSink));
nativeAddSink(getNativeMediaStreamTrack(), nativeWrapSink);
}
public void removeSink(VideoSink videoSink) {
Long remove = this.sinks.remove(videoSink);
if (remove != null) {
nativeRemoveSink(getNativeMediaStreamTrack(), remove.longValue());
nativeFreeSink(remove.longValue());
}
}
@Override // org.webrtc.MediaStreamTrack
public void dispose() {
Iterator<Long> it = this.sinks.values().iterator();
while (it.hasNext()) {
long longValue = it.next().longValue();
nativeRemoveSink(getNativeMediaStreamTrack(), longValue);
nativeFreeSink(longValue);
}
this.sinks.clear();
super.dispose();
}
/* JADX INFO: Access modifiers changed from: package-private */
public long getNativeVideoTrack() {
return getNativeMediaStreamTrack();
}
}