Commit graph

62 commits

Author SHA1 Message Date
olly
83107cc25d Fix missing release calls on loadingPeriodHolder
playingPeriodHolder can be null in the case that the first
period is still being prepared. We need to make sure we
release the period that's being prepared in such cases,
which is loadingPeriodHolder.

Issue: #1914

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=135793472
2016-10-11 18:16:28 +01:00
olly
b29b4f7e1a MergingMediaPeriod + subtitle fixes
- Correctly null out streams[j] in the case that a renderer
  is being disabled.
- Read discontinuities from all children, not just enabled
  ones. This fixes a failure when reading a discontinuity
  with all renderers disabled.
- Add in some assertions to make incorrect stream selection
  failures obvious and immediate.
- Relocate subtitles so they're above the shutter (needed so
  they continue to be visible when video is disabled but
  text is still enabled).

Issue: #1854

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=135089944
2016-10-04 23:39:24 +01:00
olly
69af389730 Trim allocator on stop/reset by default
This prevents a large amount of memory from being held
in the case that a player instance is released, but the
application is holding dangling references to the player
that are preventing it from being garbage collected.

Issue: #1855

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=134992945
2016-10-03 17:44:01 +01:00
andrewlewis
ee4d297f22 Fix seeking in the last period.
When reading the last period, the readingPeriodHolder was set to null in
updatePeriods if it was the last period. (This would occur almost immediately
when playing a single-period source.) seekToPeriodPosition suppresses reusing a
loaded/prepared period if the reading period and playing period did not match,
which meant that the whole timeline was recreated when seeking in the last
period.

Leave readingPeriodHolder non-null. This means that at all times either
playingPeriodHolder == readingPeriodHolder (and they could be null or
non-null), or playingPeriodHolder and readingPeriodHolder differ and are both
non-null.

Also fix an issue where streams were never forced to be recreated during track
reselection when reading ahead.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=134774238
2016-09-30 14:40:06 +01:00
andrewlewis
825ec70d31 Move preparation from MediaPeriod constructors to prepare().
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=134504088
2016-09-28 11:26:12 +01:00
olly
eaf8218855 Fix shutter open/close behavior
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=134389619
2016-09-28 11:26:12 +01:00
olly
57a2749a9d Fix playback of short duration content
Issue #1837

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=133944552
2016-09-28 11:25:34 +01:00
olly
59ee4341c5 Fix buffering issue for live streams
Issue: #1825

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=133401980
2016-09-16 18:56:40 +01:00
olly
8190089b32 Rename defaultStartPosition -> defaultPosition
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=132858669
2016-09-13 17:37:59 +01:00
olly
5f39b93d30 Properly release sample streams for DASH
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=132301223
2016-09-08 16:29:48 +01:00
olly
5f1a2c71f0 Finalize V2 ExoPlayer API
There's still some internal to clean up to do, and in particular
it remains a TODO to be able to handle seek calls before the
timeline is set (for this CL, such calls are dropped). This change
does however finalize the API.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=131171318
2016-08-31 15:25:25 +01:00
olly
458c7bfc05 Simplify ExoPlayerImplInternal
- Remove playingPeriodEndPositionUs. It doesn't look like it's
  required.
- Rename time variables to make it clearer what they are.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=131027164
2016-08-31 15:25:24 +01:00
olly
94c908e89c Rename Window->MediaWindow, Timline->MediaTimeline
Window is potentially confusing with Android's Window class.
Once Window is renamed, it makes sense to rename Timeline too.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=130938392
2016-08-31 15:25:24 +01:00
olly
fb55254f90 Fix a bunch more Javadoc
Also inline a few methods/classes where they can be made
private and therefore be removed from the public API.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=130935090
2016-08-31 15:25:24 +01:00
olly
1579b68cf6 Sanitize constants
- Use a single constant for unset/unknown times across
  all time bases. Note also that this moves away from
  use of -1 for unset/unknown times in ms, which was a
  bad choice (it might conflict with real times, such
  as a time representing being just behind the start
  of a live window).
- Add a few other unset constants, and use them.
- Fix some hardcoding of -1 where existing constants
  should have been used.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=130775594
2016-08-31 15:25:18 +01:00
andrewlewis
725337dab3 Fix VOD to live transitions.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=130755346
2016-08-31 15:25:18 +01:00
olly
83e466d129 Toward API finalization
- Remove getNewPlayingPeriodIndex from MediaSource
- Remove all absolute references to period indices from
  Window. Their existence prevents ConcatenatingMediaSource
  from being able to efficiently handle children with
  large numbers of entries (e.g. a cursor backed source),
  since it would copy all windows into its merged timeline.
