775 Commits

Author SHA1 Message Date
olly
6f4110f3f8 Fix buffer re-evaluation edge cases
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=179917833
2018-01-03 13:34:36 +00:00
tonihei
ec71c05e8b Add possiblity to send messages at playback position.
This adds options to ExoPlayer.sendMessages which allow to specify a window index
and position at which the message should be sent. Additionally, the options can be
configured to use a custom Handler for the messages and whether the message should
be repeated when playback reaches the same position again.

The internal player converts these window positions to period index and position
at the earliest possibility. The internal player also attempts to update these
when the source info is refreshed. A sorted list of pending posts is kept and the
player triggers these posts when the playback position moves over the specified
position.

Issue:#2189

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=179683841
2018-01-03 13:34:36 +00:00
tiffanywong
3b633f81b2 Automated g4 rollback of changelist 179563355.
*** Original change description ***

Add possiblity to send messages at playback position.

This adds options to ExoPlayer.sendMessages which allow to specify a window index
and position at which the message should be sent. Additionally, the options can be
configured to use a custom Handler for the messages and whether the message should
be repeated when playback reaches the same position again.

The internal player converts these window positions to period index and position
at the earliest possibility. The internal player also at...

***

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=179666357
2018-01-03 13:34:36 +00:00
tonihei
6c2d1e1966 Add possiblity to send messages at playback position.
This adds options to ExoPlayer.sendMessages which allow to specify a window index
and position at which the message should be sent. Additionally, the options can be
configured to use a custom Handler for the messages and whether the message should
be repeated when playback reaches the same position again.

The internal player converts these window positions to period index and position
at the earliest possibility. The internal player also attempts to update these
when the source info is refreshed. A sorted list of pending posts is kept and the
player triggers these posts when the playback position moves over the specified
position.

Issue:#2189

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=179563355
2018-01-02 21:36:07 +00:00
olly
539d291fce Fix some lint/analyze errors
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=179406910
2018-01-02 21:30:14 +00:00
olly
d9bee4d29c Bump version to 2.6.1
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=179227114
2017-12-15 20:47:57 +00:00
olly
0287f13c0a Fix analyze/lint errors
- Lint doesn't like a static import of something not available on
  the minimum API level.
- The method linked to in the Javadoc was incorrect (wrong signature).
  I couldn't really work out why it was there, so I got rid of it
  rather than updating.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=179222587
2017-12-15 20:27:20 +00:00
olly
3cc08d0ea3 Fix typo
Issue #3594

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=179167738
2017-12-15 12:13:56 +00:00
tonihei
edbb979551 Allow to configure maximum buffer size in DefaultLoadControl.
This adds a parameter to configure a maximum buffer size in bytes. If left
at its default of C.LENGTH_UNSET, the target buffer is determined using a
overridable method based on the track selection. Also adding a parameter
to decide whether to prioritize time or size constraints.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=179048554
2017-12-15 12:09:45 +00:00
aquilescanta
0ccf816a5c Add a bitmask for text tracks' selection flags in DefaultTrackSelector
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=179039563
2017-12-15 12:07:01 +00:00
olly
37a275f67e Enable SeekParameters functionality for ExtractorMediaSource
Also fix ClippingMediaSource to consider the start position an
artificial key-frame, and to properly offset the value returned
by getAdjustedSeekPositionUs.

Issue: #2882

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=179032243
2017-12-15 12:05:41 +00:00
tonihei
a17375b7d3 Resend playback info update when skipping very short periods.
Skipping short periods in a while loop is conceptually a new operation
and thus we need to send out the updated playback info in between for
the listeners to receive multiple period transition discontinuities.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=179027334
2017-12-15 12:04:20 +00:00
olly
073c92ed36 Don't send playback info updates when released.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=178916145
2017-12-15 12:01:37 +00:00
tonihei
2cbf0ef0ab Move playback state, isLoading, and track selector result to PlaybackInfo.
This is a no-op change replacing the local variables in ExoPlayerImplInternal
with the new ones in PlaybackInfo.

***
Use playbackState, isLoading and trackSelectorResult from playbackInfo in ExoPlayerImpl.

***
Move duplicated listener notification in ExoPlayerImpl to new method.

Also split reset method in one parts which creates the new playback info
and one part which notifies the listeners. The increment of the pending
operation counter needs to happen in between.

***
Use only one pending operation counter in ExoPlayerImpl.

This also allows to move onSeekProcessed into the notification chain.

***
Replace playback info changing messages to ExoPlayerImpl by single message type.

As they are all handled in the same way, they can be summarized to one message.

***
Only send playback info change notifications once per playback thread message.

