2760 Commits

Author SHA1 Message Date
andrewlewis
1e79d6eb84 Fix seeking with repeated periods
newPlayingPeriodHolder could be set then updated if seeking to a repeated period
that was loaded more than once. This led to MediaPeriodHolders leaking.

Only set newPlayingPeriodHolder once so that any later holders with the same
period identifier get released.

Also add a regression test. FakeMediaSource checks that all created
MediaPeriods were released when it is released.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172591937
2017-10-19 16:39:57 +01:00
olly
fc5e8ee516 Add some additional device specific workarounds
Issue: #3355
Issue: #3257

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172587141
2017-10-19 16:37:10 +01:00
andrewlewis
f9249d23ea Add an extractor flag for ignoring edit lists
Issue: #3358

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172464053
2017-10-17 18:28:39 +01:00
olly
2c10e6f1c3 We're not playing an ad if the timeline is empty.
Issue: #3334

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172447125
2017-10-17 18:27:26 +01:00
andrewlewis
ac31dc7c7a Allow setting output sample rate in SonicAudioProcessor
This is not really useful with the DefaultAudioSink, but could be used in a
custom AudioSink when mixing audio from sources that have different sample
rates.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172434482
2017-10-17 18:24:53 +01:00
andrewlewis
e46a7600cf Document DefaultTimeBar attributes
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172339124
2017-10-17 18:23:35 +01:00
andrewlewis
9356363117 Document load() exceptions
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172329677
2017-10-17 18:22:14 +01:00
aquilescanta
d0758c9393 Fix typo
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172328148
2017-10-17 18:20:49 +01:00
olly
ebf19c4028 Update moe equivalence
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172133622
2017-10-16 12:52:02 +01:00
Oliver Woodman
29ba640351 Delete accidentally added files 2017-10-13 23:14:49 +01:00
Oliver Woodman
12513e9898 Tweak recently merged pull requests 2017-10-13 20:40:08 +01:00
ojw28
e6d8e5b096 Merge pull request #3318 from natez0r/pass-playlist-parser
Allow passing of HlsPlaylistParser to HlsMediaSource.
2017-10-13 20:29:55 +01:00
ojw28
40d8b29c9e Merge pull request #3328 from ValveSoftware/dev-v2-multiversion
Allow multiple PSSH boxes for same system
2017-10-13 20:29:44 +01:00
olly
cad88512f5 Only parse common-encryption sinf boxes
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172124807
2017-10-13 19:57:03 +01:00
olly
2fee010938 Workaround/Fix #3351
1. Ignore edit list where the sequence doesn't contain a sync
   sample, rather than failing.
2. Make Mp4Extractor.readAtomPayload so it doesn't try and read
   the same payload twice if a failure occurs parsing it.
3. Make processAtomEnded so that it doesn't pop the moov if
   parsing it fails.

Issue: #3351

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172106244
2017-10-13 19:55:50 +01:00
tonihei
b71effb7b0 Fix MobileHarness playback tests.
This change fixes various issues:
 - MobileHarness sometimes allocated devices with SDK < 16. As we have no tests running
   on these SDKs, a new dimension filter for the mobile_test target ensures that only
   devices with SDK >= 16 are selected. A similar filter for SDK version is also added
   to the ABR playback tests to ensure no old devices are selected.
 - DRM specific tests are skipped for Api < 18, but were not able to run because the
   DashTestRunner class tried to link to the MediaDrm constructor. Moved the
   constructor to a seperate Builder class to allow execution on Api levels 16 and 17.
 - DashWidevineOfflineTest also tried to access code for Api >= 18 without checking
   the current level.
 - Action implementations which are waiting for events did not ensure that they have a
   nextAction to wait for. This caused NullPointerExceptions when this next action was
   scheduled.
 - DefaultDrmSession always restored the offline keys when a new license was requested,
   even if the keys were already restored. These repeated slow calls to restoreKeys
   resulted in high numbers of dropped buffers.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171974859
2017-10-13 19:50:20 +01:00
bachinger
333e745e7b show PlaybackControlView when on key event for DPAD center or any direction
and consume event without moving the focus.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171967057
2017-10-13 19:48:56 +01:00
hoangtc
763f663d01 Update DefaultTrackSelector to use more conditions when selecting audio track
Update the audio track selection logic in DefaultTrackSelector:

