summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2011-03-09 15:17:12 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2011-03-09 15:17:12 -0800
commitd6aaec0ce7639a9d8bb73983711e20545b55e860 (patch)
tree2ff4ead84c6d79dbb22a9c8b6368de4a8d52ab45 /media
parent7b13e27ee4a42c205b4a20d145610e8c912e7b0c (diff)
parente4a02b61290fa61955c979cfd1afc17a92bba481 (diff)
downloadframeworks_base-d6aaec0ce7639a9d8bb73983711e20545b55e860.zip
frameworks_base-d6aaec0ce7639a9d8bb73983711e20545b55e860.tar.gz
frameworks_base-d6aaec0ce7639a9d8bb73983711e20545b55e860.tar.bz2
am e4a02b61: am b9da16a1: Support IPv6 in HTTP streaming.
* commit 'e4a02b61290fa61955c979cfd1afc17a92bba481': Support IPv6 in HTTP streaming.
Diffstat (limited to 'media')
-rw-r--r--media/libstagefright/HTTPStream.cpp26
1 files changed, 17 insertions, 9 deletions
diff --git a/media/libstagefright/HTTPStream.cpp b/media/libstagefright/HTTPStream.cpp
index 498c7b8..d216ef2 100644
--- a/media/libstagefright/HTTPStream.cpp
+++ b/media/libstagefright/HTTPStream.cpp
@@ -220,15 +220,27 @@ status_t HTTPStream::connect(const char *server, int port, bool https) {
return ERROR_ALREADY_CONNECTED;
}
- struct hostent *ent = gethostbyname(server);
- if (ent == NULL) {
+ if (port < 0 || port > (int) USHRT_MAX) {
+ return UNKNOWN_ERROR;
+ }
+
+ char service[sizeof("65536")];
+ sprintf(service, "%d", port);
+ struct addrinfo hints, *ai;
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_flags = AI_ADDRCONFIG | AI_NUMERICSERV;
+ hints.ai_socktype = SOCK_STREAM;
+
+ int ret = getaddrinfo(server, service, &hints, &ai);
+ if (ret) {
return ERROR_UNKNOWN_HOST;
}
CHECK_EQ(mSocket, -1);
- mSocket = socket(AF_INET, SOCK_STREAM, 0);
+ mSocket = socket(ai[0].ai_family, ai[0].ai_socktype, ai[0].ai_protocol);
if (mSocket < 0) {
+ freeaddrinfo(ai);
return UNKNOWN_ERROR;
}
@@ -240,13 +252,9 @@ status_t HTTPStream::connect(const char *server, int port, bool https) {
mLock.unlock();
- struct sockaddr_in addr;
- addr.sin_family = AF_INET;
- addr.sin_port = htons(port);
- addr.sin_addr.s_addr = *(in_addr_t *)ent->h_addr;
- memset(addr.sin_zero, 0, sizeof(addr.sin_zero));
+ status_t res = MyConnect(s, ai[0].ai_addr, ai[0].ai_addrlen);
- status_t res = MyConnect(s, (const struct sockaddr *)&addr, sizeof(addr));
+ freeaddrinfo(ai);
mLock.lock();