The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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 | #ifndef MEDIASCANNER_H |
| 18 | #define MEDIASCANNER_H |
| 19 | |
Mathias Agopian | 3b4062e | 2009-05-31 19:13:00 -0700 | [diff] [blame] | 20 | #include <utils/Log.h> |
| 21 | #include <utils/threads.h> |
| 22 | #include <utils/List.h> |
| 23 | #include <utils/Errors.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 24 | #include <pthread.h> |
| 25 | |
| 26 | namespace android { |
| 27 | |
| 28 | class MediaScannerClient; |
| 29 | class StringArray; |
| 30 | |
Andreas Huber | bfb9fb1 | 2009-12-03 11:31:19 -0800 | [diff] [blame] | 31 | struct MediaScanner { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 32 | MediaScanner(); |
Andreas Huber | bfb9fb1 | 2009-12-03 11:31:19 -0800 | [diff] [blame] | 33 | virtual ~MediaScanner(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 34 | |
Andreas Huber | bfb9fb1 | 2009-12-03 11:31:19 -0800 | [diff] [blame] | 35 | virtual status_t processFile( |
| 36 | const char *path, const char *mimeType, |
| 37 | MediaScannerClient &client) = 0; |
| 38 | |
| 39 | typedef bool (*ExceptionCheck)(void* env); |
| 40 | virtual status_t processDirectory( |
Mike Lockwood | c37255d | 2010-09-10 14:47:36 -0400 | [diff] [blame] | 41 | const char *path, MediaScannerClient &client, |
Andreas Huber | bfb9fb1 | 2009-12-03 11:31:19 -0800 | [diff] [blame] | 42 | ExceptionCheck exceptionCheck, void *exceptionEnv); |
| 43 | |
| 44 | void setLocale(const char *locale); |
| 45 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 46 | // extracts album art as a block of data |
Andreas Huber | bfb9fb1 | 2009-12-03 11:31:19 -0800 | [diff] [blame] | 47 | virtual char *extractAlbumArt(int fd) = 0; |
| 48 | |
| 49 | protected: |
| 50 | const char *locale() const; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 51 | |
| 52 | private: |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 53 | // current locale (like "ja_JP"), created/destroyed with strdup()/free() |
Andreas Huber | bfb9fb1 | 2009-12-03 11:31:19 -0800 | [diff] [blame] | 54 | char *mLocale; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 55 | |
Andreas Huber | bfb9fb1 | 2009-12-03 11:31:19 -0800 | [diff] [blame] | 56 | status_t doProcessDirectory( |
Mike Lockwood | c37255d | 2010-09-10 14:47:36 -0400 | [diff] [blame] | 57 | char *path, int pathRemaining, MediaScannerClient &client, |
| 58 | ExceptionCheck exceptionCheck, void *exceptionEnv); |
Andreas Huber | bfb9fb1 | 2009-12-03 11:31:19 -0800 | [diff] [blame] | 59 | |
| 60 | MediaScanner(const MediaScanner &); |
| 61 | MediaScanner &operator=(const MediaScanner &); |
| 62 | }; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 63 | |
| 64 | class MediaScannerClient |
| 65 | { |
| 66 | public: |
Marco Nelissen | 8b04661 | 2009-09-03 10:49:55 -0700 | [diff] [blame] | 67 | MediaScannerClient(); |
| 68 | virtual ~MediaScannerClient(); |
| 69 | void setLocale(const char* locale); |
| 70 | void beginFile(); |
| 71 | bool addStringTag(const char* name, const char* value); |
| 72 | void endFile(); |
| 73 | |
| 74 | virtual bool scanFile(const char* path, long long lastModified, long long fileSize) = 0; |
| 75 | virtual bool handleStringTag(const char* name, const char* value) = 0; |
| 76 | virtual bool setMimeType(const char* mimeType) = 0; |
| 77 | virtual bool addNoMediaFolder(const char* path) = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 78 | |
| 79 | protected: |
| 80 | void convertValues(uint32_t encoding); |
| 81 | |
| 82 | protected: |
| 83 | // cached name and value strings, for native encoding support. |
| 84 | StringArray* mNames; |
| 85 | StringArray* mValues; |
Andreas Huber | bfb9fb1 | 2009-12-03 11:31:19 -0800 | [diff] [blame] | 86 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 87 | // default encoding based on MediaScanner::mLocale string |
| 88 | uint32_t mLocaleEncoding; |
| 89 | }; |
| 90 | |
| 91 | }; // namespace android |
| 92 | |
| 93 | #endif // MEDIASCANNER_H |
| 94 | |