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 SoftwareVideoEncoderFactory implements VideoEncoderFactory { 19 @Nullable 20 @Override createEncoder(VideoCodecInfo info)21 public VideoEncoder createEncoder(VideoCodecInfo info) { 22 if (info.name.equalsIgnoreCase("VP8")) { 23 return new LibvpxVp8Encoder(); 24 } 25 if (info.name.equalsIgnoreCase("VP9") && LibvpxVp9Encoder.nativeIsSupported()) { 26 return new LibvpxVp9Encoder(); 27 } 28 29 return null; 30 } 31 32 @Override getSupportedCodecs()33 public VideoCodecInfo[] getSupportedCodecs() { 34 return supportedCodecs(); 35 } 36 supportedCodecs()37 static VideoCodecInfo[] supportedCodecs() { 38 List<VideoCodecInfo> codecs = new ArrayList<VideoCodecInfo>(); 39 40 codecs.add(new VideoCodecInfo("VP8", new HashMap<>())); 41 if (LibvpxVp9Encoder.nativeIsSupported()) { 42 codecs.add(new VideoCodecInfo("VP9", new HashMap<>())); 43 } 44 45 return codecs.toArray(new VideoCodecInfo[codecs.size()]); 46 } 47 } 48