OSDN Git Service

FFmpegExtractor: Don't use our extractor when we agree with StageFright
authorChristopher R. Palmer <crpalmer@gmail.com>
Sat, 27 May 2017 18:44:42 +0000 (14:44 -0400)
committerChristopher R. Palmer <crpalmer@gmail.com>
Tue, 30 May 2017 10:18:43 +0000 (06:18 -0400)
Prior to this commit, if StageFright picks mimeType X with any
confidence <= .8 then it uses the StageFright extractors and otherwise
(if ffmpeg recognizes the file format) then it will use the ffmpeg
extractors.

This commit changes the logic to prefer the StageFright extractors
(keeping the behaviour closer to aosp and less dependent on ffmpeg's
implementation) whenever both agree on the same mime type.

Change-Id: I98b1b3c3e94756923106911783104ca42e916aed

extractor/FFmpegExtractor.cpp

index 2a796ad..6c41ca1 100644 (file)
@@ -2192,11 +2192,14 @@ bool SniffFFMPEG(
         ALOGV("sniff through BetterSniffFFMPEG success");
     }
 
+    if (mimeType != NULL && container != NULL && *mimeType == container) {
+        ALOGD("SniffFFMPEG sniffed the same thing as StageFright, use their extractor instead");
+        goto fail;
+    }
+
     if (container == NULL) {
         ALOGD("SniffFFMPEG failed to sniff this source");
-        (*meta)->clear();
-        *meta = NULL;
-        return false;
+        goto fail;
     }
 
     ALOGD("ffmpeg detected media content as '%s' with confidence %.2f",
@@ -2222,6 +2225,11 @@ bool SniffFFMPEG(
     }
 
     return true;
+
+fail:
+    (*meta)->clear();
+    *meta = NULL;
+    return false;
 }
 
 MediaExtractor *CreateFFMPEGExtractor(const sp<DataSource> &source, const char *mime, const sp<AMessage> &meta) {