19066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project/*
29066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Copyright (C) 2008 The Android Open Source Project
39066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
49066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License");
59066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * you may not use this file except in compliance with the License.
69066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * You may obtain a copy of the License at
79066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
89066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *      http://www.apache.org/licenses/LICENSE-2.0
99066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Unless required by applicable law or agreed to in writing, software
119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS,
129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * See the License for the specific language governing permissions and
149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * limitations under the License.
159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */
169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectpackage android.media;
189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport android.content.ContentResolver;
209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport android.content.Context;
219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport android.content.res.AssetFileDescriptor;
229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport android.graphics.Bitmap;
239066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport android.net.Uri;
24c5d5ee34d7c1026ca8d5cd8b186e5a73c5230247Marco Nelissen
259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport java.io.FileDescriptor;
269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport java.io.FileNotFoundException;
27c5d5ee34d7c1026ca8d5cd8b186e5a73c5230247Marco Nelissenimport java.io.IOException;
289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
295b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huberimport java.util.Map;
305b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber
319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project/**
329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * MediaMetadataRetriever class provides a unified interface for retrieving
339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * frame and meta data from an input media file.
349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */
359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectpublic class MediaMetadataRetriever
369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project{
379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    static {
389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        System.loadLibrary("media_jni");
394935d05eaa306cef88cf0ab13eca386f270409ecMarco Nelissen        native_init();
409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    // The field below is accessed by native methods
439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    @SuppressWarnings("unused")
449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    private int mNativeContext;
459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
46df9b349b960fff95dff4fcf8b2661899e33059daJames Dong    private static final int EMBEDDED_PICTURE_TYPE_ANY = 0xFFFF;
47df9b349b960fff95dff4fcf8b2661899e33059daJames Dong
489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public MediaMetadataRetriever() {
499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        native_setup();
509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Sets the data source (file pathname) to use. Call this
549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * method before the rest of the methods in this class. This method may be
559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * time-consuming.
569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param path The path of the input media file.
589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @throws IllegalArgumentException If the path is invalid.
599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public native void setDataSource(String path) throws IllegalArgumentException;
615b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber
625b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber    /**
635b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber     * Sets the data source (URI) to use. Call this
645b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber     * method before the rest of the methods in this class. This method may be
655b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber     * time-consuming.
665b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber     *
675b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber     * @param uri The URI of the input media.
685b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber     * @param headers the headers to be sent together with the request for the data
695b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber     * @throws IllegalArgumentException If the URI is invalid.
705b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber     */
7117524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong    public void setDataSource(String uri,  Map<String, String> headers)
7217524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong            throws IllegalArgumentException {
7317524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong        int i = 0;
7417524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong        String[] keys = new String[headers.size()];
7517524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong        String[] values = new String[headers.size()];
7617524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong        for (Map.Entry<String, String> entry: headers.entrySet()) {
7717524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong            keys[i] = entry.getKey();
7817524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong            values[i] = entry.getValue();
7917524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong            ++i;
8017524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong        }
8117524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong        _setDataSource(uri, keys, values);
8217524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong    }
8317524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong
8417524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong    private native void _setDataSource(
8517524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong        String uri, String[] keys, String[] values)
865b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber        throws IllegalArgumentException;
875b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber
889066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
899066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Sets the data source (FileDescriptor) to use.  It is the caller's
909066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * responsibility to close the file descriptor. It is safe to do so as soon
919066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * as this call returns. Call this method before the rest of the methods in
929066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * this class. This method may be time-consuming.
939066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
949066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param fd the FileDescriptor for the file you want to play
959066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param offset the offset into the file where the data to be played starts,
969066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * in bytes. It must be non-negative
979066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param length the length in bytes of the data to be played. It must be
989066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * non-negative.
999066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @throws IllegalArgumentException if the arguments are invalid
1009066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
1019066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public native void setDataSource(FileDescriptor fd, long offset, long length)
1029066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            throws IllegalArgumentException;
1039066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
1049066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
1059066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Sets the data source (FileDescriptor) to use. It is the caller's
1069066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * responsibility to close the file descriptor. It is safe to do so as soon
1079066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * as this call returns. Call this method before the rest of the methods in
1089066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * this class. This method may be time-consuming.
1099066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
1109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param fd the FileDescriptor for the file you want to play
1119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @throws IllegalArgumentException if the FileDescriptor is invalid
1129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
1139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void setDataSource(FileDescriptor fd)
1149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            throws IllegalArgumentException {
1159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        // intentionally less than LONG_MAX
1169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        setDataSource(fd, 0, 0x7ffffffffffffffL);
1179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
1189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
1199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
1209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Sets the data source as a content Uri. Call this method before
1219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * the rest of the methods in this class. This method may be time-consuming.
1229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
1239066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param context the Context to use when resolving the Uri
1249066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param uri the Content URI of the data you want to play
1259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @throws IllegalArgumentException if the Uri is invalid
1269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @throws SecurityException if the Uri cannot be used due to lack of
1279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * permission.
1289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
1299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void setDataSource(Context context, Uri uri)
1309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        throws IllegalArgumentException, SecurityException {
1319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        if (uri == null) {
1329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            throw new IllegalArgumentException();
1339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
1349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
1359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        String scheme = uri.getScheme();
1369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        if(scheme == null || scheme.equals("file")) {
1379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            setDataSource(uri.getPath());
1389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            return;
1399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
1409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
1419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        AssetFileDescriptor fd = null;
1429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        try {
1439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            ContentResolver resolver = context.getContentResolver();
1449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            try {
1459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                fd = resolver.openAssetFileDescriptor(uri, "r");
1469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            } catch(FileNotFoundException e) {
1479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                throw new IllegalArgumentException();
1489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            }
1499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            if (fd == null) {
1509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                throw new IllegalArgumentException();
1519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            }
1529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            FileDescriptor descriptor = fd.getFileDescriptor();
1539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            if (!descriptor.valid()) {
1549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                throw new IllegalArgumentException();
1559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            }
1569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            // Note: using getDeclaredLength so that our behavior is the same
1579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            // as previous versions when the content provider is returning
1589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            // a full file.
1599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            if (fd.getDeclaredLength() < 0) {
1609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                setDataSource(descriptor);
1619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            } else {
1629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                setDataSource(descriptor, fd.getStartOffset(), fd.getDeclaredLength());
1639066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            }
1649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            return;
1659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        } catch (SecurityException ex) {
1669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        } finally {
1679066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            try {
1689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                if (fd != null) {
1699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                    fd.close();
1709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                }
1719066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            } catch(IOException ioEx) {
1729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            }
1739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
1749066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        setDataSource(uri.toString());
1759066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
1769066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
1779066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
1789066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Call this method after setDataSource(). This method retrieves the
1799066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * meta data value associated with the keyCode.
1809066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
1819066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * The keyCode currently supported is listed below as METADATA_XXX
1829066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * constants. With any other value, it returns a null pointer.
1839066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
1849066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param keyCode One of the constants listed below at the end of the class.
1859066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @return The meta data value associate with the given keyCode on success;
1869066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * null on failure.
1879066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
1889066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public native String extractMetadata(int keyCode);
1899066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
1909066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
1919066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Call this method after setDataSource(). This method finds a
192faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * representative frame close to the given time position by considering
193faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * the given option if possible, and returns it as a bitmap. This is
194faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * useful for generating a thumbnail for an input data source or just
195faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * obtain and display a frame at the given time position.
196faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     *
197faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * @param timeUs The time position where the frame will be retrieved.
198faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * When retrieving the frame at the given time position, there is no
199faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * guarantee that the data source has a frame located at the position.
200faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * When this happens, a frame nearby will be returned. If timeUs is
201faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * negative, time position and option will ignored, and any frame
202faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * that the implementation considers as representative may be returned.
203faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     *
204faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * @param option a hint on how the frame is found. Use
20511eab056dd0133a390169d3581edf3eef26d6a54James Dong     * {@link #OPTION_PREVIOUS_SYNC} if one wants to retrieve a sync frame
206faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * that has a timestamp earlier than or the same as timeUs. Use
20711eab056dd0133a390169d3581edf3eef26d6a54James Dong     * {@link #OPTION_NEXT_SYNC} if one wants to retrieve a sync frame
208faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * that has a timestamp later than or the same as timeUs. Use
20911eab056dd0133a390169d3581edf3eef26d6a54James Dong     * {@link #OPTION_CLOSEST_SYNC} if one wants to retrieve a sync frame
210faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * that has a timestamp closest to or the same as timeUs. Use
21111eab056dd0133a390169d3581edf3eef26d6a54James Dong     * {@link #OPTION_CLOSEST} if one wants to retrieve a frame that may
212faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * or may not be a sync frame but is closest to or the same as timeUs.
21311eab056dd0133a390169d3581edf3eef26d6a54James Dong     * {@link #OPTION_CLOSEST} often has larger performance overhead compared
214faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * to the other options if there is no sync frame located at timeUs.
215faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     *
2169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @return A Bitmap containing a representative video frame, which
2179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *         can be null, if such a frame cannot be retrieved.
2189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
219faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    public Bitmap getFrameAtTime(long timeUs, int option) {
220faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong        if (option < OPTION_PREVIOUS_SYNC ||
221faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong            option > OPTION_CLOSEST) {
222faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong            throw new IllegalArgumentException("Unsupported option: " + option);
223faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong        }
224faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong
225faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong        return _getFrameAtTime(timeUs, option);
226faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    }
227faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong
228faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    /**
229faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * Call this method after setDataSource(). This method finds a
230faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * representative frame close to the given time position if possible,
231faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * and returns it as a bitmap. This is useful for generating a thumbnail
232faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * for an input data source. Call this method if one does not care
233faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * how the frame is found as long as it is close to the given time;
23411eab056dd0133a390169d3581edf3eef26d6a54James Dong     * otherwise, please call {@link #getFrameAtTime(long, int)}.
235faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     *
236faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * @param timeUs The time position where the frame will be retrieved.
237faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * When retrieving the frame at the given time position, there is no
238faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * guarentee that the data source has a frame located at the position.
239faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * When this happens, a frame nearby will be returned. If timeUs is
240faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * negative, time position and option will ignored, and any frame
241faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * that the implementation considers as representative may be returned.
242faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     *
243faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * @return A Bitmap containing a representative video frame, which
244faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     *         can be null, if such a frame cannot be retrieved.
245faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     *
246faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * @see #getFrameAtTime(long, int)
247faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     */
248faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    public Bitmap getFrameAtTime(long timeUs) {
249faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong        return getFrameAtTime(timeUs, OPTION_CLOSEST_SYNC);
250faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    }
251faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong
252faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    /**
253faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * Call this method after setDataSource(). This method finds a
254faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * representative frame at any time position if possible,
255faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * and returns it as a bitmap. This is useful for generating a thumbnail
256faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * for an input data source. Call this method if one does not
257faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * care about where the frame is located; otherwise, please call
25811eab056dd0133a390169d3581edf3eef26d6a54James Dong     * {@link #getFrameAtTime(long)} or {@link #getFrameAtTime(long, int)}
259faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     *
260faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * @return A Bitmap containing a representative video frame, which
261faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     *         can be null, if such a frame cannot be retrieved.
262faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     *
263faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * @see #getFrameAtTime(long)
264faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * @see #getFrameAtTime(long, int)
265faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     */
266faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    public Bitmap getFrameAtTime() {
267faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong        return getFrameAtTime(-1, OPTION_CLOSEST_SYNC);
268faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    }
269faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong
270faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    private native Bitmap _getFrameAtTime(long timeUs, int option);
271faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong
2729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
2739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
2749066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Call this method after setDataSource(). This method finds the optional
275e8b26dcec7765786bbf063b3ae6b967b8b547ab6James Dong     * graphic or album/cover art associated associated with the data source. If
27611eab056dd0133a390169d3581edf3eef26d6a54James Dong     * there are more than one pictures, (any) one of them is returned.
2779066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
2789066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @return null if no such graphic is found.
2799066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
280df9b349b960fff95dff4fcf8b2661899e33059daJames Dong    public byte[] getEmbeddedPicture() {
281df9b349b960fff95dff4fcf8b2661899e33059daJames Dong        return getEmbeddedPicture(EMBEDDED_PICTURE_TYPE_ANY);
282df9b349b960fff95dff4fcf8b2661899e33059daJames Dong    }
283df9b349b960fff95dff4fcf8b2661899e33059daJames Dong
284df9b349b960fff95dff4fcf8b2661899e33059daJames Dong    private native byte[] getEmbeddedPicture(int pictureType);
2859066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
2869066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
2879066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Call it when one is done with the object. This method releases the memory
2889066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * allocated internally.
2899066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
2909066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public native void release();
2914935d05eaa306cef88cf0ab13eca386f270409ecMarco Nelissen    private native void native_setup();
2924935d05eaa306cef88cf0ab13eca386f270409ecMarco Nelissen    private static native void native_init();
2939066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
2949066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    private native final void native_finalize();
2959066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
2969066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    @Override
2979066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    protected void finalize() throws Throwable {
2989066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        try {
2999066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            native_finalize();
3009066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        } finally {
3019066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            super.finalize();
3029066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
3039066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
3049066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
305faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    /**
30611eab056dd0133a390169d3581edf3eef26d6a54James Dong     * Option used in method {@link #getFrameAtTime(long, int)} to get a
307faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * frame at a specified location.
308faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     *
309faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * @see #getFrameAtTime(long, int)
310faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     */
31111eab056dd0133a390169d3581edf3eef26d6a54James Dong    /* Do not change these option values without updating their counterparts
312faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * in include/media/stagefright/MediaSource.h!
313faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     */
31411eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
31511eab056dd0133a390169d3581edf3eef26d6a54James Dong     * This option is used with {@link #getFrameAtTime(long, int)} to retrieve
31611eab056dd0133a390169d3581edf3eef26d6a54James Dong     * a sync (or key) frame associated with a data source that is located
31711eab056dd0133a390169d3581edf3eef26d6a54James Dong     * right before or at the given time.
31811eab056dd0133a390169d3581edf3eef26d6a54James Dong     *
31911eab056dd0133a390169d3581edf3eef26d6a54James Dong     * @see #getFrameAtTime(long, int)
32011eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
321faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    public static final int OPTION_PREVIOUS_SYNC    = 0x00;
32211eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
32311eab056dd0133a390169d3581edf3eef26d6a54James Dong     * This option is used with {@link #getFrameAtTime(long, int)} to retrieve
32411eab056dd0133a390169d3581edf3eef26d6a54James Dong     * a sync (or key) frame associated with a data source that is located
32511eab056dd0133a390169d3581edf3eef26d6a54James Dong     * right after or at the given time.
32611eab056dd0133a390169d3581edf3eef26d6a54James Dong     *
32711eab056dd0133a390169d3581edf3eef26d6a54James Dong     * @see #getFrameAtTime(long, int)
32811eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
329faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    public static final int OPTION_NEXT_SYNC        = 0x01;
33011eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
33111eab056dd0133a390169d3581edf3eef26d6a54James Dong     * This option is used with {@link #getFrameAtTime(long, int)} to retrieve
33211eab056dd0133a390169d3581edf3eef26d6a54James Dong     * a sync (or key) frame associated with a data source that is located
33311eab056dd0133a390169d3581edf3eef26d6a54James Dong     * closest to (in time) or at the given time.
33411eab056dd0133a390169d3581edf3eef26d6a54James Dong     *
33511eab056dd0133a390169d3581edf3eef26d6a54James Dong     * @see #getFrameAtTime(long, int)
33611eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
337faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    public static final int OPTION_CLOSEST_SYNC     = 0x02;
33811eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
33911eab056dd0133a390169d3581edf3eef26d6a54James Dong     * This option is used with {@link #getFrameAtTime(long, int)} to retrieve
34011eab056dd0133a390169d3581edf3eef26d6a54James Dong     * a frame (not necessarily a key frame) associated with a data source that
34111eab056dd0133a390169d3581edf3eef26d6a54James Dong     * is located closest to or at the given time.
34211eab056dd0133a390169d3581edf3eef26d6a54James Dong     *
34311eab056dd0133a390169d3581edf3eef26d6a54James Dong     * @see #getFrameAtTime(long, int)
34411eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
345faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    public static final int OPTION_CLOSEST          = 0x03;
346faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong
3479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /*
34811eab056dd0133a390169d3581edf3eef26d6a54James Dong     * Do not change these metadata key values without updating their
34911eab056dd0133a390169d3581edf3eef26d6a54James Dong     * counterparts in include/media/mediametadataretriever.h!
35011eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
35111eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
35211eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the numberic string describing the
35311eab056dd0133a390169d3581edf3eef26d6a54James Dong     * order of the audio data source on its original recording.
3549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
3559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final int METADATA_KEY_CD_TRACK_NUMBER = 0;
35611eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
35711eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the information about the album title
35811eab056dd0133a390169d3581edf3eef26d6a54James Dong     * of the data source.
35911eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
3609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final int METADATA_KEY_ALBUM           = 1;
36111eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
36211eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the information about the artist of
36311eab056dd0133a390169d3581edf3eef26d6a54James Dong     * the data source.
36411eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
3659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final int METADATA_KEY_ARTIST          = 2;
36611eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
36711eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the information about the author of
36811eab056dd0133a390169d3581edf3eef26d6a54James Dong     * the data source.
36911eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
3709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final int METADATA_KEY_AUTHOR          = 3;
37111eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
37211eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the information about the composer of
37311eab056dd0133a390169d3581edf3eef26d6a54James Dong     * the data source.
37411eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
3759066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final int METADATA_KEY_COMPOSER        = 4;
37611eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
37711eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the date when the data source was created
37811eab056dd0133a390169d3581edf3eef26d6a54James Dong     * or modified.
37911eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
3809066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final int METADATA_KEY_DATE            = 5;
38111eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
38211eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the content type or genre of the data
38311eab056dd0133a390169d3581edf3eef26d6a54James Dong     * source.
38411eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
3859066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final int METADATA_KEY_GENRE           = 6;
38611eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
38711eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the data source title.
38811eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
3899066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final int METADATA_KEY_TITLE           = 7;
39011eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
39111eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the year when the data source was created
39211eab056dd0133a390169d3581edf3eef26d6a54James Dong     * or modified.
39311eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
3949066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final int METADATA_KEY_YEAR            = 8;
39511eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
39611eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the playback duration of the data source.
39711eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
3989066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final int METADATA_KEY_DURATION        = 9;
39911eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
40011eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the number of tracks, such as audio, video,
40111eab056dd0133a390169d3581edf3eef26d6a54James Dong     * text, in the data source, such as a mp4 or 3gpp file.
40211eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
4039066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final int METADATA_KEY_NUM_TRACKS      = 10;
40411eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
40511eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the information of the writer (such as
40611eab056dd0133a390169d3581edf3eef26d6a54James Dong     * lyricist) of the data source.
40711eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
40811eab056dd0133a390169d3581edf3eef26d6a54James Dong    public static final int METADATA_KEY_WRITER          = 11;
40911eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
41011eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the mime type of the data source. Some
41111eab056dd0133a390169d3581edf3eef26d6a54James Dong     * example mime types include: "video/mp4", "audio/mp4", "audio/amr-wb",
41211eab056dd0133a390169d3581edf3eef26d6a54James Dong     * etc.
41311eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
41411eab056dd0133a390169d3581edf3eef26d6a54James Dong    public static final int METADATA_KEY_MIMETYPE        = 12;
41511eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
41611eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the information about the performers or
41711eab056dd0133a390169d3581edf3eef26d6a54James Dong     * artist associated with the data source.
41811eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
41911eab056dd0133a390169d3581edf3eef26d6a54James Dong    public static final int METADATA_KEY_ALBUMARTIST     = 13;
42011eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
42111eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the numberic string that describes which
42211eab056dd0133a390169d3581edf3eef26d6a54James Dong     * part of a set the audio data source comes from.
42311eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
42411eab056dd0133a390169d3581edf3eef26d6a54James Dong    public static final int METADATA_KEY_DISC_NUMBER     = 14;
42511eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
42611eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the music album compilation status.
42711eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
42811eab056dd0133a390169d3581edf3eef26d6a54James Dong    public static final int METADATA_KEY_COMPILATION     = 15;
429c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber    /**
430c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber     * If this key exists the media contains audio content.
431c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber     */
432c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber    public static final int METADATA_KEY_HAS_AUDIO       = 16;
433c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber    /**
434c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber     * If this key exists the media contains video content.
435c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber     */
436c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber    public static final int METADATA_KEY_HAS_VIDEO       = 17;
437c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber    /**
438c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber     * If the media contains video, this key retrieves its width.
439c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber     */
440c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber    public static final int METADATA_KEY_VIDEO_WIDTH     = 18;
441c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber    /**
442c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber     * If the media contains video, this key retrieves its height.
443c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber     */
444c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber    public static final int METADATA_KEY_VIDEO_HEIGHT    = 19;
445c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber    /**
446c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber     * This key retrieves the average bitrate (in bits/sec), if available.
447c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber     */
448c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber    public static final int METADATA_KEY_BITRATE         = 20;
449c6091ddd3a22da98b5e83d4b5d864939b451b752Gloria Wang    /**
450c6091ddd3a22da98b5e83d4b5d864939b451b752Gloria Wang     * This key retrieves the language code of text tracks, if available.
451c6091ddd3a22da98b5e83d4b5d864939b451b752Gloria Wang     * If multiple text tracks present, the return value will look like:
452c6091ddd3a22da98b5e83d4b5d864939b451b752Gloria Wang     * "eng:chi"
453c6091ddd3a22da98b5e83d4b5d864939b451b752Gloria Wang     * @hide
454c6091ddd3a22da98b5e83d4b5d864939b451b752Gloria Wang     */
455c6091ddd3a22da98b5e83d4b5d864939b451b752Gloria Wang    public static final int METADATA_KEY_TIMED_TEXT_LANGUAGES      = 21;
45682428a862f325238cfb5646bbd65de3f1a11e7ccGloria Wang    /**
45782428a862f325238cfb5646bbd65de3f1a11e7ccGloria Wang     * If this key exists the media is drm-protected.
45882428a862f325238cfb5646bbd65de3f1a11e7ccGloria Wang     * @hide
45982428a862f325238cfb5646bbd65de3f1a11e7ccGloria Wang     */
46082428a862f325238cfb5646bbd65de3f1a11e7ccGloria Wang    public static final int METADATA_KEY_IS_DRM          = 22;
46177c500c9a1f763b31fb5a03c803b3523fcb72310James Dong    /**
46277c500c9a1f763b31fb5a03c803b3523fcb72310James Dong     * This key retrieves the location information, if available.
46377c500c9a1f763b31fb5a03c803b3523fcb72310James Dong     * The location should be specified according to ISO-6709 standard, under
46477c500c9a1f763b31fb5a03c803b3523fcb72310James Dong     * a mp4/3gp box "@xyz". Location with longitude of -90 degrees and latitude
46577c500c9a1f763b31fb5a03c803b3523fcb72310James Dong     * of 180 degrees will be retrieved as "-90.0000+180.0000", for instance.
46677c500c9a1f763b31fb5a03c803b3523fcb72310James Dong     */
46777c500c9a1f763b31fb5a03c803b3523fcb72310James Dong    public static final int METADATA_KEY_LOCATION        = 23;
4689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    // Add more here...
4699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project}
470