blob: cfc205cc5d0fdd831b318f6b19d13c2ea53e3023 [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,
45 METADATA_KEY_IS_DRM_CRIPPLED = 11,
46 METADATA_KEY_CODEC = 12,
47 METADATA_KEY_RATING = 13,
48 METADATA_KEY_COMMENT = 14,
49 METADATA_KEY_COPYRIGHT = 15,
50 METADATA_KEY_BIT_RATE = 16,
51 METADATA_KEY_FRAME_RATE = 17,
52 METADATA_KEY_VIDEO_FORMAT = 18,
53 METADATA_KEY_VIDEO_HEIGHT = 19,
54 METADATA_KEY_VIDEO_WIDTH = 20,
Sahil Sachdevac9706f02009-08-14 14:52:23 -070055 METADATA_KEY_WRITER = 21,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080056 // Add more here...
57};
58
James Dong392ff3b2009-09-06 14:29:45 -070059// The intended mode of operations:$
60// METADATA_MODE_NOOP: Experimental - just add and remove data source.$
61// METADATA_MODE_FRAME_CAPTURE_ONLY: For capture frame/thumbnail only.$
62// METADATA_MODE_METADATA_RETRIEVAL_ONLY: For meta data retrieval only.$
63// METADATA_MODE_FRAME_CAPTURE_AND_METADATA_RETRIEVAL: For both frame capture
64// and meta data retrieval.$
65enum {
66 METADATA_MODE_NOOP = 0x00,
67 METADATA_MODE_FRAME_CAPTURE_ONLY = 0x01,
68 METADATA_MODE_METADATA_RETRIEVAL_ONLY = 0x02,
69 METADATA_MODE_FRAME_CAPTURE_AND_METADATA_RETRIEVAL = 0x03
70};
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080071
72class MediaMetadataRetriever: public RefBase
73{
74public:
75 MediaMetadataRetriever();
76 ~MediaMetadataRetriever();
77 void disconnect();
78 status_t setDataSource(const char* dataSourceUrl);
79 status_t setDataSource(int fd, int64_t offset, int64_t length);
80 status_t setMode(int mode);
81 status_t getMode(int* mode);
82 sp<IMemory> captureFrame();
83 sp<IMemory> extractAlbumArt();
84 const char* extractMetadata(int keyCode);
85
86private:
87 static const sp<IMediaPlayerService>& getService();
88
89 class DeathNotifier: public IBinder::DeathRecipient
90 {
91 public:
92 DeathNotifier() {}
93 virtual ~DeathNotifier();
94 virtual void binderDied(const wp<IBinder>& who);
95 };
96
97 static sp<DeathNotifier> sDeathNotifier;
98 static Mutex sServiceLock;
99 static sp<IMediaPlayerService> sService;
100
101 Mutex mLock;
102 sp<IMediaMetadataRetriever> mRetriever;
103
104};
105
106}; // namespace android
107
108#endif // MEDIAMETADATARETRIEVER_H