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;
|
2022-11-09 14:45:42 +00:00
|
|
|
import java.util.Arrays;
|
2017-11-14 13:09:12 +01:00
|
|
|
import java.util.List;
|
2017-11-10 13:15:04 +01:00
|
|
|
|
|
|
|
|
public class SoftwareVideoEncoderFactory implements VideoEncoderFactory {
|
2022-11-09 14:45:42 +00:00
|
|
|
private static final String TAG = "SoftwareVideoEncoderFactory";
|
|
|
|
|
|
|
|
|
|
private final long nativeFactory;
|
|
|
|
|
|
|
|
|
|
public SoftwareVideoEncoderFactory() {
|
|
|
|
|
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 VideoEncoder createEncoder(VideoCodecInfo info) {
|
|
|
|
|
long nativeEncoder = nativeCreateEncoder(nativeFactory, info);
|
|
|
|
|
if (nativeEncoder == 0) {
|
|
|
|
|
Logging.w(TAG, "Trying to create encoder for unsupported format. " + info);
|
|
|
|
|
return null;
|
2022-11-09 08:05:46 +00:00
|
|
|
}
|
|
|
|
|
|
2022-11-09 14:45:42 +00:00
|
|
|
return new WrappedNativeVideoEncoder() {
|
|
|
|
|
@Override
|
|
|
|
|
public long createNativeVideoEncoder() {
|
|
|
|
|
return nativeEncoder;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isHardwareEncoder() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
};
|
2017-11-10 13:15:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public VideoCodecInfo[] getSupportedCodecs() {
|
2022-11-09 14:45:42 +00:00
|
|
|
return nativeGetSupportedCodecs(nativeFactory).toArray(new VideoCodecInfo[0]);
|
2017-11-10 13:15:04 +01:00
|
|
|
}
|
|
|
|
|
|
2022-11-09 14:45:42 +00:00
|
|
|
private static native long nativeCreateFactory();
|
2017-11-10 13:15:04 +01:00
|
|
|
|
2022-11-09 14:45:42 +00:00
|
|
|
private static native long nativeCreateEncoder(long factory, VideoCodecInfo videoCodecInfo);
|
2017-11-14 13:09:12 +01:00
|
|
|
|
2022-11-09 14:45:42 +00:00
|
|
|
private static native List<VideoCodecInfo> nativeGetSupportedCodecs(long factory);
|
2017-11-10 13:15:04 +01:00
|
|
|
}
|