diff options
Diffstat (limited to 'media')
-rw-r--r-- | media/libstagefright/HTTPStream.cpp | 56 | ||||
-rw-r--r-- | media/tests/omxjpegdecoder/Android.mk | 5 |
2 files changed, 37 insertions, 24 deletions
diff --git a/media/libstagefright/HTTPStream.cpp b/media/libstagefright/HTTPStream.cpp index 498c7b8..2caf211 100644 --- a/media/libstagefright/HTTPStream.cpp +++ b/media/libstagefright/HTTPStream.cpp @@ -220,40 +220,58 @@ status_t HTTPStream::connect(const char *server, int port, bool https) { return ERROR_ALREADY_CONNECTED; } - struct hostent *ent = gethostbyname(server); - if (ent == NULL) { - return ERROR_UNKNOWN_HOST; + if (port < 0 || port > (int) USHRT_MAX) { + return UNKNOWN_ERROR; } - CHECK_EQ(mSocket, -1); - mSocket = socket(AF_INET, SOCK_STREAM, 0); + 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; - if (mSocket < 0) { - return UNKNOWN_ERROR; + int ret = getaddrinfo(server, service, &hints, &ai); + if (ret) { + return ERROR_UNKNOWN_HOST; } - setReceiveTimeout(30); // Time out reads after 30 secs by default + CHECK_EQ(mSocket, -1); mState = CONNECTING; + status_t res = -1; + struct addrinfo *tmp; + for (tmp = ai; tmp; tmp = tmp->ai_next) { + mSocket = socket(tmp->ai_family, tmp->ai_socktype, tmp->ai_protocol); + if (mSocket < 0) { + continue; + } - int s = mSocket; + setReceiveTimeout(30); // Time out reads after 30 secs by default. - mLock.unlock(); + int s = mSocket; - 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)); + mLock.unlock(); - status_t res = MyConnect(s, (const struct sockaddr *)&addr, sizeof(addr)); + res = MyConnect(s, tmp->ai_addr, tmp->ai_addrlen); - mLock.lock(); + mLock.lock(); - if (mState != CONNECTING) { - return UNKNOWN_ERROR; + if (mState != CONNECTING) { + close(s); + freeaddrinfo(ai); + return UNKNOWN_ERROR; + } + + if (res == OK) { + break; + } + + close(s); } + freeaddrinfo(ai); + if (res != OK) { close(mSocket); mSocket = -1; diff --git a/media/tests/omxjpegdecoder/Android.mk b/media/tests/omxjpegdecoder/Android.mk index 7802efd..81c6167 100644 --- a/media/tests/omxjpegdecoder/Android.mk +++ b/media/tests/omxjpegdecoder/Android.mk @@ -22,11 +22,6 @@ LOCAL_SRC_FILES := \ SkOmxPixelRef.cpp \ StreamSource.cpp - -# add external/skia/src/images/SkImageDecoder_libjpeg.cpp -LOCAL_SRC_FILES += \ - ../../../../../external/skia/src/images/SkImageDecoder_libjpeg.cpp - LOCAL_SHARED_LIBRARIES := \ libcutils \ libskia \ |