summaryrefslogtreecommitdiffstats
path: root/media/libmedia/mediaplayer.cpp
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2012-11-27 15:02:53 -0800
committerAndreas Huber <andih@google.com>2012-11-27 15:50:08 -0800
commitb7c8e91880463ff4981e3e53e98e45d68e2fe374 (patch)
tree3de921dd21aa2f4899487d3c56e4bfd28f4c004f /media/libmedia/mediaplayer.cpp
parent41829f30e60cdb7ae8eb1f0266834d245164f70e (diff)
downloadframeworks_av-b7c8e91880463ff4981e3e53e98e45d68e2fe374.zip
frameworks_av-b7c8e91880463ff4981e3e53e98e45d68e2fe374.tar.gz
frameworks_av-b7c8e91880463ff4981e3e53e98e45d68e2fe374.tar.bz2
Add support for HLS playlists of type 'event'.
related-to-bug: 6870049 Squashed commit of the following: commit eee2f3ba6bb7335f4e285632726db85645669929 Author: Andreas Huber <andih@google.com> Date: Tue Nov 27 15:02:01 2012 -0800 Make everything a lot less verbose by default. Change-Id: I884d7a7901aa1e7d4ff590f065ca57a79d2af8b3 commit 6bbdb837ed5bd88008e45efb8faf595e4051ba26 Author: Andreas Huber <andih@google.com> Date: Tue Nov 27 14:34:46 2012 -0800 HLS now properly signals media time changes at discontinuities including the start of playback (which may not necessarily be at time 0 if the playlist is of type 'event' and hasn't completed yet). Change-Id: I5ab747d024f9b8d0df72a4e06a12ebb29f62802e commit 1555589832b1878a144a976a643e1af4d61f877c Author: Andreas Huber <andih@google.com> Date: Tue Nov 27 14:32:28 2012 -0800 As part of a time discontinuity, clients of IStreamListener can now signal the corresponding media time after the discontinuity, i.e. the first PTS timestamp following the discontinuity will be considered equivalent to the specified media time and media buffers timestamped accordingly. Change-Id: Id7db7679b7faa6efd6270620ff52e34e884f3e92 commit 5c24c605c073a11c426d025b1e7478fc1ad8365a Author: Andreas Huber <andih@google.com> Date: Tue Nov 27 13:00:56 2012 -0800 NuPlayer sources now expose flags() and can announce that duration may change (increase) dynamically, in which case duration will be polled at 1 second intervals and communicated to the upper layers. Change-Id: I45102909b7a19eed0dda576747e3814d742a0eea commit ecb71de8e281e61971a2cd73e7161a97540bc357 Author: Andreas Huber <andih@google.com> Date: Tue Nov 27 12:57:47 2012 -0800 Stop caching duration in MediaPlayer, duration could increase dynamically. Change-Id: I7bb2f16c0abe49debdf45c776d2266aa069d7791 commit 544aec5823e6d7a3e97e15b6b23546616bcd343e Author: Andreas Huber <andih@google.com> Date: Tue Nov 27 08:46:28 2012 -0800 An attempt to add support for "event" style HLS playlists. Change-Id: I3dfb2e801ecaff8f5d8bdb3a4fca1b18aeeb2c60 Change-Id: I48cf7f65a654d33f2f49ded74f8be22aed9e3b98
Diffstat (limited to 'media/libmedia/mediaplayer.cpp')
-rw-r--r--media/libmedia/mediaplayer.cpp36
1 files changed, 24 insertions, 12 deletions
diff --git a/media/libmedia/mediaplayer.cpp b/media/libmedia/mediaplayer.cpp
index b52a37d..bbbf4b6 100644
--- a/media/libmedia/mediaplayer.cpp
+++ b/media/libmedia/mediaplayer.cpp
@@ -47,7 +47,6 @@ MediaPlayer::MediaPlayer()
ALOGV("constructor");
mListener = NULL;
mCookie = NULL;
- mDuration = -1;
mStreamType = AUDIO_STREAM_MUSIC;
mCurrentPosition = -1;
mSeekPosition = -1;
@@ -90,7 +89,6 @@ void MediaPlayer::disconnect()
// always call with lock held
void MediaPlayer::clear_l()
{
- mDuration = -1;
mCurrentPosition = -1;
mSeekPosition = -1;
mVideoWidth = mVideoHeight = 0;
@@ -395,14 +393,14 @@ status_t MediaPlayer::getCurrentPosition(int *msec)
status_t MediaPlayer::getDuration_l(int *msec)
{
- ALOGV("getDuration");
+ ALOGV("getDuration_l");
bool isValidState = (mCurrentState & (MEDIA_PLAYER_PREPARED | MEDIA_PLAYER_STARTED | MEDIA_PLAYER_PAUSED | MEDIA_PLAYER_STOPPED | MEDIA_PLAYER_PLAYBACK_COMPLETE));
if (mPlayer != 0 && isValidState) {
- status_t ret = NO_ERROR;
- if (mDuration <= 0)
- ret = mPlayer->getDuration(&mDuration);
- if (msec)
- *msec = mDuration;
+ int durationMs;
+ status_t ret = mPlayer->getDuration(&durationMs);
+ if (msec) {
+ *msec = durationMs;
+ }
return ret;
}
ALOGE("Attempt to call getDuration without a valid mediaplayer");
@@ -422,14 +420,28 @@ status_t MediaPlayer::seekTo_l(int msec)
if ( msec < 0 ) {
ALOGW("Attempt to seek to invalid position: %d", msec);
msec = 0;
- } else if ((mDuration > 0) && (msec > mDuration)) {
- ALOGW("Attempt to seek to past end of file: request = %d, EOF = %d", msec, mDuration);
- msec = mDuration;
}
+
+ int durationMs;
+ status_t err = mPlayer->getDuration(&durationMs);
+
+ if (err != OK) {
+ ALOGW("Stream has no duration and is therefore not seekable.");
+ return err;
+ }
+
+ if (msec > durationMs) {
+ ALOGW("Attempt to seek to past end of file: request = %d, "
+ "durationMs = %d",
+ msec,
+ durationMs);
+
+ msec = durationMs;
+ }
+
// cache duration
mCurrentPosition = msec;
if (mSeekPosition < 0) {
- getDuration_l(NULL);
mSeekPosition = msec;
return mPlayer->seekTo(msec);
}