// static sp<MediaExtractor> MediaExtractor::Create( const sp<DataSource> &source, const char *mime) { sp<AMessage> meta; String8 tmp; float confidence = 0; if (mime == NULL) { float confidence; if (!source->sniff(&tmp, &confidence, &meta)) { ALOGV("FAILED to autodetect media content."); return NULL; } mime = tmp.string(); ALOGV("Autodetected media content as '%s' with confidence %.2f", mime, confidence); } else { tmp = mime; if (!source->sniff(&tmp, &confidence, &meta)) { ALOGV("FAILED to autodetect media content."); return NULL; } ALOGV("Autodetected media content as '%s' with confidence %.2f", mime, confidence); mime = tmp.string(); } bool isDrm = false; // DRM MIME type syntax is "drm+type+original" where // type is "es_based" or "container_based" and // original is the content's cleartext MIME type if (!strncmp(mime, "drm+", 4)) { const char *originalMime = strchr(mime+4, '+'); if (originalMime == NULL) { // second + not found return NULL; } ++originalMime; if (!strncmp(mime, "drm+es_based+", 13)) { // DRMExtractor sets container metadata kKeyIsDRM to 1 return new DRMExtractor(source, originalMime); } else if (!strncmp(mime, "drm+container_based+", 20)) { mime = originalMime; isDrm = true; } else { return NULL; } } MediaExtractor *ret = NULL; char value[PROPERTY_VALUE_MAX]; if(property_get("media.demux.cfg", value, NULL)){ ALOGV("read demux cfg, value: %s", value); if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MPEG4) || !strcasecmp(mime, "audio/mp4")) { if (strstr(value, "Mov")) { ret = new MPEG4Extractor(source); } } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_MPEG)) { if (strstr(value, "Mp3")) { ret = new MP3Extractor(source, meta); } } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AMR_NB) || !strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AMR_WB)) { if (strstr(value, "Amr")) { ret = new AMRExtractor(source); } } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_FLAC)) { ret = new FLACExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_WAV)) { if (strstr(value, "Wav")) { ret = new WAVExtractor(source); } } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_OGG)) { if (strstr(value, "Ogg")) { ret = new OggExtractor(source); } } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MATROSKA)) { if (strstr(value, "Matroska")) { ret = new MatroskaExtractor(source); } } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MPEG2TS)) { if (strstr(value, "Mpeg2ts")) { ret = new MPEG2TSExtractor(source); } } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_WVM)) { ret = new WVMExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AAC_ADTS) || !strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_ADIF) || !strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_ADTS)) { if (strstr(value, "Aac")) { ret = new AACExtractor(source, meta); } } } else { if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MPEG4) || !strcasecmp(mime, "audio/mp4")) { ret = new MPEG4Extractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_MPEG)) { ret = new MP3Extractor(source, meta); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AMR_NB) || !strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AMR_WB)) { ret = new AMRExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_FLAC)) { ret = new FLACExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_WAV)) { ret = new WAVExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_OGG)) { ret = new OggExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MATROSKA)) { ret = new MatroskaExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MPEG2TS)) { ret = new MPEG2TSExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_WVM)) { ret = new WVMExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AAC_ADTS) || !strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_ADIF) || !strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_ADTS)) { ret = new AACExtractor(source, meta); } } if (ret != NULL && isDrm) { ret->getMetaData()->setInt32(kKeyIsDRM, 1); } if(ret == NULL){ ALOGI(" Using ExtendedExtractor mime = %s \n",mime); sp<MediaExtractor> retextParser = ExtendedExtractor::CreateExtractor(source, mime); if (retextParser != NULL){ return retextParser; } } return ret; }
// static sp<MediaExtractor> MediaExtractor::Create( const sp<DataSource> &source, const char *mime) { sp<AMessage> meta; String8 tmp; if (mime == NULL) { float confidence; if (!source->sniff(&tmp, &confidence, &meta)) { ALOGV("FAILED to autodetect media content."); return NULL; } mime = tmp.string(); ALOGV("Autodetected media content as '%s' with confidence %.2f", mime, confidence); } bool isDrm = false; // DRM MIME type syntax is "drm+type+original" where // type is "es_based" or "container_based" and // original is the content's cleartext MIME type if (!strncmp(mime, "drm+", 4)) { const char *originalMime = strchr(mime+4, '+'); if (originalMime == NULL) { // second + not found return NULL; } ++originalMime; if (!strncmp(mime, "drm+es_based+", 13)) { // DRMExtractor sets container metadata kKeyIsDRM to 1 return new DRMExtractor(source, originalMime); } else if (!strncmp(mime, "drm+container_based+", 20)) { mime = originalMime; isDrm = true; } else { return NULL; } } MediaExtractor *ret = NULL; if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MPEG4) || !strcasecmp(mime, "audio/mp4")) { ret = new MPEG4Extractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_MPEG)) { ret = new MP3Extractor(source, meta); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AMR_NB) || !strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AMR_WB)) { ret = new AMRExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_FLAC)) { ret = new FLACExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_WAV)) { ret = new WAVExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_OGG)) { ret = new OggExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MATROSKA)) { ret = new MatroskaExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MPEG2TS)) { ret = new MPEG2TSExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_WVM)) { ret = new WVMExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AAC_ADTS)) { ret = new AACExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MPEG2PS)) { ret = new MPEG2PSExtractor(source); } if (ret != NULL) { if (isDrm) { ret->setDrmFlag(true); } else { ret->setDrmFlag(false); } } return ret; }
// static sp<MediaExtractor> MediaExtractor::Create( const sp<DataSource> &source, const char *mime) { sp<AMessage> meta; String8 tmp; if (mime == NULL) { float confidence; if (!source->sniff(&tmp, &confidence, &meta)) { ALOGV("FAILED to autodetect media content."); return NULL; } mime = tmp.string(); ALOGV("Autodetected media content as '%s' with confidence %.2f", mime, confidence); } bool isDrm = false; // DRM MIME type syntax is "drm+type+original" where // type is "es_based" or "container_based" and // original is the content's cleartext MIME type if (!strncmp(mime, "drm+", 4)) { const char *originalMime = strchr(mime+4, '+'); if (originalMime == NULL) { // second + not found return NULL; } ++originalMime; if (!strncmp(mime, "drm+es_based+", 13)) { // DRMExtractor sets container metadata kKeyIsDRM to 1 return new DRMExtractor(source, originalMime); } else if (!strncmp(mime, "drm+container_based+", 20)) { mime = originalMime; isDrm = true; } else { return NULL; } } MediaExtractor *ret = NULL; if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MPEG4) || !strcasecmp(mime, "audio/mp4")) { int fragmented = 0; if (meta != NULL && meta->findInt32("fragmented", &fragmented) && fragmented) { ret = new FragmentedMP4Extractor(source); } else { ret = new MPEG4Extractor(source); } } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_MPEG)) { ret = new MP3Extractor(source, meta); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AMR_NB) || !strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AMR_WB)) { ret = new AMRExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_FLAC)) { ret = new FLACExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_WAV)) { ret = new WAVExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_OGG)) { ret = new OggExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MATROSKA)) { ret = new MatroskaExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MPEG2TS)) { ret = new MPEG2TSExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_WVM)) { // Return now. WVExtractor should not have the DrmFlag set in the block below. return new WVMExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AAC_ADTS)) { ret = new AACExtractor(source, meta); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MPEG2PS)) { ret = new MPEG2PSExtractor(source); #ifdef STE_FM } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_RAW)) { ret = new PCMExtractor(source); #endif } if (ret != NULL) { if (isDrm) { ret->setDrmFlag(true); } else { ret->setDrmFlag(false); } } #ifdef QCOM_HARDWARE //ret will get deleted within if replaced return QCUtilityClass::helper_MediaExtractor_CreateIfNeeded(ret, source, mime); #else return ret; #endif }
// static sp<MediaExtractor> MediaExtractor::Create( const sp<DataSource> &source, const char *mime) { sp<AMessage> meta; String8 tmp; if (mime == NULL) { float confidence; if (!source->sniff(&tmp, &confidence, &meta)) { ALOGV("FAILED to autodetect media content."); return NULL; } mime = tmp.string(); ALOGV("Autodetected media content as '%s' with confidence %.2f", mime, confidence); } bool isDrm = false; // DRM MIME type syntax is "drm+type+original" where // type is "es_based" or "container_based" and // original is the content's cleartext MIME type if (!strncmp(mime, "drm+", 4)) { const char *originalMime = strchr(mime+4, '+'); if (originalMime == NULL) { // second + not found return NULL; } ++originalMime; if (!strncmp(mime, "drm+es_based+", 13)) { // DRMExtractor sets container metadata kKeyIsDRM to 1 return new DRMExtractor(source, originalMime); } else if (!strncmp(mime, "drm+container_based+", 20)) { mime = originalMime; isDrm = true; } else { return NULL; } } MediaExtractor *ret = NULL; if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MPEG4) || !strcasecmp(mime, "audio/mp4")) { ret = new MPEG4Extractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_MPEG)) { ret = new MP3Extractor(source, meta); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AMR_NB) || !strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AMR_WB)) { ret = new AMRExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_FLAC)) { ret = new FLACExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_WAV)) { ret = new WAVExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_OGG)) { ret = new OggExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MATROSKA)) { ret = new MatroskaExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MPEG2TS)) { ret = new MPEG2TSExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_WVM)) { // Return now. WVExtractor should not have the DrmFlag set in the block below. return new WVMExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AAC_ADTS)) { ret = new AACExtractor(source, meta); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MPEG2PS)) { ret = new MPEG2PSExtractor(source); #ifdef STE_FM } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_RAW)) { ret = new PCMExtractor(source); #endif } if (ret != NULL) { if (isDrm) { ret->setDrmFlag(true); } else { ret->setDrmFlag(false); } } #ifdef QCOM_HARDWARE //If default extractor created, then pass them if (ret){ return ret; } //Create Extended Extractor only if default extractor are not selected ALOGV("Using ExtendedExtractor\n"); sp<MediaExtractor> retextParser = ExtendedExtractor::CreateExtractor(source, mime); if (retextParser != NULL){ return retextParser; } #endif return ret; }
// static sp<MediaExtractor> MediaExtractor::Create( const sp<DataSource> &source, const char *mime) { sp<AMessage> meta; bool bCheckExtendedExtractor = false; String8 tmp; if (mime == NULL) { float confidence; if (!source->sniff(&tmp, &confidence, &meta)) { ALOGV("FAILED to autodetect media content."); return NULL; } mime = tmp.string(); ALOGV("Autodetected media content as '%s' with confidence %.2f", mime, confidence); } bool isDrm = false; // DRM MIME type syntax is "drm+type+original" where // type is "es_based" or "container_based" and // original is the content's cleartext MIME type if (!strncmp(mime, "drm+", 4)) { const char *originalMime = strchr(mime+4, '+'); if (originalMime == NULL) { // second + not found return NULL; } ++originalMime; if (!strncmp(mime, "drm+es_based+", 13)) { // DRMExtractor sets container metadata kKeyIsDRM to 1 return new DRMExtractor(source, originalMime); } else if (!strncmp(mime, "drm+container_based+", 20)) { mime = originalMime; isDrm = true; } else { return NULL; } } MediaExtractor *ret = NULL; if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MPEG4) || !strcasecmp(mime, "audio/mp4")) { int fragmented = 0; if (meta != NULL && meta->findInt32("fragmented", &fragmented) && fragmented) { ret = new FragmentedMP4Extractor(source); } else { ret = new MPEG4Extractor(source); } #ifdef QCOM_ENHANCED_AUDIO bCheckExtendedExtractor = true; #endif } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_MPEG)) { ret = new MP3Extractor(source, meta); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AMR_NB) || !strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AMR_WB)) { ret = new AMRExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_FLAC)) { ret = new FLACExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_WAV)) { ret = new WAVExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_OGG)) { ret = new OggExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MATROSKA)) { ret = new MatroskaExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MPEG2TS)) { ret = new MPEG2TSExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_WVM)) { // Return now. WVExtractor should not have the DrmFlag set in the block below. return new WVMExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AAC_ADTS)) { ret = new AACExtractor(source, meta); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MPEG2PS)) { ret = new MPEG2PSExtractor(source); #ifdef STE_FM } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_RAW)) { ret = new PCMExtractor(source); #endif } if (ret != NULL) { if (isDrm) { ret->setDrmFlag(true); } else { ret->setDrmFlag(false); } } #ifdef QCOM_HARDWARE //If default extractor created and flag is not set to check extended extractor, // then pass default extractor. if (ret && (!bCheckExtendedExtractor) ) { ALOGD("returning default extractor"); return ret; } //Create Extended Extractor only if default extractor are not selected ALOGV("Using ExtendedExtractor"); sp<MediaExtractor> retextParser = ExtendedExtractor::CreateExtractor(source, mime); //if we came here, it means we do not have to use the default extractor, if created above. bool bUseDefaultExtractor = false; if(bCheckExtendedExtractor) { ALOGV("bCheckExtendedExtractor is true"); //bCheckExtendedExtractor is true which means default extractor was found // but we want to give preference to extended extractor based on certain // codec type.Set bUseDefaultExtractor to true if extended extractor //does not return specific codec type that we are looking for. bUseDefaultExtractor = true; ALOGV(" bCheckExtendedExtractor is true..checking extended extractor"); for (size_t i = 0; (retextParser!=NULL) && (i < retextParser->countTracks()); ++i) { sp<MetaData> meta = retextParser->getTrackMetaData(i); const char *mime; bool success = meta->findCString(kKeyMIMEType, &mime); if( (success == true) && !strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AMR_WB_PLUS)) { ALOGV("Discarding default extractor and using the extended one"); //We found what we were looking for, set bUseDefaultExtractor to false; bUseDefaultExtractor = false; if(ret) { //delete the default extractor as we will be using extended extractor.. delete ret; } break; } } } if( (retextParser != NULL) && (!bUseDefaultExtractor) ) { ALOGV("returning retextParser"); return retextParser; } #endif return ret; }
// static sp<MediaExtractor> MediaExtractor::Create( const sp<DataSource> &source, const char *mime) { sp<AMessage> meta; ALOGD("JB +MediaExtractor::Create"); String8 tmp; if (mime == NULL) { float confidence; if (!source->sniff(&tmp, &confidence, &meta)) { ALOGV("FAILED to autodetect media content."); return NULL; } mime = tmp.string(); ALOGD("Autodetected media content as '%s' with confidence %.2f", mime, confidence); } bool isDrm = false; // DRM MIME type syntax is "drm+type+original" where // type is "es_based" or "container_based" and // original is the content's cleartext MIME type if (!strncmp(mime, "drm+", 4)) { const char *originalMime = strchr(mime+4, '+'); if (originalMime == NULL) { // second + not found return NULL; } ++originalMime; if (!strncmp(mime, "drm+es_based+", 13)) { // DRMExtractor sets container metadata kKeyIsDRM to 1 return new DRMExtractor(source, originalMime); } else if (!strncmp(mime, "drm+container_based+", 20)) { mime = originalMime; isDrm = true; } else { return NULL; } } // M: add for OMA DRM v1.0 implementation // explanation: // for an OMA DRM v1.0 file, if it can be sniffed successfully, the mime type // would be replaced by the actual type (e.g. image/jpeg) instead of drm+containder_based+<original_mime> // Thus, the following code checks for decrypt handle and set isDrm to true // so that it's handled correctly in AwesomePlayer. #ifndef ANDROID_DEFAULT_CODE #ifdef MTK_DRM_APP DrmManagerClient *drmManagerClient = NULL; sp<DecryptHandle> decryptHandle; source->getDrmInfo(decryptHandle, &drmManagerClient); // mark isDrm as true for OMA DRM v1.0 file // the same judgement as in FileSource::flags() if (decryptHandle.get() != NULL && DecryptApiType::CONTAINER_BASED == decryptHandle->decryptApiType) { isDrm = true; } #endif #endif #ifndef ANDROID_DEFAULT_CODE sp<MediaExtractor> ret; #else MediaExtractor *ret = NULL; #endif if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MPEG4) || !strcasecmp(mime, "audio/mp4")) { int fragmented = 0; if (meta != NULL && meta->findInt32("fragmented", &fragmented) && fragmented) { ret = new FragmentedMP4Extractor(source); } else { ret = new MPEG4Extractor(source); } } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_MPEG)) { ret = new MP3Extractor(source, meta); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AMR_NB) || !strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AMR_WB)) { ret = new AMRExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_FLAC)) { ret = new FLACExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_WAV)) { ret = new WAVExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_OGG)) { ret = new OggExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MATROSKA)) { ret = new MatroskaExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MPEG2TS)) { ret = new MPEG2TSExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MPEG2PS)) { #ifndef ANDROID_DEFAULT_CODE #ifdef MTK_MTKPS_PLAYBACK_SUPPORT ret = new MPEG2PSExtractor(source); #else //MTK_MTKPS_PLAYBACK_SUPPORT ALOGV(" MediaExtractor::is PS file, not support playing now"); ret =NULL; #endif //MTK_MTKPS_PLAYBACK_SUPPORT #else //#ifndef ANDROID_DEFAULT_CODE ret = new MPEG2PSExtractor(source); #endif //#ifndef ANDROID_DEFAULT_CODE } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_AVI)) { #ifdef MTK_AVI_PLAYBACK_SUPPORT ret = new MtkAVIExtractor(source); #endif } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_WVM)) { // Return now. WVExtractor should not have the DrmFlag set in the block below. return new WVMExtractor(source); } #ifndef ANDROID_DEFAULT_CODE else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AAC)) { ret = new MtkAACExtractor(source,meta); } #else else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AAC_ADTS)) { ret = new AACExtractor(source, meta); } #endif #ifndef ANDROID_DEFAULT_CODE #ifdef MTK_ASF_PLAYBACK_SUPPORT else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_ASF)) { ret = ASFExtractorCreateInstance(source); } #endif #ifdef MTK_FLV_PLAYBACK_SUPPORT else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_FLV)) { ret = FLVExtractorCreateInstance(source); } #endif//#ifdef MTK_FLV_PLAYBACK_SUPPORT #ifdef MTK_AUDIO_APE_SUPPORT else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_APE)) { ret = new APEExtractor(source, meta); } #endif else if (!strcasecmp(mime, MEDIA_MIMETYPE_APPLICATION_SDP)) { ret = new MtkSDPExtractor(source); } #ifdef MTK_OGM_PLAYBACK_SUPPORT else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_OGM)) { ret = new OgmExtractor(source); } #endif//#ifdef MTK_OGM_PLAYBACK_SUPPORT #endif if (ret != NULL) { if (isDrm) { ret->setDrmFlag(true); } else { ret->setDrmFlag(false); } } ALOGD("JB -MediaExtractor::Create"); return ret; }
// static sp<MediaExtractor> MediaExtractor::Create( const sp<DataSource> &source, const char *mime) { sp<AMessage> meta; LCHLOGD1("mime=%s, MIME=%s", mime, source->getMIMEType().string()); String8 tmp; if (mime == NULL) { float confidence; if (!source->sniff(&tmp, &confidence, &meta)) { LOGV("FAILED to autodetect media content."); return NULL; } mime = tmp.string(); LOGV("Autodetected media content as '%s' with confidence %.2f", mime, confidence); } bool isDrm = false; // DRM MIME type syntax is "drm+type+original" where // type is "es_based" or "container_based" and // original is the content's cleartext MIME type if (!strncmp(mime, "drm+", 4)) { const char *originalMime = strchr(mime+4, '+'); if (originalMime == NULL) { // second + not found return NULL; } ++originalMime; if (!strncmp(mime, "drm+es_based+", 13)) { // DRMExtractor sets container metadata kKeyIsDRM to 1 return new DRMExtractor(source, originalMime); } else if (!strncmp(mime, "drm+container_based+", 20)) { mime = originalMime; isDrm = true; } else { return NULL; } } MediaExtractor *ret = NULL; /* a@nufront begin */ /* if (source->getUri() && strlen(source->getUri()) && !isSystemMedia(source->getUri())) { using namespace FFMPEG; ret = new FFmpegExtractor(source); LOGD("zx, create FFmpegExtractor."); } else { */ /* a@nufront end */ #if !defined(USE_FFMPEG_EXTRACTOR) ZXLOGD("not use FFmpegExtractor."); #warning "not defined USE_FFMPEG_EXTRACTOR" #endif LCHLOGD1("mime=%s, file=%s", mime, source->getUri().string()); if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MPEG4) || !strcasecmp(mime, "audio/mp4")) { ret = new MPEG4Extractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_MPEG)) { ret = new MP3Extractor(source, meta); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AMR_NB) || !strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AMR_WB)) { ret = new AMRExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_FLAC)) { ret = new FLACExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_WAV)) { ret = new WAVExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_OGG)) { ret = new OggExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MATROSKA)) { ret = new MatroskaExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MPEG2TS)) { ret = new MPEG2TSExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_WVM)) { ret = new WVMExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AAC_ADTS)) { ret = new AACExtractor(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MPEG2PS)) { ret = new MPEG2PSExtractor(source); } #if defined(USE_FFMPEG_EXTRACTOR) #warning "defined USE_FFMPEG_EXTRACTOR" else { using namespace FFMPEG; ret = new FFmpegExtractor(source); ZXLOGD("use FFmpegExtractor."); /*a@nufront start: add open status check*/ if (((FFmpegExtractor*)ret)->IsOpenFailed()) { delete ret; ret = NULL; } /*a@nufront end*/ } #endif /* a@nufront begin */ /* else { using namespace FFMPEG; ret = new FFmpegExtractor(source); } } */ /* a@nufront end */ if (ret != NULL) { if (isDrm) { ret->setDrmFlag(true); } else { ret->setDrmFlag(false); } } return ret; }
virtual status_t GetNextChunk(void **chunkBuffer, int32 *chunkSize, media_header *mediaHeader) { return fExtractor->GetNextChunk(fStream,chunkBuffer,chunkSize,mediaHeader); }