- When forcing lowest bitrate, use bitrate as tie-breaker when track scores are
the same, prefer the lower bitrate.
- Otherwise, use one of the following values as tie-breaker in order:
  - ChannelCount
  - SampleRate
  - BitRate
If the format being checked is within renderer's capabilities, select it if it
has higher tie-break value, else, select it if it has lower tie-break value.

If all tie-break values are the same, prefer the already selected track.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171803092
2017-10-11 12:35:00 +01:00
olly
5d4fa335f9 Expose public constructors for FrameworkMediaCrypto
MediaCodecRenderer implementations require DrmSessionManager<FrameworkMediaCrypto>,
but it's currently not possible for an app to provide a custom implementation due
to FrameworkMediaCrypto having a package private constructor. This change exposes
public FrameworkMediaCrypto constructors, hence removing this restriction.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171718853
2017-10-11 12:32:25 +01:00
olly
9a6d717a7a Allow overriding of DefaultDashChunkSource.getNextChunk
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171718775
2017-10-11 12:31:02 +01:00
tonihei
030f52b41b Wait for HandlerThread to terminate after calling quit.
Calling HandlerThread.quit() or .quitSafely() doesn't immediately terminate
the thread. It just instructs the Looper not to accept any new messages and
to terminate at the next opportunity. Added a HandlerThread.join() everywhere
where the intention is to close and release all resources and to stop all
threads.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171525241
2017-10-11 12:26:58 +01:00
andrewlewis
54d3df4b63 Drop to keyframe in LibvpxVideoRenderer
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171517156
2017-10-11 12:25:31 +01:00
eguven
10f8192c48 Add ActionFile which stores and loads DownloadActions to/from a file.
This change also replaces individual DownloadAction versions with a
single master version.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171273880
2017-10-11 12:22:49 +01:00
hoangtc
d5101d8d46 Allow DefaultDRMSession to retry provisioning/key request
For initial DRM provisioning and key request, we allow the requests to be
retried (with increasing delay for each successive retry) before failing.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171271384
2017-10-11 12:21:25 +01:00
andrewlewis
20e43ac4f8 Allow ads to be paused/resumed
Controls are still hidden while playing ads, but if the app pauses the player,
controls will be shown. During ads, the player is not seekable.

When the player enters the background then returns to the foreground, the
content period may not be prepared, so also cache the content window duration.
This means that if the app reenters the foreground while an ad is paused the
time bar can be populated.

Issue: #3303

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171123428
2017-10-11 12:18:45 +01:00
andrewlewis
09165ab870 Rename droppedOutputBufferCount
Now this counter includes input buffers too, which are dropped as part of
skipping to keyframes for catch up.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171119930
2017-10-11 12:17:25 +01:00
andrewlewis
498ff14439 Add @IntDef annotations to DefaultEventListener
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=170980737
2017-10-11 12:13:17 +01:00
andrewlewis
b3d462df39 Catch up video rendering by dropping to keyframes
If the current output buffer is very late and the playback position is in a
later group of pictures, drop all buffers to the keyframe preceding the
playback position.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=170975259
2017-10-11 12:11:58 +01:00
tonihei
5baddfb56a Add onSeekProcessed callback to Player interface.
This is useful to determine when a seek request was processed by the player
and all playback state changes (mostly to BUFFERING) have been performed.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=170826793
2017-10-11 12:07:54 +01:00
Justin Yorke
19f53d8a44
Merge branch 'multiversion' into dev-v2-multi-pssh 2017-10-06 15:00:53 -07:00
Justin Yorke
b8e719b101
Allow multiple PSSH boxes for same system.
Updates DefaultDrmSessionManager to use the prefered Widevine version (v1
on >= 23 and v0 for < 23).
For other DRM schemes, uses the first scheme found.
2017-10-06 14:55:25 -07:00
Nate Roy
9783fc0924 remove reordering playlist parser 2017-10-06 14:35:18 -04:00
Nate Roy
2f622b8bd8 Allow passing of HlsPlaylistParser to HlsMediaSource.
Also create helper method in HlsMasterPlaylist to allow the copying of
the playlist to another, but with the variants reordered based on a
passed comparator. Also added an implementation of HlsPlaylistParser
which will reorder the variants returned.
2017-10-06 14:31:46 -04:00
olly
1495b9a473 Fix stuck playback when media has uneven track end times
* Always assume a renderer is ready if it's read to the end of
  its current stream and there's a subsequent period already
  prepared. This prevents getting stuck when a non-clock renderer
  has a short stream.