- Fix ExoPlayerImplInternal to attempt a restart in the
  case that the loading (but not yet prepared) period is
  removed, in absence of a playing period.
- Implement logic for finding the "next" period in the old
  timeline when attempting a retry.

Removing some of the nasty US<->MS conversions left as a
virtual TODO.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=130659973
2016-08-31 15:25:18 +01:00
andrewlewis
eff82e920e Fix DASH multi-period transitions and manifest updates.
Period transitions can either be to new windows (in which case the default
position for the new window should be loaded) or to the next period of the
current window (in which case the the new period should be played from zero).
Fix the logic for calculating the new period index to load to implement this.

In processManifest, periodsById may contain periods that have been removed from
the manifest, which are still being used by the player (it releases periods on
receiving the source info refresh after processManifest returns). Ignore
periods that have been removed from the manifest when calling updateManifest.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=130626441
2016-08-31 15:25:18 +01:00
olly
b2a28a140c Move default start position into Window
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=130610236
2016-08-31 15:25:17 +01:00
olly
3e0bae616f Minor ExoPlayerImplInternal cleanup
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=130547431
2016-08-31 15:25:17 +01:00
olly
fa84aa2123 Incremental step toward correct event propagation
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=130509123
2016-08-31 15:25:07 +01:00
andrewlewis
5296d5b198 Move isFinal flag to the Window.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=130503190
2016-08-31 15:25:07 +01:00
olly
e35f9addaf Remove playWhenReadyCommitted.
This was always a bit of a hack; for Play Movies. It may well
no longer be necessary, and if not I'd like to think of a nicer
or more general way of doing it. We can always bring it back
if needed.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=130373433
2016-08-31 15:25:06 +01:00
andrewlewis
63ab601d75 Use consistent identifiers for extractor periods.
Also, fix clearing the timeline for source info changes.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=130292700
2016-08-31 15:25:06 +01:00
andrewlewis
80227840f6 Post source info refreshes.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=130289294
2016-08-31 15:25:06 +01:00
olly
1a909fd163 Change SeekWindow -> Window, and add window duration.
- This avoids the need to have to use the timeline to
  calculate a window duration, which can be awkward.
- Window now represents a window of availability with
  an isSeekable flag, rather than a window of
  seekability.
- Promoted Timeline and Window to top package; they're
  pretty important :).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=130278509
2016-08-31 15:25:06 +01:00
andrewlewis
b120bea029 Don't reuse MediaPeriods.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=130266483
2016-08-31 15:25:06 +01:00
olly
b5e41a903d Remove buffered position edge case.
It's no longer safe to convert END_OF_SOURCE -> duration on
the main therad, since the Timeline from which the duration
is obtained is posted to the main thread, where-as the
buffered position is passed by updating a volatile. Hence
an update to the latter might become visible to the main
thread before the corresponding Timeline.

This change moves the conversion to the playback thread.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=130265893
2016-08-31 15:25:06 +01:00
andrewlewis
6e24372414 Use integers as identifiers for DASH periods.
This is in preparation for making it so that periods aren't reused.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=130113382
2016-08-31 15:25:05 +01:00
olly
1811b01b07 Report duration only via Timeline
It's error prone (and more code) to report two ways

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=129999117
2016-08-31 13:25:21 +01:00
olly
5deb948d14 Bugfix: If no renderers enabled, we don't need buffer
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=129987973
2016-08-31 13:23:30 +01:00
olly
f9005c7a78 Bugfix: Allow discontinuity on selectTracks
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=129987709
2016-08-31 13:22:54 +01:00
olly
153c0aef2b Rework MediaPeriod track selection
This change allows MediaPeriod instances to replace
SampleStream instances when the selection isn't changing.
It also allows MediaPeriod instances to retain a
SampleStream but indicate that the renderer consuming
from it needs to be reset.

The change is used to fix the ref'd bug, and is used to
do the same thing in HLS without the need for the source
to report a discontinuity. Note that reporting discontinuity
could cause unnecessary failure when used as a child of
MergingMediaSource.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=129971782
2016-08-31 13:22:15 +01:00
andrewlewis
e883b7c270 Clear the timeline on seeking if renderers are reading ahead.
If a renderer is reading ahead of the playing period, seeking within the
playing period would fail, because renderers would not be disabled but then try
to read from SampleStreams that have a released period.

Also, in the same circumstances, seeking within the reading period would fail,
because all renderers would be disabled, but their sample streams have already
been read. When they are reenabled they expect to see a format but don't
receive one.

