Merge "Add AssetFileDescriptor to MediaExtractor." into nyc-dev
This commit is contained in:
@@ -20850,6 +20850,7 @@ package android.media {
|
||||
method public final void setDataSource(android.content.Context, android.net.Uri, java.util.Map<java.lang.String, java.lang.String>) throws java.io.IOException;
|
||||
method public final void setDataSource(java.lang.String, java.util.Map<java.lang.String, java.lang.String>) throws java.io.IOException;
|
||||
method public final void setDataSource(java.lang.String) throws java.io.IOException;
|
||||
method public final void setDataSource(android.content.res.AssetFileDescriptor) throws java.io.IOException, java.lang.IllegalArgumentException, java.lang.IllegalStateException;
|
||||
method public final void setDataSource(java.io.FileDescriptor) throws java.io.IOException;
|
||||
method public final void setDataSource(java.io.FileDescriptor, long, long) throws java.io.IOException;
|
||||
method public void unselectTrack(int);
|
||||
|
||||
@@ -22342,6 +22342,7 @@ package android.media {
|
||||
method public final void setDataSource(android.content.Context, android.net.Uri, java.util.Map<java.lang.String, java.lang.String>) throws java.io.IOException;
|
||||
method public final void setDataSource(java.lang.String, java.util.Map<java.lang.String, java.lang.String>) throws java.io.IOException;
|
||||
method public final void setDataSource(java.lang.String) throws java.io.IOException;
|
||||
method public final void setDataSource(android.content.res.AssetFileDescriptor) throws java.io.IOException, java.lang.IllegalArgumentException, java.lang.IllegalStateException;
|
||||
method public final void setDataSource(java.io.FileDescriptor) throws java.io.IOException;
|
||||
method public final void setDataSource(java.io.FileDescriptor, long, long) throws java.io.IOException;
|
||||
method public void unselectTrack(int);
|
||||
|
||||
@@ -20861,6 +20861,7 @@ package android.media {
|
||||
method public final void setDataSource(android.content.Context, android.net.Uri, java.util.Map<java.lang.String, java.lang.String>) throws java.io.IOException;
|
||||
method public final void setDataSource(java.lang.String, java.util.Map<java.lang.String, java.lang.String>) throws java.io.IOException;
|
||||
method public final void setDataSource(java.lang.String) throws java.io.IOException;
|
||||
method public final void setDataSource(android.content.res.AssetFileDescriptor) throws java.io.IOException, java.lang.IllegalArgumentException, java.lang.IllegalStateException;
|
||||
method public final void setDataSource(java.io.FileDescriptor) throws java.io.IOException;
|
||||
method public final void setDataSource(java.io.FileDescriptor, long, long) throws java.io.IOException;
|
||||
method public void unselectTrack(int);
|
||||
|
||||
@@ -28,6 +28,8 @@ import android.media.MediaHTTPService;
|
||||
import android.net.Uri;
|
||||
import android.os.IBinder;
|
||||
|
||||
import com.android.internal.util.Preconditions;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -188,6 +190,26 @@ final public class MediaExtractor {
|
||||
null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the data source (AssetFileDescriptor) to use. It is the caller's
|
||||
* responsibility to close the file descriptor. It is safe to do so as soon
|
||||
* as this call returns.
|
||||
*
|
||||
* @param afd the AssetFileDescriptor for the file you want to extract from.
|
||||
*/
|
||||
public final void setDataSource(@NonNull AssetFileDescriptor afd)
|
||||
throws IOException, IllegalArgumentException, IllegalStateException {
|
||||
Preconditions.checkNotNull(afd);
|
||||
// Note: using getDeclaredLength so that our behavior is the same
|
||||
// as previous versions when the content provider is returning
|
||||
// a full file.
|
||||
if (afd.getDeclaredLength() < 0) {
|
||||
setDataSource(afd.getFileDescriptor());
|
||||
} else {
|
||||
setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getDeclaredLength());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the data source (FileDescriptor) to use. It is the caller's responsibility
|
||||
* to close the file descriptor. It is safe to do so as soon as this call returns.
|
||||
|
||||
Reference in New Issue
Block a user