diff options
author | Lajos Molnar <lajos@google.com> | 2014-04-03 19:13:01 -0700 |
---|---|---|
committer | Lajos Molnar <lajos@google.com> | 2014-04-04 19:05:32 -0700 |
commit | a1df816c0677185534babba6ffc29970b048e52e (patch) | |
tree | a2bf0a6954b805b7eef330387940067fb132da4f | |
parent | bcf08569453dcb42730cda3230d5d375a697005b (diff) | |
download | frameworks_av-a1df816c0677185534babba6ffc29970b048e52e.zip frameworks_av-a1df816c0677185534babba6ffc29970b048e52e.tar.gz frameworks_av-a1df816c0677185534babba6ffc29970b048e52e.tar.bz2 |
stagefright: log uri protocols, and opt-in to log full uri
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
-rw-r--r-- | include/media/stagefright/Utils.h | 2 | ||||
-rw-r--r-- | media/libstagefright/AwesomePlayer.cpp | 4 | ||||
-rw-r--r-- | media/libstagefright/Utils.cpp | 36 | ||||
-rw-r--r-- | media/libstagefright/httplive/LiveSession.cpp | 9 | ||||
-rw-r--r-- | media/libstagefright/httplive/M3UParser.cpp | 3 | ||||
-rw-r--r-- | media/libstagefright/rtsp/ARTSPConnection.cpp | 2 | ||||
-rw-r--r-- | media/libstagefright/rtsp/SDPLoader.cpp | 7 |
7 files changed, 48 insertions, 15 deletions
diff --git a/include/media/stagefright/Utils.h b/include/media/stagefright/Utils.h index bbad271..c85368f 100644 --- a/include/media/stagefright/Utils.h +++ b/include/media/stagefright/Utils.h @@ -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_ diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp index 4bad14b..e924076 100644 --- a/media/libstagefright/AwesomePlayer.cpp +++ b/media/libstagefright/AwesomePlayer.cpp @@ -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); } diff --git a/media/libstagefright/Utils.cpp b/media/libstagefright/Utils.cpp index 4ff805f..047fac7 100644 --- a/media/libstagefright/Utils.cpp +++ b/media/libstagefright/Utils.cpp @@ -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 diff --git a/media/libstagefright/httplive/LiveSession.cpp b/media/libstagefright/httplive/LiveSession.cpp index fd42e77..08a146f 100644 --- a/media/libstagefright/httplive/LiveSession.cpp +++ b/media/libstagefright/httplive/LiveSession.cpp @@ -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; diff --git a/media/libstagefright/httplive/M3UParser.cpp b/media/libstagefright/httplive/M3UParser.cpp index f22d650..785c515 100644 --- a/media/libstagefright/httplive/M3UParser.cpp +++ b/media/libstagefright/httplive/M3UParser.cpp @@ -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()); } } diff --git a/media/libstagefright/rtsp/ARTSPConnection.cpp b/media/libstagefright/rtsp/ARTSPConnection.cpp index cc3b63c..f25539c 100644 --- a/media/libstagefright/rtsp/ARTSPConnection.cpp +++ b/media/libstagefright/rtsp/ARTSPConnection.cpp @@ -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(); diff --git a/media/libstagefright/rtsp/SDPLoader.cpp b/media/libstagefright/rtsp/SDPLoader.cpp index 09f7eee..424badf 100644 --- a/media/libstagefright/rtsp/SDPLoader.cpp +++ b/media/libstagefright/rtsp/SDPLoader.cpp @@ -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); |