In both cases, seeking can just clear the timeline. This only occurs in rare
circumstances when the player is reading ahead, so the cost of re-preparing
will not be incurred often, and allows the seeking logic to be simpler.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=129891060
2016-08-10 20:15:30 +01:00
andrewlewis
cdb706bac8 Fix period durations for single period and concatenated timelines.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=129748865
2016-08-10 20:08:31 +01:00
andrewlewis
88bf1d0739 Expose the seekable window.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=129747377
2016-08-10 20:07:56 +01:00
andrewlewis
95f4113456 Fix seeking into a different period that has been prepared.
When seekToPeriodPosition found that the seek destination period was already
prepared, it would not disable/re-enable renderers. This was fine if the
playing period wasn't changing, but in other cases the renderers would be left
reading the incorrect streams (and the underlying periods may have been
released).

Also, transition to the buffering state before re-enabling renderers, so that
the renderers are not started until leaving the buffering state.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=129625632
2016-08-10 20:04:56 +01:00
andrewlewis
c2c41558e5 Merge the internal timeline into ExoPlayerImplInternal.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=129325922
2016-08-08 11:53:30 +01:00
eguven
bd7c8fed1b While buffering check for errors even if renderes are ready.
On an edge case, player may get stuck when the renderers are ready but the buffer doesn't get full enough because of a fatal error in data source. An example state can be created by starting a live DASH stream and switching between normal and slow network connections.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=129084824
2016-08-08 11:15:06 +01:00
olly
9a272068b4 Allow resetting of position when setting source
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=129083335
2016-08-08 11:14:18 +01:00
andrewlewis
c1729b640c Allow seeking to a default position in a period.
When seeking to the default position in a period, the containing source may
actually return a position in another period. Multi-period live sources can do
this to seek the player to the live edge.

ExoPlayerImplInternal uses the same functionality when the playback position
reaches the end of a period to determine what period/position to play next.
This means that when playback transitions to a multi-period live source from
some other source (playing a concatenation of those two sources), the player
will play the live edge rather than the beginning of the earliest period.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=128984355
2016-08-08 11:08:50 +01:00
andrewlewis
8d122a101d Use new import ordering.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=128967776
2016-08-08 11:06:48 +01:00
olly
3501332dd3 Converge track selection to a single place.
This change merges the duties of FormatEvaluator into
TrackSelection classes, so that both the static and
dynamic parts of track selection are implemented in a
single place.

New feature: Demo app now allows you to enable random
adaptation in the track selection dialog.

Notes:

- It should be quite easy to allow application side
track blacklisting in addition to source side, as an
extension to this. That would effectively allow
applications to do seamless/deferred track selection
by creating a TrackSelection with all tracks enabled,
and then toggling the blacklist flags to select the
ones they want to be active.

- It should be trivial to implement format blacklisting
for DASH and SS as an extension to this. Will do in a
follow up CL.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=128707517
2016-07-28 20:04:40 +01:00
olly
2f20fd7c03 Simple language + Javadoc consistency
- Invoked --> Called
- Gets --> Returns
- "True if X. False otherwise." --> "Whether X."
- Removed some @returns where the Javadoc is in "Returns X" form

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=128678638
2016-07-28 20:04:40 +01:00
andrewlewis
dfdb3bbc95 Count buffer ahead periods rather than using their indices.
This is in preparation for allowing MediaSources to skip over periods when one
period ends, which is needed for starting to play a multi-period live stream
that is concatenated on to another period at the live edge.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=128674659
2016-07-28 20:04:40 +01:00
cdrolle
47346c39c1 Fixed minor error that occurred when the manifest was updated.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=128472884
2016-07-28 20:04:39 +01:00
andrewlewis
d657360341 Expose period information from MediaSources.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=128357449
2016-07-28 19:39:07 +01:00
olly
692d756ee6 Simplification: Move common logic to TrackSelection
- TrackSelection now exposes the selected formats, ordered
  by decreasing bandwidth. This removes the need for DASH,
  SS and HLS to do the sorting individually.
- The change also removes the need to reconstruct TrackSelection
  instances with a different group index in various places
  (e.g. MergingMediaPeriod).
- This is also a step toward potentially packaging the
  FormatEvaluator inside of the TrackSelection (TBD).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=128159064
2016-07-22 22:41:36 +01:00
olly
e7d95aff34 Update Renderer documentation
- Cleaned up documentation
- Removed getIndex from Renderer interface
- Renamed reset to be positionReset

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=127731006
2016-07-22 22:19:56 +01:00
olly
98a0c5f05c Fix restoring of position.
This change restores ExoPlayer to its previous behaviour.
I think we'll want a "resetPosition" boolean parameter on
setMediaSource at some point, but no need to add it right
now. Note that this would not always reset to the start
of the source. For a live playback it will reset to the
desired position (normally somewhere slightly behind the
live edge).

Issue: #1667
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=127549700
2016-07-15 18:21:40 +01:00