• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright 2017 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 package org.webrtc;
12 
13 import android.media.MediaCodecInfo;
14 import androidx.annotation.Nullable;
15 import java.util.Arrays;
16 
17 /** Factory for Android hardware VideoDecoders. */
18 public class HardwareVideoDecoderFactory extends MediaCodecVideoDecoderFactory {
19   private final static Predicate<MediaCodecInfo> defaultAllowedPredicate =
20       new Predicate<MediaCodecInfo>() {
21         @Override
22         public boolean test(MediaCodecInfo arg) {
23           return MediaCodecUtils.isHardwareAccelerated(arg);
24         }
25       };
26 
27   /** Creates a HardwareVideoDecoderFactory that does not use surface textures. */
28   @Deprecated // Not removed yet to avoid breaking callers.
HardwareVideoDecoderFactory()29   public HardwareVideoDecoderFactory() {
30     this(null);
31   }
32 
33   /**
34    * Creates a HardwareVideoDecoderFactory that supports surface texture rendering.
35    *
36    * @param sharedContext The textures generated will be accessible from this context. May be null,
37    *                      this disables texture support.
38    */
HardwareVideoDecoderFactory(@ullable EglBase.Context sharedContext)39   public HardwareVideoDecoderFactory(@Nullable EglBase.Context sharedContext) {
40     this(sharedContext, /* codecAllowedPredicate= */ null);
41   }
42 
43   /**
44    * Creates a HardwareVideoDecoderFactory that supports surface texture rendering.
45    *
46    * @param sharedContext The textures generated will be accessible from this context. May be null,
47    *                      this disables texture support.
48    * @param codecAllowedPredicate predicate to filter codecs. It is combined with the default
49    *                              predicate that only allows hardware codecs.
50    */
HardwareVideoDecoderFactory(@ullable EglBase.Context sharedContext, @Nullable Predicate<MediaCodecInfo> codecAllowedPredicate)51   public HardwareVideoDecoderFactory(@Nullable EglBase.Context sharedContext,
52       @Nullable Predicate<MediaCodecInfo> codecAllowedPredicate) {
53     super(sharedContext,
54         (codecAllowedPredicate == null ? defaultAllowedPredicate
55                                        : codecAllowedPredicate.and(defaultAllowedPredicate)));
56   }
57 }
58