1 /* 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> 23 #include <binder/IMemory.h> 24 #include <media/IMediaMetadataRetriever.h> 25 26 namespace android { 27 28 struct IMediaHTTPService; 29 class IMediaPlayerService; 30 class IMediaMetadataRetriever; 31 32 // Keep these in synch with the constants defined in MediaMetadataRetriever.java 33 // class. 34 enum { 35 METADATA_KEY_CD_TRACK_NUMBER = 0, 36 METADATA_KEY_ALBUM = 1, 37 METADATA_KEY_ARTIST = 2, 38 METADATA_KEY_AUTHOR = 3, 39 METADATA_KEY_COMPOSER = 4, 40 METADATA_KEY_DATE = 5, 41 METADATA_KEY_GENRE = 6, 42 METADATA_KEY_TITLE = 7, 43 METADATA_KEY_YEAR = 8, 44 METADATA_KEY_DURATION = 9, 45 METADATA_KEY_NUM_TRACKS = 10, 46 METADATA_KEY_WRITER = 11, 47 METADATA_KEY_MIMETYPE = 12, 48 METADATA_KEY_ALBUMARTIST = 13, 49 METADATA_KEY_DISC_NUMBER = 14, 50 METADATA_KEY_COMPILATION = 15, 51 METADATA_KEY_HAS_AUDIO = 16, 52 METADATA_KEY_HAS_VIDEO = 17, 53 METADATA_KEY_VIDEO_WIDTH = 18, 54 METADATA_KEY_VIDEO_HEIGHT = 19, 55 METADATA_KEY_BITRATE = 20, 56 METADATA_KEY_TIMED_TEXT_LANGUAGES = 21, 57 METADATA_KEY_IS_DRM = 22, 58 METADATA_KEY_LOCATION = 23, 59 METADATA_KEY_VIDEO_ROTATION = 24, 60 61 // Add more here... 62 }; 63 64 class MediaMetadataRetriever: public RefBase 65 { 66 public: 67 MediaMetadataRetriever(); 68 ~MediaMetadataRetriever(); 69 void disconnect(); 70 71 status_t setDataSource( 72 const sp<IMediaHTTPService> &httpService, 73 const char *dataSourceUrl, 74 const KeyedVector<String8, String8> *headers = NULL); 75 76 status_t setDataSource(int fd, int64_t offset, int64_t length); 77 sp<IMemory> getFrameAtTime(int64_t timeUs, int option); 78 sp<IMemory> extractAlbumArt(); 79 const char* extractMetadata(int keyCode); 80 81 private: 82 static const sp<IMediaPlayerService>& getService(); 83 84 class DeathNotifier: public IBinder::DeathRecipient 85 { 86 public: DeathNotifier()87 DeathNotifier() {} 88 virtual ~DeathNotifier(); 89 virtual void binderDied(const wp<IBinder>& who); 90 }; 91 92 static sp<DeathNotifier> sDeathNotifier; 93 static Mutex sServiceLock; 94 static sp<IMediaPlayerService> sService; 95 96 Mutex mLock; 97 sp<IMediaMetadataRetriever> mRetriever; 98 99 }; 100 101 }; // namespace android 102 103 #endif // MEDIAMETADATARETRIEVER_H 104