Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a3c1c229 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Add AssetFileDescriptor to MediaExtractor.

Mirrors API on MediaPlayer.

Bug: 27506874
Change-Id: Ibc07cf8151c362ff7375b89e7a9044bef1d9e94d
parent aacb89e9
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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);
+1 −0
Original line number Diff line number Diff line
@@ -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);
+1 −0
Original line number Diff line number Diff line
@@ -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);
+22 −0
Original line number Diff line number Diff line
@@ -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.