Skip to content

Commit

Permalink
Remove software fallback in Android hardware codec factories.
Browse files Browse the repository at this point in the history
Remove backwards compatiblity. Users who need software codecs should
migrate to the DefaultVideoCodecFactories.

Bug: webrtc:7925
Change-Id: Ifb41c9511d53c17c83222422c221b595bc056cb2
Reviewed-on: https://webrtc-review.googlesource.com/82920
Reviewed-by: Sami Kalliomäki <[email protected]>
Commit-Queue: Anders Carlsson <[email protected]>
Cr-Commit-Position: refs/heads/master@{#23563}
  • Loading branch information
Anders Carlsson authored and Commit Bot committed Jun 11, 2018
1 parent 24db1c9 commit 80a0a4c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 68 deletions.
15 changes: 3 additions & 12 deletions sdk/android/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ generate_jni("generated_java_audio_device_module_native_jni") {
generate_jni("generated_video_jni") {
sources = [
"api/org/webrtc/EncodedImage.java",
"api/org/webrtc/HardwareVideoEncoderFactory.java",
"api/org/webrtc/MediaCodecVideoDecoder.java",
"api/org/webrtc/MediaCodecVideoEncoder.java",
"api/org/webrtc/VideoCodecInfo.java",
Expand All @@ -284,9 +285,6 @@ generate_jni("generated_video_jni") {
"src/java/org/webrtc/WrappedNativeVideoDecoder.java",
"src/java/org/webrtc/WrappedNativeVideoEncoder.java",
]
if (rtc_use_builtin_sw_codecs) {
sources += [ "api/org/webrtc/HardwareVideoEncoderFactory.java" ] # TODO(andersc): This currently depends on SoftwareVideoEncoderFactory
}
jni_package = ""
namespace = "webrtc::jni"
jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h"
Expand Down Expand Up @@ -924,6 +922,8 @@ if (rtc_use_builtin_sw_codecs) {

rtc_android_library("hwcodecs_java") {
java_files = [
"api/org/webrtc/HardwareVideoDecoderFactory.java",
"api/org/webrtc/HardwareVideoEncoderFactory.java",
"src/java/org/webrtc/BaseBitrateAdjuster.java",
"src/java/org/webrtc/BitrateAdjuster.java",
"src/java/org/webrtc/DynamicBitrateAdjuster.java",
Expand All @@ -941,15 +941,6 @@ rtc_android_library("hwcodecs_java") {
":video_java",
"//rtc_base:base_java",
]

if (rtc_use_builtin_sw_codecs) {
java_files += [
"api/org/webrtc/HardwareVideoDecoderFactory.java", # TODO(andersc): make this not depend on SoftwareVideoDecoderFactory
"api/org/webrtc/HardwareVideoEncoderFactory.java", # TODO(andersc): make this not depend on SoftwareVideoEncoderFactory
]

deps += [ ":swcodecs_java" ]
}
}

rtc_android_library("peerconnection_java") {
Expand Down
3 changes: 1 addition & 2 deletions sdk/android/api/org/webrtc/DefaultVideoDecoderFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ public class DefaultVideoDecoderFactory implements VideoDecoderFactory {
private final SoftwareVideoDecoderFactory softwareVideoDecoderFactory;

public DefaultVideoDecoderFactory(EglBase.Context eglContext) {
hardwareVideoDecoderFactory =
new HardwareVideoDecoderFactory(eglContext, false /* fallbackToSoftware */);
hardwareVideoDecoderFactory = new HardwareVideoDecoderFactory(eglContext);
softwareVideoDecoderFactory = new SoftwareVideoDecoderFactory();
}

Expand Down
4 changes: 2 additions & 2 deletions sdk/android/api/org/webrtc/DefaultVideoEncoderFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public class DefaultVideoEncoderFactory implements VideoEncoderFactory {

public DefaultVideoEncoderFactory(
EglBase.Context eglContext, boolean enableIntelVp8Encoder, boolean enableH264HighProfile) {
hardwareVideoEncoderFactory = new HardwareVideoEncoderFactory(
eglContext, enableIntelVp8Encoder, enableH264HighProfile, false /* fallbackToSoftware */);
hardwareVideoEncoderFactory =
new HardwareVideoEncoderFactory(eglContext, enableIntelVp8Encoder, enableH264HighProfile);
softwareVideoEncoderFactory = new SoftwareVideoEncoderFactory();
}

Expand Down
26 changes: 1 addition & 25 deletions sdk/android/api/org/webrtc/HardwareVideoDecoderFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public class HardwareVideoDecoderFactory implements VideoDecoderFactory {
private static final String TAG = "HardwareVideoDecoderFactory";

private final EglBase.Context sharedContext;
private final boolean fallbackToSoftware;

/** Creates a HardwareVideoDecoderFactory that does not use surface textures. */
@Deprecated // Not removed yet to avoid breaking callers.
Expand All @@ -42,12 +41,7 @@ public HardwareVideoDecoderFactory() {
* shared context. The context may be null. If it is null, then surface support is disabled.
*/
public HardwareVideoDecoderFactory(EglBase.Context sharedContext) {
this(sharedContext, true /* fallbackToSoftware */);
}

HardwareVideoDecoderFactory(EglBase.Context sharedContext, boolean fallbackToSoftware) {
this.sharedContext = sharedContext;
this.fallbackToSoftware = fallbackToSoftware;
}

@Nullable
Expand All @@ -57,15 +51,7 @@ public VideoDecoder createDecoder(String codecType) {
MediaCodecInfo info = findCodecForType(type);

if (info == null) {
// No hardware support for this type.
// TODO(andersc): This is for backwards compatibility. Remove when clients have migrated to
// new DefaultVideoEncoderFactory.
if (fallbackToSoftware) {
SoftwareVideoDecoderFactory softwareVideoDecoderFactory = new SoftwareVideoDecoderFactory();
return softwareVideoDecoderFactory.createDecoder(codecType);
} else {
return null;
}
return null;
}

CodecCapabilities capabilities = info.getCapabilitiesForType(type.mimeType());
Expand Down Expand Up @@ -94,16 +80,6 @@ public VideoCodecInfo[] getSupportedCodecs() {
}
}

// TODO(andersc): This is for backwards compatibility. Remove when clients have migrated to
// new DefaultVideoEncoderFactory.
if (fallbackToSoftware) {
for (VideoCodecInfo info : SoftwareVideoDecoderFactory.supportedCodecs()) {
if (!supportedCodecInfos.contains(info)) {
supportedCodecInfos.add(info);
}
}
}

return supportedCodecInfos.toArray(new VideoCodecInfo[supportedCodecInfos.size()]);
}

Expand Down
28 changes: 1 addition & 27 deletions sdk/android/api/org/webrtc/HardwareVideoEncoderFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,9 @@ public class HardwareVideoEncoderFactory implements VideoEncoderFactory {
@Nullable private final EglBase14.Context sharedContext;
private final boolean enableIntelVp8Encoder;
private final boolean enableH264HighProfile;
private final boolean fallbackToSoftware;

public HardwareVideoEncoderFactory(
EglBase.Context sharedContext, boolean enableIntelVp8Encoder, boolean enableH264HighProfile) {
this(
sharedContext, enableIntelVp8Encoder, enableH264HighProfile, true /* fallbackToSoftware */);
}

HardwareVideoEncoderFactory(EglBase.Context sharedContext, boolean enableIntelVp8Encoder,
boolean enableH264HighProfile, boolean fallbackToSoftware) {
// Texture mode requires EglBase14.
if (sharedContext instanceof EglBase14.Context) {
this.sharedContext = (EglBase14.Context) sharedContext;
Expand All @@ -61,7 +54,6 @@ public HardwareVideoEncoderFactory(
}
this.enableIntelVp8Encoder = enableIntelVp8Encoder;
this.enableH264HighProfile = enableH264HighProfile;
this.fallbackToSoftware = fallbackToSoftware;
}

@Deprecated
Expand All @@ -76,15 +68,7 @@ public VideoEncoder createEncoder(VideoCodecInfo input) {
MediaCodecInfo info = findCodecForType(type);

if (info == null) {
// No hardware support for this type.
// TODO(andersc): This is for backwards compatibility. Remove when clients have migrated to
// new DefaultVideoEncoderFactory.
if (fallbackToSoftware) {
SoftwareVideoEncoderFactory softwareVideoEncoderFactory = new SoftwareVideoEncoderFactory();
return softwareVideoEncoderFactory.createEncoder(input);
} else {
return null;
}
return null;
}

String codecName = info.getName();
Expand Down Expand Up @@ -133,16 +117,6 @@ public VideoCodecInfo[] getSupportedCodecs() {
}
}

// TODO(andersc): This is for backwards compatibility. Remove when clients have migrated to
// new DefaultVideoEncoderFactory.
if (fallbackToSoftware) {
for (VideoCodecInfo info : SoftwareVideoEncoderFactory.supportedCodecs()) {
if (!supportedCodecInfos.contains(info)) {
supportedCodecInfos.add(info);
}
}
}

return supportedCodecInfos.toArray(new VideoCodecInfo[supportedCodecInfos.size()]);
}

Expand Down

0 comments on commit 80a0a4c

Please sign in to comment.