diff options
author | Andreas Huber <andih@google.com> | 2011-03-29 13:34:28 -0700 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2011-03-29 13:34:28 -0700 |
commit | b0e7381ccb2f1c8f472760b9b9f573068dc914cf (patch) | |
tree | 056355ae9df1e2cedbd296a9e827b24a9e6d5b24 /media | |
parent | 397de169e5462bf0c62506827819f93336b3f123 (diff) | |
download | frameworks_base-b0e7381ccb2f1c8f472760b9b9f573068dc914cf.zip frameworks_base-b0e7381ccb2f1c8f472760b9b9f573068dc914cf.tar.gz frameworks_base-b0e7381ccb2f1c8f472760b9b9f573068dc914cf.tar.bz2 |
Add a user-agent header to our RTSP requests.
Change-Id: I02f8ff6a4a37fa59cc8c5fcfd3afb64ee11ba576
related-to-bug: 4173725
Diffstat (limited to 'media')
-rw-r--r-- | media/libstagefright/rtsp/ARTSPConnection.cpp | 27 | ||||
-rw-r--r-- | media/libstagefright/rtsp/ARTSPConnection.h | 6 |
2 files changed, 33 insertions, 0 deletions
diff --git a/media/libstagefright/rtsp/ARTSPConnection.cpp b/media/libstagefright/rtsp/ARTSPConnection.cpp index 0740515..c4e0cdc 100644 --- a/media/libstagefright/rtsp/ARTSPConnection.cpp +++ b/media/libstagefright/rtsp/ARTSPConnection.cpp @@ -20,6 +20,8 @@ #include "ARTSPConnection.h" +#include <cutils/properties.h> + #include <media/stagefright/foundation/ABuffer.h> #include <media/stagefright/foundation/ADebug.h> #include <media/stagefright/foundation/AMessage.h> @@ -44,6 +46,7 @@ ARTSPConnection::ARTSPConnection() mConnectionID(0), mNextCSeq(0), mReceiveResponseEventPending(false) { + MakeUserAgent(&mUserAgent); } ARTSPConnection::~ARTSPConnection() { @@ -378,6 +381,7 @@ void ARTSPConnection::onSendRequest(const sp<AMessage> &msg) { reply->setString("original-request", request.c_str(), request.size()); addAuthentication(&request); + addUserAgent(&request); // Find the boundary between headers and the body. ssize_t i = request.find("\r\n\r\n"); @@ -979,4 +983,27 @@ void ARTSPConnection::addAuthentication(AString *request) { #endif } +// static +void ARTSPConnection::MakeUserAgent(AString *userAgent) { + userAgent->clear(); + userAgent->setTo("User-Agent: stagefright/1.1 (Linux;Android "); + +#if (PROPERTY_VALUE_MAX < 8) +#error "PROPERTY_VALUE_MAX must be at least 8" +#endif + + char value[PROPERTY_VALUE_MAX]; + property_get("ro.build.version.release", value, "Unknown"); + userAgent->append(value); + userAgent->append(")\r\n"); +} + +void ARTSPConnection::addUserAgent(AString *request) const { + // Find the boundary between headers and the body. + ssize_t i = request->find("\r\n\r\n"); + CHECK_GE(i, 0); + + request->insert(mUserAgent, i + 2); +} + } // namespace android diff --git a/media/libstagefright/rtsp/ARTSPConnection.h b/media/libstagefright/rtsp/ARTSPConnection.h index 0fecf3c..ac2e3ae 100644 --- a/media/libstagefright/rtsp/ARTSPConnection.h +++ b/media/libstagefright/rtsp/ARTSPConnection.h @@ -87,6 +87,8 @@ private: sp<AMessage> mObserveBinaryMessage; + AString mUserAgent; + void onConnect(const sp<AMessage> &msg); void onDisconnect(const sp<AMessage> &msg); void onCompleteConnection(const sp<AMessage> &msg); @@ -106,6 +108,8 @@ private: bool parseAuthMethod(const sp<ARTSPResponse> &response); void addAuthentication(AString *request); + void addUserAgent(AString *request) const; + status_t findPendingRequest( const sp<ARTSPResponse> &response, ssize_t *index) const; @@ -114,6 +118,8 @@ private: static bool ParseSingleUnsignedLong( const char *from, unsigned long *x); + static void MakeUserAgent(AString *userAgent); + DISALLOW_EVIL_CONSTRUCTORS(ARTSPConnection); }; |