-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start/Stop receiving stream method for VideoTrack (#25) Properly remove observer upon deconstruction (#26) feat: Expose setCodecPreferences/getCapabilities for android. (#61) fix: add WrappedVideoDecoderFactory.java. (#74) Co-authored-by: davidliu <davidliu@deviange.net>
- Loading branch information
1 parent
b0b9fe9
commit 9aaaab5
Showing
18 changed files
with
217 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
sdk/android/api/org/webrtc/WrappedVideoDecoderFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright 2023 LiveKit | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.webrtc; | ||
|
||
import android.media.MediaCodecInfo; | ||
import androidx.annotation.Nullable; | ||
|
||
import java.util.Arrays; | ||
import java.util.LinkedHashSet; | ||
|
||
public class WrappedVideoDecoderFactory implements VideoDecoderFactory { | ||
public WrappedVideoDecoderFactory(@Nullable EglBase.Context eglContext) { | ||
this.hardwareVideoDecoderFactory = new HardwareVideoDecoderFactory(eglContext); | ||
this.platformSoftwareVideoDecoderFactory = new PlatformSoftwareVideoDecoderFactory(eglContext); | ||
} | ||
|
||
private final VideoDecoderFactory hardwareVideoDecoderFactory; | ||
private final VideoDecoderFactory hardwareVideoDecoderFactoryWithoutEglContext = new HardwareVideoDecoderFactory(null) ; | ||
private final VideoDecoderFactory softwareVideoDecoderFactory = new SoftwareVideoDecoderFactory(); | ||
@Nullable | ||
private final VideoDecoderFactory platformSoftwareVideoDecoderFactory; | ||
|
||
@Override | ||
public VideoDecoder createDecoder(VideoCodecInfo codecType) { | ||
VideoDecoder softwareDecoder = this.softwareVideoDecoderFactory.createDecoder(codecType); | ||
VideoDecoder hardwareDecoder = this.hardwareVideoDecoderFactory.createDecoder(codecType); | ||
if (softwareDecoder == null && this.platformSoftwareVideoDecoderFactory != null) { | ||
softwareDecoder = this.platformSoftwareVideoDecoderFactory.createDecoder(codecType); | ||
} | ||
|
||
if(hardwareDecoder != null && disableSurfaceTextureFrame(hardwareDecoder.getImplementationName())) { | ||
hardwareDecoder.release(); | ||
hardwareDecoder = this.hardwareVideoDecoderFactoryWithoutEglContext.createDecoder(codecType); | ||
} | ||
|
||
if (hardwareDecoder != null && softwareDecoder != null) { | ||
return new VideoDecoderFallback(softwareDecoder, hardwareDecoder); | ||
} else { | ||
return hardwareDecoder != null ? hardwareDecoder : softwareDecoder; | ||
} | ||
} | ||
|
||
private boolean disableSurfaceTextureFrame(String name) { | ||
if (name.startsWith("OMX.qcom.") || name.startsWith("OMX.hisi.")) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public VideoCodecInfo[] getSupportedCodecs() { | ||
LinkedHashSet<VideoCodecInfo> supportedCodecInfos = new LinkedHashSet(); | ||
supportedCodecInfos.addAll(Arrays.asList(this.softwareVideoDecoderFactory.getSupportedCodecs())); | ||
supportedCodecInfos.addAll(Arrays.asList(this.hardwareVideoDecoderFactory.getSupportedCodecs())); | ||
if (this.platformSoftwareVideoDecoderFactory != null) { | ||
supportedCodecInfos.addAll(Arrays.asList(this.platformSoftwareVideoDecoderFactory.getSupportedCodecs())); | ||
} | ||
|
||
return (VideoCodecInfo[])supportedCodecInfos.toArray(new VideoCodecInfo[supportedCodecInfos.size()]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.