6848 Commits

Author SHA1 Message Date
tonihei
3f6ec59868 Improve PlaybackStatsListener by using onEvents callback
Previously the PlaybackStatsListener needed to handle all events
individually, which required to keep some state of the player and
to resolve potentially transient state changes.

Using onEvents allows to channel all simultanous updates through
one method so that no transient player state and other
inconsistencies need to be handled. This makes the logic easier
to read.

In addition it also allows to resolve all simultaneous events to
use one EventTime (with one timestamp).

#exofixit

PiperOrigin-RevId: 344415459
2020-11-27 11:08:10 +00:00
samrobinson
f1cf3d98d8 Add Format field to AudioSink.WriteException.
#exofixit

PiperOrigin-RevId: 344414313
2020-11-27 11:08:02 +00:00
olly
dd0246a31c DefaultAudioSink: Fix transient position calculation errors
PiperOrigin-RevId: 344408351
2020-11-27 11:07:47 +00:00
sungsoo
43713abe79 Add MediaUtilsTest
PiperOrigin-RevId: 344384426
2020-11-27 11:07:39 +00:00
olly
2fbad2105e Make special exception for cleartext-not-permitted
#exofixit

PiperOrigin-RevId: 344246408
2020-11-27 11:07:07 +00:00
olly
1201466b5c Fix NPE in onInputFormatChanged
PiperOrigin-RevId: 344243929
2020-11-27 11:06:59 +00:00
ibaker
3aa17bfb9b Switch extractor tests to single-parameter parameterized syntax
This is simpler than instantiating a single-element string array for
every parameter.

#exofixit

PiperOrigin-RevId: 344237475
2020-11-27 11:06:51 +00:00
samrobinson
8c9b92efc1 Add Format field to AudioSink.InitializationException
#exofixit

PiperOrigin-RevId: 344232362
2020-11-27 11:06:43 +00:00
tonihei
87e141d376 Remove boilerplate setting up FakeTimeline and FakeMediaSource.
In many cases it doesn't matter for the test itself how many windows
a timeline has, or even how the timeline of a MediaSource looks like.

And since we introduced the MediaItem-based APIs, single-window
Timelines are the only fully supported Timelines. Thus there is no
point in specifiying this explicitly.

Using these assumptions, we can remove some boilerplate when setting
up standard FakeTimelines or FakeMediaSources with a standard
FakeTimeline.

#exofixit

PiperOrigin-RevId: 344210395
2020-11-27 11:06:27 +00:00
olly
b7047a2467 Improve Player next/previous documentation
#exofixit
Issue: #5602
PiperOrigin-RevId: 344093622
2020-11-27 11:06:19 +00:00
tonihei
06bd3a65fe Don't inform of static metadata changes if they are all empty.
The current code creates placeholder metadata elements if there is no
static metadata. This causes onStaticMetadataChanged callbacks even
if there is no metadata.

Instead, we can keep the empty list as the static metadata is already
documented to be an empty list if the metadata is unavailable.

#exofixit

PiperOrigin-RevId: 344071639
2020-11-27 11:06:11 +00:00
bachinger
c17d1091f3 Remove "live" from fields in MediaItem.LiveConfiguraton
#exofixit

PiperOrigin-RevId: 344065519
2020-11-27 11:05:54 +00:00
olly
93ed71fb3e Support enabling next/previous actions in PlayerNotificationManager
The ref'd issue was marked as a doucmentation candidate, but I think
the confusion likely arises from the lack of "next" and "previous" in
the method names. Our other UI components also support enabling each
button individually, so this also brings notifications in line with
those.

