Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a1df816c authored by Lajos Molnar's avatar Lajos Molnar
Browse files

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
parent bcf08569
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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_
+2 −2
Original line number Diff line number Diff line
@@ -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);
    }
+36 −0
Original line number Diff line number Diff line
@@ -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
+3 −6
Original line number Diff line number Diff line
@@ -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;
+2 −1
Original line number Diff line number Diff line
@@ -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());
                }
            }

Loading