2017-06-20 11:35:04 -07: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;
|
|
|
|
|
|
2018-11-28 15:41:17 +03:00
|
|
|
import android.media.MediaCodecInfo;
|
2021-08-14 11:41:59 +09:00
|
|
|
import androidx.annotation.Nullable;
|
2018-11-28 15:41:17 +03:00
|
|
|
import java.util.Arrays;
|
2017-06-20 11:35:04 -07:00
|
|
|
|
|
|
|
|
/** Factory for Android hardware VideoDecoders. */
|
2018-09-05 16:38:57 +02:00
|
|
|
public class HardwareVideoDecoderFactory extends MediaCodecVideoDecoderFactory {
|
2018-11-28 15:41:17 +03:00
|
|
|
private final static Predicate<MediaCodecInfo> defaultAllowedPredicate =
|
|
|
|
|
new Predicate<MediaCodecInfo>() {
|
|
|
|
|
@Override
|
|
|
|
|
public boolean test(MediaCodecInfo arg) {
|
2020-07-02 02:00:25 +09:00
|
|
|
return MediaCodecUtils.isHardwareAccelerated(arg);
|
2018-11-28 15:41:17 +03:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2017-07-18 11:33:39 -07:00
|
|
|
/** Creates a HardwareVideoDecoderFactory that does not use surface textures. */
|
|
|
|
|
@Deprecated // Not removed yet to avoid breaking callers.
|
|
|
|
|
public HardwareVideoDecoderFactory() {
|
|
|
|
|
this(null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2018-09-05 16:38:57 +02:00
|
|
|
* Creates a HardwareVideoDecoderFactory that supports surface texture rendering.
|
|
|
|
|
*
|
|
|
|
|
* @param sharedContext The textures generated will be accessible from this context. May be null,
|
|
|
|
|
* this disables texture support.
|
2017-07-18 11:33:39 -07:00
|
|
|
*/
|
2018-09-05 16:38:57 +02:00
|
|
|
public HardwareVideoDecoderFactory(@Nullable EglBase.Context sharedContext) {
|
2018-11-28 15:41:17 +03:00
|
|
|
this(sharedContext, /* codecAllowedPredicate= */ null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates a HardwareVideoDecoderFactory that supports surface texture rendering.
|
|
|
|
|
*
|
|
|
|
|
* @param sharedContext The textures generated will be accessible from this context. May be null,
|
|
|
|
|
* this disables texture support.
|
|
|
|
|
* @param codecAllowedPredicate predicate to filter codecs. It is combined with the default
|
|
|
|
|
* predicate that only allows hardware codecs.
|
|
|
|
|
*/
|
|
|
|
|
public HardwareVideoDecoderFactory(@Nullable EglBase.Context sharedContext,
|
|
|
|
|
@Nullable Predicate<MediaCodecInfo> codecAllowedPredicate) {
|
|
|
|
|
super(sharedContext,
|
|
|
|
|
(codecAllowedPredicate == null ? defaultAllowedPredicate
|
|
|
|
|
: codecAllowedPredicate.and(defaultAllowedPredicate)));
|
2018-05-21 13:45:51 +02:00
|
|
|
}
|
2017-06-20 11:35:04 -07:00
|
|
|
}
|