Add extra headers specified in the media player's setDataSource call

to all http requests made by the http live implementation.

Change-Id: I9dd78bb261bc678ea98c82009ca2634b74f3cd58
related-to-bug: 4315346
diff --git a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp
index d07ea1b..576a850 100644
--- a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp
+++ b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp
@@ -33,11 +33,25 @@
 
 namespace android {
 
-NuPlayer::HTTPLiveSource::HTTPLiveSource(const char *url, uint32_t flags)
+NuPlayer::HTTPLiveSource::HTTPLiveSource(
+        const char *url,
+        const KeyedVector<String8, String8> *headers)
     : mURL(url),
-      mFlags(flags),
+      mFlags(0),
       mEOS(false),
       mOffset(0) {
+    if (headers) {
+        mExtraHeaders = *headers;
+
+        ssize_t index =
+            mExtraHeaders.indexOfKey(String8("x-hide-urls-from-log"));
+
+        if (index >= 0) {
+            mFlags |= kFlagIncognito;
+
+            mExtraHeaders.removeItemsAt(index);
+        }
+    }
 }
 
 NuPlayer::HTTPLiveSource::~HTTPLiveSource() {
@@ -55,7 +69,8 @@
 
     mLiveLooper->registerHandler(mLiveSession);
 
-    mLiveSession->connect(mURL.c_str());
+    mLiveSession->connect(
+            mURL.c_str(), mExtraHeaders.isEmpty() ? NULL : &mExtraHeaders);
 
     mTSParser = new ATSParser;
 }