free(mLocale);
}
-static PVMFStatus parseMP3(const char *filename, MediaScannerClient& client)
+static PVMFStatus parseID3Tag(const char *filename, MediaScannerClient& client)
{
+ // This method parses the ID3 tags in a source file.
PVID3ParCom pvId3Param;
PVFile fileHandle;
Oscl_FileServer iFs;
uint32 trackType = mp4Input->getTrackMediaType(tracks[i]);
OSCL_HeapString<OsclMemAllocator> streamtype;
mp4Input->getTrackMIMEType(tracks[i], streamtype);
- char streamtypeutf8[128];
- strncpy (streamtypeutf8, streamtype.get_str(), streamtype.get_size());
- if (streamtypeutf8[0])
- {
- if (strcmp(streamtypeutf8,"FORMATUNKNOWN") != 0) {
- if (trackType == MEDIA_TYPE_AUDIO) {
- hasAudio = true;
- } else if (trackType == MEDIA_TYPE_VISUAL) {
- hasVideo = true;
- }
- } else {
- //LOGI("@@@@@@@@ %100s: %s\n", filename, streamtypeutf8);
+
+ if (!(streamtype == "FORMATUNKNOWN")) {
+ if (trackType == MEDIA_TYPE_AUDIO) {
+ hasAudio = true;
+ } else if (trackType == MEDIA_TYPE_VISUAL) {
+ hasVideo = true;
}
+ } else {
+ //LOGI("@@@@@@@@ %100s: %s\n", filename, streamtypeutf8);
}
}
status_t MediaScanner::processFile(const char *path, const char* mimeType, MediaScannerClient& client)
{
- status_t result;
+ status_t result = PVMFSuccess;
int error = 0;
InitializeForThread();
-
+
OSCL_TRY(error,
- client.setLocale(mLocale);
- client.beginFile();
-
- //LOGD("processFile %s mimeType: %s\n", path, mimeType);
- const char* extension = strrchr(path, '.');
-
- if (extension && strcasecmp(extension, ".mp3") == 0) {
- result = parseMP3(path, client);
- } else if (extension &&
- (strcasecmp(extension, ".mp4") == 0 || strcasecmp(extension, ".m4a") == 0 ||
- strcasecmp(extension, ".3gp") == 0 || strcasecmp(extension, ".3gpp") == 0 ||
- strcasecmp(extension, ".3g2") == 0 || strcasecmp(extension, ".3gpp2") == 0)) {
- result = parseMP4(path, client);
- } else if (extension && strcasecmp(extension, ".ogg") == 0) {
- result = parseOgg(path, client);
- } else if (extension &&
- ( strcasecmp(extension, ".mid") == 0 || strcasecmp(extension, ".smf") == 0
- || strcasecmp(extension, ".imy") == 0)) {
- result = parseMidi(path, client);
- } else if (extension &&
- (strcasecmp(extension, ".wma") == 0 || strcasecmp(extension, ".wmv") == 0 ||
- strcasecmp(extension, ".asf") == 0 )) {
- result = parseASF(path, client);
- } else {
- result = PVMFFailure;
- }
+ client.setLocale(mLocale);
+ client.beginFile();
+
+ //LOGD("processFile %s mimeType: %s\n", path, mimeType);
+ const char* extension = strrchr(path, '.');
+
+ if (extension &&
+ (strcasecmp(extension, ".mp3") == 0 || strcasecmp(extension, ".aac") == 0)) {
+ // Both mp3 and aac files use ID3 tags to hold metadata
+ result = parseID3Tag(path, client);
+ } else if (extension &&
+ (strcasecmp(extension, ".mp4") == 0 || strcasecmp(extension, ".m4a") == 0 ||
+ strcasecmp(extension, ".3gp") == 0 || strcasecmp(extension, ".3gpp") == 0 ||
+ strcasecmp(extension, ".3g2") == 0 || strcasecmp(extension, ".m4b") == 0 ||
+ strcasecmp(extension, ".3gpp2") == 0)) {
+ result = parseMP4(path, client);
+ } else if (extension && strcasecmp(extension, ".ogg") == 0) {
+ result = parseOgg(path, client);
+ } else if (extension &&
+ (strcasecmp(extension, ".mid") == 0 || strcasecmp(extension, ".smf") == 0 ||
+ strcasecmp(extension, ".imy") == 0)) {
+ result = parseMidi(path, client);
+ } else if (extension &&
+ (strcasecmp(extension, ".wma") == 0 || strcasecmp(extension, ".wmv") == 0 ||
+ strcasecmp(extension, ".asf") == 0 || strcasecmp(extension, ".amr") == 0 ||
+ strcasecmp(extension, ".wav") == 0 || strcasecmp(extension, ".awb") == 0)) {
+ result = parseASF(path, client);
+ } else {
+ result = PVMFFailure;
+ }
client.endFile();
- );
-
+ );
+
OSCL_FIRST_CATCH_ANY( error,LOGV("OSCL_LEAVE happened in processFile Exit with failure");return PVMFFailure);
return result;
}
strcpy(fileSpot, ".nomedia");
if (access(path, F_OK) == 0) {
LOGD("found .nomedia, skipping directory\n");
+ // restore path
+ fileSpot[0] = 0;
+ // notify client
+ client.addNoMediaFolder(path);
return OK;
}