3551 Commits

Author SHA1 Message Date
bachinger
fa0cc1e15f Improve javadoc of Window.windowStartTimeMs
PiperOrigin-RevId: 346346359
2021-01-11 16:13:28 +00:00
Oliver Woodman
8c935e366c Merge pull request #8154 from samoylenkodmitry:handle_out_of_space
PiperOrigin-RevId: 345428731
2021-01-11 16:12:36 +00:00
andrewlewis
2516e94eb9 Fix SonicAudioProcessor end of stream behavior
The `AudioProcessor` interface requires that no more input is queued after
queueing end of stream, but `DefaultAudioSink` did queue more input and the
implementation of `SonicAudioProcessor` actually relied on this to drain output
at the end of the stream.

Fix this behavior by getting `Sonic` output in `getOutput` and having
`DefaultAudioSink` only queue input to processors that are not draining.

Also add TODOs to clean up audio processor implementations where the code
handles interaction that doesn't conform to the interface.

PiperOrigin-RevId: 345406478
2021-01-11 16:12:36 +00:00
andrewlewis
fe754f313e Mask ad media periods before the URI is available
Previously `MediaPeriodQueue` would return null if an ad media URI hadn't
loaded yet, but this meant that the player could be stuck in `STATE_READY` if
an `AdsLoader` unexpectedly didn't provide an ad URI. Fix this behavior by
masking ad media periods. `MaskingMediaPeriod` no longer requires a
`MediaSource` to instantiate it.

This also fixes a specific case where playback gets stuck when using the IMA
extension with an empty ad where the IMA SDK unexpectedly doesn't notify the ad
group fetch error.

Issue: #8205
PiperOrigin-RevId: 344984824
2021-01-08 16:52:25 +00:00
bachinger
d8df5411b8 Fix flaky test
PiperOrigin-RevId: 334801561
2021-01-08 16:46:18 +00:00
olly
0e4d3162eb SonicAudioProcessor: Fix scaling to account for pending input bytes
PiperOrigin-RevId: 344420436
2020-11-30 10:51:19 +00:00
olly
26aa6f6dbf DefaultAudioSink: Fix transient position calculation errors
PiperOrigin-RevId: 344408351
2020-11-30 10:51:10 +00:00
olly
46396a93e9 Make special exception for cleartext-not-permitted
#exofixit

PiperOrigin-RevId: 344246408
2020-11-30 10:51:03 +00:00
olly
41d6c26904 Improve Player next/previous documentation
#exofixit
Issue: #5602
PiperOrigin-RevId: 344093622
2020-11-30 10:42:44 +00:00
olly
d5829336eb Remove unused logic in SonicAudioProcessor
PiperOrigin-RevId: 343882631
2020-11-30 10:40:02 +00:00
olly
3a8524d044 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-23 11:08:09 +00:00
tonihei
10164d7491 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-23 09:58:49 +00:00
olly
305ec3b449 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
PiperOrigin-RevId: 343296081
2020-11-23 09:58:49 +00:00
tonihei
5698eadc08 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-23 09:58:48 +00:00
kimvde
8e638ec753 Work around AudioManager#getStreamVolume crashes
Issue:#8191
PiperOrigin-RevId: 341632732
2020-11-19 16:55:21 +00:00
bachinger
11b09dd58d Add dispatchPrepare(player) to ControlDispatcher
Issue: #7882
PiperOrigin-RevId: 341394254
2020-11-19 16:54:23 +00:00
Oliver Woodman
ac1ffa4fc2 Merge pull request #8133 from xufuji456:dev-v2
PiperOrigin-RevId: 340254878
2020-11-19 16:40:03 +00:00
ibaker
07455da2f5 Migrate Tx3gDecoderTest to Guava and SpannedSubject
#minor-release

PiperOrigin-RevId: 340249019
2020-11-19 16:39:53 +00:00
olly
379cd8a04f Make defaultLicenseUrl optional
Some content types always provide the license URL in the media.
The PlayReady example in the demo app doesn't provide a default
license URL for this reason, as an example.

#minor-release

PiperOrigin-RevId: 340125784
2020-11-18 19:10:50 +00:00
andrewlewis
1264dbcd36 Handle stream volume register/unregister errors
Issue: #8106
Issue: #8087
PiperOrigin-RevId: 338664455
2020-11-18 19:07:04 +00:00
Oliver Woodman
452f68fb6c Merge pull request #7867 from GeneticGenesis:pc/update-expected-http-statuses-for-failover
PiperOrigin-RevId: 338051017
2020-10-20 22:16:12 +01:00
krocard
e72082710c AudioSink: Remove comment about unconfirmed crash
Consensus is that the NoClassDefFoundError does not
causes a crash but only a warning.

