Merge "DO NOT MERGE: Derive the Transport "source" attribute from the RTSP endpoint address if necessary" into gingerbread
This commit is contained in:
committed by
Android (Google) Code Review
commit
8db7a7bfad
@@ -38,6 +38,7 @@
|
|||||||
|
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
|
||||||
// If no access units are received within 3 secs, assume that the rtp
|
// If no access units are received within 3 secs, assume that the rtp
|
||||||
// stream has ended and signal end of stream.
|
// stream has ended and signal end of stream.
|
||||||
@@ -119,9 +120,10 @@ struct MyHandler : public AHandler {
|
|||||||
// want to transmit user/pass in cleartext.
|
// want to transmit user/pass in cleartext.
|
||||||
AString host, path, user, pass;
|
AString host, path, user, pass;
|
||||||
unsigned port;
|
unsigned port;
|
||||||
if (ARTSPConnection::ParseURL(
|
CHECK(ARTSPConnection::ParseURL(
|
||||||
mSessionURL.c_str(), &host, &port, &path, &user, &pass)
|
mSessionURL.c_str(), &host, &port, &path, &user, &pass));
|
||||||
&& user.size() > 0) {
|
|
||||||
|
if (user.size() > 0) {
|
||||||
mSessionURL.clear();
|
mSessionURL.clear();
|
||||||
mSessionURL.append("rtsp://");
|
mSessionURL.append("rtsp://");
|
||||||
mSessionURL.append(host);
|
mSessionURL.append(host);
|
||||||
@@ -131,6 +133,8 @@ struct MyHandler : public AHandler {
|
|||||||
|
|
||||||
LOGI("rewritten session url: '%s'", mSessionURL.c_str());
|
LOGI("rewritten session url: '%s'", mSessionURL.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mSessionHost = host;
|
||||||
}
|
}
|
||||||
|
|
||||||
void connect(const sp<AMessage> &doneMsg) {
|
void connect(const sp<AMessage> &doneMsg) {
|
||||||
@@ -247,14 +251,35 @@ struct MyHandler : public AHandler {
|
|||||||
// rtp/rtcp ports to poke a hole into the firewall for future incoming
|
// rtp/rtcp ports to poke a hole into the firewall for future incoming
|
||||||
// packets. We're going to send an RR/SDES RTCP packet to both of them.
|
// packets. We're going to send an RR/SDES RTCP packet to both of them.
|
||||||
bool pokeAHole(int rtpSocket, int rtcpSocket, const AString &transport) {
|
bool pokeAHole(int rtpSocket, int rtcpSocket, const AString &transport) {
|
||||||
|
struct sockaddr_in addr;
|
||||||
|
memset(addr.sin_zero, 0, sizeof(addr.sin_zero));
|
||||||
|
addr.sin_family = AF_INET;
|
||||||
|
|
||||||
AString source;
|
AString source;
|
||||||
AString server_port;
|
AString server_port;
|
||||||
if (!GetAttribute(transport.c_str(),
|
if (!GetAttribute(transport.c_str(),
|
||||||
"source",
|
"source",
|
||||||
&source)
|
&source)) {
|
||||||
|| !GetAttribute(transport.c_str(),
|
LOGW("Missing 'source' field in Transport response. Using "
|
||||||
|
"RTSP endpoint address.");
|
||||||
|
|
||||||
|
struct hostent *ent = gethostbyname(mSessionHost.c_str());
|
||||||
|
if (ent == NULL) {
|
||||||
|
LOGE("Failed to look up address of session host '%s'",
|
||||||
|
mSessionHost.c_str());
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
addr.sin_addr.s_addr = *(in_addr_t *)ent->h_addr;
|
||||||
|
} else {
|
||||||
|
addr.sin_addr.s_addr = inet_addr(source.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!GetAttribute(transport.c_str(),
|
||||||
"server_port",
|
"server_port",
|
||||||
&server_port)) {
|
&server_port)) {
|
||||||
|
LOGI("Missing 'server_port' field in Transport response.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,11 +301,6 @@ struct MyHandler : public AHandler {
|
|||||||
"in the future.");
|
"in the future.");
|
||||||
}
|
}
|
||||||
|
|
||||||
struct sockaddr_in addr;
|
|
||||||
memset(addr.sin_zero, 0, sizeof(addr.sin_zero));
|
|
||||||
addr.sin_family = AF_INET;
|
|
||||||
addr.sin_addr.s_addr = inet_addr(source.c_str());
|
|
||||||
|
|
||||||
if (addr.sin_addr.s_addr == INADDR_NONE) {
|
if (addr.sin_addr.s_addr == INADDR_NONE) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -497,22 +517,20 @@ struct MyHandler : public AHandler {
|
|||||||
if (!track->mUsingInterleavedTCP) {
|
if (!track->mUsingInterleavedTCP) {
|
||||||
AString transport = response->mHeaders.valueAt(i);
|
AString transport = response->mHeaders.valueAt(i);
|
||||||
|
|
||||||
if (!pokeAHole(
|
// We are going to continue even if we were
|
||||||
track->mRTPSocket,
|
// unable to poke a hole into the firewall...
|
||||||
track->mRTCPSocket,
|
pokeAHole(
|
||||||
transport)) {
|
track->mRTPSocket,
|
||||||
result = UNKNOWN_ERROR;
|
track->mRTCPSocket,
|
||||||
}
|
transport);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == OK) {
|
mRTPConn->addStream(
|
||||||
mRTPConn->addStream(
|
track->mRTPSocket, track->mRTCPSocket,
|
||||||
track->mRTPSocket, track->mRTCPSocket,
|
mSessionDesc, index,
|
||||||
mSessionDesc, index,
|
notify, track->mUsingInterleavedTCP);
|
||||||
notify, track->mUsingInterleavedTCP);
|
|
||||||
|
|
||||||
mSetupTracksSuccessful = true;
|
mSetupTracksSuccessful = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1059,6 +1077,7 @@ private:
|
|||||||
sp<ASessionDescription> mSessionDesc;
|
sp<ASessionDescription> mSessionDesc;
|
||||||
AString mOriginalSessionURL; // This one still has user:pass@
|
AString mOriginalSessionURL; // This one still has user:pass@
|
||||||
AString mSessionURL;
|
AString mSessionURL;
|
||||||
|
AString mSessionHost;
|
||||||
AString mBaseURL;
|
AString mBaseURL;
|
||||||
AString mSessionID;
|
AString mSessionID;
|
||||||
bool mSetupTracksSuccessful;
|
bool mSetupTracksSuccessful;
|
||||||
|
|||||||
Reference in New Issue
Block a user