17928 Commits

Author SHA1 Message Date
samrobinson
5438e6cdb4 Only init SpeedChangingAudioProcessor if Format.Metadata not null.
If the Metadata passed to SegmentSpeedProvider is null, then the
SegmentSpeedProvider will always return 1f from getSpeed.

Initializing a SpeedChangingAudioProcessor requires a SpeedProvider.
Once configured,this audioProcessor is always active, so buffers are
passed through it. Because getSpeed is always 1, the processor performs
a no-op, but still has to do a buffer copy for each buffer.

By not initializing the audio processor when metadata is null, this
copy can be skipped and the audio pipeline is more performant.

Note: This change does not affect the multiple media-item case, which
is not supported with speed changes, as per Transformer API
documentation.
PiperOrigin-RevId: 513261811
2023-03-02 08:13:34 +00:00
christosts
a64a9e67ca Extend documentation for ForwardingPlayer
Add some additional information which methods to override
for available commands.

#minor-release

PiperOrigin-RevId: 513251805
2023-03-01 18:18:54 +00:00
sheenachhabra
d2d9168f9d Move Mp4MuxerMetadataTest into muxer module
Changes include:
1. Move the test fine into muxer module.
2. Use dump file infra for test cases.
3. Add one additional test for adding float metadata.
4. Few improvements in the code.

In next CL will remove Mp4 term from the file name as we are not using this term in test file names.

PiperOrigin-RevId: 513222506
2023-03-01 18:14:52 +00:00
tonihei
d2ba290746 Merge pull request #255 from mayurk2:use_edts_offset_if_it_is_for_entire_file
PiperOrigin-RevId: 513213229
2023-03-01 18:10:49 +00:00
ibaker
3e1f8258c4 Delete VorbisUtil.CodeBook since it's not used
PiperOrigin-RevId: 513186205
2023-03-01 18:06:43 +00:00
ibaker
ef5a1ce932 Remove @see tags with <a> tags
These are not supported by Dackka

#minor-release

PiperOrigin-RevId: 513176533
2023-03-01 18:02:43 +00:00
andrewlewis
3634e552e6 Don't log removed encoders
We shouldn't have this logging unless we really need it to debug
a specific problem, as it can be noisy (even at debug level).

PiperOrigin-RevId: 512904412
2023-03-01 17:58:46 +00:00
ibaker
78357e42d2 Remove Dackka integration from media3 gradle files
Reference docs are now generated by the standard Jetpack machinery, so there's no need for us to generate these docs ourselves.

PiperOrigin-RevId: 512898248
2023-03-01 17:54:47 +00:00
christosts
48047cf9e8 Minor change in ForwardingPlayer javadoc
#minor-release

PiperOrigin-RevId: 512897269
2023-03-01 17:50:47 +00:00
tonihei
13a86b3833 Update translations
#minor-release

PiperOrigin-RevId: 512890813
2023-03-01 17:46:46 +00:00
kimvde
128d8ff036 Handle multiple sequences in a Composition
This lays the groundwork for full multi-asset, and more particularly for
adding looping background audio.

PiperOrigin-RevId: 512887888
2023-03-01 17:42:50 +00:00
tonihei
4cf7d3c7ac Ensure getPlaybackHeadPosition isn't called if not needed
Once the value returned from AudioTimestampPoller advances, we
only need getPlaybackHeadPosition to sample sync params and
verify the returned timestamp. Both of these happen less often
and we can avoid calling getPlaybackHeadPosition if we don't
actually need it.

PiperOrigin-RevId: 512882170
2023-03-01 17:38:51 +00:00
andrewlewis
05d3652443 Increase GL release timeout to 500 ms
Based on 1000 test runs an emulator, with the current timeout releasing
fails (even with no custom effects) about one percent of the time.
Releasing normally completes in about 30 ms but occasionally
`eglTerminate` took up to 200 ms (and even releasing an effect
took up to 80 ms in one case).

With the new timeout of 500 ms, we still catch stuck effects reasonably
quickly but the number of flaky test failures should be less than one in
ten thousand.

