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; 24d2506a506303ed94fd1991cf986b825b870a67c5Andreas Huberimport android.os.IBinder; 25c5d5ee34d7c1026ca8d5cd8b186e5a73c5230247Marco Nelissen 269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport java.io.FileDescriptor; 270041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dongimport java.io.FileInputStream; 289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport java.io.FileNotFoundException; 29c5d5ee34d7c1026ca8d5cd8b186e5a73c5230247Marco Nelissenimport java.io.IOException; 309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 315b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huberimport java.util.Map; 325b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber 339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project/** 349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * MediaMetadataRetriever class provides a unified interface for retrieving 359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * frame and meta data from an input media file. 369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectpublic class MediaMetadataRetriever 389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project{ 399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project static { 409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project System.loadLibrary("media_jni"); 414935d05eaa306cef88cf0ab13eca386f270409ecMarco Nelissen native_init(); 429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project // The field below is accessed by native methods 459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project @SuppressWarnings("unused") 46075e9a19ce645752f8282bc19c91b25978a7dc52Ashok Bhat private long mNativeContext; 479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 48df9b349b960fff95dff4fcf8b2661899e33059daJames Dong private static final int EMBEDDED_PICTURE_TYPE_ANY = 0xFFFF; 49df9b349b960fff95dff4fcf8b2661899e33059daJames Dong 509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public MediaMetadataRetriever() { 519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project native_setup(); 529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Sets the data source (file pathname) to use. Call this 569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * method before the rest of the methods in this class. This method may be 579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * time-consuming. 589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * 599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param path The path of the input media file. 609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @throws IllegalArgumentException If the path is invalid. 619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 620041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong public void setDataSource(String path) throws IllegalArgumentException { 63425916e4c5305b9bfff5b5d60d203363afcb7b89Oscar Rydhé if (path == null) { 64425916e4c5305b9bfff5b5d60d203363afcb7b89Oscar Rydhé throw new IllegalArgumentException(); 65425916e4c5305b9bfff5b5d60d203363afcb7b89Oscar Rydhé } 66425916e4c5305b9bfff5b5d60d203363afcb7b89Oscar Rydhé 67e1856e482933b24e66f0f432ac0cb0157787e9ceharvey_tsai try (FileInputStream is = new FileInputStream(path)) { 680041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong FileDescriptor fd = is.getFD(); 690041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong setDataSource(fd, 0, 0x7ffffffffffffffL); 700041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong } catch (FileNotFoundException fileEx) { 710041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong throw new IllegalArgumentException(); 720041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong } catch (IOException ioEx) { 730041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong throw new IllegalArgumentException(); 740041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong } 750041b5c561a48ed8f63c4fe8ae3bff5196f68d0fJames Dong } 765b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber 775b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber /** 785b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber * Sets the data source (URI) to use. Call this 795b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber * method before the rest of the methods in this class. This method may be 805b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber * time-consuming. 815b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber * 825b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber * @param uri The URI of the input media. 835b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber * @param headers the headers to be sent together with the request for the data 845b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber * @throws IllegalArgumentException If the URI is invalid. 855b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber */ 8617524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong public void setDataSource(String uri, Map<String, String> headers) 8717524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong throws IllegalArgumentException { 8817524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong int i = 0; 8917524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong String[] keys = new String[headers.size()]; 9017524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong String[] values = new String[headers.size()]; 9117524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong for (Map.Entry<String, String> entry: headers.entrySet()) { 9217524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong keys[i] = entry.getKey(); 9317524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong values[i] = entry.getValue(); 9417524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong ++i; 9517524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong } 96d2506a506303ed94fd1991cf986b825b870a67c5Andreas Huber 97d2506a506303ed94fd1991cf986b825b870a67c5Andreas Huber _setDataSource( 98d2506a506303ed94fd1991cf986b825b870a67c5Andreas Huber MediaHTTPService.createHttpServiceBinderIfNecessary(uri), 99d2506a506303ed94fd1991cf986b825b870a67c5Andreas Huber uri, 100d2506a506303ed94fd1991cf986b825b870a67c5Andreas Huber keys, 101d2506a506303ed94fd1991cf986b825b870a67c5Andreas Huber values); 10217524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong } 10317524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong 10417524dc0d296146c8ffb3f692dc8ab05fee5b1e0James Dong private native void _setDataSource( 105d2506a506303ed94fd1991cf986b825b870a67c5Andreas Huber IBinder httpServiceBinder, String uri, String[] keys, String[] values) 1065b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber throws IllegalArgumentException; 1075b7ced6a4ebcec34a36d0779773bc9e671732dbfAndreas Huber 1089066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 1099066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Sets the data source (FileDescriptor) to use. It is the caller's 1109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * responsibility to close the file descriptor. It is safe to do so as soon 1119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * as this call returns. Call this method before the rest of the methods in 1129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * this class. This method may be time-consuming. 1139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * 1149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param fd the FileDescriptor for the file you want to play 1159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param offset the offset into the file where the data to be played starts, 1169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * in bytes. It must be non-negative 1179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param length the length in bytes of the data to be played. It must be 1189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * non-negative. 1199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @throws IllegalArgumentException if the arguments are invalid 1209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 1219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public native void setDataSource(FileDescriptor fd, long offset, long length) 1229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project throws IllegalArgumentException; 1239066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 1249066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 1259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Sets the data source (FileDescriptor) to use. It is the caller's 1269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * responsibility to close the file descriptor. It is safe to do so as soon 1279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * as this call returns. Call this method before the rest of the methods in 1289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * this class. This method may be time-consuming. 1299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * 1309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param fd the FileDescriptor for the file you want to play 1319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @throws IllegalArgumentException if the FileDescriptor is invalid 1329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 1339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public void setDataSource(FileDescriptor fd) 1349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project throws IllegalArgumentException { 1359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project // intentionally less than LONG_MAX 1369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project setDataSource(fd, 0, 0x7ffffffffffffffL); 1379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 1389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 1399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 1409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Sets the data source as a content Uri. Call this method before 1419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * the rest of the methods in this class. This method may be time-consuming. 1429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * 1439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param context the Context to use when resolving the Uri 1449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param uri the Content URI of the data you want to play 1459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @throws IllegalArgumentException if the Uri is invalid 1469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @throws SecurityException if the Uri cannot be used due to lack of 1479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * permission. 1489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 1499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public void setDataSource(Context context, Uri uri) 1509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project throws IllegalArgumentException, SecurityException { 1519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project if (uri == null) { 1529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project throw new IllegalArgumentException(); 1539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 1549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 1559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project String scheme = uri.getScheme(); 1569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project if(scheme == null || scheme.equals("file")) { 1579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project setDataSource(uri.getPath()); 1589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return; 1599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 1609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 1619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project AssetFileDescriptor fd = null; 1629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project try { 1639066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project ContentResolver resolver = context.getContentResolver(); 1649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project try { 1659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project fd = resolver.openAssetFileDescriptor(uri, "r"); 1669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } catch(FileNotFoundException e) { 1679066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project throw new IllegalArgumentException(); 1689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 1699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project if (fd == null) { 1709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project throw new IllegalArgumentException(); 1719066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 1729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project FileDescriptor descriptor = fd.getFileDescriptor(); 1739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project if (!descriptor.valid()) { 1749066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project throw new IllegalArgumentException(); 1759066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 1769066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project // Note: using getDeclaredLength so that our behavior is the same 1779066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project // as previous versions when the content provider is returning 1789066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project // a full file. 1799066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project if (fd.getDeclaredLength() < 0) { 1809066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project setDataSource(descriptor); 1819066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } else { 1829066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project setDataSource(descriptor, fd.getStartOffset(), fd.getDeclaredLength()); 1839066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 1849066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return; 1859066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } catch (SecurityException ex) { 1869066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } finally { 1879066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project try { 1889066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project if (fd != null) { 1899066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project fd.close(); 1909066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 1919066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } catch(IOException ioEx) { 1929066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 1939066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 1949066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project setDataSource(uri.toString()); 1959066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 1969066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 1979066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 1984eaa2938084353a54dc259466172909329a048ccChris Watkins * Sets the data source (MediaDataSource) to use. 1994eaa2938084353a54dc259466172909329a048ccChris Watkins * 2004eaa2938084353a54dc259466172909329a048ccChris Watkins * @param dataSource the MediaDataSource for the media you want to play 2014eaa2938084353a54dc259466172909329a048ccChris Watkins */ 2024eaa2938084353a54dc259466172909329a048ccChris Watkins public void setDataSource(MediaDataSource dataSource) 2034eaa2938084353a54dc259466172909329a048ccChris Watkins throws IllegalArgumentException { 2044eaa2938084353a54dc259466172909329a048ccChris Watkins _setDataSource(dataSource); 2054eaa2938084353a54dc259466172909329a048ccChris Watkins } 2064eaa2938084353a54dc259466172909329a048ccChris Watkins 2074eaa2938084353a54dc259466172909329a048ccChris Watkins private native void _setDataSource(MediaDataSource dataSource) 2084eaa2938084353a54dc259466172909329a048ccChris Watkins throws IllegalArgumentException; 2094eaa2938084353a54dc259466172909329a048ccChris Watkins 2104eaa2938084353a54dc259466172909329a048ccChris Watkins /** 2114eaa2938084353a54dc259466172909329a048ccChris Watkins * Call this method after setDataSource(). This method retrieves the 2129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * meta data value associated with the keyCode. 2139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * 2149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * The keyCode currently supported is listed below as METADATA_XXX 2159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * constants. With any other value, it returns a null pointer. 2169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * 2179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param keyCode One of the constants listed below at the end of the class. 2189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @return The meta data value associate with the given keyCode on success; 2199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * null on failure. 2209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 2219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public native String extractMetadata(int keyCode); 2229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 2239066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 2249066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Call this method after setDataSource(). This method finds a 225faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * representative frame close to the given time position by considering 226faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * the given option if possible, and returns it as a bitmap. This is 227faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * useful for generating a thumbnail for an input data source or just 228faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * obtain and display a frame at the given time position. 229faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * 230faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * @param timeUs The time position where the frame will be retrieved. 231faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * When retrieving the frame at the given time position, there is no 232faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * guarantee that the data source has a frame located at the position. 233faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * When this happens, a frame nearby will be returned. If timeUs is 234faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * negative, time position and option will ignored, and any frame 235faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * that the implementation considers as representative may be returned. 236faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * 237faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * @param option a hint on how the frame is found. Use 23811eab056dd0133a390169d3581edf3eef26d6a54James Dong * {@link #OPTION_PREVIOUS_SYNC} if one wants to retrieve a sync frame 239faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * that has a timestamp earlier than or the same as timeUs. Use 24011eab056dd0133a390169d3581edf3eef26d6a54James Dong * {@link #OPTION_NEXT_SYNC} if one wants to retrieve a sync frame 241faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * that has a timestamp later than or the same as timeUs. Use 24211eab056dd0133a390169d3581edf3eef26d6a54James Dong * {@link #OPTION_CLOSEST_SYNC} if one wants to retrieve a sync frame 243faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * that has a timestamp closest to or the same as timeUs. Use 24411eab056dd0133a390169d3581edf3eef26d6a54James Dong * {@link #OPTION_CLOSEST} if one wants to retrieve a frame that may 245faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * or may not be a sync frame but is closest to or the same as timeUs. 24611eab056dd0133a390169d3581edf3eef26d6a54James Dong * {@link #OPTION_CLOSEST} often has larger performance overhead compared 247faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * to the other options if there is no sync frame located at timeUs. 248faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * 2499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @return A Bitmap containing a representative video frame, which 2509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * can be null, if such a frame cannot be retrieved. 2519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 252faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong public Bitmap getFrameAtTime(long timeUs, int option) { 253faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong if (option < OPTION_PREVIOUS_SYNC || 254faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong option > OPTION_CLOSEST) { 255faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong throw new IllegalArgumentException("Unsupported option: " + option); 256faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong } 257faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong 258faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong return _getFrameAtTime(timeUs, option); 259faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong } 260faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong 261faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong /** 262faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * Call this method after setDataSource(). This method finds a 263faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * representative frame close to the given time position if possible, 264faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * and returns it as a bitmap. This is useful for generating a thumbnail 265faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * for an input data source. Call this method if one does not care 266faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * how the frame is found as long as it is close to the given time; 26711eab056dd0133a390169d3581edf3eef26d6a54James Dong * otherwise, please call {@link #getFrameAtTime(long, int)}. 268faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * 269faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * @param timeUs The time position where the frame will be retrieved. 270faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * When retrieving the frame at the given time position, there is no 271faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * guarentee that the data source has a frame located at the position. 272faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * When this happens, a frame nearby will be returned. If timeUs is 273faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * negative, time position and option will ignored, and any frame 274faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * that the implementation considers as representative may be returned. 275faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * 276faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * @return A Bitmap containing a representative video frame, which 277faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * can be null, if such a frame cannot be retrieved. 278faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * 279faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * @see #getFrameAtTime(long, int) 280faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong */ 281faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong public Bitmap getFrameAtTime(long timeUs) { 282faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong return getFrameAtTime(timeUs, OPTION_CLOSEST_SYNC); 283faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong } 284faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong 285faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong /** 286faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * Call this method after setDataSource(). This method finds a 287faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * representative frame at any time position if possible, 288faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * and returns it as a bitmap. This is useful for generating a thumbnail 289faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * for an input data source. Call this method if one does not 290faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * care about where the frame is located; otherwise, please call 29111eab056dd0133a390169d3581edf3eef26d6a54James Dong * {@link #getFrameAtTime(long)} or {@link #getFrameAtTime(long, int)} 292faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * 293faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * @return A Bitmap containing a representative video frame, which 294faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * can be null, if such a frame cannot be retrieved. 295faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * 296faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * @see #getFrameAtTime(long) 297faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * @see #getFrameAtTime(long, int) 298faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong */ 299faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong public Bitmap getFrameAtTime() { 300faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong return getFrameAtTime(-1, OPTION_CLOSEST_SYNC); 301faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong } 302faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong 303faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong private native Bitmap _getFrameAtTime(long timeUs, int option); 304faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong 3059066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 3069066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 3079066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Call this method after setDataSource(). This method finds the optional 308e8b26dcec7765786bbf063b3ae6b967b8b547ab6James Dong * graphic or album/cover art associated associated with the data source. If 30911eab056dd0133a390169d3581edf3eef26d6a54James Dong * there are more than one pictures, (any) one of them is returned. 3109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * 3119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @return null if no such graphic is found. 3129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 313df9b349b960fff95dff4fcf8b2661899e33059daJames Dong public byte[] getEmbeddedPicture() { 314df9b349b960fff95dff4fcf8b2661899e33059daJames Dong return getEmbeddedPicture(EMBEDDED_PICTURE_TYPE_ANY); 315df9b349b960fff95dff4fcf8b2661899e33059daJames Dong } 316df9b349b960fff95dff4fcf8b2661899e33059daJames Dong 317df9b349b960fff95dff4fcf8b2661899e33059daJames Dong private native byte[] getEmbeddedPicture(int pictureType); 3189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 3199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 3209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Call it when one is done with the object. This method releases the memory 3219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * allocated internally. 3229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 3239066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public native void release(); 3244935d05eaa306cef88cf0ab13eca386f270409ecMarco Nelissen private native void native_setup(); 3254935d05eaa306cef88cf0ab13eca386f270409ecMarco Nelissen private static native void native_init(); 3269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 3279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project private native final void native_finalize(); 3289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 3299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project @Override 3309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project protected void finalize() throws Throwable { 3319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project try { 3329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project native_finalize(); 3339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } finally { 3349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project super.finalize(); 3359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 3369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 3379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 338faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong /** 33911eab056dd0133a390169d3581edf3eef26d6a54James Dong * Option used in method {@link #getFrameAtTime(long, int)} to get a 340faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * frame at a specified location. 341faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * 342faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * @see #getFrameAtTime(long, int) 343faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong */ 34411eab056dd0133a390169d3581edf3eef26d6a54James Dong /* Do not change these option values without updating their counterparts 345faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong * in include/media/stagefright/MediaSource.h! 346faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong */ 34711eab056dd0133a390169d3581edf3eef26d6a54James Dong /** 34811eab056dd0133a390169d3581edf3eef26d6a54James Dong * This option is used with {@link #getFrameAtTime(long, int)} to retrieve 34911eab056dd0133a390169d3581edf3eef26d6a54James Dong * a sync (or key) frame associated with a data source that is located 35011eab056dd0133a390169d3581edf3eef26d6a54James Dong * right before or at the given time. 35111eab056dd0133a390169d3581edf3eef26d6a54James Dong * 35211eab056dd0133a390169d3581edf3eef26d6a54James Dong * @see #getFrameAtTime(long, int) 35311eab056dd0133a390169d3581edf3eef26d6a54James Dong */ 354faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong public static final int OPTION_PREVIOUS_SYNC = 0x00; 35511eab056dd0133a390169d3581edf3eef26d6a54James Dong /** 35611eab056dd0133a390169d3581edf3eef26d6a54James Dong * This option is used with {@link #getFrameAtTime(long, int)} to retrieve 35711eab056dd0133a390169d3581edf3eef26d6a54James Dong * a sync (or key) frame associated with a data source that is located 35811eab056dd0133a390169d3581edf3eef26d6a54James Dong * right after or at the given time. 35911eab056dd0133a390169d3581edf3eef26d6a54James Dong * 36011eab056dd0133a390169d3581edf3eef26d6a54James Dong * @see #getFrameAtTime(long, int) 36111eab056dd0133a390169d3581edf3eef26d6a54James Dong */ 362faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong public static final int OPTION_NEXT_SYNC = 0x01; 36311eab056dd0133a390169d3581edf3eef26d6a54James Dong /** 36411eab056dd0133a390169d3581edf3eef26d6a54James Dong * This option is used with {@link #getFrameAtTime(long, int)} to retrieve 36511eab056dd0133a390169d3581edf3eef26d6a54James Dong * a sync (or key) frame associated with a data source that is located 36611eab056dd0133a390169d3581edf3eef26d6a54James Dong * closest to (in time) or at the given time. 36711eab056dd0133a390169d3581edf3eef26d6a54James Dong * 36811eab056dd0133a390169d3581edf3eef26d6a54James Dong * @see #getFrameAtTime(long, int) 36911eab056dd0133a390169d3581edf3eef26d6a54James Dong */ 370faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong public static final int OPTION_CLOSEST_SYNC = 0x02; 37111eab056dd0133a390169d3581edf3eef26d6a54James Dong /** 37211eab056dd0133a390169d3581edf3eef26d6a54James Dong * This option is used with {@link #getFrameAtTime(long, int)} to retrieve 37311eab056dd0133a390169d3581edf3eef26d6a54James Dong * a frame (not necessarily a key frame) associated with a data source that 37411eab056dd0133a390169d3581edf3eef26d6a54James Dong * is located closest to or at the given time. 37511eab056dd0133a390169d3581edf3eef26d6a54James Dong * 37611eab056dd0133a390169d3581edf3eef26d6a54James Dong * @see #getFrameAtTime(long, int) 37711eab056dd0133a390169d3581edf3eef26d6a54James Dong */ 378faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong public static final int OPTION_CLOSEST = 0x03; 379faf09ba9405ff019b5ca7e2317debe4ff269d4f8James Dong 3809066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /* 38111eab056dd0133a390169d3581edf3eef26d6a54James Dong * Do not change these metadata key values without updating their 38211eab056dd0133a390169d3581edf3eef26d6a54James Dong * counterparts in include/media/mediametadataretriever.h! 38311eab056dd0133a390169d3581edf3eef26d6a54James Dong */ 38411eab056dd0133a390169d3581edf3eef26d6a54James Dong /** 38524e22d19a2316ff89be2530eb9bde5b3607ecf4cJeff Brown * The metadata key to retrieve the numeric string describing the 38611eab056dd0133a390169d3581edf3eef26d6a54James Dong * order of the audio data source on its original recording. 3879066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 3889066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public static final int METADATA_KEY_CD_TRACK_NUMBER = 0; 38911eab056dd0133a390169d3581edf3eef26d6a54James Dong /** 39011eab056dd0133a390169d3581edf3eef26d6a54James Dong * The metadata key to retrieve the information about the album title 39111eab056dd0133a390169d3581edf3eef26d6a54James Dong * of the data source. 39211eab056dd0133a390169d3581edf3eef26d6a54James Dong */ 3939066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public static final int METADATA_KEY_ALBUM = 1; 39411eab056dd0133a390169d3581edf3eef26d6a54James Dong /** 39511eab056dd0133a390169d3581edf3eef26d6a54James Dong * The metadata key to retrieve the information about the artist of 39611eab056dd0133a390169d3581edf3eef26d6a54James Dong * the data source. 39711eab056dd0133a390169d3581edf3eef26d6a54James Dong */ 3989066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public static final int METADATA_KEY_ARTIST = 2; 39911eab056dd0133a390169d3581edf3eef26d6a54James Dong /** 40011eab056dd0133a390169d3581edf3eef26d6a54James Dong * The metadata key to retrieve the information about the author of 40111eab056dd0133a390169d3581edf3eef26d6a54James Dong * the data source. 40211eab056dd0133a390169d3581edf3eef26d6a54James Dong */ 4039066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public static final int METADATA_KEY_AUTHOR = 3; 40411eab056dd0133a390169d3581edf3eef26d6a54James Dong /** 40511eab056dd0133a390169d3581edf3eef26d6a54James Dong * The metadata key to retrieve the information about the composer of 40611eab056dd0133a390169d3581edf3eef26d6a54James Dong * the data source. 40711eab056dd0133a390169d3581edf3eef26d6a54James Dong */ 4089066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public static final int METADATA_KEY_COMPOSER = 4; 40911eab056dd0133a390169d3581edf3eef26d6a54James Dong /** 41011eab056dd0133a390169d3581edf3eef26d6a54James Dong * The metadata key to retrieve the date when the data source was created 41111eab056dd0133a390169d3581edf3eef26d6a54James Dong * or modified. 41211eab056dd0133a390169d3581edf3eef26d6a54James Dong */ 4139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public static final int METADATA_KEY_DATE = 5; 41411eab056dd0133a390169d3581edf3eef26d6a54James Dong /** 41511eab056dd0133a390169d3581edf3eef26d6a54James Dong * The metadata key to retrieve the content type or genre of the data 41611eab056dd0133a390169d3581edf3eef26d6a54James Dong * source. 41711eab056dd0133a390169d3581edf3eef26d6a54James Dong */ 4189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public static final int METADATA_KEY_GENRE = 6; 41911eab056dd0133a390169d3581edf3eef26d6a54James Dong /** 42011eab056dd0133a390169d3581edf3eef26d6a54James Dong * The metadata key to retrieve the data source title. 42111eab056dd0133a390169d3581edf3eef26d6a54James Dong */ 4229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public static final int METADATA_KEY_TITLE = 7; 42311eab056dd0133a390169d3581edf3eef26d6a54James Dong /** 42411eab056dd0133a390169d3581edf3eef26d6a54James Dong * The metadata key to retrieve the year when the data source was created 42511eab056dd0133a390169d3581edf3eef26d6a54James Dong * or modified. 42611eab056dd0133a390169d3581edf3eef26d6a54James Dong */ 4279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public static final int METADATA_KEY_YEAR = 8; 42811eab056dd0133a390169d3581edf3eef26d6a54James Dong /** 42911eab056dd0133a390169d3581edf3eef26d6a54James Dong * The metadata key to retrieve the playback duration of the data source. 43011eab056dd0133a390169d3581edf3eef26d6a54James Dong */ 4319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public static final int METADATA_KEY_DURATION = 9; 43211eab056dd0133a390169d3581edf3eef26d6a54James Dong /** 43311eab056dd0133a390169d3581edf3eef26d6a54James Dong * The metadata key to retrieve the number of tracks, such as audio, video, 43411eab056dd0133a390169d3581edf3eef26d6a54James Dong * text, in the data source, such as a mp4 or 3gpp file. 43511eab056dd0133a390169d3581edf3eef26d6a54James Dong */ 4369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public static final int METADATA_KEY_NUM_TRACKS = 10; 43711eab056dd0133a390169d3581edf3eef26d6a54James Dong /** 43811eab056dd0133a390169d3581edf3eef26d6a54James Dong * The metadata key to retrieve the information of the writer (such as 43911eab056dd0133a390169d3581edf3eef26d6a54James Dong * lyricist) of the data source. 44011eab056dd0133a390169d3581edf3eef26d6a54James Dong */ 44111eab056dd0133a390169d3581edf3eef26d6a54James Dong public static final int METADATA_KEY_WRITER = 11; 44211eab056dd0133a390169d3581edf3eef26d6a54James Dong /** 44311eab056dd0133a390169d3581edf3eef26d6a54James Dong * The metadata key to retrieve the mime type of the data source. Some 44411eab056dd0133a390169d3581edf3eef26d6a54James Dong * example mime types include: "video/mp4", "audio/mp4", "audio/amr-wb", 44511eab056dd0133a390169d3581edf3eef26d6a54James Dong * etc. 44611eab056dd0133a390169d3581edf3eef26d6a54James Dong */ 44711eab056dd0133a390169d3581edf3eef26d6a54James Dong public static final int METADATA_KEY_MIMETYPE = 12; 44811eab056dd0133a390169d3581edf3eef26d6a54James Dong /** 44911eab056dd0133a390169d3581edf3eef26d6a54James Dong * The metadata key to retrieve the information about the performers or 45011eab056dd0133a390169d3581edf3eef26d6a54James Dong * artist associated with the data source. 45111eab056dd0133a390169d3581edf3eef26d6a54James Dong */ 45211eab056dd0133a390169d3581edf3eef26d6a54James Dong public static final int METADATA_KEY_ALBUMARTIST = 13; 45311eab056dd0133a390169d3581edf3eef26d6a54James Dong /** 45411eab056dd0133a390169d3581edf3eef26d6a54James Dong * The metadata key to retrieve the numberic string that describes which 45511eab056dd0133a390169d3581edf3eef26d6a54James Dong * part of a set the audio data source comes from. 45611eab056dd0133a390169d3581edf3eef26d6a54James Dong */ 45711eab056dd0133a390169d3581edf3eef26d6a54James Dong public static final int METADATA_KEY_DISC_NUMBER = 14; 45811eab056dd0133a390169d3581edf3eef26d6a54James Dong /** 45911eab056dd0133a390169d3581edf3eef26d6a54James Dong * The metadata key to retrieve the music album compilation status. 46011eab056dd0133a390169d3581edf3eef26d6a54James Dong */ 46111eab056dd0133a390169d3581edf3eef26d6a54James Dong public static final int METADATA_KEY_COMPILATION = 15; 462c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber /** 463c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber * If this key exists the media contains audio content. 464c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber */ 465c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber public static final int METADATA_KEY_HAS_AUDIO = 16; 466c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber /** 467c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber * If this key exists the media contains video content. 468c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber */ 469c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber public static final int METADATA_KEY_HAS_VIDEO = 17; 470c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber /** 471c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber * If the media contains video, this key retrieves its width. 472c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber */ 473c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber public static final int METADATA_KEY_VIDEO_WIDTH = 18; 474c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber /** 475c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber * If the media contains video, this key retrieves its height. 476c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber */ 477c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber public static final int METADATA_KEY_VIDEO_HEIGHT = 19; 478c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber /** 479c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber * This key retrieves the average bitrate (in bits/sec), if available. 480c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber */ 481c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716bAndreas Huber public static final int METADATA_KEY_BITRATE = 20; 482c6091ddd3a22da98b5e83d4b5d864939b451b752Gloria Wang /** 483c6091ddd3a22da98b5e83d4b5d864939b451b752Gloria Wang * This key retrieves the language code of text tracks, if available. 484c6091ddd3a22da98b5e83d4b5d864939b451b752Gloria Wang * If multiple text tracks present, the return value will look like: 485c6091ddd3a22da98b5e83d4b5d864939b451b752Gloria Wang * "eng:chi" 486c6091ddd3a22da98b5e83d4b5d864939b451b752Gloria Wang * @hide 487c6091ddd3a22da98b5e83d4b5d864939b451b752Gloria Wang */ 488c6091ddd3a22da98b5e83d4b5d864939b451b752Gloria Wang public static final int METADATA_KEY_TIMED_TEXT_LANGUAGES = 21; 48982428a862f325238cfb5646bbd65de3f1a11e7ccGloria Wang /** 49082428a862f325238cfb5646bbd65de3f1a11e7ccGloria Wang * If this key exists the media is drm-protected. 49182428a862f325238cfb5646bbd65de3f1a11e7ccGloria Wang * @hide 49282428a862f325238cfb5646bbd65de3f1a11e7ccGloria Wang */ 49382428a862f325238cfb5646bbd65de3f1a11e7ccGloria Wang public static final int METADATA_KEY_IS_DRM = 22; 49477c500c9a1f763b31fb5a03c803b3523fcb72310James Dong /** 49577c500c9a1f763b31fb5a03c803b3523fcb72310James Dong * This key retrieves the location information, if available. 49677c500c9a1f763b31fb5a03c803b3523fcb72310James Dong * The location should be specified according to ISO-6709 standard, under 49777c500c9a1f763b31fb5a03c803b3523fcb72310James Dong * a mp4/3gp box "@xyz". Location with longitude of -90 degrees and latitude 49877c500c9a1f763b31fb5a03c803b3523fcb72310James Dong * of 180 degrees will be retrieved as "-90.0000+180.0000", for instance. 49977c500c9a1f763b31fb5a03c803b3523fcb72310James Dong */ 50077c500c9a1f763b31fb5a03c803b3523fcb72310James Dong public static final int METADATA_KEY_LOCATION = 23; 501998483319195f903529363ebbad0e694acd0a21bJames Dong /** 502998483319195f903529363ebbad0e694acd0a21bJames Dong * This key retrieves the video rotation angle in degrees, if available. 503998483319195f903529363ebbad0e694acd0a21bJames Dong * The video rotation angle may be 0, 90, 180, or 270 degrees. 504998483319195f903529363ebbad0e694acd0a21bJames Dong */ 505998483319195f903529363ebbad0e694acd0a21bJames Dong public static final int METADATA_KEY_VIDEO_ROTATION = 24; 5068f73a1be7c1550b791593e59d7ec787187014839Chong Zhang /** 5078f73a1be7c1550b791593e59d7ec787187014839Chong Zhang * This key retrieves the original capture framerate, if it's 5088f73a1be7c1550b791593e59d7ec787187014839Chong Zhang * available. The capture framerate will be a floating point 5098f73a1be7c1550b791593e59d7ec787187014839Chong Zhang * number. 5108f73a1be7c1550b791593e59d7ec787187014839Chong Zhang */ 5118f73a1be7c1550b791593e59d7ec787187014839Chong Zhang public static final int METADATA_KEY_CAPTURE_FRAMERATE = 25; 5129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project // Add more here... 5139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project} 514