638 Commits

Author SHA1 Message Date
andrewlewis
7b08899818 Move resetting audio processors to initialize()
The set of active audio processors was only updated on reconfiguration and when
draining playback parameters completed. Draining playback parameters are cleared
in reset(), so if parameters were set while paused then the sink was quickly
reset, without draining completing, the set of active audio processors wouldn't
be updated. This means that a switch to or from speed or pitch = 1 would not be
handled correctly if made while paused and followed by a seek.

Move resetting active audio processors from configure (where if the active audio
processors were reset we'd always initialize a new AudioTrack) to initialize().

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177442098
2017-12-04 17:38:11 +00:00
olly
cc54d4d3e6 Snap to frame boundary in ConstantBitrateSeeker
- This change snaps the seek position for constant bitrate MP3s
  to the nearest frame boundary, avoiding the need to skip one
  byte at a time to re-synchronize (this may still happen if the
  MP3 does not really have fixed size frames).
- Tweaked both ConstantBitrateSeeker and WavHeader to ensure the
  returned positions are valid.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177441798
2017-12-04 17:38:11 +00:00
aquilescanta
21d55d4eba Rename DefaultTrackSelector.ParameterBuilder.setViewportSize{FromContext->ToPhysicalDisplaySize}
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177440699
2017-12-04 17:38:11 +00:00
aquilescanta
58e60e1f9d Use the Builder pattern for DefaultTrackSelector#Parameters
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177438430
2017-12-04 17:38:11 +00:00
andrewlewis
a9c33590df Update getPosition(0) positions for FragmentedMp4Extractor
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177424314
2017-12-04 17:38:11 +00:00
andrewlewis
5865f1fe40 Use a MediaSource factory internally in AdsMediaSource
Support ad MediaSources that aren't prepared immediately by using
DeferredMediaPeriod, moved up from DynamicConcatenatingMediaSource.

In a later change the new interfaces will be made public so that apps
can provide their own MediaSource factories.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177424172
2017-12-04 17:38:11 +00:00
mdoucleff
079a5b3d8c Add manifestless captions support. This code fits into the pre-existing
captions fetcher architecture.

1.  ManifestlessCaptionsMetadata

Other captions fetchers must first fetch a manifest (HLS or manifest) to
discover captions tracks.  This process does not exist for manifestless.  All
we need to do is scan the FormatStream's for the right itag, so this is an
all-static class.

2.  ManifestlessSubtitleWindowProvider

Once a captions track is selected, a subtitles provider is instantiated.  This
is the main interface used by the player to retrieve captions according to
playback position.  This class stores fetched captions in a tree index by time
for efficient lookups.  Background captions fetches are used to populate
the tree.

3.  ManifestlessCaptionsFetch

Captions are fetched one segment at a time.  One instance of this object
is required per fetch.  It performs a blocking fetch on call(), and is
intended to be submitted to a background-thread executor.

4.  ManifestlessCaptionsFetch.CaptionSegment

This is the result of the caption fetch.  These values are used to populate
the captions tree.

Manifestlessness

The initial request is always a headm request.  There is a separate tree
of every segment indexed by start time.  This tree is used to improve
manifestless sequence number calculation.  Once we have data for the current
timestamp, we walk forward through the tree to find the next unfetched
sequence number, and fetch that.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177385094
2017-12-04 17:38:11 +00:00
hoangtc
3afdb24f25 Add support for outputing Emsg messages to a sideloaded track output.
Currently FragmentedMp4Extractor only parses and outputs emsg messages if the
flag FLAG_ENABLE_EMSG_TRACK is set (when there's a metadata renderer that
handles emsg messages). Since there are emsg messages that only targets the
player, which we want to handle independently from MetadateRenderer, this CL
adds the ability for FragmentedMp4Extractor to output emsg messages to an
additional TrackOutput if provided, independently from FLAG_ENABLED_EMSG_TRACK.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177318983
2017-12-04 17:38:11 +00:00
olly
a99ef01d3a Optimize seeking for unseekable SeekMaps
- Avoid re-downloading data prior to the first mdat box when
  seeking back to the start of an unseekable FMP4.
- Avoid re-downloading data prior to the first frame for
  constant bitrate MP3.
- Update SeekMap.getPosition documentation to allow a non-zero
  position for the unseekable case. Note that XingSeeker was
  already returning a non-zero position if unseekable.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177317256
2017-12-04 17:38:11 +00:00
olly
21ea9a821d Fix weird XingSeeker indexing
There are still things broken about the seeker, but this
cleans up some of the weird bits.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177315136
2017-12-04 17:38:11 +00:00
tonihei
835b6382ac Move external timeline and start position overwrites to ExoPlayerImpl.
Makes it less error-prone to accidentatly forget to set the right overwrites.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177282089
2017-12-04 17:38:11 +00:00
tonihei
9e8f50a9c0 Allow multiple video and audio debug listeners in SimpleExoPlayer.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177184331
2017-12-04 17:38:11 +00:00
andrewlewis
2282527821 Allow setting supported formats on AdsLoaders
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177175377
2017-12-04 17:38:11 +00:00
olly
ff49bc97c4 Clean up some extrator SeekMap implementations
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177173618
2017-12-04 17:38:11 +00:00
aquilescanta
baa80a1b68 Fix DefaultTrackSelector#Parameter withSelectUndeterminedTextLanguage
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177170994
2017-12-04 17:38:11 +00:00
tonihei
54a1bb186e Allow resetInternal to release MediaSource but keep timeline.
This allows to keep the state synced with ExoPlayerImpl after stopping the player,
but still releases the media source immediately as it needs to be reprepared.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177167980
2017-12-04 17:38:11 +00:00
olly
f2d5541752 Extractor cleanup
- Align class summary Javadoc
- Fix ErrorProne + Style warnings

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177165593
2017-12-04 17:38:11 +00:00
tonihei
efc709f366 Remove initial seek counting in ExoPlayerImplInternal.
We can acknoledge seeks before preparation finished immediately now,
because ExoPlayerImpl won't leave the masking state until the first prepare
operation is processed.

As a side effect, it also cleans up the responsibility of the callbacks.
Prepares are always acknowledged with a SOURCE_INFO_REFRESHED, while seeks
are always acknowledged with a SEEK_ACK.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177144089
2017-12-04 17:38:11 +00:00
olly
1ae50cb9e5 Add some clarifications to MediaSource documentation
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177141094
2017-12-04 17:38:11 +00:00
tonihei
f46cb907b7 Add stop with position reset to Player interface.
The ExoPlayerImpl implementation forwards the stop request with this optional
parameter. To ensure correct masking (e.g. when timeline updates arrive after
calling reset in ExoPlayerImpl but before resetInternal in
ExoPlayerImplInternal), we use the existing prepareAck counter and extend it
also count stop operations. For this to work, we also return the updated
empty timeline after finishing the reset.

The CastPlayer doesn't support the two reset options so far.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177132107
2017-12-04 17:38:11 +00:00
tonihei
95de9c96fe Don't always wait for action schedule in ExoPlayerTestRunner.
Unconditionally waiting for the action schedule to finish in ExoPlayerTestRunner
doesn't work if the action schedule is not intended to be finished.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177024139
2017-11-27 21:28:34 +00:00
tonihei
ee26da682c Add throws IllegalSeekPositionException doc to seekTo(windowIndex, positionMs).
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177011497
2017-11-27 21:28:34 +00:00
aquilescanta
16c43c6bb7 Support undefined text track language when preferred is not available
Also slightly improve language normalization/documentation.

For this CL, it is assumed that null and "und" languages are different
entities. Once we fully tackle language tag normalization, we can decide
whether to normalize the "undefined" language.

Issue:#2867
Issue:#2980

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177008509
2017-11-27 21:28:34 +00:00
andrewlewis
8833a2930c Take into account the playback speed for loading
Update the default AdaptiveTrackSelection and DefaultLoadControl to use playback
speed information.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176989168
2017-11-27 13:50:19 +00:00
andrewlewis
a9ed6b191d Switch from currentTimeMillis to elapsedRealtime
currentTimeMillis is not guaranteed to be monotonic and elapsedRealtime is
recommend for interval timing.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176853118
2017-11-27 13:49:04 +00:00
tonihei
c4385c738f Temporarily fix flakiness of testPlayEmptyTimeline.
Fixed by explicitly waiting for the timeline update. This shouldn't be
necessary and will be removed as soon as the correct order of events
can be guaranteed (timeline change -> state change -> onSeekProcessed).

The waiting for the timeline update is implemented by introducing the
feature that the test runner also waits until the action schedule has
finished before stopping the test.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176848540
2017-11-27 13:47:48 +00:00
andrewlewis
36255c42cf Test setPlaybackParameters before preparation completes
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176837939
2017-11-27 13:46:33 +00:00
baiming
5cd8869646 Really fix the NPE in ExoPlayer.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176821463
2017-11-27 13:44:05 +00:00
olly
5d70b9e02d Partialy revert "Make ExtractorMediaSource timeline dynamic until duration is set"
This change broke playback through playlists.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176764830
2017-11-23 15:16:58 +00:00
olly
874d1be852 stopInternal should release MediaSource
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176763841
2017-11-23 15:15:16 +00:00
tonihei
7eb0af7c0e Replace LinkedList with ArrayList in ChunkSampleStream.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176759080
2017-11-23 15:12:23 +00:00
olly
2086c129fc Suppress discontinuities that don't change the position
This is mostly useful for suppressing the initial position
discontinuity reported by ClippingMediaPeriod.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176758972
2017-11-23 15:10:52 +00:00
tonihei
ba5f35995f Send discontinuity at adjustments after shuffle/repeat mode changes.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176749136
2017-11-23 15:09:04 +00:00
olly
d537c21888 Test ClippingMediaSource handles initial dynamic timelines
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176666247
2017-11-22 18:29:52 +00:00
olly
e04bdcea50 Relax requirement that MergingMediaSource children are not dynamic
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176664332
2017-11-22 18:28:39 +00:00
olly
494a41c8b2 Improve ClippingMediaSource "cannot clip" behavior
This brings ClippingMediaSource clip failures in line with
what MergingMediaSource does when it cannot merge.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176660123
2017-11-22 18:27:16 +00:00
olly
d909dc1863 Report correct discontinuity from ClippingMediaPeriod
It currently always reports 0, but it should report the position
passed through selectTracks. Reporting should also be disabled if
there's a seekToUs call.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176644228
2017-11-22 18:25:55 +00:00
olly
b5480e0e97 Relax requirement that ClippingMediaSource children are not dynamic
Tests to follow (want to fix breakages first).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176642610
2017-11-22 18:24:27 +00:00
jrochest
4193a1f705 Guard against null TrackSelections in updateTrackSelectionPlaybackSpeed.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176629070
2017-11-22 18:22:58 +00:00
tonihei
6607f49be6 Fix reporting of format changes in ChunkSampleStream.
Until recently, changing primary track formats were reported when the
corresponding media chunk was discarded which always happened immediately
after the sample has been read.

Now, media chunks may be discarded later on or in batches, leaving the
current reporting mechanism broken because changes may never be reported.

This fix separates the discarding from the reporting such that format changes
can be reported when the media chunk is first read from, while the discarding
operation only discards without reporting format changes.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176519071
2017-11-22 18:19:46 +00:00
andrewlewis
15a1f9a552 Remove DefaultLoadControl buffer time state
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176515168
2017-11-22 18:18:19 +00:00
hoangtc
e619079a0d Let EventMessage encloses its presentationTimeMs.
Currently EventMessage's presentationTimeMs is kept separately in
EventSampleStream. However, EventMessage's presentationTimeMs maybe used in
other places besides EventSampleStream, such as when handling `emsg' messages
targeting the player. This CL let EventMessage object to holds its
presentationTimeMs for such use cases.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176502938
2017-11-22 18:16:58 +00:00
Oliver Woodman
3998ed49ae Mini cleanup 2017-11-21 13:42:12 +00:00
ojw28
1a138ad4dc
Merge pull request #3486 from IanDBird/dev-v2
Fix initializationData check for SSA subtitles
2017-11-21 13:31:06 +00:00
olly
856c2f8d3e Make ExtractorMediaSource timeline dynamic until duration is set
We (eventually - albeit possibly infinitely far in the future)
expect a timeline update with a window of known duration. This
also stops live radio stream playbacks transitioning to ended
state when their tracks are disabled.

As part of this fix, I found an issue where getPeriodPosition
could return null even when defaultPositionProjectionUs is 0,
which is not as documented.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176492024
2017-11-21 13:16:19 +00:00
andrewlewis
31e2cfce9e Pass playback speed to LoadControl and TrackSelection
This allows implementations of those classes to take into account the playback
speed for adaptive track selection and controlling when to resume the player.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176484361
2017-11-21 13:13:35 +00:00
tonihei
e1d960db68 Unify internal reset method to support state and position resets.
The ExoPlayerImplInternal.reset method now takes the same set of options
as the ExoPlayer.prepare method. This also allows to
- Remove some code duplication within ExoPlayerImplInternal
- Fix calls to prepare(sameSource, resetPosition=true, resetState=false)
  with enabled shuffle mode where the position was not correctly reset to the
  first period index.
- Keep the current timeline when calling stop (in line with ExoPlayerImpl).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176481878
2017-11-21 13:10:45 +00:00
tonihei
aac53cac56 Add reason to onTimelineChanged.
Currently onTimelineChanged doesn't allow to distinguish easily between the
different reasons why it's being called. Especially, finding
out whether a new media source has been prepared or the current source
refreshed dynamically was impossible without tightly coupling the player
operations with the listener.

The new reasons provide this disdinction by either indicating a newly
initialized media source, a dynamic update to an existing timeline
or manifest, or a reset of the player (which usually results in an
empty timeline).

The original onTimelineChanged method without reason is kept in the
DefaultEventListener as deprecated to prevent the need to update all
existing listeners in one go.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176478701
2017-11-21 13:07:46 +00:00
olly
13b595ed39 Don't do work after track selection when in ended state
This causes the player to report that it's started loading
when in the ended state.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176371892
2017-11-21 13:06:11 +00:00
olly
275292cb63 Report additional position discontinuities
- Properly report internal discontinuities
- Add DISCONTINUITY_REASON_SEEK_ADJUSTMENT to distinguish
  seek adjustments from other internal discontinuity events

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176367365
2017-11-21 13:04:47 +00:00