diff options
author | Marco Nelissen <marcone@google.com> | 2012-08-24 09:55:44 -0700 |
---|---|---|
committer | Marco Nelissen <marcone@google.com> | 2012-08-24 10:36:51 -0700 |
commit | c209a06cfdcf633f12a299245312e3ac32bff27c (patch) | |
tree | 036c6847186f84384127378e914da23326f3a969 /media/java | |
parent | 6715d1effaa70abf261112d2771d4d555cc109c2 (diff) | |
download | frameworks_base-c209a06cfdcf633f12a299245312e3ac32bff27c.zip frameworks_base-c209a06cfdcf633f12a299245312e3ac32bff27c.tar.gz frameworks_base-c209a06cfdcf633f12a299245312e3ac32bff27c.tar.bz2 |
Let apps provide a custom data source for extractors
Adds android.media.DataSource, which is modeled after its native namesake,
and a new method on MediaExtractor that lets apps specify their implementation
of a DataSource as the source of data for the extractor.
Change-Id: If1b169bd18d2691ebc4f8996494dfc8ee0894b6c
Diffstat (limited to 'media/java')
-rw-r--r-- | media/java/android/media/DataSource.java | 43 | ||||
-rw-r--r-- | media/java/android/media/MediaExtractor.java | 7 |
2 files changed, 50 insertions, 0 deletions
diff --git a/media/java/android/media/DataSource.java b/media/java/android/media/DataSource.java new file mode 100644 index 0000000..347bd5f --- /dev/null +++ b/media/java/android/media/DataSource.java @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package android.media; + +import java.io.Closeable; + +/** + * An abstraction for a media data source, e.g. a file or an http stream + * {@hide} + */ +public interface DataSource extends Closeable { + /** + * Reads data from the data source at the requested position + * + * @param offset where in the source to read + * @param buffer the buffer to read the data into + * @param size how many bytes to read + * @return the number of bytes read, or -1 if there was an error + */ + public int readAt(long offset, byte[] buffer, int size); + + /** + * Gets the size of the data source. + * + * @return size of data source, or -1 if the length is unknown + */ + public long getSize(); +} diff --git a/media/java/android/media/MediaExtractor.java b/media/java/android/media/MediaExtractor.java index 687d3a5..4b8d3cb 100644 --- a/media/java/android/media/MediaExtractor.java +++ b/media/java/android/media/MediaExtractor.java @@ -22,6 +22,7 @@ import android.content.res.AssetFileDescriptor; import android.media.MediaCodec; import android.media.MediaFormat; import android.net.Uri; + import java.io.FileDescriptor; import java.io.IOException; import java.nio.ByteBuffer; @@ -60,6 +61,12 @@ final public class MediaExtractor { } /** + * Sets the DataSource object to be used as the data source for this extractor + * {@hide} + */ + public native final void setDataSource(DataSource source); + + /** * Sets the data source as a content Uri. * * @param context the Context to use when resolving the Uri |