PiperOrigin-RevId: 338022354
2020-10-20 22:16:12 +01:00
Oliver Woodman
7303005873 Merge pull request #8030 from yqritc:add-output-surface-workaround
PiperOrigin-RevId: 338016707
2020-10-20 22:16:12 +01:00
andrewlewis
fac3515016 Move DataSource reading methods into Util
This will be used to read ads responses out of data: URLs in a subsequent
change.

PiperOrigin-RevId: 334778780
2020-10-20 22:16:12 +01:00
krocard
0de938c4aa Do not inherit directly from AudioTrack.StreamEventCallback
This was causing issues old devices where the class
inheriting StreamEventCallback was loaded even though
it was not used.

Instead use an anonymous class that seem to be loaded
more lazily.

PiperOrigin-RevId: 337252687
2020-10-20 22:16:12 +01:00
krocard
ec96e0c495 Add MiTV devices requiring the output surface workaround
Issue: #8014
PiperOrigin-RevId: 337142176
2020-10-20 22:16:12 +01:00
ibaker
a635bdd4ba Switch to an 'api' dependency on Guava
The 'implementation' dependency causes problems when resolving
ListenableFuture in contexts that also include the
com.google.guava:listenablefuture:1.0 dependency.

Issue: #7905
Issue: #7997
Issue: #7993
PiperOrigin-RevId: 337093024
2020-10-20 22:16:12 +01:00
andrewlewis
53c4a393f3 Pass ad tags via AdsMediaSource
This is in preparation for supporting playlists of ads media sources using
ImaAdsLoader.

