1501 Commits

Author SHA1 Message Date
tonihei
8b1080d5cc Check if source has been prepared before releasing it.
In ConcatenatingMediaSource, the source may be removed before it started
preparing (this may happen if lazyPreparation=true). In this case, we
shouldn't call releaseSource as the preparation didn't start.

Issue:#4986

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=218141658
2018-10-24 18:58:14 +01:00
tonihei
9607c6de1b Properly reset period id and start position in ExoPlayerImpl.
This is a no-op change as the respective values are not used so far but
the change makes the current state cleaner and is less error-prone.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=217892421
2018-10-24 18:56:31 +01:00
tonihei
6ae015ecbd Replace DefaultBandwidthMeter with CountryAndNetworkTypeBandwidthMeter.
This removes the experimental bandwidth meter and uses it as the new default.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=215404065
2018-10-20 14:37:22 +01:00
olly
e346707199 Code shrinking doesn't like Class.super.defaultMethodName
Just not doing it seems simplier and more obviously correct
than suppressing the warnings in our proguard file.

Issue: #4890

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=217675527
2018-10-20 14:16:00 +01:00
andrewlewis
225230b984 Support seeking based on MLLT metadata
Issue: #3241

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=217252254
2018-10-20 14:15:43 +01:00
olly
0d169ca456 Remove assertion causing failure on some Samsung devices
The assertion was so weak it probably wouldn't detect genuine
misuse of the DefaultAllocator API, so it seems fine just to
remove it.

We don't really know what happens when the player is allowed to
continue on the affected devices, but hopefully it either "just
works" or fails in a more graceful way.

Issue: #4532

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=217113060
2018-10-20 14:15:21 +01:00
andrewlewis
362a21e17b Handle rotation signaled in MKV track name from HTC devices
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=216704331
2018-10-20 14:14:56 +01:00
andrewlewis
db0f107fb3 Project start position for preroll ad to content transitions
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=216675981
2018-10-20 14:14:44 +01:00
olly
4d8b6803af Minor fixes for period clipping
- Always clip to period duration for the last chunk. We previously
  did this only when the last chunk explicitly exceeded the period
  end time. We now also do it when the chunk claims to end at the
  period boundary, but still contains samples that exceed it.
- If pendingResetPositionUs == chunk.startTimeUs == 0 but the
  chunk still contains samples with negative timestamps, we now
  clip them by setting the decode only flag. Previously we only
  clipped such samples if the first chunk explicitly preceeded the
  start of the period.

Issue: #4899

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=215763467
2018-10-20 14:13:05 +01:00
tonihei
a35bf5151d Fix updates of loading period and buffered positions in PlaybackInfo.
This makes the following changes to improve consistency among the PlaybackInfo
values:
 1. Update buffered position and total buffered duration after loading period
    is set as both values are affected by a loading period update.
 2. Add copyWithPosition to allow updating the position without resetting the
    loading period.
 3. Forward the total buffered duration to playing position updates
    as it may have changed with the new playing position.

Issue:#4899

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=215712328
2018-10-20 14:12:30 +01:00
Oliver Woodman
4347bf0416 Subrip cleanup 2018-10-20 14:11:34 +01:00
ojw28
4d6b008ef6 Merge pull request #4582 from szaboa/feature/4306_srt_position_tags
#4306 - Extract tags from SubRip subtitles, add support for alignment
2018-10-20 14:11:00 +01:00
tonihei
4921595041 Fix prepare position of DeferredMediaPeriods for windows with non-zero offset.
If we prepare a deferred media period before the actual timeline is available,
we either prepare with position zero (= the default) or with a non-zero
initial seek position.

So far, the zero (default) position got replaced by the actual default position
(including any potential non-zero window offset) when the timeline became known.

However, a non-zero initial seek position was not corrected by the non-zero
window offset. This is fixed by this change.

Related to that, we always assumed that the deferred media period will the
first period in the actual timeline. This is not true if we prepare with an
offset (either because of an initial seek position or because of a default
window position). So, we also determine the actual first period when the
timeline becomes known.

Issue:#4873

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=215213030
2018-10-20 14:04:16 +01:00
tonihei
6b562f0a74 Add @Documented to @IntDef and @StringDef annotations.
This makes the annotations appear in the generated JavaDoc.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=214952419
2018-10-20 14:01:13 +01:00
Andrew Shu
edee8cfbde Make DefaultTrackSelector.AudioTrackScore protected
This allows selectAudioTrack() to be overridden.
2018-10-20 13:58:34 +01:00
tonihei
150e54b560 Fix issue with stale createPeriod events in ConcatenatingMediaSource.
If a source is removed from the playlist, the player may still call createPeriod
for a period of the removed source as long as the new timeline hasn't been handled
by the player. These events are stale and can be ignored by using a dummy media
source. The stale media period will be released when the player handles the updated
timeline.

