blob: 9aa67005278d9316e84cf1b192baef97fb55b51d [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17
18#ifndef MEDIAMETADATARETRIEVER_H
19#define MEDIAMETADATARETRIEVER_H
20
21#include <utils/Errors.h> // for status_t
22#include <utils/threads.h>
Mathias Agopian07952722009-05-19 19:08:10 -070023#include <binder/IMemory.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080024#include <media/IMediaMetadataRetriever.h>
25
26namespace android {
27
28class IMediaPlayerService;
29class IMediaMetadataRetriever;
30
31// Keep these in synch with the constants defined in MediaMetadataRetriever.java
32// class.
33enum {
34 METADATA_KEY_CD_TRACK_NUMBER = 0,
35 METADATA_KEY_ALBUM = 1,
36 METADATA_KEY_ARTIST = 2,
37 METADATA_KEY_AUTHOR = 3,
38 METADATA_KEY_COMPOSER = 4,
39 METADATA_KEY_DATE = 5,
40 METADATA_KEY_GENRE = 6,
41 METADATA_KEY_TITLE = 7,
42 METADATA_KEY_YEAR = 8,
43 METADATA_KEY_DURATION = 9,
44 METADATA_KEY_NUM_TRACKS = 10,
James Dong11eab052011-01-06 12:20:35 -080045 METADATA_KEY_WRITER = 11,
46 METADATA_KEY_MIMETYPE = 12,
47 METADATA_KEY_ALBUMARTIST = 13,
48 METADATA_KEY_DISC_NUMBER = 14,
49 METADATA_KEY_COMPILATION = 15,
Andreas Huberc4c38fc2011-03-04 10:24:54 -080050 METADATA_KEY_HAS_AUDIO = 16,
51 METADATA_KEY_HAS_VIDEO = 17,
52 METADATA_KEY_VIDEO_WIDTH = 18,
53 METADATA_KEY_VIDEO_HEIGHT = 19,
54 METADATA_KEY_BITRATE = 20,
Gloria Wangc6091dd2011-05-03 15:59:03 -070055 METADATA_KEY_TIMED_TEXT_LANGUAGES = 21,
Gloria Wang82428a82011-06-27 11:09:00 -070056 METADATA_KEY_IS_DRM = 22,
Andreas Huberc4c38fc2011-03-04 10:24:54 -080057
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080058 // Add more here...
59};
60
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080061class MediaMetadataRetriever: public RefBase
62{
63public:
64 MediaMetadataRetriever();
65 ~MediaMetadataRetriever();
66 void disconnect();
Andreas Huber5b7ced62011-03-21 10:25:44 -070067
68 status_t setDataSource(
69 const char *dataSourceUrl,
70 const KeyedVector<String8, String8> *headers = NULL);
71
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080072 status_t setDataSource(int fd, int64_t offset, int64_t length);
James Dongfaf09ba2010-12-02 17:42:08 -080073 sp<IMemory> getFrameAtTime(int64_t timeUs, int option);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080074 sp<IMemory> extractAlbumArt();
75 const char* extractMetadata(int keyCode);
76
77private:
78 static const sp<IMediaPlayerService>& getService();
79
80 class DeathNotifier: public IBinder::DeathRecipient
81 {
82 public:
83 DeathNotifier() {}
84 virtual ~DeathNotifier();
85 virtual void binderDied(const wp<IBinder>& who);
86 };
87
88 static sp<DeathNotifier> sDeathNotifier;
89 static Mutex sServiceLock;
90 static sp<IMediaPlayerService> sService;
91
92 Mutex mLock;
93 sp<IMediaMetadataRetriever> mRetriever;
94
95};
96
97}; // namespace android
98
99#endif // MEDIAMETADATARETRIEVER_H