summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/rtsp/ARTSPConnection.cpp
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2010-08-21 09:40:57 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-08-21 09:40:57 -0700
commit91d113e8daa9d71c4ea8afd595a3921e03787cbf (patch)
treefea830e50f39e59aaef2e5935bbb86a708d027d8 /media/libstagefright/rtsp/ARTSPConnection.cpp
parent69e0b8c5556df1d4db1a730db1c13409a96749c7 (diff)
parentb9b08ff55456fe845cb4c64500e9cb53682e202f (diff)
downloadframeworks_av-91d113e8daa9d71c4ea8afd595a3921e03787cbf.zip
frameworks_av-91d113e8daa9d71c4ea8afd595a3921e03787cbf.tar.gz
frameworks_av-91d113e8daa9d71c4ea8afd595a3921e03787cbf.tar.bz2
am 6bcffcd2: am 8c192fe9: Merge "Better support for rtsp streamed through VLC. Temporarily make the socket blocking to read all of the session description." into gingerbread
Merge commit '6bcffcd2dc410db780c152c70a01b22da6ca58be' * commit '6bcffcd2dc410db780c152c70a01b22da6ca58be': Better support for rtsp streamed through VLC. Temporarily make the socket blocking to read all of the session description.
Diffstat (limited to 'media/libstagefright/rtsp/ARTSPConnection.cpp')
-rw-r--r--media/libstagefright/rtsp/ARTSPConnection.cpp29
1 files changed, 23 insertions, 6 deletions
diff --git a/media/libstagefright/rtsp/ARTSPConnection.cpp b/media/libstagefright/rtsp/ARTSPConnection.cpp
index 9826990..5345218 100644
--- a/media/libstagefright/rtsp/ARTSPConnection.cpp
+++ b/media/libstagefright/rtsp/ARTSPConnection.cpp
@@ -136,6 +136,20 @@ bool ARTSPConnection::ParseURL(
return true;
}
+static void MakeSocketBlocking(int s, bool blocking) {
+ // Make socket non-blocking.
+ int flags = fcntl(s, F_GETFL, 0);
+ CHECK_NE(flags, -1);
+
+ if (blocking) {
+ flags &= ~O_NONBLOCK;
+ } else {
+ flags |= O_NONBLOCK;
+ }
+
+ CHECK_NE(fcntl(s, F_SETFL, flags), -1);
+}
+
void ARTSPConnection::onConnect(const sp<AMessage> &msg) {
++mConnectionID;
@@ -150,10 +164,7 @@ void ARTSPConnection::onConnect(const sp<AMessage> &msg) {
mSocket = socket(AF_INET, SOCK_STREAM, 0);
- // Make socket non-blocking.
- int flags = fcntl(mSocket, F_GETFL, 0);
- CHECK_NE(flags, -1);
- CHECK_NE(fcntl(mSocket, F_SETFL, flags | O_NONBLOCK), -1);
+ MakeSocketBlocking(mSocket, false);
AString url;
CHECK(msg->findString("url", &url));
@@ -210,7 +221,7 @@ void ARTSPConnection::onDisconnect(const sp<AMessage> &msg) {
mSocket = -1;
flushPendingRequests();
- }
+ }
sp<AMessage> reply;
CHECK(msg->findMessage("reply", &reply));
@@ -347,7 +358,13 @@ void ARTSPConnection::onReceiveResponse() {
CHECK_GE(res, 0);
if (res == 1) {
- if (!receiveRTSPReponse()) {
+ MakeSocketBlocking(mSocket, true);
+
+ bool success = receiveRTSPReponse();
+
+ MakeSocketBlocking(mSocket, false);
+
+ if (!success) {
// Something horrible, irreparable has happened.
flushPendingRequests();
return;