Issue: #6491
#exofixit
PiperOrigin-RevId: 344058969
2020-11-24 16:04:14 +00:00
kim-vde
1cd08519f1 Merge pull request #8257 from xufuji456:dev-v2
PiperOrigin-RevId: 344057097
2020-11-24 16:04:04 +00:00
olly
f04941ed91 Fix 2 ErrorProneStyle findings:
* These grouping parentheses are unnecessary; it is unlikely the code will be misinterpreted without them
  (see http://go/bugpattern/UnnecessaryParentheses) (2 times)

This CL looks good? Just LGTM and Approve it!
This CL doesn’t look good? This is what you can do:
* Suggest a fix on the CL (go/how-to-suggest-fix).
* Revert this CL, by replying "REVERT: <provide reason>"
* File a bug under go/error-prone-bug for category ErrorProneStyle if the change looks generally problematic.
* Revert this CL and not get a CL that cleans up these paths in the future by
replying "BLOCKLIST: <provide reason>". This is not reversible! We recommend to
opt out the respective paths in your CL Robot configuration instead:
go/clrobot-opt-out.

This CL was generated by CL Robot - a tool that cleans up code findings
(go/clrobot). The affected code paths have been enabled for CL Robot in //depot/google3/java/com/google/android/libraries/exoplayer/METADATA which is reachable following include_presubmits from //depot/google3/third_party/java_src/android_libs/exoplayer/METADATA.
Anything wrong with the signup? File a bug at go/clrobot-bug.

#codehealth

PiperOrigin-RevId: 344053269
2020-11-24 16:03:54 +00:00
kimvde
7a7d3d1b07 Add FMP4 extractor test with sideloaded track
#exofixit

PiperOrigin-RevId: 344052500
2020-11-24 16:03:46 +00:00
christosts
a8365c2cca Set tag for every track in TrackSelectionView
#minor-release

PiperOrigin-RevId: 344051610
2020-11-24 16:03:38 +00:00
andrewlewis
866c7f85f8 Allow playing ads in playlists
- Remove restriction on `AdsMediaSource`s in playlists in `ExoPlayerImpl`.
- Allow playing playlists of `AdsMediaSource`s in the demo app.
- Add a sample with ads in a playlist in the demo app.

Issue: #3750
PiperOrigin-RevId: 344018774
2020-11-24 16:03:04 +00:00
tonihei
d4e1904604 Rollback of 483a350e84
*** Original commit ***

Suppress warnings in preparation for Checker Framework 3.7.1 upgrade.

LSC: go/checker-lsc

Tested:
    TAP train for global presubmit queue
    http://test/OCL:342788973:BASE:342817196:1605636478036:6c558c0c

***

PiperOrigin-RevId: 343895651
2020-11-24 16:02:45 +00:00
olly
3ec5ad1d1e Remove unused logic in SonicAudioProcessor
PiperOrigin-RevId: 343882631
2020-11-24 16:02:26 +00:00
samrobinson
ffc6a0d5f7 Add Format field to AudioSink.ConfigurationException
#exofixit

PiperOrigin-RevId: 343857564
2020-11-24 16:01:59 +00:00
bachinger
aec3e458d8 Use onEvents in PlayerNotificationManager
This saves a few lines of code and is nicer. We already did make sure to update the notification only once by posting because of b/145521438.

#exofixit

PiperOrigin-RevId: 343852256
2020-11-24 16:01:49 +00:00
ibaker
b562adf26c Tweak ParsableByteArray#readLine javadoc
Don't refer to the "system's default charset", just specify UTF-8
explicitly.

PiperOrigin-RevId: 343839878
2020-11-24 16:01:41 +00:00
olly
6c31e34528 Use onEvents in PlayerControlView/StyledPlayerControlView
#exofixit

PiperOrigin-RevId: 343821736
2020-11-24 16:01:29 +00:00
tonihei
e5e903eb8a Add EventTimes to AnalyticsListener.onEvents
The EventTime wasn't part of the onEvents callbacks so far because the
individual events may have different event times (e.g. if they relate to
different media periods). By adding a query method to obtain the
EventTime by event type, we can solve this issue.

#exofixit

PiperOrigin-RevId: 343818819
2020-11-24 16:01:19 +00:00
tonihei
7d3399764e Improve JavaDoc and method discovery for onEvents
Mentioning the realtionship on every other callback makes
it easier for the casual developer to understand the
relationship between the methods and discover the existence
of onEvents.

PiperOrigin-RevId: 343811032
2020-11-24 16:01:09 +00:00
olly
e0ccfdde1b Notify VideoFrameReleaseTimeHelper of all frame PTS values
Previously, VideoFrameReleaseTimeHelper didn't receive PTS values for
frames that were skipped. This would lead to unnecessary sync loss when
encountering such buffers, because the helper would see a frame-rate
change (i.e., the next frame being significantly longer than previous
ones). After this change, VideoFrameReleaseTimeHelper is notified of
all frame PTS values, so it can retain sync in this case.

This change also propagates onStarted and onPositionReset to the helper.
This paves the way for decoupling frame-rate estimation from release
adjustment sync. Note that currently, loss of sync effectively resets
both. This is unnecessary. For example, if the renderer is paused and
later resumed, then release adjustment sync needs to be reset, but any
frame-rate estimate we have is still valid.

PiperOrigin-RevId: 343803531
2020-11-23 11:01:52 +00:00
olly
b16cf5941e Rollback of 8d84a50fa1
*** Original commit ***

Update Styled non bottom buttons to be borderless.

This requires the parent of the background to draw and have padding large enough to support the size of the ripple.

The bottom buttons must remained bordered as the space around them is constrained.

***

PiperOrigin-RevId: 343531411
2020-11-23 10:49:00 +00:00
tonihei
a987e106e6 Update docs with onEvents callback information.
PiperOrigin-RevId: 343507207
2020-11-23 10:03:18 +00:00
olly
1b50071f4f Fix ProgressiveDownloader retry logic
RunnableFutureTask is not reusable. Trying to reuse it meant that a
failure in one doWork() call would cause subsequent download() calls
to (a) not block until the runnable has finished executing (does not
apply when using a direct executor), and (b) throw the same failure
as thrown from the first doWork() call.

This could cause #8078 if the initial failure occurred before the
content length was resolved. Retries are not blocked on their work
completing due to (a), and the download would be marked as failed due
to (b). The work itself could then resolve the content length, which
causes the stack trace in this issue.

Issue: #8078
PiperOrigin-RevId: 343498252
2020-11-20 17:10:14 +00:00
tonihei
bd631a6ce2 Add onEvents callback.
This callback allows listeners to know when all simultanous changes
have been handled and the values reported through callbacks are
again completely consistent with value obtained from Player
getter calls.

PiperOrigin-RevId: 343476639
2020-11-20 17:10:05 +00:00
tonihei
a6b53d24af Add OGG playback tests
PiperOrigin-RevId: 343467276
2020-11-20 17:09:56 +00:00
tonihei
1d2cf6f270 Fix bug in SampleQueue.discardTo for duplicate timestamps.
When a stream has duplicate timestamps we currently discard to
the last sample with the specified discardTo timestamp, but
it should be the first one to adhere to the method doc and the
intended usage.

#minor-release

PiperOrigin-RevId: 343458870
2020-11-20 11:11:28 +00:00
olly
8c8176647c Minimal fix for playback freezes when enabling tracks #8203
Background:

1. When the player has multiple audio renderers, by default they share a
   single AudioSink.
2. When any new renderer is enabled, all disabled renderers are reset
   prior to the new renderer being enabled. This is to give them a chance
   to free up resources in case the renderer being enabled needs them. These
   reset calls are expected to be no-ops for renderers that have never been
   enabled.

The issue:

The problematic case arises when there are two audio renderers and a third
renderer (e.g., text) is being enabled. In this case, the disabled audio
renderer's reset call ends up resetting the AudioSink that's shared with the
enabled audio renderer. The enabled audio renderer is then unable to make
progress, causing playback to freeze.

This is a minimal fix that directly prevents the mentioned issue. There are
multiple follow-ups that would probably make sense:

1. Having ExoPlayerImplInternal track which renderers need to be reset, and
   only resetting those renderers rather than all that are disabled. This
   seems like a good thing to do regardless, rather than relying on those
   calls being no-ops.
2. If we want to continue sharing AudioSink, we need to formalize this much
   better and make sure we have good test coverage. Messages like
   MSG_SET_VOLUME are also delivered to the AudioSink multiple times via
   each of the renderers, which works currently because DefaultAudioSink
   no-ops all but the first call in each case. This is pretty fragile though!

Issue: #8203
#minor-release
PiperOrigin-RevId: 343296081
2020-11-19 17:13:28 +00:00
bachinger
39f8c77568 Replace cancelled HLS preload parts
Issue: #5011
PiperOrigin-RevId: 343277357
2020-11-19 17:13:19 +00:00
ibaker
31166d41c4 Remove FLAG_SIDELOADED from FragmentedMp4Extractor
This isn't used any more, the last usage was removed in
<unknown commit>

PiperOrigin-RevId: 343266553
2020-11-19 17:13:11 +00:00
olly
2714fb0241 Remove custom speed from StyledPlayerControlView
Real apps probably aren't going to be allowing playback speed to be
set to anything other than the options listed in their UI, and so
this is not worth the complexity.

It also violates the idea that the UI should look the same regardless
of when the player is set on the view, since if it's set and then the
playback speed is changed to a listed option then the custom speed
remains, where-as if the speed is changed to a listed option and then
it's set, the custom speed will not be shown.

PiperOrigin-RevId: 343260450
2020-11-19 17:12:51 +00:00
tonihei
e5fd2eb088 Rollback of db8356a17c
*** Original commit ***

Suppress warnings in preparation for Checker Framework 3.7.1 upgrade.

LSC: go/checker-lsc

Tested:
    tap_presubmit: http://test/OCL:342788975:BASE:342885903:1605667635149:7731b723
    Some tests failed; test failures are believed to be unrelated to this CL

***

PiperOrigin-RevId: 343251530
2020-11-19 17:12:33 +00:00
olly
0191febbe6 Fix fastforward and rewind color tinting and text alignment
#minor-release
Issue: #7898
PiperOrigin-RevId: 343251455
2020-11-19 17:12:25 +00:00
olly
db8356a17c Suppress warnings in preparation for Checker Framework 3.7.1 upgrade.
LSC: go/checker-lsc

Tested:
    tap_presubmit: http://test/OCL:342788975:BASE:342885903:1605667635149:7731b723
    Some tests failed; test failures are believed to be unrelated to this CL
PiperOrigin-RevId: 343129490
2020-11-19 17:12:16 +00:00
xufuji456
6682e6235c Compat video coding with mpeg1video in Mp4Extractor 2020-11-19 19:31:43 +08:00
olly
7cf0620231 Rollback of f6928c0ef9
*** Original commit ***

Keep download in completed state if only metadata is updated

Issue: #8116

***

PiperOrigin-RevId: 343102068
2020-11-18 18:40:43 +00:00
tonihei
c529a0b9c7 Rollback of 31430f1ac5
*** Original commit ***

Suppress warnings in preparation for Checker Framework 3.7.1 upgrade.

***

PiperOrigin-RevId: 343100646
2020-11-18 18:40:37 +00:00
ibaker
6d7997e747 Move DataSourceContractTest to the testutil package
PiperOrigin-RevId: 343096974
2020-11-18 18:40:36 +00:00
tonihei
f13ffb4390 Rollback of 5d9c2d7b6a
*** Original commit ***

Suppress warnings in preparation for Checker Framework 3.7.1 upgrade.

***

PiperOrigin-RevId: 343086403
2020-11-18 18:40:30 +00:00
tonihei
44009ea686 Rollback of fa6e01312b
*** Original commit ***

Suppress warnings in preparation for Checker Framework 3.7.1 upgrade.

***

PiperOrigin-RevId: 343085407
2020-11-18 18:40:22 +00:00
aquilescanta
79e8295cd2 Fix HLS format derivation in traditional preparation
ExoPlayer's traditional HLS preparation works by loading a chunk from each track
group, and then tries to use the sample information plus the master playlist
information to generate the preparation's resulting TrackGroups.

There are 3 possible scenarios:
- Supported case: Each variant has a single codec string per track type. We can
  assign each track the codec string which matches the loaded sample's type.
- Supported case: Each variant has more than one codec string, but each track
  group has a single track. This is the case when different languages use
  different codecs. In this case, we can assign whichever codec matches the
  loaded sample's mime type.
- Unsupported case: Each variant has more than one codec string, and track
  groups contain more than one track. We are not able to safely map tracks to
  codec strings because that would require loading a chunk from each track
  (which would considerably delay preparation).

Broken in:
4783c329cc

PiperOrigin-RevId: 343072201
2020-11-18 18:40:21 +00:00
olly
3c91ba14b3 Suppress warnings in preparation for Checker Framework 3.7.1 upgrade.
PiperOrigin-RevId: 343003559
2020-11-18 18:40:17 +00:00
olly
755f5b7d76 Suppress warnings in preparation for Checker Framework 3.7.1 upgrade.
PiperOrigin-RevId: 342999709
2020-11-18 18:40:10 +00:00
olly
483a350e84 Suppress warnings in preparation for Checker Framework 3.7.1 upgrade.
PiperOrigin-RevId: 342999390
2020-11-18 18:40:06 +00:00