OSDN Git Service

make NuPlayer's http connection mechanism behave
authorChong Zhang <chz@google.com>
Wed, 13 Aug 2014 22:26:49 +0000 (15:26 -0700)
committerChong Zhang <chz@google.com>
Thu, 14 Aug 2014 17:16:18 +0000 (10:16 -0700)
more like that of AwesomePlayer's

- remove cache specific headers before connect

- read mime type before creating cached source on top
  of the http source

Bug: 16892521

Change-Id: Ie13a62dd8dd959be6095a42e2b41e3bc817efeb5

media/libstagefright/DataSource.cpp

index 908cdca..008da5a 100644 (file)
@@ -209,25 +209,29 @@ sp<DataSource> DataSource::CreateFromURI(
             uri = tmp.string();
         }
 
-        if (httpSource->connect(uri, headers) != OK) {
+        String8 cacheConfig;
+        bool disconnectAtHighwatermark;
+        KeyedVector<String8, String8> nonCacheSpecificHeaders;
+        if (headers != NULL) {
+            nonCacheSpecificHeaders = *headers;
+            NuCachedSource2::RemoveCacheSpecificHeaders(
+                    &nonCacheSpecificHeaders,
+                    &cacheConfig,
+                    &disconnectAtHighwatermark);
+        }
+
+        if (httpSource->connect(uri, &nonCacheSpecificHeaders) != OK) {
             ALOGE("Failed to connect http source!");
             return NULL;
         }
 
         if (!isWidevine) {
-            String8 cacheConfig;
-            bool disconnectAtHighwatermark;
-            if (headers != NULL) {
-                KeyedVector<String8, String8> copy = *headers;
-                NuCachedSource2::RemoveCacheSpecificHeaders(
-                        &copy, &cacheConfig, &disconnectAtHighwatermark);
-            }
+            String8 contentType = httpSource->getMIMEType();
 
             sp<NuCachedSource2> cachedSource = new NuCachedSource2(
                     httpSource,
-                    cacheConfig.isEmpty() ? NULL : cacheConfig.string());
-
-            String8 contentType = httpSource->getMIMEType();
+                    cacheConfig.isEmpty() ? NULL : cacheConfig.string(),
+                    disconnectAtHighwatermark);
 
             if (strncasecmp(contentType.string(), "audio/", 6)) {
                 // We're not doing this for streams that appear to be audio-only