2017-11-10 13:15:04 +01:00
|
|
|
/*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package org.webrtc;
|
|
|
|
|
|
2021-08-14 11:41:59 +09:00
|
|
|
import androidx.annotation.Nullable;
|
2018-05-21 13:45:51 +02:00
|
|
|
import java.util.List;
|
2018-03-22 13:32:44 +01:00
|
|
|
|
2017-11-10 13:15:04 +01:00
|
|
|
public class SoftwareVideoDecoderFactory implements VideoDecoderFactory {
|
2022-11-09 14:45:42 +00:00
|
|
|
private static final String TAG = "SoftwareVideoDecoderFactory";
|
|
|
|
|
|
|
|
|
|
private final long nativeFactory;
|
|
|
|
|
|
|
|
|
|
public SoftwareVideoDecoderFactory() {
|
|
|
|
|
this.nativeFactory = nativeCreateFactory();
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-22 13:32:44 +01:00
|
|
|
@Nullable
|
2017-11-10 13:15:04 +01:00
|
|
|
@Override
|
2022-11-09 14:45:42 +00:00
|
|
|
public VideoDecoder createDecoder(VideoCodecInfo info) {
|
2024-02-06 21:31:44 +01:00
|
|
|
if (!nativeIsSupported(nativeFactory, info)) {
|
2022-11-09 14:45:42 +00:00
|
|
|
Logging.w(TAG, "Trying to create decoder for unsupported format. " + info);
|
|
|
|
|
return null;
|
2022-11-09 08:05:46 +00:00
|
|
|
}
|
2022-11-09 14:45:42 +00:00
|
|
|
return new WrappedNativeVideoDecoder() {
|
2024-02-06 21:31:44 +01:00
|
|
|
@Override
|
|
|
|
|
public long createNative(long webrtcEnvRef) {
|
|
|
|
|
return nativeCreate(nativeFactory, webrtcEnvRef, info);
|
2022-11-09 14:45:42 +00:00
|
|
|
}
|
|
|
|
|
};
|
2017-11-10 13:15:04 +01:00
|
|
|
}
|
2018-05-21 13:45:51 +02:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public VideoCodecInfo[] getSupportedCodecs() {
|
2022-11-09 14:45:42 +00:00
|
|
|
return nativeGetSupportedCodecs(nativeFactory).toArray(new VideoCodecInfo[0]);
|
2018-05-21 13:45:51 +02:00
|
|
|
}
|
|
|
|
|
|
2022-11-09 14:45:42 +00:00
|
|
|
private static native long nativeCreateFactory();
|
2022-11-09 08:05:46 +00:00
|
|
|
|
2024-02-06 21:31:44 +01:00
|
|
|
private static native boolean nativeIsSupported(long factory, VideoCodecInfo info);
|
|
|
|
|
|
|
|
|
|
private static native long nativeCreate(
|
|
|
|
|
long factory, long webrtcEnvRef, VideoCodecInfo info);
|
|
|
|
|
|
2022-11-09 14:45:42 +00:00
|
|
|
private static native List<VideoCodecInfo> nativeGetSupportedCodecs(long factory);
|
2017-11-10 13:15:04 +01:00
|
|
|
}
|