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.support.annotation.Nullable; 14 import java.util.ArrayList; 15 import java.util.HashMap; 16 import java.util.List; 17 18 public class SoftwareVideoDecoderFactory implements VideoDecoderFactory { 19 @Deprecated 20 @Nullable 21 @Override createDecoder(String codecType)22 public VideoDecoder createDecoder(String codecType) { 23 return createDecoder(new VideoCodecInfo(codecType, new HashMap<>())); 24 } 25 26 @Nullable 27 @Override createDecoder(VideoCodecInfo codecType)28 public VideoDecoder createDecoder(VideoCodecInfo codecType) { 29 if (codecType.getName().equalsIgnoreCase("VP8")) { 30 return new LibvpxVp8Decoder(); 31 } 32 if (codecType.getName().equalsIgnoreCase("VP9") && LibvpxVp9Decoder.nativeIsSupported()) { 33 return new LibvpxVp9Decoder(); 34 } 35 36 return null; 37 } 38 39 @Override getSupportedCodecs()40 public VideoCodecInfo[] getSupportedCodecs() { 41 return supportedCodecs(); 42 } 43 supportedCodecs()44 static VideoCodecInfo[] supportedCodecs() { 45 List<VideoCodecInfo> codecs = new ArrayList<VideoCodecInfo>(); 46 47 codecs.add(new VideoCodecInfo("VP8", new HashMap<>())); 48 if (LibvpxVp9Decoder.nativeIsSupported()) { 49 codecs.add(new VideoCodecInfo("VP9", new HashMap<>())); 50 } 51 52 return codecs.toArray(new VideoCodecInfo[codecs.size()]); 53 } 54 } 55