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

Commit 8cc99938 authored by Andreas Huber's avatar Andreas Huber Committed by Android (Google) Code Review
Browse files

Merge "Support the specification of additional HTTP headers in the creation of a DataSource."

parents 4d3cef34 433c9aca
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include <sys/types.h>

#include <utils/Errors.h>
#include <utils/KeyedVector.h>
#include <utils/List.h>
#include <utils/RefBase.h>
#include <utils/threads.h>
@@ -35,7 +36,9 @@ public:
        kWantsPrefetching = 1,
    };

    static sp<DataSource> CreateFromURI(const char *uri);
    static sp<DataSource> CreateFromURI(
            const char *uri,
            const KeyedVector<String8, String8> *headers = NULL);

    DataSource() {}

+11 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#define HTTP_DATASOURCE_H_

#include <media/stagefright/DataSource.h>
#include <utils/String8.h>

namespace android {

@@ -26,8 +27,13 @@ class HTTPStream;

class HTTPDataSource : public DataSource {
public:
    HTTPDataSource(const char *host, int port, const char *path);
    HTTPDataSource(const char *uri);
    HTTPDataSource(
            const char *host, int port, const char *path,
            const KeyedVector<String8, String8> *headers = NULL);

    HTTPDataSource(
            const char *uri,
            const KeyedVector<String8, String8> *headers = NULL);

    virtual status_t initCheck() const;

@@ -45,6 +51,8 @@ private:
        kBufferSize = 64 * 1024
    };

    String8 mHeaders;

    HTTPStream *mHttp;
    char *mHost;
    int mPort;
@@ -58,6 +66,7 @@ private:
    status_t mInitCheck;

    ssize_t sendRangeRequest(size_t offset);
    void initHeaders(const KeyedVector<String8, String8> *overrides);

    HTTPDataSource(const HTTPDataSource &);
    HTTPDataSource &operator=(const HTTPDataSource &);
+0 −3
Original line number Diff line number Diff line
@@ -31,9 +31,6 @@ public:
    static sp<MediaExtractor> Create(
            const sp<DataSource> &source, const char *mime = NULL);

    static sp<MediaExtractor> CreateFromURI(
            const char *uri, const char *mime = NULL);

    virtual size_t countTracks() = 0;
    virtual sp<MediaSource> getTrack(size_t index) = 0;

+2 −2
Original line number Diff line number Diff line
@@ -29,9 +29,9 @@ status_t StagefrightPlayer::initCheck() {
}

status_t StagefrightPlayer::setDataSource(
        const char *url, const KeyedVector<String8, String8> *) {
        const char *url, const KeyedVector<String8, String8> *headers) {
    LOGI("setDataSource('%s')", url);
    return mPlayer->setDataSource(url);
    return mPlayer->setDataSource(url, headers);
}

// Warning: The filedescriptor passed into this method will only be valid until
+3 −2
Original line number Diff line number Diff line
@@ -152,12 +152,13 @@ void AwesomePlayer::setListener(const wp<MediaPlayerBase> &listener) {
    mListener = listener;
}

status_t AwesomePlayer::setDataSource(const char *uri) {
status_t AwesomePlayer::setDataSource(
        const char *uri, const KeyedVector<String8, String8> *headers) {
    Mutex::Autolock autoLock(mLock);

    reset_l();

    sp<DataSource> dataSource = DataSource::CreateFromURI(uri);
    sp<DataSource> dataSource = DataSource::CreateFromURI(uri, headers);

    if (dataSource == NULL) {
        return UNKNOWN_ERROR;
Loading