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

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

Merge "Squashed commit of the following:"

parents 9c950b41 61c79b6d
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -49,7 +49,6 @@ LOCAL_SRC_FILES:= \
        WVMExtractor.cpp                  \
        XINGSeeker.cpp                    \
        avc_utils.cpp                     \
        string.cpp

LOCAL_C_INCLUDES:= \
	$(JNI_H_INCLUDE) \
+15 −6
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@
namespace android {

// static
const char *HTTPStream::kStatusKey = ":status:";
const char *HTTPStream::kStatusKey = ":status:";  // MUST be lowercase.

HTTPStream::HTTPStream()
    : mState(READY),
@@ -220,7 +220,7 @@ status_t HTTPStream::receive_header(int *http_status) {
        return err;
    }

    mHeaders.add(string(kStatusKey), string(line));
    mHeaders.add(AString(kStatusKey), AString(line));

    char *spacePos = strchr(line, ' ');
    if (spacePos == NULL) {
@@ -264,7 +264,10 @@ status_t HTTPStream::receive_header(int *http_status) {

        char *colonPos = strchr(line, ':');
        if (colonPos == NULL) {
            mHeaders.add(string(line), string());
            AString key = line;
            key.tolower();

            mHeaders.add(key, AString());
        } else {
            char *end_of_key = colonPos;
            while (end_of_key > line && isspace(end_of_key[-1])) {
@@ -278,7 +281,10 @@ status_t HTTPStream::receive_header(int *http_status) {

            *end_of_key = '\0';

            mHeaders.add(string(line), string(start_of_value));
            AString key = line;
            key.tolower();

            mHeaders.add(key, AString(start_of_value));
        }
    }

@@ -314,8 +320,11 @@ ssize_t HTTPStream::receive(void *data, size_t size) {
    return (ssize_t)total;
}

bool HTTPStream::find_header_value(const string &key, string *value) const {
    ssize_t index = mHeaders.indexOfKey(key);
bool HTTPStream::find_header_value(const AString &key, AString *value) const {
    AString key_lower = key;
    key_lower.tolower();

    ssize_t index = mHeaders.indexOfKey(key_lower);
    if (index < 0) {
        value->clear();
        return false;
+8 −9
Original line number Diff line number Diff line
@@ -178,7 +178,7 @@ status_t NuHTTPDataSource::connect(
        }

        if (IsRedirectStatusCode(httpStatus)) {
            string value;
            AString value;
            CHECK(mHTTP.find_header_value("Location", &value));

            mState = DISCONNECTED;
@@ -198,9 +198,8 @@ status_t NuHTTPDataSource::connect(
        mHasChunkedTransferEncoding = false;

        {
            string value;
            if (mHTTP.find_header_value("Transfer-Encoding", &value)
                    || mHTTP.find_header_value("Transfer-encoding", &value)) {
            AString value;
            if (mHTTP.find_header_value("Transfer-Encoding", &value)) {
                // We don't currently support any transfer encodings but
                // chunked.

@@ -222,9 +221,9 @@ status_t NuHTTPDataSource::connect(
        applyTimeoutResponse();

        if (offset == 0) {
            string value;
            AString value;
            unsigned long x;
            if (mHTTP.find_header_value(string("Content-Length"), &value)
            if (mHTTP.find_header_value(AString("Content-Length"), &value)
                    && ParseSingleUnsignedLong(value.c_str(), &x)) {
                mContentLength = (off64_t)x;
                mContentLengthValid = true;
@@ -239,9 +238,9 @@ status_t NuHTTPDataSource::connect(
                return ERROR_UNSUPPORTED;
            }

            string value;
            AString value;
            unsigned long x;
            if (mHTTP.find_header_value(string("Content-Range"), &value)) {
            if (mHTTP.find_header_value(AString("Content-Range"), &value)) {
                const char *slashPos = strchr(value.c_str(), '/');
                if (slashPos != NULL
                        && ParseSingleUnsignedLong(slashPos + 1, &x)) {
@@ -439,7 +438,7 @@ void NuHTTPDataSource::MakeFullHeaders(
}

void NuHTTPDataSource::applyTimeoutResponse() {
    string timeout;
    AString timeout;
    if (mHTTP.find_header_value("X-SocketTimeout", &timeout)) {
        const char *s = timeout.c_str();
        char *end;
+1 −2
Original line number Diff line number Diff line
@@ -14,7 +14,6 @@
 * limitations under the License.
 */

#include "include/stagefright_string.h"
#include "include/HTTPStream.h"

#include <stdlib.h>
@@ -34,7 +33,7 @@ ShoutcastSource::ShoutcastSource(HTTPStream *http)
      mBytesUntilMetaData(0),
      mGroup(NULL),
      mStarted(false) {
    string metaint;
    AString metaint;
    if (mHttp->find_header_value("icy-metaint", &metaint)) {
        char *end;
        const char *start = metaint.c_str();
+3 −4
Original line number Diff line number Diff line
@@ -18,10 +18,9 @@

#define HTTP_STREAM_H_

#include "stagefright_string.h"

#include <sys/types.h>

#include <media/stagefright/foundation/AString.h>
#include <media/stagefright/MediaErrors.h>
#include <utils/KeyedVector.h>
#include <utils/threads.h>
@@ -50,7 +49,7 @@ public:
    static const char *kStatusKey;

    bool find_header_value(
            const string &key, string *value) const;
            const AString &key, AString *value) const;

    // Pass a negative value to disable the timeout.
    void setReceiveTimeout(int seconds);
@@ -70,7 +69,7 @@ private:
    Mutex mLock;
    int mSocket;

    KeyedVector<string, string> mHeaders;
    KeyedVector<AString, AString> mHeaders;

    HTTPStream(const HTTPStream &);
    HTTPStream &operator=(const HTTPStream &);
Loading