MediaMetadataRetriever.java revision 998483319195f903529363ebbad0e694acd0a21b
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")
459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    private int 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 {
620041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong        FileInputStream is = null;
630041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong        try {
640041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong            is = new FileInputStream(path);
650041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong            FileDescriptor fd = is.getFD();
660041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong            setDataSource(fd, 0, 0x7ffffffffffffffL);
670041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong        } catch (FileNotFoundException fileEx) {
680041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong            throw new IllegalArgumentException();
690041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong        } catch (IOException ioEx) {
700041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong            throw new IllegalArgumentException();
710041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong        }
720041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong
730041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong        try {
740041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong            if (is != null) {
750041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong                is.close();
760041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong            }
770041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong        } catch (Exception e) {}
780041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong    }
795b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber
805b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber    /**
815b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber     * Sets the data source (URI) to use. Call this
825b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber     * method before the rest of the methods in this class. This method may be
835b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber     * time-consuming.
845b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber     *
855b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber     * @param uri The URI of the input media.
865b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber     * @param headers the headers to be sent together with the request for the data
875b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber     * @throws IllegalArgumentException If the URI is invalid.
885b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber     */
8917524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong    public void setDataSource(String uri,  Map<String, String> headers)
9017524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong            throws IllegalArgumentException {
9117524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong        int i = 0;
9217524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong        String[] keys = new String[headers.size()];
9317524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong        String[] values = new String[headers.size()];
9417524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong        for (Map.Entry<String, String> entry: headers.entrySet()) {
9517524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong            keys[i] = entry.getKey();
9617524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong            values[i] = entry.getValue();
9717524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong            ++i;
9817524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong        }
9917524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong        _setDataSource(uri, keys, values);
10017524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong    }
10117524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong
10217524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong    private native void _setDataSource(
10317524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong        String uri, String[] keys, String[] values)
1045b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber        throws IllegalArgumentException;
1055b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber
1069066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
1079066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Sets the data source (FileDescriptor) to use.  It is the caller's
1089066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * responsibility to close the file descriptor. It is safe to do so as soon
1099066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * as this call returns. Call this method before the rest of the methods in
1109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * this class. This method may be time-consuming.
1119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
1129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param fd the FileDescriptor for the file you want to play
1139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param offset the offset into the file where the data to be played starts,
1149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * in bytes. It must be non-negative
1159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param length the length in bytes of the data to be played. It must be
1169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * non-negative.
1179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @throws IllegalArgumentException if the arguments are invalid
1189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
1199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public native void setDataSource(FileDescriptor fd, long offset, long length)
1209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            throws IllegalArgumentException;
1219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
1229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
1239066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Sets the data source (FileDescriptor) to use. It is the caller's
1249066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * responsibility to close the file descriptor. It is safe to do so as soon
1259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * as this call returns. Call this method before the rest of the methods in
1269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * this class. This method may be time-consuming.
1279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
1289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param fd the FileDescriptor for the file you want to play
1299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @throws IllegalArgumentException if the FileDescriptor is invalid
1309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
1319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void setDataSource(FileDescriptor fd)
1329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            throws IllegalArgumentException {
1339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        // intentionally less than LONG_MAX
1349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        setDataSource(fd, 0, 0x7ffffffffffffffL);
1359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
1369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
1379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
1389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Sets the data source as a content Uri. Call this method before
1399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * the rest of the methods in this class. This method may be time-consuming.
1409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
1419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param context the Context to use when resolving the Uri
1429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param uri the Content URI of the data you want to play
1439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @throws IllegalArgumentException if the Uri is invalid
1449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @throws SecurityException if the Uri cannot be used due to lack of
1459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * permission.
1469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
1479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void setDataSource(Context context, Uri uri)
1489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        throws IllegalArgumentException, SecurityException {
1499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        if (uri == null) {
1509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            throw new IllegalArgumentException();
1519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
1529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
1539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        String scheme = uri.getScheme();
1549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        if(scheme == null || scheme.equals("file")) {
1559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            setDataSource(uri.getPath());
1569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            return;
1579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
1589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
1599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        AssetFileDescriptor fd = null;
1609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        try {
1619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            ContentResolver resolver = context.getContentResolver();
1629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            try {
1639066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                fd = resolver.openAssetFileDescriptor(uri, "r");
1649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            } catch(FileNotFoundException e) {
1659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                throw new IllegalArgumentException();
1669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            }
1679066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            if (fd == null) {
1689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                throw new IllegalArgumentException();
1699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            }
1709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            FileDescriptor descriptor = fd.getFileDescriptor();
1719066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            if (!descriptor.valid()) {
1729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                throw new IllegalArgumentException();
1739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            }
1749066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            // Note: using getDeclaredLength so that our behavior is the same
1759066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            // as previous versions when the content provider is returning
1769066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            // a full file.
1779066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            if (fd.getDeclaredLength() < 0) {
1789066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                setDataSource(descriptor);
1799066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            } else {
1809066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                setDataSource(descriptor, fd.getStartOffset(), fd.getDeclaredLength());
1819066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            }
1829066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            return;
1839066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        } catch (SecurityException ex) {
1849066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        } finally {
1859066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            try {
1869066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                if (fd != null) {
1879066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                    fd.close();
1889066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                }
1899066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            } catch(IOException ioEx) {
1909066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            }
1919066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
1929066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        setDataSource(uri.toString());
1939066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
1949066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
1959066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
1969066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Call this method after setDataSource(). This method retrieves the
1979066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * meta data value associated with the keyCode.
1989066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
1999066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * The keyCode currently supported is listed below as METADATA_XXX
2009066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * constants. With any other value, it returns a null pointer.
2019066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
2029066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param keyCode One of the constants listed below at the end of the class.
2039066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @return The meta data value associate with the given keyCode on success;
2049066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * null on failure.
2059066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
2069066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public native String extractMetadata(int keyCode);
2079066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
2089066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
2099066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Call this method after setDataSource(). This method finds a
210faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * representative frame close to the given time position by considering
211faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * the given option if possible, and returns it as a bitmap. This is
212faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * useful for generating a thumbnail for an input data source or just
213faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * obtain and display a frame at the given time position.
214faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     *
215faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * @param timeUs The time position where the frame will be retrieved.
216faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * When retrieving the frame at the given time position, there is no
217faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * guarantee that the data source has a frame located at the position.
218faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * When this happens, a frame nearby will be returned. If timeUs is
219faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * negative, time position and option will ignored, and any frame
220faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * that the implementation considers as representative may be returned.
221faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     *
222faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * @param option a hint on how the frame is found. Use
22311eab056dd0133a390169d3581edf3eef26d6a54James Dong     * {@link #OPTION_PREVIOUS_SYNC} if one wants to retrieve a sync frame
224faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * that has a timestamp earlier than or the same as timeUs. Use
22511eab056dd0133a390169d3581edf3eef26d6a54James Dong     * {@link #OPTION_NEXT_SYNC} if one wants to retrieve a sync frame
226faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * that has a timestamp later than or the same as timeUs. Use
22711eab056dd0133a390169d3581edf3eef26d6a54James Dong     * {@link #OPTION_CLOSEST_SYNC} if one wants to retrieve a sync frame
228faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * that has a timestamp closest to or the same as timeUs. Use
22911eab056dd0133a390169d3581edf3eef26d6a54James Dong     * {@link #OPTION_CLOSEST} if one wants to retrieve a frame that may
230faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * or may not be a sync frame but is closest to or the same as timeUs.
23111eab056dd0133a390169d3581edf3eef26d6a54James Dong     * {@link #OPTION_CLOSEST} often has larger performance overhead compared
232faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * to the other options if there is no sync frame located at timeUs.
233faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     *
2349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @return A Bitmap containing a representative video frame, which
2359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *         can be null, if such a frame cannot be retrieved.
2369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
237faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    public Bitmap getFrameAtTime(long timeUs, int option) {
238faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong        if (option < OPTION_PREVIOUS_SYNC ||
239faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong            option > OPTION_CLOSEST) {
240faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong            throw new IllegalArgumentException("Unsupported option: " + option);
241faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong        }
242faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong
243faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong        return _getFrameAtTime(timeUs, option);
244faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    }
245faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong
246faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    /**
247faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * Call this method after setDataSource(). This method finds a
248faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * representative frame close to the given time position if possible,
249faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * and returns it as a bitmap. This is useful for generating a thumbnail
250faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * for an input data source. Call this method if one does not care
251faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * how the frame is found as long as it is close to the given time;
25211eab056dd0133a390169d3581edf3eef26d6a54James Dong     * otherwise, please call {@link #getFrameAtTime(long, int)}.
253faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     *
254faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * @param timeUs The time position where the frame will be retrieved.
255faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * When retrieving the frame at the given time position, there is no
256faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * guarentee that the data source has a frame located at the position.
257faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * When this happens, a frame nearby will be returned. If timeUs is
258faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * negative, time position and option will ignored, and any frame
259faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * that the implementation considers as representative may be returned.
260faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     *
261faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * @return A Bitmap containing a representative video frame, which
262faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     *         can be null, if such a frame cannot be retrieved.
263faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     *
264faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * @see #getFrameAtTime(long, int)
265faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     */
266faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    public Bitmap getFrameAtTime(long timeUs) {
267faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong        return getFrameAtTime(timeUs, OPTION_CLOSEST_SYNC);
268faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    }
269faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong
270faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    /**
271faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * Call this method after setDataSource(). This method finds a
272faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * representative frame at any time position if possible,
273faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * and returns it as a bitmap. This is useful for generating a thumbnail
274faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * for an input data source. Call this method if one does not
275faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * care about where the frame is located; otherwise, please call
27611eab056dd0133a390169d3581edf3eef26d6a54James Dong     * {@link #getFrameAtTime(long)} or {@link #getFrameAtTime(long, int)}
277faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     *
278faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * @return A Bitmap containing a representative video frame, which
279faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     *         can be null, if such a frame cannot be retrieved.
280faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     *
281faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * @see #getFrameAtTime(long)
282faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * @see #getFrameAtTime(long, int)
283faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     */
284faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    public Bitmap getFrameAtTime() {
285faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong        return getFrameAtTime(-1, OPTION_CLOSEST_SYNC);
286faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    }
287faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong
288faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    private native Bitmap _getFrameAtTime(long timeUs, int option);
289faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong
2909066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
2919066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
2929066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Call this method after setDataSource(). This method finds the optional
293e8b26dcec7765786bbf063b3ae6b967b8b547ab6James Dong     * graphic or album/cover art associated associated with the data source. If
29411eab056dd0133a390169d3581edf3eef26d6a54James Dong     * there are more than one pictures, (any) one of them is returned.
2959066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
2969066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @return null if no such graphic is found.
2979066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
298df9b349b960fff95dff4fcf8b2661899e33059daJames Dong    public byte[] getEmbeddedPicture() {
299df9b349b960fff95dff4fcf8b2661899e33059daJames Dong        return getEmbeddedPicture(EMBEDDED_PICTURE_TYPE_ANY);
300df9b349b960fff95dff4fcf8b2661899e33059daJames Dong    }
301df9b349b960fff95dff4fcf8b2661899e33059daJames Dong
302df9b349b960fff95dff4fcf8b2661899e33059daJames Dong    private native byte[] getEmbeddedPicture(int pictureType);
3039066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
3049066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
3059066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Call it when one is done with the object. This method releases the memory
3069066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * allocated internally.
3079066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
3089066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public native void release();
3094935d05eaa306cef88cf0ab13eca386f270409ecMarco Nelissen    private native void native_setup();
3104935d05eaa306cef88cf0ab13eca386f270409ecMarco Nelissen    private static native void native_init();
3119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
3129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    private native final void native_finalize();
3139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
3149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    @Override
3159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    protected void finalize() throws Throwable {
3169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        try {
3179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            native_finalize();
3189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        } finally {
3199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            super.finalize();
3209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
3219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
3229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
323faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    /**
32411eab056dd0133a390169d3581edf3eef26d6a54James Dong     * Option used in method {@link #getFrameAtTime(long, int)} to get a
325faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * frame at a specified location.
326faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     *
327faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * @see #getFrameAtTime(long, int)
328faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     */
32911eab056dd0133a390169d3581edf3eef26d6a54James Dong    /* Do not change these option values without updating their counterparts
330faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     * in include/media/stagefright/MediaSource.h!
331faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong     */
33211eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
33311eab056dd0133a390169d3581edf3eef26d6a54James Dong     * This option is used with {@link #getFrameAtTime(long, int)} to retrieve
33411eab056dd0133a390169d3581edf3eef26d6a54James Dong     * a sync (or key) frame associated with a data source that is located
33511eab056dd0133a390169d3581edf3eef26d6a54James Dong     * right before or at the given time.
33611eab056dd0133a390169d3581edf3eef26d6a54James Dong     *
33711eab056dd0133a390169d3581edf3eef26d6a54James Dong     * @see #getFrameAtTime(long, int)
33811eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
339faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    public static final int OPTION_PREVIOUS_SYNC    = 0x00;
34011eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
34111eab056dd0133a390169d3581edf3eef26d6a54James Dong     * This option is used with {@link #getFrameAtTime(long, int)} to retrieve
34211eab056dd0133a390169d3581edf3eef26d6a54James Dong     * a sync (or key) frame associated with a data source that is located
34311eab056dd0133a390169d3581edf3eef26d6a54James Dong     * right after or at the given time.
34411eab056dd0133a390169d3581edf3eef26d6a54James Dong     *
34511eab056dd0133a390169d3581edf3eef26d6a54James Dong     * @see #getFrameAtTime(long, int)
34611eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
347faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    public static final int OPTION_NEXT_SYNC        = 0x01;
34811eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
34911eab056dd0133a390169d3581edf3eef26d6a54James Dong     * This option is used with {@link #getFrameAtTime(long, int)} to retrieve
35011eab056dd0133a390169d3581edf3eef26d6a54James Dong     * a sync (or key) frame associated with a data source that is located
35111eab056dd0133a390169d3581edf3eef26d6a54James Dong     * closest to (in time) or at the given time.
35211eab056dd0133a390169d3581edf3eef26d6a54James Dong     *
35311eab056dd0133a390169d3581edf3eef26d6a54James Dong     * @see #getFrameAtTime(long, int)
35411eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
355faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    public static final int OPTION_CLOSEST_SYNC     = 0x02;
35611eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
35711eab056dd0133a390169d3581edf3eef26d6a54James Dong     * This option is used with {@link #getFrameAtTime(long, int)} to retrieve
35811eab056dd0133a390169d3581edf3eef26d6a54James Dong     * a frame (not necessarily a key frame) associated with a data source that
35911eab056dd0133a390169d3581edf3eef26d6a54James Dong     * is located closest to or at the given time.
36011eab056dd0133a390169d3581edf3eef26d6a54James Dong     *
36111eab056dd0133a390169d3581edf3eef26d6a54James Dong     * @see #getFrameAtTime(long, int)
36211eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
363faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong    public static final int OPTION_CLOSEST          = 0x03;
364faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong
3659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /*
36611eab056dd0133a390169d3581edf3eef26d6a54James Dong     * Do not change these metadata key values without updating their
36711eab056dd0133a390169d3581edf3eef26d6a54James Dong     * counterparts in include/media/mediametadataretriever.h!
36811eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
36911eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
37011eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the numberic string describing the
37111eab056dd0133a390169d3581edf3eef26d6a54James Dong     * order of the audio data source on its original recording.
3729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
3739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final int METADATA_KEY_CD_TRACK_NUMBER = 0;
37411eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
37511eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the information about the album title
37611eab056dd0133a390169d3581edf3eef26d6a54James Dong     * of the data source.
37711eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
3789066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final int METADATA_KEY_ALBUM           = 1;
37911eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
38011eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the information about the artist of
38111eab056dd0133a390169d3581edf3eef26d6a54James Dong     * the data source.
38211eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
3839066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final int METADATA_KEY_ARTIST          = 2;
38411eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
38511eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the information about the author of
38611eab056dd0133a390169d3581edf3eef26d6a54James Dong     * the data source.
38711eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
3889066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final int METADATA_KEY_AUTHOR          = 3;
38911eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
39011eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the information about the composer of
39111eab056dd0133a390169d3581edf3eef26d6a54James Dong     * the data source.
39211eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
3939066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final int METADATA_KEY_COMPOSER        = 4;
39411eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
39511eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the date when the data source was created
39611eab056dd0133a390169d3581edf3eef26d6a54James Dong     * or modified.
39711eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
3989066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final int METADATA_KEY_DATE            = 5;
39911eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
40011eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the content type or genre of the data
40111eab056dd0133a390169d3581edf3eef26d6a54James Dong     * source.
40211eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
4039066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final int METADATA_KEY_GENRE           = 6;
40411eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
40511eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the data source title.
40611eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
4079066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final int METADATA_KEY_TITLE           = 7;
40811eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
40911eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the year when the data source was created
41011eab056dd0133a390169d3581edf3eef26d6a54James Dong     * or modified.
41111eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
4129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final int METADATA_KEY_YEAR            = 8;
41311eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
41411eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the playback duration of the data source.
41511eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
4169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final int METADATA_KEY_DURATION        = 9;
41711eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
41811eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the number of tracks, such as audio, video,
41911eab056dd0133a390169d3581edf3eef26d6a54James Dong     * text, in the data source, such as a mp4 or 3gpp file.
42011eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
4219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final int METADATA_KEY_NUM_TRACKS      = 10;
42211eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
42311eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the information of the writer (such as
42411eab056dd0133a390169d3581edf3eef26d6a54James Dong     * lyricist) of the data source.
42511eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
42611eab056dd0133a390169d3581edf3eef26d6a54James Dong    public static final int METADATA_KEY_WRITER          = 11;
42711eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
42811eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the mime type of the data source. Some
42911eab056dd0133a390169d3581edf3eef26d6a54James Dong     * example mime types include: "video/mp4", "audio/mp4", "audio/amr-wb",
43011eab056dd0133a390169d3581edf3eef26d6a54James Dong     * etc.
43111eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
43211eab056dd0133a390169d3581edf3eef26d6a54James Dong    public static final int METADATA_KEY_MIMETYPE        = 12;
43311eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
43411eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the information about the performers or
43511eab056dd0133a390169d3581edf3eef26d6a54James Dong     * artist associated with the data source.
43611eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
43711eab056dd0133a390169d3581edf3eef26d6a54James Dong    public static final int METADATA_KEY_ALBUMARTIST     = 13;
43811eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
43911eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the numberic string that describes which
44011eab056dd0133a390169d3581edf3eef26d6a54James Dong     * part of a set the audio data source comes from.
44111eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
44211eab056dd0133a390169d3581edf3eef26d6a54James Dong    public static final int METADATA_KEY_DISC_NUMBER     = 14;
44311eab056dd0133a390169d3581edf3eef26d6a54James Dong    /**
44411eab056dd0133a390169d3581edf3eef26d6a54James Dong     * The metadata key to retrieve the music album compilation status.
44511eab056dd0133a390169d3581edf3eef26d6a54James Dong     */
44611eab056dd0133a390169d3581edf3eef26d6a54James Dong    public static final int METADATA_KEY_COMPILATION     = 15;
447c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber    /**
448c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber     * If this key exists the media contains audio content.
449c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber     */
450c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber    public static final int METADATA_KEY_HAS_AUDIO       = 16;
451c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber    /**
452c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber     * If this key exists the media contains video content.
453c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber     */
454c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber    public static final int METADATA_KEY_HAS_VIDEO       = 17;
455c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber    /**
456c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber     * If the media contains video, this key retrieves its width.
457c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber     */
458c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber    public static final int METADATA_KEY_VIDEO_WIDTH     = 18;
459c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber    /**
460c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber     * If the media contains video, this key retrieves its height.
461c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber     */
462c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber    public static final int METADATA_KEY_VIDEO_HEIGHT    = 19;
463c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber    /**
464c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber     * This key retrieves the average bitrate (in bits/sec), if available.
465c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber     */
466c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber    public static final int METADATA_KEY_BITRATE         = 20;
467c6091ddd3a22da98b5e83d4b5d864939b451b752Gloria Wang    /**
468c6091ddd3a22da98b5e83d4b5d864939b451b752Gloria Wang     * This key retrieves the language code of text tracks, if available.
469c6091ddd3a22da98b5e83d4b5d864939b451b752Gloria Wang     * If multiple text tracks present, the return value will look like:
470c6091ddd3a22da98b5e83d4b5d864939b451b752Gloria Wang     * "eng:chi"
471c6091ddd3a22da98b5e83d4b5d864939b451b752Gloria Wang     * @hide
472c6091ddd3a22da98b5e83d4b5d864939b451b752Gloria Wang     */
473c6091ddd3a22da98b5e83d4b5d864939b451b752Gloria Wang    public static final int METADATA_KEY_TIMED_TEXT_LANGUAGES      = 21;
47482428a862f325238cfb5646bbd65de3f1a11e7ccGloria Wang    /**
47582428a862f325238cfb5646bbd65de3f1a11e7ccGloria Wang     * If this key exists the media is drm-protected.
47682428a862f325238cfb5646bbd65de3f1a11e7ccGloria Wang     * @hide
47782428a862f325238cfb5646bbd65de3f1a11e7ccGloria Wang     */
47882428a862f325238cfb5646bbd65de3f1a11e7ccGloria Wang    public static final int METADATA_KEY_IS_DRM          = 22;
47977c500c9a1f763b31fb5a03c803b3523fcb72310James Dong    /**
48077c500c9a1f763b31fb5a03c803b3523fcb72310James Dong     * This key retrieves the location information, if available.
48177c500c9a1f763b31fb5a03c803b3523fcb72310James Dong     * The location should be specified according to ISO-6709 standard, under
48277c500c9a1f763b31fb5a03c803b3523fcb72310James Dong     * a mp4/3gp box "@xyz". Location with longitude of -90 degrees and latitude
48377c500c9a1f763b31fb5a03c803b3523fcb72310James Dong     * of 180 degrees will be retrieved as "-90.0000+180.0000", for instance.
48477c500c9a1f763b31fb5a03c803b3523fcb72310James Dong     */
48577c500c9a1f763b31fb5a03c803b3523fcb72310James Dong    public static final int METADATA_KEY_LOCATION        = 23;
486998483319195f903529363ebbad0e694acd0a21bJames Dong    /**
487998483319195f903529363ebbad0e694acd0a21bJames Dong     * This key retrieves the video rotation angle in degrees, if available.
488998483319195f903529363ebbad0e694acd0a21bJames Dong     * The video rotation angle may be 0, 90, 180, or 270 degrees.
489998483319195f903529363ebbad0e694acd0a21bJames Dong     */
490998483319195f903529363ebbad0e694acd0a21bJames Dong    public static final int METADATA_KEY_VIDEO_ROTATION = 24;
4919066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    // Add more here...
4929066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project}
493