PiperOrigin-RevId: 512690715
2023-03-01 17:34:49 +00:00
bachinger
28545c6673 Add FakeMultiPeriodLiveTimeline and test case
This timeline will be used in unit test cases of follow-up
CLs. It basically can be used to emulate the timeline created by a
multi-period live media source when the real time advances.

PiperOrigin-RevId: 512665552
2023-03-01 17:30:52 +00:00
tofunmi
f2c06fff2b Create DataSourceBitmapLoader
PiperOrigin-RevId: 512659747
2023-03-01 17:26:55 +00:00
tonihei
d363977156 Fix some playback parameter signalling problems.
Playback parameter signalling can be quite complex because
 (a) the renderer clock often has a delay before it realizes
     that it doesn't support a previously set speed and
 (b) the speed set on media clock sometimes intentionally
     differs from the one surfaced to the user, e.g. during
     live speed adjustment or when overriding ad playback
     speed to 1.0f.

This change fixes two problems related to this signalling:
 1. When resetting the media clock speed at a period transition,
    we don't currently tell the renderers that this happened.
 2. When a delayed speed change update from the media clock is
    pending and the renderer for this media clock is disabled
    before the change can be handled, the pending update becomes
    stale but it still applied later and overrides any other valid
    speed set in the meantime.

Both edge cases are also covered by extended or new player tests.

Issue: google/ExoPlayer#10882

#minor-release

PiperOrigin-RevId: 512658918
2023-03-01 17:23:01 +00:00
tonihei
38639e5a5f Ensure output format is updated in sync with stream changes.
MediaCodecRenderer currently has two independent paths to trigger
events at stream changes:
 1. Detection of the last output buffer of the old stream to trigger
    onProcessedStreamChange and setting the new output stream offset.
 2. Detection of the first input buffer of the new stream to trigger
    onOutputFormatChanged.
Both events are identical for most media. However, there are two
problematic cases:
  A. (1) happens after (2). This may happen if the declared media
     duration is shorter than the actual last sample timestamp.
  B. (2) is too late and there are output samples between (1) and (2).
     This can happen if the new media outputs samples with a timestamp
     less than the first input timestamp.

This can be made more robust by:
 - Keeping a separate formatQueue for each stream to avoid case A.
 - Force outputting the first format after a stream change to
   avoid case B.

Issue: google/ExoPlayer#8594

#minor-release

PiperOrigin-RevId: 512586838
(cherry picked from commit a02c8d855c8eae8cb3132365548ecf7a0730815b)
2023-02-28 18:05:48 +00:00
tonihei
095a0b5e6e Add workaround for wrong PerformancePoints on some devices.
Some devices were reported to have wrong PerformancePoint sets
that cause 60 fps to be marked as unsupported even though they
are supported.

Issue: google/ExoPlayer#10898

#minor-release

PiperOrigin-RevId: 512580395
(cherry picked from commit 04f0cc949f0d524d5a8ab367a15716175bacf18f)
2023-02-28 18:05:47 +00:00
tonihei
f5c696729c Correctly update output info if previous stream has been fully rendered
The output info for a new stream is marked pending until the last
sample of the previous stream has been processed. However, this fails
if the previous stream has already been fully processed. We need to
detect this case explicitly to avoid signalling the output change one
sample too late.

#minor-release

PiperOrigin-RevId: 512572854
(cherry picked from commit 39935d7f1202a4e327b968815bf499cc7bcab4c4)
2023-02-28 18:05:47 +00:00
tonihei
5862fe4d8c Use more realistic time values for MediaCodecVideoRendererTest
This test became flaky after cbb6878f9f because some of the
unrealistic frame times ended up on the same release time.

Using realistic numbers avoids the flakiness.

PiperOrigin-RevId: 512566469
(cherry picked from commit 13700e0aec06b2a7f5ed0d710690b44dbb7146bc)
2023-02-28 18:05:47 +00:00
tonihei
29eeca3359 Do not specify export flags for protected system broadcasts.
Protected system broadcasts should not specify the export flag.
Marking them as NOT_EXPORTED breaks sticky broadcasts in some
cases.

