OSDN Git Service

add build file name function.
authorMichael Chen <omxcodec@gmail.com>
Thu, 4 Apr 2013 03:04:54 +0000 (11:04 +0800)
committerMichael Chen <omxcodec@gmail.com>
Thu, 4 Apr 2013 03:04:54 +0000 (11:04 +0800)
read av stuff from DataSource now, it is OK!

libstagefright/FFmpegExtractor/FFmpegExtractor.cpp
libstagefright/FFmpegExtractor/FFmpegExtractor.h

index fb4bc9e..eecccb7 100644 (file)
@@ -108,19 +108,9 @@ FFmpegExtractor::FFmpegExtractor(const sp<DataSource> &source)
       mInitCheck(NO_INIT) {
     LOGV("FFmpegExtractor::FFmpegExtractor");
 
-    int err;
-    const char *url = mDataSource->getNamURI();
-    if (url == NULL) {
-        LOGI("url is error!");
-        return;
-    }
-    // is it right?
-    if (!strcmp(url, "-")) {
-        av_strlcpy(mFilename, "pipe:", strlen("pipe:") + 1);
-    } else {
-        av_strlcpy(mFilename, url, strlen(url) + 1);
-    }
-    LOGI("url: %s, mFilename: %s", url, mFilename);
+    int err = 0;
+
+    buildFileName(source);
 
     err = initStreams();
     if (err < 0) {
@@ -943,6 +933,29 @@ void FFmpegExtractor::print_error_ex(const char *filename, int err)
     LOGI("%s: %s\n", filename, errbuf_ptr);
 }
 
+void FFmpegExtractor::buildFileName(const sp<DataSource> &source)
+{
+#if 1
+    LOGI("android source: %x", &source);
+    // pass the addr of smart pointer("source")
+    snprintf(mFilename, sizeof(mFilename), "android-source:%x", &source);
+    LOGI("build mFilename: %s", mFilename);
+#else
+    const char *url = mDataSource->getNamURI();
+    if (url == NULL) {
+        LOGI("url is error!");
+        return;
+    }
+    // is it right?
+    if (!strcmp(url, "-")) {
+        av_strlcpy(mFilename, "pipe:", strlen("pipe:") + 1);
+    } else {
+        av_strlcpy(mFilename, url, strlen(url) + 1);
+    }
+    LOGI("build url: %s, mFilename: %s", url, mFilename);
+#endif
+}
+
 void FFmpegExtractor::setFFmpegDefaultOpts()
 {
     mGenPTS       = 0;
index 9f3b77e..f1d1455 100644 (file)
@@ -137,6 +137,7 @@ private:
     void print_error_ex(const char *filename, int err);
     int initStreams();
     void deInitStreams();
+    void buildFileName(const sp<DataSource> &source);
     void setFFmpegDefaultOpts();
     void printTime(int64_t time);
     int stream_component_open(int stream_index);