Issue:#4871

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=214787090
2018-09-27 17:55:09 +01:00
aquilescanta
1bb7ec8203 Make DefaultLoadErrorHandlingPolicy non-final
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=214584874
2018-09-26 13:20:26 +01:00
olly
d92787b58d Don't request session sharing on CDMs that don't support it
Issue: #4834

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=214258163
2018-09-24 15:43:22 +01:00
olly
b0cd6cf622 Allow configuration of DefaultLoadControl back buffer
Issue: #4857

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=214254231
2018-09-24 15:43:10 +01:00
olly
321393e7cf Fix broken Javadoc
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=213979058
2018-09-24 15:42:49 +01:00
tonihei
108a7099e4 Add missing calls to LoadControl.onTracksSelected.
This method needs to be called whenever the track selection of the current
loading period changes, but also when the loading period itself (and thus
the "loading track selection") changes. These are the same situations in which
we update the loading media period id and thus we can move both updates in
a common helper method.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=213959982
2018-09-21 12:39:43 +01:00
andrewlewis
b79156c334 Propagate output format in tunneling mode
From API 23 this uses the timed format queue. Before API 23 the
format is notified as soon as the buffer is queued.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=213830729
2018-09-21 12:39:28 +01:00
andrewlewis
b58daf8dc5 Reset start trim only if input was queued
Before this change we would reset the start trim to zero after initial
configuration (at the start of playback) and after seeking to any position. The
fact that no trimming was applied at the start of playback meant that after the
first period transition we'd see a mismatch between the next buffer timestamp
(equal to the duration of the period taking into account edits) and the duration
of audio submitted to the sink.

This change modifies the behavior so that we reset the start trim to zero only
if some audio was queued since configuration. This is incorrect in the case of
starting playback at a non-zero position, but fixes the common case of starting
at zero. As before, a later seek to any position is handled via a flush and
resets the trim as required.

Transitions from one period to the next are unaffected by this change.

One way to implement start trimming correctly would be to provide the input
buffer timestamp to the audio processors and only trim when handling audio from
the start of the stream, but that is a larger change so left for later.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=213828511
2018-09-21 12:39:19 +01:00
andrewlewis
1c07b95fbb Compensate for trimmed audio in buffer time check
After a period transition the first buffer queued has the sum of previous period
durations added to its source presentation timestamp. These durations take into
account gapless edits, but the check on the timestamp was based on the submitted
frame count, not the frame count after trimming.

This change fixes an issue where audio/video would gradually drift apart due to
accumulated error in the audio track position, which could lead to freezing due
to the audio renderer stopping being ready and switching to the standalone media
clock.

Issue: #4559

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=213819908
2018-09-21 12:38:50 +01:00
Oliver Woodman
7d90396c27 Cleanup 2018-09-20 12:55:10 +01:00
ojw28
1e3c2a6b37 Merge pull request #4801 from nicklasl/trackselector-filter-on-framerate
Trackselector filter on framerate
2018-09-20 12:54:56 +01:00
tonihei
6323c1904f Stop overriding deprecated method.
Fixed and random track selection were still overriding the deprecated version
of updateSelectedTrack.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=213637728
2018-09-20 12:30:38 +01:00
tonihei
5c1829f063 Deprecate FixedTrackSelecion.Factory.
The only use of track selection factories is as adaptive track selection factories
in the DefaultTrackSelector. Using the fixed track selection factory here is dangerous
as it will throw if more than one track is selected.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=213637500
2018-09-20 12:29:00 +01:00
olly
64b50ff9e6 Fix broken Javadoc
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=213599127
2018-09-20 12:27:18 +01:00
sharjeel
1726f9e5fe Don't notify drop frames when maxDroppedFramesToNotify < 1
With default of value set to -1, every single dropped frame is reported because of expression: if (droppedFrames >= maxDroppedFramesToNotify) {  maybeNotifyDroppedFrames(); }

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=213502573
2018-09-20 12:25:44 +01:00
olly
918a43e48d Work around adaptation issue for Tab 4
The decoder doesn't claim to be adaptive, but if we're staying
in the same resolution we'll try and re-use the decoder anyway.
The H264 decoder can't handle this case on the Tab 4 can't deal
with this case.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=213478378
2018-09-20 12:24:10 +01:00
andrewlewis
7fe5230a7e Use gapless edit duration as sample table duration
This matches the non-gapless case.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=213462936
2018-09-20 12:22:43 +01:00
andrewlewis
e4f41880bd Add E-AC3 Ac3Extractor sample and test
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=213451163
2018-09-20 12:21:13 +01:00
aquilescanta
bca2f5c3a0 Fix Ac3 extractor sniffing for E-AC-3 frames
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=213443047
2018-09-20 12:19:43 +01:00
tonihei
a92344ac9e Log warning with stack trace if player is accessed from the wrong thread.
This doesn't break apps which violate this policy. But it creates a clear
warning which is also likely to be reported in analytics tools.