Issue: google/ExoPlayer#10970

#minor-release

PiperOrigin-RevId: 512020154
(cherry picked from commit 34b9824201314b4fa6442deac643635f2fa9e541)
2023-02-28 18:05:47 +00:00
andrewlewis
342ae31a00 Add missing variant to package transformations
PiperOrigin-RevId: 512002735
(cherry picked from commit 1ef70cd6a02aabf302a7d3c37785e928d93973c3)
2023-02-28 18:05:41 +00:00
tonihei
629e1c515f Use ArrayDeque for pending output stream changes.
The current logic uses manual array operations to keep track of pending
changes. Modernize this code by using an ArrayDeque and a data class.
This also allows to extend the output stream information in the future.

This also fixes a bug where a position reset accidentally assigns a pending
stream offset instead of keeping the current one.

PiperOrigin-RevId: 511787571
(cherry picked from commit 4e0babdcd1c272c5470572e3b29dc15e42e9221a)
2023-02-28 18:04:42 +00:00
tonihei
d0c07691d3 Indicate that SCTE-35 metadata in not supported with HLS
Issue: google/ExoPlayer#10992

#minor-release

PiperOrigin-RevId: 510988140
(cherry picked from commit 57a638aa88a4b85ca9f39573bddfc9b45df11254)
2023-02-28 18:04:03 +00:00
christosts
5f91e45f3c Skip rendering multiple frames on the same vsync
When rendering frames at a rate higher than the screen refresh rate,
e.g. playing at 8x, the player is releasing multiple frames at the same
release time (nanos) which are then dropped by the platform. The output
buffers are available later and as a result MediaCodec cannot keep up
decoding fast enough.

This change skips releasing multiple video frames on the same vsync
period and proactivelly drops the frame. The frame is counted as skipped
rather than dropped to differentiate with frames dropped due to slow
decoding.

PiperOrigin-RevId: 510964976
(cherry picked from commit cbb6878f9fef20ea440c6ffda77dd4edc00ce1f2)
2023-02-28 18:04:03 +00:00
tonihei
0563c4327f Reduce number of calls to AudioTrack.getPlaybackHeadPosition
This call may cause performance overhead in some situations,
for example if the AudioTrack needs to query an offload DSP
for the current position. We don't need to check this multiple
times per doSomeWork iteration as the value is unlikely to
change in any meaningful way.

PiperOrigin-RevId: 510957116
(cherry picked from commit 829b49d724ed220e7d58397dfdf97752aac73696)
2023-02-28 18:04:03 +00:00
bachinger
61a38a1920 Map PLAYER_STATE_LOADING to STATE_BUFFERING
#minor-release
Issue: androidx/media#245
PiperOrigin-RevId: 510456793
(cherry picked from commit a231ff4fa91471c59d2ab62945603614b8c8a742)
2023-02-28 18:04:03 +00:00
Googler
52d5ff466c Add exception cause to thrown exception
PiperOrigin-RevId: 509473556
(cherry picked from commit 08cf6db305d4ae26bc74769660aa3e687d7120ad)
2023-02-28 18:04:03 +00:00
michaelkatz
89acf3cf08 Catch IllegalArgumentExceptions in RTSP Response parsing
In parsing Describe RTSP response messages, IllegalArgumentExceptions are thrown for invalid parameters and values. These exceptions were not caught and crashed the Playback thread. Now these exceptions will be caught and their errors forwarded to the proper error handling listeners.

#minor-release

Issue: google/ExoPlayer#10971
PiperOrigin-RevId: 509207881
(cherry picked from commit 711fa44d56678ebdb5c1c3a48f940fa71810c510)
2023-02-28 18:04:03 +00:00
bachinger
65f2e16708 Add ad event listeners in the Looper event of the ad manager callback
#minor-release

