trancoding: Rework some API signature.
This is for addressing part of API counsel comments. 1. Remove AutoCloseable from MediaTranscodeManager. 2. Return job id in progress update callback. 3. Hide PRIORITY_OFFLINE. Bug: 160260102 Test: Unit test Change-Id: I7ae4d723a8f1b325ddc5fe7e81c49783adcbae19
This commit is contained in:
@@ -4334,11 +4334,8 @@ package android.media {
|
||||
field @RequiresPermission(android.Manifest.permission.CAPTURE_AUDIO_OUTPUT) public static final int RADIO_TUNER = 1998; // 0x7ce
|
||||
}
|
||||
|
||||
public final class MediaTranscodeManager implements java.lang.AutoCloseable {
|
||||
method public void close();
|
||||
public final class MediaTranscodeManager {
|
||||
method @NonNull public android.media.MediaTranscodeManager.TranscodingJob enqueueRequest(@NonNull android.media.MediaTranscodeManager.TranscodingRequest, @NonNull java.util.concurrent.Executor, @NonNull android.media.MediaTranscodeManager.OnTranscodingFinishedListener) throws java.io.FileNotFoundException;
|
||||
method protected void finalize();
|
||||
field public static final int PRIORITY_OFFLINE = 2; // 0x2
|
||||
field public static final int PRIORITY_REALTIME = 1; // 0x1
|
||||
field public static final int TRANSCODING_TYPE_VIDEO = 1; // 0x1
|
||||
}
|
||||
@@ -4367,7 +4364,7 @@ package android.media {
|
||||
}
|
||||
|
||||
@java.lang.FunctionalInterface public static interface MediaTranscodeManager.TranscodingJob.OnProgressUpdateListener {
|
||||
method public void onProgressUpdate(@IntRange(from=0, to=100) int);
|
||||
method public void onProgressUpdate(@NonNull android.media.MediaTranscodeManager.TranscodingJob, @IntRange(from=0, to=100) int);
|
||||
}
|
||||
|
||||
public static final class MediaTranscodeManager.TranscodingRequest {
|
||||
|
||||
@@ -1819,11 +1819,8 @@ package android.media {
|
||||
method @NonNull public String getOriginalId();
|
||||
}
|
||||
|
||||
public final class MediaTranscodeManager implements java.lang.AutoCloseable {
|
||||
method public void close();
|
||||
public final class MediaTranscodeManager {
|
||||
method @NonNull public android.media.MediaTranscodeManager.TranscodingJob enqueueRequest(@NonNull android.media.MediaTranscodeManager.TranscodingRequest, @NonNull java.util.concurrent.Executor, @NonNull android.media.MediaTranscodeManager.OnTranscodingFinishedListener) throws java.io.FileNotFoundException;
|
||||
method protected void finalize();
|
||||
field public static final int PRIORITY_OFFLINE = 2; // 0x2
|
||||
field public static final int PRIORITY_REALTIME = 1; // 0x1
|
||||
field public static final int TRANSCODING_TYPE_VIDEO = 1; // 0x1
|
||||
}
|
||||
@@ -1852,7 +1849,7 @@ package android.media {
|
||||
}
|
||||
|
||||
@java.lang.FunctionalInterface public static interface MediaTranscodeManager.TranscodingJob.OnProgressUpdateListener {
|
||||
method public void onProgressUpdate(@IntRange(from=0, to=100) int);
|
||||
method public void onProgressUpdate(@NonNull android.media.MediaTranscodeManager.TranscodingJob, @IntRange(from=0, to=100) int);
|
||||
}
|
||||
|
||||
public static final class MediaTranscodeManager.TranscodingRequest {
|
||||
|
||||
@@ -102,7 +102,7 @@ import java.util.concurrent.Executors;
|
||||
*/
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public final class MediaTranscodeManager implements AutoCloseable {
|
||||
public final class MediaTranscodeManager {
|
||||
private static final String TAG = "MediaTranscodeManager";
|
||||
|
||||
private static final String MEDIA_TRANSCODING_SERVICE = "media.transcoding";
|
||||
@@ -131,28 +131,6 @@ public final class MediaTranscodeManager implements AutoCloseable {
|
||||
*/
|
||||
public static final int TRANSCODING_TYPE_IMAGE = 2;
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
release();
|
||||
}
|
||||
|
||||
/**
|
||||
* Releases the MediaTranscodeManager.
|
||||
*/
|
||||
private void release() {
|
||||
synchronized (mLock) {
|
||||
try {
|
||||
if (mTranscodingClient != null) {
|
||||
mTranscodingClient.unregister();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Log.e(TAG, "Failed to unregister the client");
|
||||
} finally {
|
||||
mTranscodingClient = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@IntDef(prefix = {"TRANSCODING_TYPE_"}, value = {
|
||||
TRANSCODING_TYPE_UNKNOWN,
|
||||
@@ -182,6 +160,7 @@ public final class MediaTranscodeManager implements AutoCloseable {
|
||||
* <p>Jobs with PRIORITY_OFFLINE will be scheduled behind PRIORITY_REALTIME. Always set to
|
||||
* PRIORITY_OFFLINE if client does not need the result as soon as possible and could accept
|
||||
* delay of the transcoding result.
|
||||
* @hide
|
||||
* TODO(hkuang): Add more description of this when priority is finalized.
|
||||
*/
|
||||
public static final int PRIORITY_OFFLINE = 2;
|
||||
@@ -287,7 +266,7 @@ public final class MediaTranscodeManager implements AutoCloseable {
|
||||
// Notifies client the progress update.
|
||||
if (job.mProgressUpdateExecutor != null && job.mProgressUpdateListener != null) {
|
||||
job.mProgressUpdateExecutor.execute(
|
||||
() -> job.mProgressUpdateListener.onProgressUpdate(newProgress));
|
||||
() -> job.mProgressUpdateListener.onProgressUpdate(job, newProgress));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -503,11 +482,6 @@ public final class MediaTranscodeManager implements AutoCloseable {
|
||||
mTranscodingClient = registerClient(service);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() {
|
||||
release();
|
||||
}
|
||||
|
||||
public static final class TranscodingRequest {
|
||||
/** Uri of the source media file. */
|
||||
private @NonNull Uri mSourceUri;
|
||||
@@ -892,9 +866,12 @@ public final class MediaTranscodeManager implements AutoCloseable {
|
||||
/**
|
||||
* Called when the progress changes. The progress is in percentage between 0 and 1,
|
||||
* where 0 means that the job has not yet started and 100 means that it has finished.
|
||||
*
|
||||
* @param job The job associated with the progress.
|
||||
* @param progress The new progress ranging from 0 ~ 100 inclusive.
|
||||
*/
|
||||
void onProgressUpdate(@IntRange(from = 0, to = 100) int progress);
|
||||
void onProgressUpdate(@NonNull TranscodingJob job,
|
||||
@IntRange(from = 0, to = 100) int progress);
|
||||
}
|
||||
|
||||
private final ITranscodingClient mJobOwner;
|
||||
|
||||
@@ -231,7 +231,7 @@ public class MediaTranscodeManagerDiedTest
|
||||
job.setOnProgressUpdateListener(listenerExecutor,
|
||||
new TranscodingJob.OnProgressUpdateListener() {
|
||||
@Override
|
||||
public void onProgressUpdate(int newProgress) {
|
||||
public void onProgressUpdate(TranscodingJob job, int newProgress) {
|
||||
if (newProgress > 0) {
|
||||
jobStartedSemaphore.release();
|
||||
}
|
||||
|
||||
@@ -532,7 +532,7 @@ public class MediaTranscodeManagerTest
|
||||
int mPreviousProgress = 0;
|
||||
|
||||
@Override
|
||||
public void onProgressUpdate(int newProgress) {
|
||||
public void onProgressUpdate(TranscodingJob job, int newProgress) {
|
||||
assertTrue("Invalid proress update", newProgress > mPreviousProgress);
|
||||
assertTrue("Invalid proress update", newProgress <= 100);
|
||||
if (newProgress > 0) {
|
||||
|
||||
@@ -4274,11 +4274,8 @@ package android.media {
|
||||
field @RequiresPermission(android.Manifest.permission.CAPTURE_AUDIO_OUTPUT) public static final int RADIO_TUNER = 1998; // 0x7ce
|
||||
}
|
||||
|
||||
public final class MediaTranscodeManager implements java.lang.AutoCloseable {
|
||||
method public void close();
|
||||
public final class MediaTranscodeManager {
|
||||
method @NonNull public android.media.MediaTranscodeManager.TranscodingJob enqueueRequest(@NonNull android.media.MediaTranscodeManager.TranscodingRequest, @NonNull java.util.concurrent.Executor, @NonNull android.media.MediaTranscodeManager.OnTranscodingFinishedListener) throws java.io.FileNotFoundException;
|
||||
method protected void finalize();
|
||||
field public static final int PRIORITY_OFFLINE = 2; // 0x2
|
||||
field public static final int PRIORITY_REALTIME = 1; // 0x1
|
||||
field public static final int TRANSCODING_TYPE_VIDEO = 1; // 0x1
|
||||
}
|
||||
@@ -4307,7 +4304,7 @@ package android.media {
|
||||
}
|
||||
|
||||
@java.lang.FunctionalInterface public static interface MediaTranscodeManager.TranscodingJob.OnProgressUpdateListener {
|
||||
method public void onProgressUpdate(@IntRange(from=0, to=100) int);
|
||||
method public void onProgressUpdate(@NonNull android.media.MediaTranscodeManager.TranscodingJob, @IntRange(from=0, to=100) int);
|
||||
}
|
||||
|
||||
public static final class MediaTranscodeManager.TranscodingRequest {
|
||||
|
||||
Reference in New Issue
Block a user