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.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
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 {
|
2018-03-22 13:32:44 +01:00
|
|
|
@Nullable
|
2017-11-10 13:15:04 +01:00
|
|
|
@Override
|
2021-06-04 12:13:37 +02:00
|
|
|
public VideoDecoder createDecoder(VideoCodecInfo codecInfo) {
|
|
|
|
|
String codecName = codecInfo.getName();
|
|
|
|
|
|
2021-09-09 15:09:11 +02:00
|
|
|
if (codecName.equalsIgnoreCase(VideoCodecMimeType.VP8.name())) {
|
2018-11-06 14:10:51 -08:00
|
|
|
return new LibvpxVp8Decoder();
|
2017-11-10 13:15:04 +01:00
|
|
|
}
|
2021-09-09 15:09:11 +02:00
|
|
|
if (codecName.equalsIgnoreCase(VideoCodecMimeType.VP9.name())
|
2021-06-04 12:13:37 +02:00
|
|
|
&& LibvpxVp9Decoder.nativeIsSupported()) {
|
2018-11-06 14:10:51 -08:00
|
|
|
return new LibvpxVp9Decoder();
|
2017-11-10 13:15:04 +01:00
|
|
|
}
|
2021-09-09 15:09:11 +02:00
|
|
|
if (codecName.equalsIgnoreCase(VideoCodecMimeType.AV1.name())
|
2021-06-04 12:13:37 +02:00
|
|
|
&& LibaomAv1Decoder.nativeIsSupported()) {
|
2021-04-12 15:41:21 +03:00
|
|
|
return new LibaomAv1Decoder();
|
|
|
|
|
}
|
2017-11-10 13:15:04 +01:00
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2018-05-21 13:45:51 +02:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public VideoCodecInfo[] getSupportedCodecs() {
|
|
|
|
|
return supportedCodecs();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static VideoCodecInfo[] supportedCodecs() {
|
|
|
|
|
List<VideoCodecInfo> codecs = new ArrayList<VideoCodecInfo>();
|
|
|
|
|
|
2021-09-09 15:09:11 +02:00
|
|
|
codecs.add(new VideoCodecInfo(VideoCodecMimeType.VP8.name(), new HashMap<>()));
|
2018-11-06 14:10:51 -08:00
|
|
|
if (LibvpxVp9Decoder.nativeIsSupported()) {
|
2021-09-09 15:09:11 +02:00
|
|
|
codecs.add(new VideoCodecInfo(VideoCodecMimeType.VP9.name(), new HashMap<>()));
|
2018-05-21 13:45:51 +02:00
|
|
|
}
|
2021-04-12 15:41:21 +03:00
|
|
|
if (LibaomAv1Decoder.nativeIsSupported()) {
|
2021-09-09 15:09:11 +02:00
|
|
|
codecs.add(new VideoCodecInfo(VideoCodecMimeType.AV1.name(), new HashMap<>()));
|
2021-04-12 15:41:21 +03:00
|
|
|
}
|
2018-05-21 13:45:51 +02:00
|
|
|
|
|
|
|
|
return codecs.toArray(new VideoCodecInfo[codecs.size()]);
|
|
|
|
|
}
|
2017-11-10 13:15:04 +01:00
|
|
|
}
|