PiperOrigin-RevId: 509189206
(cherry picked from commit e98670e2f94a04d90f6ec7188f748eb1c31fb09f)
2023-02-28 18:04:03 +00:00
christosts
aeff51c507 AsynchronousMediaCodecAdapter: surface queueing errors sooner
The AsynchronousMediaCodecAdapter's queuing thread stores any exceptions
raised by MediaCodec and re-throws them on the next call to
queueInputBuffer()/queueSecureInputBuffer(). However, if MediaCodec
raises and error while queueing, it goes into a failed state and does
not announce available input buffers. If there is no input available
input buffer, the MediaCodecRenderer will never call
queueInputBuffer()/queueSecureInputBuffer(), hence playback is stalled.

This change surfaces the queueing error through the adapter's dequeueing
methods.

PiperOrigin-RevId: 508637346
(cherry picked from commit a5f4651d555de8c5e99405b002bcf536cae4567e)
2023-02-28 18:04:03 +00:00
ibaker
2794992243 Add null check to ExoPlayerImpl.isTunnelingEnabled
`TrackSelectorResult.rendererConfigurations` can contain null elements:
> A null entry indicates the corresponding renderer should be disabled.

This wasn't caught by the nullness checker because `ExoPlayerImpl` is
currently excluded from analysis.

#minor-release

Issue: google/ExoPlayer#10977
PiperOrigin-RevId: 508619169
(cherry picked from commit 5e3cd7a3c3f2cd590d77ccd318c5ba4824f414b8)
2023-02-28 18:04:03 +00:00
tonihei
58650b87d6 Document spatialization behavior constants.
PiperOrigin-RevId: 508602059
(cherry picked from commit 1c29131016c9d140ca40d7f1b9038eeffb343bf7)
2023-02-28 18:04:03 +00:00
christosts
3bd0896080 Merge pull request #10959 from balachandarlinks:handle-sql-exception-in-cached-content-index
PiperOrigin-RevId: 508323432
(cherry picked from commit 20a5e468f449e29ecb6f3bd55cc8526fff74acda)
2023-02-28 18:04:02 +00:00
microkatz
3dcdfe5d7c Merge pull request #248 from lemondoglol:update-segment-size
PiperOrigin-RevId: 507784608
(cherry picked from commit 08342ea9da96240c87e3e7c486eec0b0929138da)
2023-02-28 18:04:02 +00:00
tonihei
bc9f2be8ab Fix AudioTrackPositionTracker logic for playback speed adjustments
The AudioTrackPositionTracker needs to correct positions by
the speed set on the AudioTrack itself whenever it makes
estimations based on real-time (=the real-time playout
duration is not equal to the media duration played).

This happens for the main playback path already, but not for
the mode in which the position is estimated from the playback
head position and also not in the phase after the track has
been stopped. Both cases are not very noticeable during
normal playback, but become relevant when playing in offload
mode.

PiperOrigin-RevId: 507736408
(cherry picked from commit 4ede931c2a7ad11003194cb0ee638535ecab7f31)
2023-02-28 18:04:02 +00:00
christosts
8f1aeca0a1 Detect HEVC HDR10 codec profile more accurately
In MediaCodecUtil, use Format.colorInfo, besides the codec string,
to accurately map to a 10bit HEVC profile.

PiperOrigin-RevId: 507500071
(cherry picked from commit 80dbaca0e520c32a599a379feedb49e6bed3de30)
2023-02-28 18:04:02 +00:00
sheenachhabra
ffc268eb7e Add Muxer end to end tests
Following test cases are added:
1. Mux H264 video
2. Mux H265 video
3. Mux HDR video

Each test case performs following actions:
1. Extract track and samples from input Mp4 using MediaExtractor.
2. Feed those samples into Mp4 muxer.
3. Use extractor to extract the samples from muxed file and create dump file.

PiperOrigin-RevId: 512589069
2023-02-27 19:04:32 +00:00
tonihei
a02c8d855c Ensure output format is updated in sync with stream changes.
MediaCodecRenderer currently has two independent paths to trigger
events at stream changes:
 1. Detection of the last output buffer of the old stream to trigger
    onProcessedStreamChange and setting the new output stream offset.
 2. Detection of the first input buffer of the new stream to trigger
    onOutputFormatChanged.