Existing ways of passing ad tags should still function but are deprecated (and
won't be supported with playlists).

Issue: #3750
PiperOrigin-RevId: 335618364
2020-10-20 22:16:12 +01:00
bachinger
36c2fe1053 Add missing properties of MediaItem.Subtitle
Issue: #8044
PiperOrigin-RevId: 336955479
2020-10-20 22:16:12 +01:00
ibaker
907d10705a Use MP4VTT MIME type in DashManifestParser (again)
We stopped using using this MIME type in
74a9d8f680

This broke subtitle decoding in some cases (Issue: #7985), which I
fixed in
7b8895d655.

After some discussion we've decided SubtitleDecoderFactory shouldn't
depend on Format.containerMimeType (since the samples have already been
extracted by this point, so the container shouldn't matter). So this
change fixes DashManifestParser to use MimeTypes.APPLICATION_MP4VTT (and
reverts the no-longer-needed SubtitleDecoderFactory change).

PiperOrigin-RevId: 336668450
2020-10-20 22:11:34 +01:00
bachinger
c8879392ab Make resetPosition reset the position if true
Issue: #8024
PiperOrigin-RevId: 335846035
2020-10-17 12:18:39 +01:00
andrewlewis
837cdc4f67 Fix miscellaneous nits/typos
PiperOrigin-RevId: 335642909
2020-10-17 12:18:13 +01:00
ibaker
13d8860221 Tweak null-checking in TextRenderer#getNextEventTime()
`subtitle` is only guaranteed to be non-null if
`nextSubtitleEventIndex != C.INDEX_UNSET`. The null check added in
0efec5f6c1
was too early.

Issue: #8017
PiperOrigin-RevId: 334777742
2020-10-17 12:09:20 +01:00
ibaker
b8c8ce0ee0 Use Mp4WebvttDecoder for WebVTT content in DASH MP4 containers
This was broken by 74a9d8f680
because DashManifestParser switched to setting Format.sampleMimeType to
text/vtt while SubtitleDecoderFactory was still expecting
application/x-mp4-vtt. This change teaches SubtitleDecoderFactory to
check both Format.containerMimeType and Format.sampleMimeType.

I'll investigate a follow-up change to remove
MimeTypes.APPLICATION_MP4VTT completely (it's currently still used in
AtomParsers).

Issue: #7985
PiperOrigin-RevId: 334771672
2020-10-17 12:09:13 +01:00
ibaker
9ce2ac8a8c Create a robolectricutils module
This holds shared test infrastructure that needs to depend on
Robolectric.

PiperOrigin-RevId: 334604041
2020-10-17 12:08:59 +01:00
andrewlewis
824b2a7305 Fix position ramping behavior with AudioTrack speed params
Non-realtime AudioTrack playback speed was not taken into account when
extrapolating the old mode's position, causing the position not to
advance smoothly.

This should be a no-op when not using AudioTrack playback params for
speed adjustment.

Issue: #7982
PiperOrigin-RevId: 334151163
2020-10-17 11:53:06 +01:00
christosts
300bee5f0b Bring back setRenderTimeLimitMs
PiperOrigin-RevId: 333712782
2020-10-17 11:51:18 +01:00
tonihei
30be792a15 Switch SntpClient to time.android.com and allow to set host.
PiperOrigin-RevId: 333480727
2020-10-17 11:48:08 +01:00
krocard
64aa634f9b Fix offload buffer full detection after setEndOfStream
This issue has been observed on a test app stress
testing setEndOfStream.

The issue has not been observed on ExoPlayer,
probably due to timing differences, but it is fixed
preventively.

#exo-offload

PiperOrigin-RevId: 333472136
2020-10-17 11:48:02 +01:00
tonihei
93948471c8 Don't require the existence of the next period to wait for its stream.
We have a workaround for uneven sample stream durarions in playlists that
assumes a renderer allows playback if it's reading ahead or waiting for
the next stream.

652c2f9c18 changed this logic to no longer require to
wait until the next stream is prepared due to a change in how we advance
media periods in the queue. However, the code falsely still requires the
next stream to exist (even if it's not prepared). This can cause a stuck
buffering state when the difference in the duration of the streams is more
than what we buffer ahead because we never create the next stream in such
a case.

Note: DefaultMediaClock.shouldUseStandaloneClock has roughly the same logic
and also doesn't require the next stream to be present.

Also fix a test that seemed to rely on this stuck buffering case to test
stuck buffering detection. Changed the test to not read the end of stream
to ensure it runs into the desired stuck buffering case.

Issue:#7943
PiperOrigin-RevId: 333050285
2020-10-17 11:47:27 +01:00
ibaker
77249bdf0e Use replace() instead of replaceAll() in SsaDecoder
We're not using regex so there's no need to use replaceAll()

PiperOrigin-RevId: 332865724
2020-10-17 11:44:17 +01:00
krocard
201d120e38 Recover from audio server crash while sleeping for offload
Without this patch, playback would be frozen indefinitely
until the user manually pauses and unpauses it.

This has the side effect of disabling offload until
the next stop due to the workaround of
disabling offload when it encounters a failure.

As an audio server crash is considered very
infrequent, especially in stable conditions like
an audio only playback, it is unlikely that disabling
offload is an issue.

PiperOrigin-RevId: 332857094
2020-10-17 11:44:10 +01:00
Oliver Woodman
1850a918f1 Merge pull request #7938 from bennettpeter:pullreq-ssa-subtitles
PiperOrigin-RevId: 332814223
2020-10-17 11:43:54 +01:00
ibaker
3e36ebe28e Suppress Guava-related ProGuard/R8 warnings
I didn't copy-paste the whole of
https://github.com/google/guava/wiki/UsingProGuardWithGuava because
this line seems relevant based on our current usage.

Lots of that file seems to relate to classes that are strongly
discouraged on Android:
https://github.com/google/guava/wiki/Android#specifics

I've only added this to the `common` module, since everyone that uses
ExoPlayer must depend on that. This avoids duplicating this line into
every module that has a Guava dependency.

Also remove some other warning suppressions that are defined in both
`core` and `common`.

Issue: #7904
PiperOrigin-RevId: 332203086
2020-10-17 11:41:41 +01:00
kimvde
97a0df77f6 Support android.resource URI scheme
Issue: #7866
PiperOrigin-RevId: 330736774
2020-10-17 11:40:56 +01:00
olly
8955cd3a61 Clean up experimental offload Javadoc
PiperOrigin-RevId: 331591005
2020-10-17 01:17:36 +01:00
olly
8386d617bf Fix OOM-is-prevented test OOM-ing :)
This test is intended to check that DefaultLoadControl will cause
playback to fail as "stuck buffering" rather than OOM-ing, in the
case that its target buffer size is reached and playback still
hasn't started.

Unfortunately, the target buffer size is ~130MB, and when running
on some setups an OOM actually ends up happening before this much
memory is allocated.

This change makes the target buffer size much smaller to avoid the
problem.

PiperOrigin-RevId: 331748208
2020-09-16 13:37:26 +01:00
bachinger
4f982763cf Add getMediaItemCount() and getMediaItemAt(int)
PiperOrigin-RevId: 331211708
2020-09-11 23:21:08 +01:00
olly
9fb2902dad Exclude Guava transitive annotation dependencies
PiperOrigin-RevId: 331148067
2020-09-11 16:02:37 +01:00
olly
ea25729a09 Make BatchBufferTest allocate less memory
Setting to 2x BATCH_SIZE_BYTES

PiperOrigin-RevId: 331124129
2020-09-11 13:30:33 +01:00