transcoding: Unhide setClientCapabilities.
And use the new ApplicationMediaCapabilities class. CTS-Coverage-Bug:168990206 Bug: 169849854 Test:tracking in b/168990206 Change-Id: I0e0d801de019b453ad4171816e1d59d82a085a52
This commit is contained in:
@@ -4433,9 +4433,9 @@ package android.media {
|
||||
public static class MediaTranscodeManager.TranscodingRequest.MediaFormatResolver {
|
||||
ctor public MediaTranscodeManager.TranscodingRequest.MediaFormatResolver();
|
||||
method @Nullable public android.media.MediaFormat resolveVideoFormat();
|
||||
method @NonNull public android.media.MediaTranscodeManager.TranscodingRequest.MediaFormatResolver setClientCapabilities(@NonNull android.media.ApplicationMediaCapabilities);
|
||||
method @NonNull public android.media.MediaTranscodeManager.TranscodingRequest.MediaFormatResolver setSourceVideoFormatHint(@NonNull android.media.MediaFormat);
|
||||
method public boolean shouldTranscode();
|
||||
field public static final String CAPS_SUPPORTS_HEVC = "support-hevc";
|
||||
}
|
||||
|
||||
public static final class MediaTranscodeManager.TranscodingSession {
|
||||
|
||||
@@ -26,7 +26,6 @@ import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.res.AssetFileDescriptor;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
@@ -901,29 +900,19 @@ public final class MediaTranscodeManager {
|
||||
|
||||
private MediaFormat mSrcVideoFormatHint;
|
||||
private MediaFormat mSrcAudioFormatHint;
|
||||
private Bundle mClientCaps;
|
||||
|
||||
/**
|
||||
* A key describing whether the client supports HEVC-encoded video.
|
||||
*
|
||||
* The value associated with this key is a boolean. If unspecified, it's up to
|
||||
* the MediaFormatResolver to determine the default.
|
||||
*
|
||||
* @see #setClientCapabilities(Bundle)
|
||||
*/
|
||||
public static final String CAPS_SUPPORTS_HEVC = "support-hevc";
|
||||
private ApplicationMediaCapabilities mClientCaps;
|
||||
|
||||
/**
|
||||
* Sets the abilities of the client consuming the media. Must be called
|
||||
* before {@link #shouldTranscode()} or {@link #resolveVideoFormat()}.
|
||||
*
|
||||
* @param clientCaps A Bundle object containing the client's capabilities, such as
|
||||
* {@link #CAPS_SUPPORTS_HEVC}.
|
||||
* @param clientCaps An ApplicationMediaCapabilities object containing the client's
|
||||
* capabilities.
|
||||
* @return the same VideoFormatResolver instance.
|
||||
* @hide
|
||||
*/
|
||||
@NonNull
|
||||
public MediaFormatResolver setClientCapabilities(@NonNull Bundle clientCaps) {
|
||||
public MediaFormatResolver setClientCapabilities(
|
||||
@NonNull ApplicationMediaCapabilities clientCaps) {
|
||||
mClientCaps = clientCaps;
|
||||
return this;
|
||||
}
|
||||
@@ -964,7 +953,8 @@ public final class MediaTranscodeManager {
|
||||
* Returns whether the source content should be transcoded.
|
||||
*
|
||||
* @return true if the source should be transcoded.
|
||||
* @throws UnsupportedOperationException if {@link #setClientCapabilities(Bundle)}
|
||||
* @throws UnsupportedOperationException
|
||||
* if {@link #setClientCapabilities(ApplicationMediaCapabilities)}
|
||||
* or {@link #setSourceVideoFormatHint(MediaFormat)} was not called.
|
||||
*/
|
||||
public boolean shouldTranscode() {
|
||||
@@ -977,7 +967,8 @@ public final class MediaTranscodeManager {
|
||||
throw new UnsupportedOperationException(
|
||||
"Source video format hint must be set!");
|
||||
}
|
||||
boolean supportHevc = mClientCaps.getBoolean(CAPS_SUPPORTS_HEVC, false);
|
||||
boolean supportHevc = mClientCaps.isVideoMimeTypeSupported(
|
||||
MediaFormat.MIMETYPE_VIDEO_HEVC);
|
||||
if (!supportHevc && MediaFormat.MIMETYPE_VIDEO_HEVC.equals(
|
||||
mSrcVideoFormatHint.getString(MediaFormat.KEY_MIME))) {
|
||||
return true;
|
||||
@@ -992,7 +983,8 @@ public final class MediaTranscodeManager {
|
||||
*
|
||||
* @return the video track format to be used if transcoding should be performed,
|
||||
* and null otherwise.
|
||||
* @throws UnsupportedOperationException if {@link #setClientCapabilities(Bundle)}
|
||||
* @throws UnsupportedOperationException
|
||||
* if {@link #setClientCapabilities(ApplicationMediaCapabilities)}
|
||||
* or {@link #setSourceVideoFormatHint(MediaFormat)} was not called.
|
||||
*/
|
||||
@Nullable
|
||||
@@ -1013,7 +1005,8 @@ public final class MediaTranscodeManager {
|
||||
*
|
||||
* @return the audio track format to be used if transcoding should be performed, and
|
||||
* null otherwise.
|
||||
* @throws UnsupportedOperationException if {@link #setClientCapabilities(Bundle)}
|
||||
* @throws UnsupportedOperationException
|
||||
* if {@link #setClientCapabilities(ApplicationMediaCapabilities)}
|
||||
* or {@link #setSourceVideoFormatHint(MediaFormat)} was not called.
|
||||
* @hide
|
||||
*/
|
||||
|
||||
@@ -20,6 +20,7 @@ import static org.testng.Assert.assertThrows;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.media.ApplicationMediaCapabilities;
|
||||
import android.media.MediaFormat;
|
||||
import android.media.MediaTranscodeManager;
|
||||
import android.media.MediaTranscodeManager.TranscodingRequest;
|
||||
@@ -454,8 +455,8 @@ public class MediaTranscodeManagerTest
|
||||
Uri destinationUri = Uri.parse(ContentResolver.SCHEME_FILE + "://"
|
||||
+ mContext.getCacheDir().getAbsolutePath() + "/HevcTranscode.mp4");
|
||||
|
||||
Bundle clientCaps = new Bundle();
|
||||
clientCaps.putBoolean(MediaFormatResolver.CAPS_SUPPORTS_HEVC, false);
|
||||
ApplicationMediaCapabilities clientCaps =
|
||||
new ApplicationMediaCapabilities.Builder().build();
|
||||
MediaFormatResolver resolver = new MediaFormatResolver()
|
||||
.setSourceVideoFormatHint(MediaFormat.createVideoFormat(
|
||||
MediaFormat.MIMETYPE_VIDEO_HEVC, WIDTH, HEIGHT))
|
||||
|
||||
Reference in New Issue
Block a user