3809 Commits

Author SHA1 Message Date
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
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
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
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
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
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
olly
48d3d63144 Add experimentalSetForegroundModeTimeoutMs
Allows to set a timeout for the setForegroundMode(false) call, different than releaseTimeoutMs.

PiperOrigin-RevId: 342980350
2020-11-18 18:40:05 +00:00
olly
0abdfe94a6 Suppress warnings in preparation for Checker Framework 3.7.1 upgrade.
PiperOrigin-RevId: 342952746
2020-11-18 18:39:55 +00:00
tonihei
eb8a57ee46 Only notify rebuffer to if we are actually rebuffering.
Right now we also notify while we are paused although this doesn't classify as a rebuffer.

PiperOrigin-RevId: 342892667
2020-11-18 18:31:10 +00:00
ibaker
4936c730c3 Add a contract testing abstract class for DataSource implementations
This only has a couple of simple tests for now. We'll add more tests
after we've written some concrete sub-class tests for various
DataSource implementations.

I've included a concrete FileDataSourceContractTest as a demonstration.

PiperOrigin-RevId: 342851187
2020-11-18 18:30:58 +00:00
veronicaradu
a19941f09c Add methods in TrackSelection to get details about the playback state.
Determine whether a rebuffer occurred and if the playback is paused or resumed.

PiperOrigin-RevId: 342849010
2020-11-18 18:30:47 +00:00
christosts
cbd91999b4 Add Robolectric playback tests for existing VP9 assets
PiperOrigin-RevId: 342660971
2020-11-17 13:50:35 +00:00
christosts
c87f95e153 Add Robolectric playback tests for existing MKV assets
PiperOrigin-RevId: 342618706
2020-11-16 16:50:46 +00:00
tonihei
1984779fa1 Discard buffer synchronously after seek before cancelling a load.
This ensures the buffer is not full when the `DefaultLoadControl` determines
whether we should continue loading and thus prevents a false warning about
not having enough memory left.

PiperOrigin-RevId: 342616623
2020-11-16 16:50:35 +00:00
olly
c47e62209d Report reasons for not being able to reuse decoders
PiperOrigin-RevId: 342344090
2020-11-16 16:49:48 +00:00
olly
3ef609fa3b Plumb playback speed and frame-rate via VideoFrameReleaseTimeHelper
PiperOrigin-RevId: 342289646
2020-11-16 16:49:37 +00:00
olly
f6928c0ef9 Keep download in completed state if only metadata is updated
#minor-release

Issue: #8116
PiperOrigin-RevId: 342269114
2020-11-16 16:49:25 +00:00
olly
7fe68b52d5 Remove stray arguments from method
PiperOrigin-RevId: 342263700
2020-11-13 16:30:28 +00:00
christosts
7fd78666d1 Add Robolectric playback tests for existing MKA assets
PiperOrigin-RevId: 342060794
2020-11-13 14:55:20 +00:00
olly
2693a107cd Fix frame release timing to be aware of playback speed
PiperOrigin-RevId: 342007987
2020-11-13 14:54:32 +00:00
tonihei
51c8ffbb0e Tweak DefaultLivePlaybackSpeedControl parameters.
Changing them to have fewer updates when adjusting the playback speed.

PiperOrigin-RevId: 341834423
2020-11-13 14:54:22 +00:00
claincly
6f7c97a729 Add method to expose the locally opened port for UdpDataSource.
PiperOrigin-RevId: 341707809
2020-11-11 09:51:09 +00:00
kimvde
4ae0401c34 Work around AudioManager#getStreamVolume crashes
#minor-release
Issue:#8191
PiperOrigin-RevId: 341632732
2020-11-11 09:50:49 +00:00
ibaker
363693d8ec Add multi-channel audio samples to Mp4PlaybackTest
Robolectric now supports multi-channel audio:
https://github.com/robolectric/robolectric/commit/9d84ceb6d588d5f53be29b

PiperOrigin-RevId: 341574417
2020-11-11 09:50:40 +00:00
ibaker
1e776a864b Fix some typos
PiperOrigin-RevId: 341573964
2020-11-11 09:50:30 +00:00
ibaker
337c412d2b Add multi-channel audio samples to TsPlaybackTest
Multi-channel audio is now supported by Robolectric:
https://github.com/robolectric/robolectric/commit/9d84ceb6d588d5f53be29b

PiperOrigin-RevId: 341573838
2020-11-11 09:50:21 +00:00
ibaker
f13058942a Add Robolectric playback tests for existing FLV assets
PiperOrigin-RevId: 341573808
2020-11-11 09:50:11 +00:00
christosts
9e98a680da Add flag to force synchronization in async queueing
Add experiment flag to force synchronization between
queueing threads in AsynchronousMediaCodecAdapter.

PiperOrigin-RevId: 341431481
2020-11-11 09:50:01 +00:00
christosts
9473fda056 Synchronize codec interaction with buffer queueing
Add experimental method to synchronize MediaCodec interactions
with asynchronous queueing. When the feature is enabled, interactions
such as MediaCodec.setOutputSurface() triggered by the
MediaCodecRenderer will wait until all input buffers pending queueing
are first submitted to the MediaCodec.

PiperOrigin-RevId: 341423837
2020-11-11 09:49:51 +00:00
tonihei
86ae7ebac4 Decrease target live offset if safely possible.
To check what is safely possible we keep track of the live offset
corresponding to the buffered duration and only deecrease the
target offset to a safe margin from the buffered duration.

Also, while still possible (i.e. while the actual offset is larger
than the safe margin), we increase the target offset to the safe
margin to avoid rebuffers to start with.

Issue: #4904
PiperOrigin-RevId: 341396492
2020-11-11 09:49:41 +00:00
bachinger
b03df4e8b5 Add dispatchPrepare(player) to ControlDispatcher
Issue: #7882
PiperOrigin-RevId: 341394254
2020-11-11 09:49:32 +00:00
christosts
1d4321b86e Move ownership of MediaCodec to MediaCodecAdapter
Move ownership of MediaCodec to MediaCodecAdapter so that all MediaCodec
interactions go through MediaCodecAdapter.

PiperOrigin-RevId: 341066926
2020-11-11 09:49:21 +00:00
claincly
8b5ecdb98d Fix javadoc formatting
PiperOrigin-RevId: 341051348
2020-11-06 16:40:34 +00:00
christosts
92ec1ab628 Add more MediaCodec methods to MediaCodecAdapter
Add more MediaCodec methods to MediaCodedAdapter so that renderers
interact with the MediaCodec through the MediaCodecAdapter.

PiperOrigin-RevId: 341023452
2020-11-06 16:35:23 +00:00
andrewlewis
764e5e8141 Expose the ads identifier in the Timeline period
Issue: #3750
PiperOrigin-RevId: 341021084
2020-11-06 16:35:06 +00:00
andrewlewis
0c301fefa8 Pass AdsMediaSource to other AdsLoader methods
Issue: #3750
PiperOrigin-RevId: 341020676
2020-11-06 16:34:57 +00:00
christosts
07e33a1395 Add getInputBuffer/getOutputBuffer in MediaCodecAdapter
PiperOrigin-RevId: 341016263
2020-11-06 16:34:37 +00:00
olly
1bcf1cf9f7 Decide whether to release rather than flush in onInputFormatChanged
- This change removes the last piece of logic that could cause deferred
  codec release (i.e., where the decision to release was made in
  processEndOfStream rather than in onInputFormatChanged.
- After this change, whether the codec will be released as a result of
  a format change is always established in onInputFormatChanged.

PiperOrigin-RevId: 341012403
2020-11-06 16:34:28 +00:00