package org.webrtc; import java.util.Arrays; import java.util.LinkedHashSet; import org.webrtc.EglBase; /* loaded from: classes3.dex */ public class DefaultVideoDecoderFactory implements VideoDecoderFactory { private final VideoDecoderFactory hardwareVideoDecoderFactory; private final VideoDecoderFactory platformSoftwareVideoDecoderFactory; private final VideoDecoderFactory softwareVideoDecoderFactory; public DefaultVideoDecoderFactory(EglBase.Context context) { this.softwareVideoDecoderFactory = new SoftwareVideoDecoderFactory(); this.hardwareVideoDecoderFactory = new HardwareVideoDecoderFactory(context); this.platformSoftwareVideoDecoderFactory = new PlatformSoftwareVideoDecoderFactory(context); } DefaultVideoDecoderFactory(VideoDecoderFactory videoDecoderFactory) { this.softwareVideoDecoderFactory = new SoftwareVideoDecoderFactory(); this.hardwareVideoDecoderFactory = videoDecoderFactory; this.platformSoftwareVideoDecoderFactory = null; } @Override // org.webrtc.VideoDecoderFactory public VideoDecoder createDecoder(VideoCodecInfo videoCodecInfo) { VideoDecoderFactory videoDecoderFactory; VideoDecoder createDecoder = this.softwareVideoDecoderFactory.createDecoder(videoCodecInfo); VideoDecoder createDecoder2 = this.hardwareVideoDecoderFactory.createDecoder(videoCodecInfo); if (createDecoder == null && (videoDecoderFactory = this.platformSoftwareVideoDecoderFactory) != null) { createDecoder = videoDecoderFactory.createDecoder(videoCodecInfo); } if (createDecoder2 == null || createDecoder == null) { return createDecoder2 != null ? createDecoder2 : createDecoder; } return new VideoDecoderFallback(createDecoder, createDecoder2); } @Override // org.webrtc.VideoDecoderFactory public VideoCodecInfo[] getSupportedCodecs() { LinkedHashSet linkedHashSet = new LinkedHashSet(); linkedHashSet.addAll(Arrays.asList(this.softwareVideoDecoderFactory.getSupportedCodecs())); linkedHashSet.addAll(Arrays.asList(this.hardwareVideoDecoderFactory.getSupportedCodecs())); VideoDecoderFactory videoDecoderFactory = this.platformSoftwareVideoDecoderFactory; if (videoDecoderFactory != null) { linkedHashSet.addAll(Arrays.asList(videoDecoderFactory.getSupportedCodecs())); } return (VideoCodecInfo[]) linkedHashSet.toArray(new VideoCodecInfo[linkedHashSet.size()]); } }