* Switch to the standalone clock if the renderer providing the
  media clock has read to the end of its current stream, is no
  longer ready, and there's a subsequent period already prepared.
  This prevents getting stuck when a clock renderer has a short
  stream.
* Remove unnecessary clock synchronization logic (since it would
  need to be made more complicated as a result of this change).
* Don't update the playing period holder when playWhenReady is
  false. This avoids the position jumping to the start of the
  next period when seeking to the very end of the current period
  whilst paused (we still end up showing the first frame of video
  from the next period, but fixing that will have to wait).

Github: #1874

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=170717481
2017-10-03 08:58:25 +01:00
olly
fd576d2189 Smoother PlaybackControlView updates when speed != 1
* If speed <= 0.1, update every second.
* If 0.1 < speed < 1, update approximately once per
  second in real time, aligned so that each second boundary
  in media time has a corresponding updatae.
* If speed == 1, keep existing behavior.
* If 1 < speed <= 5, update every second in media time
* If speed > 5, update every 200ms.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=170559037
2017-10-03 08:55:52 +01:00
olly
a3a9c0f3b0 Sanity check current position <= written frame position
This avoids spurious position reports following an underrun.

Github: #1874

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=170344399
2017-10-03 08:51:36 +01:00
andrewlewis
60de157410 Add a few initial tests for SimpleDecoderAudioRenderer
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=170318174
2017-10-03 08:48:46 +01:00
andrewlewis
9c7950f342 Add AudioSink interface and use it from audio renderers
This change allows applications to provide custom AudioSinks, which could be
based on android.media.AudioTrack like AudioTrackAudioSink, or could be
completely custom.

The refactoring is mostly mechanical and shouldn't result in any functionality
changes.

Some android.media.AudioTrack-specific details have to appear in the AudioSink
interface so this change modifies the javadoc on the AudioTrack (now AudioSink)
to note that some methods will have no effect.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=170311083
2017-10-03 08:47:20 +01:00
zhihuichen
b14b3d43de Expose OnKeyStatusChange events, this is required to learn the usabilities of the keys.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=170268043
2017-10-03 08:45:53 +01:00
tonihei
52de36c5eb Add abstract, default Player event listener.
This allows simplified listener implementations as most listeners
will not listen to all possible notifications.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=170177821
2017-10-03 08:44:33 +01:00
olly
a3be937650 Prevent unnecessary consecutive playlist loads
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=170078933
2017-09-26 19:19:57 +01:00
Oliver Woodman
792f046c02 Clean up HlsPlaylistTracker 2017-09-26 17:06:36 +01:00
ojw28
8ee6da1fe9 Merge pull request #3280 from yqritc/fix-primary-playlist-update
Fix primary hls playlist update
2017-09-26 16:54:47 +01:00
andrewlewis
06f7b6be6a Use IntDef for AudioTrack.startMediaTimeState
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=169880369
2017-09-26 14:00:59 +01:00
eguven
1f8a8dbfa3 Add version number to serialized DownloadAction data
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=169681768
2017-09-26 13:57:32 +01:00
aquilescanta
4fb18453e1 Add a "forceLowestBitrate" option to DefaultTrackSelector
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=169668371
2017-09-26 13:56:04 +01:00
aquilescanta
25a9177ce3 Deduplicate DefaultTrackSelector javadocs
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=169552239
2017-09-26 13:54:10 +01:00
hoangtc
324339b88f Tweak live-streaming track selection logic.
Follow-up on the update to ABR logic in AdaptiveTrackSelection for live
streaming case:
- Do not reset liveEdgeTimeUs when user seek to a different position.
- For HlsChunkSource, for non-independent segments, currently the
bufferedDuration calculate will subtract previousChunk's duration. So to make
it work with live-streaming ABR logic, we subtract timeToLiveEdgeUs a similar
amount to compensate for that operation.
- Minor update to DefaultSSChunkSource, only perform TrackSelection when needed
(after checking necessary conditions).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=169531275
2017-09-26 13:48:23 +01:00
eguven
d71400d280 Add DashDownloadActionTest
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=169522830
2017-09-26 13:45:42 +01:00
yqritc
455f9fb9f0 remove space 2017-09-21 16:01:32 +09:00