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

Commit a2e57ca6 authored by Andreas Huber's avatar Andreas Huber
Browse files

Stagefright DataSources now expose the underlying content mime type.

Use that mime type to determine if we should do upfront buffering at the start of
playback and don't for audio streams to ensure playback starts fairly instantly.

Change-Id: If21e36d1b024f0e5c723911bceadaa2e0307ab42
related-to-bug: 4090916
parent 163ac289
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -84,6 +84,8 @@ public:
        return String8();
        return String8();
    }
    }


    virtual String8 getMIMEType() const;

protected:
protected:
    virtual ~DataSource() {}
    virtual ~DataSource() {}


+24 −16
Original line number Original line Diff line number Diff line
@@ -1693,6 +1693,13 @@ status_t AwesomePlayer::finishSetDataSource_l() {


        dataSource = mCachedSource;
        dataSource = mCachedSource;


        String8 contentType = dataSource->getMIMEType();

        if (strncasecmp(contentType.string(), "audio/", 6)) {
            // We're not doing this for streams that appear to be audio-only
            // streams to ensure that even low bandwidth streams start
            // playing back fairly instantly.

            // We're going to prefill the cache before trying to instantiate
            // We're going to prefill the cache before trying to instantiate
            // the extractor below, as the latter is an operation that otherwise
            // the extractor below, as the latter is an operation that otherwise
            // could block on the datasource for a significant amount of time.
            // could block on the datasource for a significant amount of time.
@@ -1715,6 +1722,7 @@ status_t AwesomePlayer::finishSetDataSource_l() {
            }
            }


            mLock.lock();
            mLock.lock();
        }


        if (mFlags & PREPARE_CANCELLED) {
        if (mFlags & PREPARE_CANCELLED) {
            LOGI("Prepare cancelled while waiting for initial cache fill.");
            LOGI("Prepare cancelled while waiting for initial cache fill.");
+4 −0
Original line number Original line Diff line number Diff line
@@ -144,4 +144,8 @@ sp<DataSource> DataSource::CreateFromURI(
    return source;
    return source;
}
}


String8 DataSource::getMIMEType() const {
    return String8("application/octet-stream");
}

}  // namespace android
}  // namespace android
+4 −0
Original line number Original line Diff line number Diff line
@@ -493,4 +493,8 @@ String8 NuCachedSource2::getUri() {
    return mSource->getUri();
    return mSource->getUri();
}
}


String8 NuCachedSource2::getMIMEType() const {
    return mSource->getMIMEType();
}

}  // namespace android
}  // namespace android
+14 −0
Original line number Original line Diff line number Diff line
@@ -136,6 +136,7 @@ status_t NuHTTPDataSource::connect(
    unsigned port;
    unsigned port;


    mUri = uri;
    mUri = uri;
    mContentType = String8("application/octet-stream");


    bool https;
    bool https;
    if (!ParseURL(uri, &host, &port, &path, &https)) {
    if (!ParseURL(uri, &host, &port, &path, &https)) {
@@ -265,6 +266,15 @@ status_t NuHTTPDataSource::connect(
            }
            }
        }
        }


        {
            AString value;
            if (mHTTP.find_header_value("Content-Type", &value)) {
                mContentType = String8(value.c_str());
            } else {
                mContentType = String8("application/octet-stream");
            }
        }

        applyTimeoutResponse();
        applyTimeoutResponse();


        if (offset == 0) {
        if (offset == 0) {
@@ -564,4 +574,8 @@ String8 NuHTTPDataSource::getUri() {
    return mUri;
    return mUri;
}
}


String8 NuHTTPDataSource::getMIMEType() const {
    return mContentType;
}

}  // namespace android
}  // namespace android
Loading