Both events are identical for most media. However, there are two
problematic cases:
  A. (1) happens after (2). This may happen if the declared media
     duration is shorter than the actual last sample timestamp.
  B. (2) is too late and there are output samples between (1) and (2).
     This can happen if the new media outputs samples with a timestamp
     less than the first input timestamp.

This can be made more robust by:
 - Keeping a separate formatQueue for each stream to avoid case A.
 - Force outputting the first format after a stream change to
   avoid case B.

Issue: google/ExoPlayer#8594

#minor-release

PiperOrigin-RevId: 512586838
2023-02-27 19:00:22 +00:00
tonihei
04f0cc949f Add workaround for wrong PerformancePoints on some devices.
Some devices were reported to have wrong PerformancePoint sets
that cause 60 fps to be marked as unsupported even though they
are supported.

Issue: google/ExoPlayer#10898

#minor-release

PiperOrigin-RevId: 512580395
2023-02-27 18:56:08 +00:00
tonihei
39935d7f12 Correctly update output info if previous stream has been fully rendered
The output info for a new stream is marked pending until the last
sample of the previous stream has been processed. However, this fails
if the previous stream has already been fully processed. We need to
detect this case explicitly to avoid signalling the output change one
sample too late.

#minor-release

PiperOrigin-RevId: 512572854
2023-02-27 18:47:32 +00:00
tonihei
13700e0aec Use more realistic time values for MediaCodecVideoRendererTest
This test became flaky after cbb6878f9f because some of the
unrealistic frame times ended up on the same release time.

Using realistic numbers avoids the flakiness.

PiperOrigin-RevId: 512566469
2023-02-27 18:43:16 +00:00
claincly
b0659e12f0 Allow video format change.
Uses the first mediaItem's format as the output format.

If there is `Presentation` supplied in the `Composition.effects`, add it as the
last effect of the first EditedMediaItem.

PiperOrigin-RevId: 512082659
2023-02-27 18:38:52 +00:00
kimvde
e64f70effc Clarify some threading requirements.
PiperOrigin-RevId: 512079471
2023-02-27 18:34:21 +00:00
kimvde
2b02eb8c62 Update experimentalSetForceAudioTrack Javadoc to throw
This is consistent with the code behaviour.

PiperOrigin-RevId: 512073465
2023-02-27 18:30:07 +00:00
andrewlewis
6566237153 Mark methods needing to be called on GL thread
Also remove @WorkerThread annotations, as static checks associated with
this annotation aren't useful in this part of the codebase because
almost no methods are called on the main thread.

This change should be a no-op.

PiperOrigin-RevId: 512060367
2023-02-27 18:25:40 +00:00
sheenachhabra
51f8d103dc Move DumpableBox into test-util module
We need to use this class in muxer's robolectric and instrumentation tests, hence moving it to test-util module.

PiperOrigin-RevId: 512047605
2023-02-27 18:21:26 +00:00
andrewlewis
fd0a8cadc6 Continue releasing programs on failure
Currently if releasing a shader program throws we don't release the GL
context, which could leak resources, and any errors are silently dropped
as we suppress notifications during releasing.

Improve resource cleanup and debuggability of errors from custom effects
by continuing to release shaders on failure (for runtime and
`VideoFrameProcessingException`s) and always clean up the GL context.

Note: this doesn't help with the case where releasing a custom shader
blocks for a long time, causing releasing the frame processor to
time out.
PiperOrigin-RevId: 512042501
2023-02-27 18:16:59 +00:00
kimvde
be014f30c3 Small fixes in CompositeAssetLoader
PiperOrigin-RevId: 512038052
2023-02-27 18:12:45 +00:00
tonihei
34b9824201 Do not specify export flags for protected system broadcasts.
Protected system broadcasts should not specify the export flag.
Marking them as NOT_EXPORTED breaks sticky broadcasts in some
cases.

Issue: google/ExoPlayer#10970

#minor-release

PiperOrigin-RevId: 512020154
2023-02-27 18:08:18 +00:00