OSDN Git Service

stagefright: log uri protocols, and opt-in to log full uri
authorLajos Molnar <lajos@google.com>
Fri, 4 Apr 2014 02:13:01 +0000 (19:13 -0700)
committerLajos Molnar <lajos@google.com>
Sat, 5 Apr 2014 02:05:32 +0000 (19:05 -0700)
Added property media.stagefright.log-uri.  Set it to true or 1 to
log uris by AwesomePlayer.

Added utility function to get uri debug string based on incognito
and log opt-in status.

Change-Id: I5ccc23079ddfb120dd9703a3ed651a162ed5acec
Related-Bug: 6994761

include/media/stagefright/Utils.h
media/libstagefright/AwesomePlayer.cpp
media/libstagefright/Utils.cpp
media/libstagefright/httplive/LiveSession.cpp
media/libstagefright/httplive/M3UParser.cpp
media/libstagefright/rtsp/ARTSPConnection.cpp
media/libstagefright/rtsp/SDPLoader.cpp

index bbad271..c85368f 100644 (file)
@@ -60,6 +60,8 @@ status_t sendMetaDataToHal(sp<MediaPlayerBase::AudioSink>& sink, const sp<MetaDa
 bool canOffloadStream(const sp<MetaData>& meta, bool hasVideo,
                       bool isStreaming, audio_stream_type_t streamType);
 
+AString uriDebugString(const AString &uri, bool incognito = false);
+
 }  // namespace android
 
 #endif  // UTILS_H_
index 4bad14b..e924076 100644 (file)
@@ -310,7 +310,7 @@ status_t AwesomePlayer::setDataSource_l(
         }
     }
 
-    ALOGI("setDataSource_l(URL suppressed)");
+    ALOGI("setDataSource_l(%s)", uriDebugString(mUri, mFlags & INCOGNITO).c_str());
 
     // The actual work will be done during preparation in the call to
     // ::finishSetDataSource_l to avoid blocking the calling thread in
@@ -2823,7 +2823,7 @@ status_t AwesomePlayer::dump(
 
     fprintf(out, " AwesomePlayer\n");
     if (mStats.mFd < 0) {
-        fprintf(out, "  URI(suppressed)");
+        fprintf(out, "  URI(%s)", uriDebugString(mUri, mFlags & INCOGNITO).c_str());
     } else {
         fprintf(out, "  fd(%d)", mStats.mFd);
     }
index 4ff805f..047fac7 100644 (file)
@@ -17,6 +17,7 @@
 //#define LOG_NDEBUG 0
 #define LOG_TAG "Utils"
 #include <utils/Log.h>
+#include <ctype.h>
 
 #include "include/ESDS.h"
 
@@ -628,5 +629,40 @@ bool canOffloadStream(const sp<MetaData>& meta, bool hasVideo,
     return AudioSystem::isOffloadSupported(info);
 }
 
+AString uriDebugString(const AString &uri, bool incognito) {
+    if (incognito) {
+        return AString("<URI suppressed>");
+    }
+
+    char prop[PROPERTY_VALUE_MAX];
+    if (property_get("media.stagefright.log-uri", prop, "false") &&
+        (!strcmp(prop, "1") || !strcmp(prop, "true"))) {
+        return uri;
+    }
+
+    // find scheme
+    AString scheme;
+    const char *chars = uri.c_str();
+    for (size_t i = 0; i < uri.size(); i++) {
+        const char c = chars[i];
+        if (!isascii(c)) {
+            break;
+        } else if (isalpha(c)) {
+            continue;
+        } else if (i == 0) {
+            // first character must be a letter
+            break;
+        } else if (isdigit(c) || c == '+' || c == '.' || c =='-') {
+            continue;
+        } else if (c != ':') {
+            break;
+        }
+        scheme = AString(uri, 0, i);
+        scheme.append("://<suppressed>");
+        return scheme;
+    }
+    return AString("<no-scheme URI suppressed>");
+}
+
 }  // namespace android
 
index fd42e77..08a146f 100644 (file)
@@ -477,11 +477,8 @@ void LiveSession::onConnect(const sp<AMessage> &msg) {
         headers = NULL;
     }
 
-#if 1
-    ALOGI("onConnect <URL suppressed>");
-#else
-    ALOGI("onConnect %s", url.c_str());
-#endif
+    // TODO currently we don't know if we are coming here from incognito mode
+    ALOGI("onConnect %s", uriDebugString(url).c_str());
 
     mMasterURL = url;
 
@@ -489,7 +486,7 @@ void LiveSession::onConnect(const sp<AMessage> &msg) {
     mPlaylist = fetchPlaylist(url.c_str(), NULL /* curPlaylistHash */, &dummy);
 
     if (mPlaylist == NULL) {
-        ALOGE("unable to fetch master playlist <URL suppressed>.");
+        ALOGE("unable to fetch master playlist %s.", uriDebugString(url).c_str());
 
         postPrepared(ERROR_IO);
         return;
index f22d650..785c515 100644 (file)
@@ -798,7 +798,8 @@ status_t M3UParser::parseCipherInfo(
                 if (MakeURL(baseURI.c_str(), val.c_str(), &absURI)) {
                     val = absURI;
                 } else {
-                    ALOGE("failed to make absolute url for <URL suppressed>.");
+                    ALOGE("failed to make absolute url for %s.",
+                            uriDebugString(baseURI).c_str());
                 }
             }
 
index cc3b63c..f25539c 100644 (file)
@@ -239,7 +239,7 @@ void ARTSPConnection::onConnect(const sp<AMessage> &msg) {
         // right here, since we currently have no way of asking the user
         // for this information.
 
-        ALOGE("Malformed rtsp url <URL suppressed>");
+        ALOGE("Malformed rtsp url %s", uriDebugString(url).c_str());
 
         reply->setInt32("result", ERROR_MALFORMED);
         reply->post();
index 09f7eee..424badf 100644 (file)
@@ -27,6 +27,7 @@
 #include <media/stagefright/MediaHTTP.h>
 #include <media/stagefright/foundation/ABuffer.h>
 #include <media/stagefright/foundation/ADebug.h>
+#include <media/stagefright/Utils.h>
 
 #define DEFAULT_SDP_SIZE 100000
 
@@ -89,11 +90,7 @@ void SDPLoader::onLoad(const sp<AMessage> &msg) {
     KeyedVector<String8, String8> *headers = NULL;
     msg->findPointer("headers", (void **)&headers);
 
-    if (!(mFlags & kFlagIncognito)) {
-        ALOGV("onLoad '%s'", url.c_str());
-    } else {
-        ALOGI("onLoad <URL suppressed>");
-    }
+    ALOGV("onLoad %s", uriDebugString(url, mFlags & kFlagIncognito).c_str());
 
     if (!mCancelled) {
         err = mHTTPDataSource->connect(url.c_str(), headers);