Loading media/libstagefright/rtsp/ARTSPConnection.cpp +27 −0 Original line number Diff line number Diff line Loading @@ -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> Loading @@ -44,6 +46,7 @@ ARTSPConnection::ARTSPConnection() mConnectionID(0), mNextCSeq(0), mReceiveResponseEventPending(false) { MakeUserAgent(&mUserAgent); } ARTSPConnection::~ARTSPConnection() { Loading Loading @@ -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"); Loading Loading @@ -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 media/libstagefright/rtsp/ARTSPConnection.h +6 −0 Original line number Diff line number Diff line Loading @@ -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); Loading @@ -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; Loading @@ -114,6 +118,8 @@ private: static bool ParseSingleUnsignedLong( const char *from, unsigned long *x); static void MakeUserAgent(AString *userAgent); DISALLOW_EVIL_CONSTRUCTORS(ARTSPConnection); }; Loading Loading
media/libstagefright/rtsp/ARTSPConnection.cpp +27 −0 Original line number Diff line number Diff line Loading @@ -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> Loading @@ -44,6 +46,7 @@ ARTSPConnection::ARTSPConnection() mConnectionID(0), mNextCSeq(0), mReceiveResponseEventPending(false) { MakeUserAgent(&mUserAgent); } ARTSPConnection::~ARTSPConnection() { Loading Loading @@ -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"); Loading Loading @@ -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
media/libstagefright/rtsp/ARTSPConnection.h +6 −0 Original line number Diff line number Diff line Loading @@ -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); Loading @@ -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; Loading @@ -114,6 +118,8 @@ private: static bool ParseSingleUnsignedLong( const char *from, unsigned long *x); static void MakeUserAgent(AString *userAgent); DISALLOW_EVIL_CONSTRUCTORS(ARTSPConnection); }; Loading