mediascanner.h revision 2729ea9262ca60d93047e984739887cfc89e82eb
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
20#include <utils.h>
21#include <pthread.h>
22
23namespace android {
24
25class MediaScannerClient;
26
27class MediaScanner
28{
29public:
30    MediaScanner();
31    ~MediaScanner();
32
33    typedef bool (*ExceptionCheck)(void* env);
34
35    status_t processFile(const char *path, const char *mimeType, MediaScannerClient& client);
36    status_t processDirectory(const char *path, const char* extensions,
37            MediaScannerClient& client, ExceptionCheck exceptionCheck, void* exceptionEnv);
38
39    // extracts album art as a block of data
40    char* extractAlbumArt(int fd);
41
42    static void uninitializeForThread();
43
44private:
45    status_t doProcessDirectory(char *path, int pathRemaining, const char* extensions,
46            MediaScannerClient& client, ExceptionCheck exceptionCheck, void* exceptionEnv);
47    void initializeForThread();
48};
49
50
51class MediaScannerClient
52{
53public:
54	virtual ~MediaScannerClient() {}
55	virtual bool scanFile(const char* path, long long lastModified, long long fileSize) = 0;
56	virtual bool handleStringTag(const char* name, const char* value) = 0;
57	virtual bool setMimeType(const char* mimeType) = 0;
58};
59
60}; // namespace android
61
62#endif // MEDIASCANNER_H
63
64