This ensures that all concurrent changes actually reach ExoPlayerImpl concurrently.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=178907165
2017-12-15 12:00:16 +00:00
olly
a5cd0b87bc Update SingleSampleMediaSource with factory/listener changes
- Convert the Builder into a Factory
- Have it use MediaSourceEventListener
- Also made some misc related fixes to other sources

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=178906521
2017-12-15 11:58:48 +00:00
tonihei
318618d7a2 Fix seek/prepare/stop acks when exception is thrown.
1. The player doesn't acknowledge phantom stops when an exception is thrown anymore.
2. It also makes sure it doesn't reset the pendingPrepareCount unless it's actually
immediately acknowledging these prepares.
3. It ensures a seek is acknowledged even though an exception is thrown during seeking.

Added tests (which previously failed) for all three cases.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=178876362
2017-12-13 12:53:39 +00:00
andrewlewis
a4ae206ebe Support non-extractor ads in AdsMediaSource and demo apps
Issue: #3302

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=178615074
2017-12-12 19:17:58 +00:00
olly
2e3667eeff Expose ability to get adjusted seek position from MediaPeriod
Issue: #2882

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=178606133
2017-12-12 19:16:34 +00:00
andrewlewis
8c7fe8a258 Make ExtractorMediaSource.Builder a factory for ExtractorMediaSources
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=178605481
2017-12-12 19:15:14 +00:00
andrewlewis
f8834dacc6 Use surfaceless context in DummySurface, if available
Issue: #3558

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=178604607
2017-12-12 19:12:35 +00:00
andrewlewis
e419154b86 Make DashMediaSource.Builder a factory for DashMediaSources
This is in preparation for supporting non-extractor MediaSources for ads in
AdsMediaSource.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=178377627
2017-12-12 19:08:25 +00:00
olly
2b0b39ca38 Public API for setting seek parameters
Issue: #2882

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=178370038
2017-12-12 19:05:42 +00:00
olly
fede9c39c6 Treat captions that are wider than expected as middle aligned
Issue: #3534

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=178364353
2017-12-12 19:04:22 +00:00
olly
439c3022d9 Blacklist Moto Z from using secure DummySurface.
Issue: #3215

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=178218535
2017-12-12 18:57:25 +00:00
olly
a7b11ecb17 Add missing Nullable annotation
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=178117289
2017-12-12 18:53:14 +00:00
tonihei
8a0a8339e8 Change handling of renderer position offset for first media period.
This should be a no-op change. And it eliminates the need to use the index variable
which will be removed once the MediaPeriodHolderQueue is implemented.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177963360
2017-12-12 18:44:47 +00:00
hoangtc
88dea59cd2 Add ability for media period to discard buffered media at the back of the queue
In some occasions, we may want to discard a part of the buffered media to
improve playback quality. This CL adds this functionality by allowing the
loading media period to re-evaluate its buffer periodically (every 2s) and discard
chunks as it needs.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177958910
2017-12-12 18:43:26 +00:00
olly
2b31723434 Remove self @link
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177938212
2017-12-12 18:37:52 +00:00
andrewlewis
f2f767bc12 Invoke onLoadCanceled/Completed for ExtractorMediaSource
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177936271
2017-12-12 18:36:26 +00:00
olly
fbfa43f5a3 Enhance SeekMaps to return SeekPoints
Issue: #2882

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177814974
2017-12-04 17:39:43 +00:00
olly
bb0fae3ee8 Fix playback of FLV live streams with no audio track
Issue: #3188

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177811487
2017-12-04 17:39:43 +00:00
olly
a9c3ca1cfe Tentative fix for roll-up row count
Issue: #3513

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177804505
2017-12-04 17:38:11 +00:00
andrewlewis
fd938fb454 Update internal usages of deprecated AdaptiveMediaSourceEventListener
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177786580
2017-12-04 17:38:11 +00:00
andrewlewis
fbccdf594a Use AdaptiveMediaSourceEventListener for ExtractorMediaSource
This is a step towards harmonizing the MediaSource Builders and (potentially)
providing MediaSource factories.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177783157
2017-12-04 17:38:11 +00:00
tonihei
03b0d9d46c Fix flaky testEmptyTimeline again.
Waiting for the timeline change didn't work correctly because the timeline was
already equal to Timeline.EMPTY (due to the masking). Now waiting explicitly
for the empty Timeline exposed by the source.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177749292
2017-12-04 17:38:11 +00:00
olly
3a6b7a346c Fix mp3 extractor test
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177458840
2017-12-04 17:38:11 +00:00
olly
754260e944 Fix VBRI and XING seekers
- Remove skipping of the VBRI/XING frame before calculating position
  offsets. This was incorrect. Instead, a constraint is used to ensure
  we don't return positions within these frames, the difference being
  that the constraint adjusts only positions that would fall within
  the frames, where-as the previous approach shifted positions through
  the whole stream.
- Excluded last entry in the VBRI table because it has an invalid
  position (the length of the stream).
- Give variables in XingSeeker descriptive names.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177451295
2017-12-04 17:38:11 +00:00
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