Issue:#4463

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=213442510
2018-09-20 12:18:15 +01:00
tonihei
decbb33490 Add super-simple SimpleExoPlayer factory method.
The DefaultTrackSelector can now be constructed without leaving out a
vital part of the initialization. This allows this new simple factory method.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=213438163
2018-09-20 12:15:19 +01:00
tonihei
e25b7d2148 Add wrapper for Log messages to allow settig the log level.
Currently there is no way to disable (or reduce) the logcat output generated
by ExoPlayer.

Issue:#4665

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=213421072
2018-09-20 12:12:21 +01:00
tonihei
585806de24 Clarify doc of components which only allow a main thread player.
ExoPlayer can be run on a background thread, but some components (UI and IMA)
only support players on the main thread. This adds some documentation and
assertions for that.

To simplify assertions, this also moves the getApplicationLooper method from
ExoPlayer to Player.

Issue:#4439

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=213280359
2018-09-17 17:56:36 +01:00
tonihei
c18ee3f96d Add some missing @Nullable to public API to improve Kotlin compatiblity.
Kotlin will throw NPE whenever a method returns null or an interface is
called with a null parameter and the respective values are not marked as
@Nullable.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=213262886
2018-09-17 17:55:03 +01:00
aquilescanta
76255dfae7 Make ExtractorsFactory javadoc consistent
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=213248388
2018-09-17 17:53:30 +01:00
tonihei
d1df41a39e Fix window index comparison.
To check the validity of a window index it needs to be compared with a greater
or equal sign to the window count.

Issue:#4822

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=213234403
2018-09-17 17:50:20 +01:00
aquilescanta
caa46d49e5 Explicitly document empty range removal in Util.removeRange.
Also prevent an unnecessary allocation when the removed range is empty.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=212993427
2018-09-17 17:48:45 +01:00
tonihei
1284f9ea4d Add Nullable to message payload.
Not having this annotation may cause Kotlin implementations to fail.

Issue:#4802

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=212980643
2018-09-17 17:47:11 +01:00
olly
6f6f381beb Fix audio and text track selection in the multi-renderer case
If we can select a track that has a strictly higher score than a
selection already made for a renderer of the same type, we should
prefer it.

Issue: #4711

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=212835895
2018-09-13 18:44:53 +01:00
aquilescanta
3e4115ff3c No-op ConcatenatingMediaSource simplification
- Make addMediaSource a specific case of addMediaSources.
- Make clear a specific case of removeMediaSourceRange.
- Make removeMediaSource a specific case of removeMediaSourceRange.
- Remove the unnecessary message handling and constants.
- Move a method so that depending appears before depended.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=212809667
2018-09-13 18:43:26 +01:00
olly
b17d49ed27 Add nullness annotations to a few more files
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=212644046
2018-09-13 18:40:17 +01:00
olly
b4dfed874d Enable GZIP for SingleSampleMediaSource
Issue: #4771

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=212623142
2018-09-12 15:32:14 +01:00
olly
a5a7e988e3 Clip DASH periods to their durations
Issue: #4185

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=212619419
2018-09-12 15:30:47 +01:00
andrewlewis
35c230f3c6 Allow partial format for adaptation check
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=212443793
2018-09-12 15:25:56 +01:00
tonihei
b1d48179e8 Add support to change shuffle order after playlist creation.
This allows to update the shuffle order after the ConcatenatingMediaSource
has been created. ShuffleOrder objects should be immutable to ensure thread
safety and thus there is no way to do this currently.

Issue:#4791

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=212443146
2018-09-12 15:24:23 +01:00