MediaMetadataRetriever.java revision 075e9a19ce645752f8282bc19c91b25978a7dc52
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;
260041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dongimport java.io.FileInputStream;
279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport java.io.FileNotFoundException;
28c5d5ee34d7c1026ca8d5cd8b186e5a73c5230247Marco Nelissenimport java.io.IOException;
299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
305b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huberimport java.util.Map;
315b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber
329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project/**
339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * MediaMetadataRetriever class provides a unified interface for retrieving
349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * frame and meta data from an input media file.
359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */
369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectpublic class MediaMetadataRetriever
379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project{
389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    static {
399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        System.loadLibrary("media_jni");
404935d05eaa306cef88cf0ab13eca386f270409ecMarco Nelissen        native_init();
419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    // The field below is accessed by native methods
449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    @SuppressWarnings("unused")
45075e9a19ce645752f8282bc19c91b25978a7dc52Ashok Bhat    private long mNativeContext;
469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
47df9b349b960fff95dff4fcf8b2661899e33059daJames Dong    private static final int EMBEDDED_PICTURE_TYPE_ANY = 0xFFFF;
48df9b349b960fff95dff4fcf8b2661899e33059daJames Dong
499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public MediaMetadataRetriever() {
509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        native_setup();
519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Sets the data source (file pathname) to use. Call this
559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * method before the rest of the methods in this class. This method may be
569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * time-consuming.
579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param path The path of the input media file.
599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @throws IllegalArgumentException If the path is invalid.
609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
610041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong    public void setDataSource(String path) throws IllegalArgumentException {
62425916e4c5305b9bfff5b5d60d203363afcb7b89Oscar Rydhé        if (path == null) {
63425916e4c5305b9bfff5b5d60d203363afcb7b89Oscar Rydhé            throw new IllegalArgumentException();
64425916e4c5305b9bfff5b5d60d203363afcb7b89Oscar Rydhé        }
65425916e4c5305b9bfff5b5d60d203363afcb7b89Oscar Rydhé
660041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong        FileInputStream is = null;
670041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong        try {
680041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong            is = new FileInputStream(path);
690041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong            FileDescriptor fd = is.getFD();
700041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong            setDataSource(fd, 0, 0x7ffffffffffffffL);
710041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong        } catch (FileNotFoundException fileEx) {
720041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong            throw new IllegalArgumentException();
730041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong        } catch (IOException ioEx) {
740041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong            throw new IllegalArgumentException();
750041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong        }
760041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong
770041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong        try {
780041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong            if (is != null) {
790041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong                is.close();
800041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong            }
810041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong        } catch (Exception e) {}
820041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong    }
835b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber
845b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber    /**
855b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber     * Sets the data source (URI) to use. Call this
865b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber     * method before the rest of the methods in this class. This method may be
875b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber     * time-consuming.
885b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber     *
895b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber     * @param uri The URI of the input media.
905b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber     * @param headers the headers to be sent together with the request for the data
915b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber     * @throws IllegalArgumentException If the URI is invalid.
925b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber     */
9317524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong    public void setDataSource(String uri,  Map<String, String> headers)
9417524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong            throws IllegalArgumentException {
9517524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong        int i = 0;
9617524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong        String[] keys = new String[headers.size()];
9717524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong        String[] values = new String[headers.size()];
9817524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong        for (Map.Entry<String, String> entry: headers.entrySet()) {
9917524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong            keys[i] = entry.getKey();
10017524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong            values[i] = entry.getValue();
10117524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong            ++i;
10217524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong        }
10317524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong        _setDataSource(uri, keys, values);
10417524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong    }
10517524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong
10617524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong    private native void _setDataSource(
10717524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong        String uri, String[] keys, String[] values)
1085b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber        throws IllegalArgumentException;
1095b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber
1109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
1119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Sets the data source (FileDescriptor) to use.  It is the caller's
1129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * responsibility to close the file descriptor. It is safe to do so as soon
1139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * as this call returns. Call this method before the rest of the methods in
1149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * this class. This method may be time-consuming.
1159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
1169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param fd the FileDescriptor for the file you want to play
1179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param offset the offset into the file where the data to be played starts,
1189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * in bytes. It must be non-negative
1199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param length the length in bytes of the data to be played. It must be
1209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * non-negative.
1219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @throws IllegalArgumentException if the arguments are invalid
1229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
1239066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public native void setDataSource(FileDescriptor fd, long offset, long length)
1249066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            throws IllegalArgumentException;
1259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
1269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
1279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Sets the data source (FileDescriptor) to use. It is the caller's
1289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * responsibility to close the file descriptor. It is safe to do so as soon
1299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * as this call returns. Call this method before the rest of the methods in
1309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * this class. This method may be time-consuming.
1319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
1329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param fd the FileDescriptor for the file you want to play
1339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @throws IllegalArgumentException if the FileDescriptor is invalid
1349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
1359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void setDataSource(FileDescriptor fd)
1369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            throws IllegalArgumentException {
1379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        // intentionally less than LONG_MAX
1389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        setDataSource(fd, 0, 0x7ffffffffffffffL);
1399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
1409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
1419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
1429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Sets the data source as a content Uri. Call this method before
1439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * the rest of the methods in this class. This method may be time-consuming.
1449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
1459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param context the Context to use when resolving the Uri
1469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param uri the Content URI of the data you want to play
1479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @throws IllegalArgumentException if the Uri is invalid
1489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @throws SecurityException if the Uri cannot be used due to lack of
1499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * permission.
1509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
1519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void setDataSource(Context context, Uri uri)
1529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        throws IllegalArgumentException, SecurityException {
1539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        if (uri == null) {
1549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            throw new IllegalArgumentException();
1559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
1569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
1579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        String scheme = uri.getScheme();
1589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        if(scheme == null || scheme.equals("file")) {
1599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            setDataSource(uri.getPath());
1609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            return;
1619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
1629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
1639066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        AssetFileDescriptor fd = null;
1649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        try {
1659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            ContentResolver resolver = context.getContentResolver();
1669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            try {
1679066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                fd = resolver.openAssetFileDescriptor(uri, "r");
1689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            } catch(FileNotFoundException e) {
1699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                throw new IllegalArgumentException();
1709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            }
1719066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            if (fd == null) {
1729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                throw new IllegalArgumentException();
1739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            }
1749066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            FileDescriptor descriptor = fd.getFileDescriptor();
1759066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            if (!descriptor.valid()) {
1769066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                throw new IllegalArgumentException();
1779066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            }
1789066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            // Note: using getDeclaredLength so that our behavior is the same
1799066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            // as previous versions when the content provider is returning
1809066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            // a full file.
1819066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            if (fd.getDeclaredLength() < 0) {
1829066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                setDataSource(descriptor);
1839066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            } else {
1849066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                setDataSource(descriptor, fd.getStartOffset(), fd.getDeclaredLength());
1859066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            }
1869066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            return;
1879066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        } catch (SecurityException ex) {
1889066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        } finally {
1899066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            try {
1909066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                if (fd != null) {
1919066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                    fd.close();
1929066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                }
1939066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            } catch(IOException ioEx) {
1949066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            }
1959066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
1969066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        setDataSource(uri.toString());
1979066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
1989066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
1999066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
2009066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Call this method after setDataSource(). This method retrieves the
2019066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * meta data value associated with the keyCode.
2029066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
2039066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * The keyCode currently supported is listed below as METADATA_XXX
2049066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * constants. With any other value, it returns a null pointer.
2059066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
2069066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param keyCode One of the constants listed below at the end of the class.
2079066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @return The meta data value associate with the given keyCode on success;
2089066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * null on failure.
2099066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
2109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public native String extractMetadata(int keyCode);
2119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
2129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
2139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Call this method after setDataSource(). This method finds a
214faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * representative frame close to the given time position by considering
215faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * the given option if possible, and returns it as a bitmap. This is
216faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * useful for generating a thumbnail for an input data source or just
217faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * obtain and display a frame at the given time position.
218faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     *
219faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * @param timeUs The time position where the frame will be retrieved.
220faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * When retrieving the frame at the given time position, there is no
221faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * guarantee that the data source has a frame located at the position.
222faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * When this happens, a frame nearby will be returned. If timeUs is
223faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * negative, time position and option will ignored, and any frame
224faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * that the implementation considers as representative may be returned.
225faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     *
226faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * @param option a hint on how the frame is found. Use
22711eab056dd0133a390169d3581edf3eef26d6a54James Dong     * {@link #OPTION_PREVIOUS_SYNC} if one wants to retrieve a sync frame
228faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * that has a timestamp earlier than or the same as timeUs. Use
22911eab056dd0133a390169d3581edf3eef26d6a54James Dong     * {@link #OPTION_NEXT_SYNC} if one wants to retrieve a sync frame
230faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * that has a timestamp later than or the same as timeUs. Use
23111eab056dd0133a390169d3581edf3eef26d6a54James Dong     * {@link #OPTION_CLOSEST_SYNC} if one wants to retrieve a sync frame
232faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * that has a timestamp closest to or the same as timeUs. Use
23311eab056dd0133a390169d3581edf3eef26d6a54James Dong     * {@link #OPTION_CLOSEST} if one wants to retrieve a frame that may
234faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * or may not be a sync frame but is closest to or the same as timeUs.
23511eab056dd0133a390169d3581edf3eef26d6a54James Dong     * {@link #OPTION_CLOSEST} often has larger performance overhead compared
236faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * to the other options if there is no sync frame located at timeUs.
237faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     *
2389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @return A Bitmap containing a representative video frame, which
2399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *         can be null, if such a frame cannot be retrieved.
2409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
241faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    public Bitmap getFrameAtTime(long timeUs, int option) {
242faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong        if (option < OPTION_PREVIOUS_SYNC ||
243faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong            option > OPTION_CLOSEST) {
244faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong            throw new IllegalArgumentException("Unsupported option: " + option);
245faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong        }
246faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong
247faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong        return _getFrameAtTime(timeUs, option);
248faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    }
249faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong
250faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    /**
251faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * Call this method after setDataSource(). This method finds a
252faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * representative frame close to the given time position if possible,
253faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * and returns it as a bitmap. This is useful for generating a thumbnail
254faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * for an input data source. Call this method if one does not care
255faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * how the frame is found as long as it is close to the given time;
25611eab056dd0133a390169d3581edf3eef26d6a54James Dong     * otherwise, please call {@link #getFrameAtTime(long, int)}.
257faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     *
258faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * @param timeUs The time position where the frame will be retrieved.
259faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * When retrieving the frame at the given time position, there is no
260faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * guarentee that the data source has a frame located at the position.
261faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * When this happens, a frame nearby will be returned. If timeUs is
262faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * negative, time position and option will ignored, and any frame
263faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * that the implementation considers as representative may be returned.
264faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     *
265faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * @return A Bitmap containing a representative video frame, which
266faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     *         can be null, if such a frame cannot be retrieved.
267faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     *
268faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * @see #getFrameAtTime(long, int)
269faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     */
270faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    public Bitmap getFrameAtTime(long timeUs) {
271faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong        return getFrameAtTime(timeUs, OPTION_CLOSEST_SYNC);
272faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    }
273faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong
274faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    /**
275faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * Call this method after setDataSource(). This method finds a
276faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * representative frame at any time position if possible,
277faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * and returns it as a bitmap. This is useful for generating a thumbnail
278faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * for an input data source. Call this method if one does not
279faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * care about where the frame is located; otherwise, please call
28011eab056dd0133a390169d3581edf3eef26d6a54James Dong     * {@link #getFrameAtTime(long)} or {@link #getFrameAtTime(long, int)}
281faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     *
282faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * @return A Bitmap containing a representative video frame, which
283faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     *         can be null, if such a frame cannot be retrieved.
284faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     *
285faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * @see #getFrameAtTime(long)
286faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * @see #getFrameAtTime(long, int)
287faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     */
288faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    public Bitmap getFrameAtTime() {
289faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong        return getFrameAtTime(-1, OPTION_CLOSEST_SYNC);
290faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    }
291faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong
292faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    private native Bitmap _getFrameAtTime(long timeUs, int option);
293faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong
2949066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
2959066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
2969066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Call this method after setDataSource(). This method finds the optional
297e8b26dcec7765786bbf063b3ae6b967b8b547ab6James Dong     * graphic or album/cover art associated associated with the data source. If
29811eab056dd0133a390169d3581edf3eef26d6a54James Dong     * there are more than one pictures, (any) one of them is returned.
2999066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
3009066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @return null if no such graphic is found.
3019066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
302df9b349b960fff95dff4fcf8b2661899e33059daJames Dong    public byte[] getEmbeddedPicture() {
303df9b349b960fff95dff4fcf8b2661899e33059daJames Dong        return getEmbeddedPicture(EMBEDDED_PICTURE_TYPE_ANY);
304df9b349b960fff95dff4fcf8b2661899e33059daJames Dong    }
305df9b349b960fff95dff4fcf8b2661899e33059daJames Dong
306df9b349b960fff95dff4fcf8b2661899e33059daJames Dong    private native byte[] getEmbeddedPicture(int pictureType);
3079066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
3089066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
3099066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Call it when one is done with the object. This method releases the memory
3109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * allocated internally.
3119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
3129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public native void release();
3134935d05eaa306cef88cf0ab13eca386f270409ecMarco Nelissen    private native void native_setup();
3144935d05eaa306cef88cf0ab13eca386f270409ecMarco Nelissen    private static native void native_init();
3159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
3169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    private native final void native_finalize();
3179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
3189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    @Override
3199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    protected void finalize() throws Throwable {
3209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        try {
3219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            native_finalize();
3229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        } finally {
3239066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            super.finalize();
3249066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
3259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
3269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
327faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    /**
32811eab056dd0133a390169d3581edf3eef26d6a54James Dong     * Option used in method {@link #getFrameAtTime(long, int)} to get a
329faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * frame at a specified location.
330faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     *
331faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * @see #getFrameAtTime(long, int)
332faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     */
33311eab056dd0133a390169d3581edf3eef26d6a54James Dong    /* Do not change these option values without updating their counterparts
334faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * in include/media/stagefright/MediaSource.h!
335faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     */
33611eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
33711eab056dd0133a390169d3581edf3eef26d6a54James Dong     * This option is used with {@link #getFrameAtTime(long, int)} to retrieve
33811eab056dd0133a390169d3581edf3eef26d6a54James Dong     * a sync (or key) frame associated with a data source that is located
33911eab056dd0133a390169d3581edf3eef26d6a54James Dong     * right before or at the given time.
34011eab056dd0133a390169d3581edf3eef26d6a54James Dong     *
34111eab056dd0133a390169d3581edf3eef26d6a54James Dong     * @see #getFrameAtTime(long, int)
34211eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
343faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    public static final int OPTION_PREVIOUS_SYNC    = 0x00;
34411eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
34511eab056dd0133a390169d3581edf3eef26d6a54James Dong     * This option is used with {@link #getFrameAtTime(long, int)} to retrieve
34611eab056dd0133a390169d3581edf3eef26d6a54James Dong     * a sync (or key) frame associated with a data source that is located
34711eab056dd0133a390169d3581edf3eef26d6a54James Dong     * right after or at the given time.
34811eab056dd0133a390169d3581edf3eef26d6a54James Dong     *
34911eab056dd0133a390169d3581edf3eef26d6a54James Dong     * @see #getFrameAtTime(long, int)
35011eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
351faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    public static final int OPTION_NEXT_SYNC        = 0x01;
35211eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
35311eab056dd0133a390169d3581edf3eef26d6a54James Dong     * This option is used with {@link #getFrameAtTime(long, int)} to retrieve
35411eab056dd0133a390169d3581edf3eef26d6a54James Dong     * a sync (or key) frame associated with a data source that is located
35511eab056dd0133a390169d3581edf3eef26d6a54James Dong     * closest to (in time) or at the given time.
35611eab056dd0133a390169d3581edf3eef26d6a54James Dong     *
35711eab056dd0133a390169d3581edf3eef26d6a54James Dong     * @see #getFrameAtTime(long, int)
35811eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
359faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    public static final int OPTION_CLOSEST_SYNC     = 0x02;
36011eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
36111eab056dd0133a390169d3581edf3eef26d6a54James Dong     * This option is used with {@link #getFrameAtTime(long, int)} to retrieve
36211eab056dd0133a390169d3581edf3eef26d6a54James Dong     * a frame (not necessarily a key frame) associated with a data source that
36311eab056dd0133a390169d3581edf3eef26d6a54James Dong     * is located closest to or at the given time.
36411eab056dd0133a390169d3581edf3eef26d6a54James Dong     *
36511eab056dd0133a390169d3581edf3eef26d6a54James Dong     * @see #getFrameAtTime(long, int)
36611eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
367faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    public static final int OPTION_CLOSEST          = 0x03;
368faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong
3699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /*
37011eab056dd0133a390169d3581edf3eef26d6a54James Dong     * Do not change these metadata key values without updating their
37111eab056dd0133a390169d3581edf3eef26d6a54James Dong     * counterparts in include/media/mediametadataretriever.h!
37211eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
37311eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
37424e22d19a2316ff89be2530eb9bde5b3607ecf4cJeff Brown     * The metadata key to retrieve the numeric string describing the
37511eab056dd0133a390169d3581edf3eef26d6a54James Dong     * order of the audio data source on its original recording.
3769066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
3779066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final int METADATA_KEY_CD_TRACK_NUMBER = 0;
37811eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
37911eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the information about the album title
38011eab056dd0133a390169d3581edf3eef26d6a54James Dong     * of the data source.
38111eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
3829066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final int METADATA_KEY_ALBUM           = 1;
38311eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
38411eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the information about the artist of
38511eab056dd0133a390169d3581edf3eef26d6a54James Dong     * the data source.
38611eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
3879066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final int METADATA_KEY_ARTIST          = 2;
38811eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
38911eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the information about the author of
39011eab056dd0133a390169d3581edf3eef26d6a54James Dong     * the data source.
39111eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
3929066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final int METADATA_KEY_AUTHOR          = 3;
39311eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
39411eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the information about the composer of
39511eab056dd0133a390169d3581edf3eef26d6a54James Dong     * the data source.
39611eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
3979066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final int METADATA_KEY_COMPOSER        = 4;
39811eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
39911eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the date when the data source was created
40011eab056dd0133a390169d3581edf3eef26d6a54James Dong     * or modified.
40111eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
4029066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final int METADATA_KEY_DATE            = 5;
40311eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
40411eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the content type or genre of the data
40511eab056dd0133a390169d3581edf3eef26d6a54James Dong     * source.
40611eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
4079066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final int METADATA_KEY_GENRE           = 6;
40811eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
40911eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the data source title.
41011eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
4119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final int METADATA_KEY_TITLE           = 7;
41211eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
41311eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the year when the data source was created
41411eab056dd0133a390169d3581edf3eef26d6a54James Dong     * or modified.
41511eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
4169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final int METADATA_KEY_YEAR            = 8;
41711eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
41811eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the playback duration of the data source.
41911eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
4209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final int METADATA_KEY_DURATION        = 9;
42111eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
42211eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the number of tracks, such as audio, video,
42311eab056dd0133a390169d3581edf3eef26d6a54James Dong     * text, in the data source, such as a mp4 or 3gpp file.
42411eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
4259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final int METADATA_KEY_NUM_TRACKS      = 10;
42611eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
42711eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the information of the writer (such as
42811eab056dd0133a390169d3581edf3eef26d6a54James Dong     * lyricist) of the data source.
42911eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
43011eab056dd0133a390169d3581edf3eef26d6a54James Dong    public static final int METADATA_KEY_WRITER          = 11;
43111eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
43211eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the mime type of the data source. Some
43311eab056dd0133a390169d3581edf3eef26d6a54James Dong     * example mime types include: "video/mp4", "audio/mp4", "audio/amr-wb",
43411eab056dd0133a390169d3581edf3eef26d6a54James Dong     * etc.
43511eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
43611eab056dd0133a390169d3581edf3eef26d6a54James Dong    public static final int METADATA_KEY_MIMETYPE        = 12;
43711eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
43811eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the information about the performers or
43911eab056dd0133a390169d3581edf3eef26d6a54James Dong     * artist associated with the data source.
44011eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
44111eab056dd0133a390169d3581edf3eef26d6a54James Dong    public static final int METADATA_KEY_ALBUMARTIST     = 13;
44211eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
44311eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the numberic string that describes which
44411eab056dd0133a390169d3581edf3eef26d6a54James Dong     * part of a set the audio data source comes from.
44511eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
44611eab056dd0133a390169d3581edf3eef26d6a54James Dong    public static final int METADATA_KEY_DISC_NUMBER     = 14;
44711eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
44811eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the music album compilation status.
44911eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
45011eab056dd0133a390169d3581edf3eef26d6a54James Dong    public static final int METADATA_KEY_COMPILATION     = 15;
451c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber    /**
452c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber     * If this key exists the media contains audio content.
453c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber     */
454c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber    public static final int METADATA_KEY_HAS_AUDIO       = 16;
455c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber    /**
456c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber     * If this key exists the media contains video content.
457c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber     */
458c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber    public static final int METADATA_KEY_HAS_VIDEO       = 17;
459c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber    /**
460c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber     * If the media contains video, this key retrieves its width.
461c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber     */
462c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber    public static final int METADATA_KEY_VIDEO_WIDTH     = 18;
463c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber    /**
464c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber     * If the media contains video, this key retrieves its height.
465c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber     */
466c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber    public static final int METADATA_KEY_VIDEO_HEIGHT    = 19;
467c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber    /**
468c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber     * This key retrieves the average bitrate (in bits/sec), if available.
469c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber     */
470c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber    public static final int METADATA_KEY_BITRATE         = 20;
471c6091ddd3a22da98b5e83d4b5d864939b451b752Gloria Wang    /**
472c6091ddd3a22da98b5e83d4b5d864939b451b752Gloria Wang     * This key retrieves the language code of text tracks, if available.
473c6091ddd3a22da98b5e83d4b5d864939b451b752Gloria Wang     * If multiple text tracks present, the return value will look like:
474c6091ddd3a22da98b5e83d4b5d864939b451b752Gloria Wang     * "eng:chi"
475c6091ddd3a22da98b5e83d4b5d864939b451b752Gloria Wang     * @hide
476c6091ddd3a22da98b5e83d4b5d864939b451b752Gloria Wang     */
477c6091ddd3a22da98b5e83d4b5d864939b451b752Gloria Wang    public static final int METADATA_KEY_TIMED_TEXT_LANGUAGES      = 21;
47882428a862f325238cfb5646bbd65de3f1a11e7ccGloria Wang    /**
47982428a862f325238cfb5646bbd65de3f1a11e7ccGloria Wang     * If this key exists the media is drm-protected.
48082428a862f325238cfb5646bbd65de3f1a11e7ccGloria Wang     * @hide
48182428a862f325238cfb5646bbd65de3f1a11e7ccGloria Wang     */
48282428a862f325238cfb5646bbd65de3f1a11e7ccGloria Wang    public static final int METADATA_KEY_IS_DRM          = 22;
48377c500c9a1f763b31fb5a03c803b3523fcb72310James Dong    /**
48477c500c9a1f763b31fb5a03c803b3523fcb72310James Dong     * This key retrieves the location information, if available.
48577c500c9a1f763b31fb5a03c803b3523fcb72310James Dong     * The location should be specified according to ISO-6709 standard, under
48677c500c9a1f763b31fb5a03c803b3523fcb72310James Dong     * a mp4/3gp box "@xyz". Location with longitude of -90 degrees and latitude
48777c500c9a1f763b31fb5a03c803b3523fcb72310James Dong     * of 180 degrees will be retrieved as "-90.0000+180.0000", for instance.
48877c500c9a1f763b31fb5a03c803b3523fcb72310James Dong     */
48977c500c9a1f763b31fb5a03c803b3523fcb72310James Dong    public static final int METADATA_KEY_LOCATION        = 23;
490998483319195f903529363ebbad0e694acd0a21bJames Dong    /**
491998483319195f903529363ebbad0e694acd0a21bJames Dong     * This key retrieves the video rotation angle in degrees, if available.
492998483319195f903529363ebbad0e694acd0a21bJames Dong     * The video rotation angle may be 0, 90, 180, or 270 degrees.
493998483319195f903529363ebbad0e694acd0a21bJames Dong     */
494998483319195f903529363ebbad0e694acd0a21bJames Dong    public static final int METADATA_KEY_VIDEO_ROTATION = 24;
4959066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    // Add more here...
4969066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project}
497