HLS: faster switching and pause/resume on low buffer

- when upswitching, discard excessive buffering on low
  bandwidth variant, switch to new variant earlier

- when downswitching, report newly found IDR positions
  continuously, and switch as soon as new fetcher passes
  playback position. This allows us to skip time-consuming
  resumeUntil() of old fetcher most of the time

- implement pause/resume on low buffering, and notify
  buffering percentage

- buffering parameter tuning, separate pause/resume/ready
  buffer level and up/down switch buffer level, boost up
  fetcher buffering significantly

bug: 19567254

Change-Id: I750dfcc6f861d78d16a71f501beb86d8129cb048
diff --git a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp
index d01e83a..0476c9b 100644
--- a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp
+++ b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp
@@ -281,6 +281,34 @@
             break;
         }
 
+        case LiveSession::kWhatBufferingStart:
+        {
+            sp<AMessage> notify = dupNotify();
+            notify->setInt32("what", kWhatPauseOnBufferingStart);
+            notify->post();
+            break;
+        }
+
+        case LiveSession::kWhatBufferingEnd:
+        {
+            sp<AMessage> notify = dupNotify();
+            notify->setInt32("what", kWhatResumeOnBufferingEnd);
+            notify->post();
+            break;
+        }
+
+
+        case LiveSession::kWhatBufferingUpdate:
+        {
+            sp<AMessage> notify = dupNotify();
+            int32_t percentage;
+            CHECK(msg->findInt32("percentage", &percentage));
+            notify->setInt32("what", kWhatBufferingUpdate);
+            notify->setInt32("percentage", percentage);
+            notify->post();
+            break;
+        }
+
         case LiveSession::kWhatError:
         {
             break;