blob: 2261a7f3b95ca61400a1f54bc24cd7b482490d27 [file] [log] [blame]
The Android Open Source Project89fa4ad2009-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 Agopian75624082009-05-19 19:08:10 -070023#include <binder/IMemory.h>
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080024#include <media/IMediaMetadataRetriever.h>
25
26namespace android {
27
Chris Watkins99f31602015-03-20 13:06:33 -070028class IDataSource;
29class IMediaHTTPService;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080030class IMediaPlayerService;
31class IMediaMetadataRetriever;
32
33// Keep these in synch with the constants defined in MediaMetadataRetriever.java
34// class.
35enum {
36 METADATA_KEY_CD_TRACK_NUMBER = 0,
37 METADATA_KEY_ALBUM = 1,
38 METADATA_KEY_ARTIST = 2,
39 METADATA_KEY_AUTHOR = 3,
40 METADATA_KEY_COMPOSER = 4,
41 METADATA_KEY_DATE = 5,
42 METADATA_KEY_GENRE = 6,
43 METADATA_KEY_TITLE = 7,
44 METADATA_KEY_YEAR = 8,
45 METADATA_KEY_DURATION = 9,
46 METADATA_KEY_NUM_TRACKS = 10,
James Dong7f7d52a2011-01-06 12:20:35 -080047 METADATA_KEY_WRITER = 11,
48 METADATA_KEY_MIMETYPE = 12,
49 METADATA_KEY_ALBUMARTIST = 13,
50 METADATA_KEY_DISC_NUMBER = 14,
51 METADATA_KEY_COMPILATION = 15,
Andreas Huber2256d512011-03-04 10:24:54 -080052 METADATA_KEY_HAS_AUDIO = 16,
53 METADATA_KEY_HAS_VIDEO = 17,
54 METADATA_KEY_VIDEO_WIDTH = 18,
55 METADATA_KEY_VIDEO_HEIGHT = 19,
56 METADATA_KEY_BITRATE = 20,
Gloria Wang7a1e3e82011-05-03 15:59:03 -070057 METADATA_KEY_TIMED_TEXT_LANGUAGES = 21,
Gloria Wang0d0edfb2011-06-27 11:09:00 -070058 METADATA_KEY_IS_DRM = 22,
James Dong49488182011-11-09 00:48:56 -080059 METADATA_KEY_LOCATION = 23,
James Dong5a81ad82012-07-31 14:41:35 -070060 METADATA_KEY_VIDEO_ROTATION = 24,
Andreas Huber2256d512011-03-04 10:24:54 -080061
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080062 // Add more here...
63};
64
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080065class MediaMetadataRetriever: public RefBase
66{
67public:
68 MediaMetadataRetriever();
69 ~MediaMetadataRetriever();
70 void disconnect();
Andreas Huberaf8791e2011-03-21 10:25:44 -070071
72 status_t setDataSource(
Andreas Huber1b86fe02014-01-29 11:13:26 -080073 const sp<IMediaHTTPService> &httpService,
Andreas Huberaf8791e2011-03-21 10:25:44 -070074 const char *dataSourceUrl,
75 const KeyedVector<String8, String8> *headers = NULL);
76
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080077 status_t setDataSource(int fd, int64_t offset, int64_t length);
Chris Watkins99f31602015-03-20 13:06:33 -070078 status_t setDataSource(const sp<IDataSource>& dataSource);
James Dong16afe2f2010-12-02 17:42:08 -080079 sp<IMemory> getFrameAtTime(int64_t timeUs, int option);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080080 sp<IMemory> extractAlbumArt();
81 const char* extractMetadata(int keyCode);
82
83private:
84 static const sp<IMediaPlayerService>& getService();
85
86 class DeathNotifier: public IBinder::DeathRecipient
87 {
88 public:
89 DeathNotifier() {}
90 virtual ~DeathNotifier();
91 virtual void binderDied(const wp<IBinder>& who);
92 };
93
94 static sp<DeathNotifier> sDeathNotifier;
95 static Mutex sServiceLock;
96 static sp<IMediaPlayerService> sService;
97
98 Mutex mLock;
99 sp<IMediaMetadataRetriever> mRetriever;
100
101};
102
103}; // namespace android
104
105#endif // MEDIAMETADATARETRIEVER_H