4780 Commits

Author SHA1 Message Date
Googler
dadf2812ec Add 'Player.getVideoSurfaceSize' that returns the size of the surface
on which the video is rendered.

Design Doc: go/aaos-mu-media-dd

PiperOrigin-RevId: 485884772
2022-11-03 15:50:19 +00:00
rohks
721487a701 Disable failing tests of FlacExtractorSeekTest
PiperOrigin-RevId: 485061783
(cherry picked from commit 55b82ff8ae491f6bcc7f3901476d2b1571a10005)
2022-10-31 15:53:41 +00:00
andrewlewis
c02d477cc2 Upgrade dackka and fix some generation errors
#minor-release

PiperOrigin-RevId: 484483080
(cherry picked from commit fc1eca10f4934fd92c84db222815fc1e77ddd5f6)
2022-10-28 10:03:56 +00:00
bachinger
f06e8ee736 Make adding ad live breaks more robust
This change makes adding ad events in live streams more robust by allowing ad
groups to grow in number of ads if more ad events are received than initially
announced by the SDK.

With the IMA prefetch feature, an AdPod can grow in size in certain conditions
like from initially 2 ads to 4 ads being part of the ad group. With this change,
if an additional ad event arrives while the ad group is still being played,
the ad group is expanded. If the event arrives late and the ad group is already
completed, a new group is created for the remaining ads.

This also covers the case where we join the live stream while an ad is being
played and we missed at least one LOADED event from the SDK. Ads of the group
before the first LOADED event are ignored in such a case.

PiperOrigin-RevId: 484214760
(cherry picked from commit 136addf640e451602163be9e4272d1e27b8ed5b8)
2022-10-27 11:10:10 +00:00
samrobinson
fe9bad1119 Move DefaultAudioSink.AudioProcessorChain to AudioProcessorChain
Split inner interface into separate file, which will go in common
module. The old interface will be deprecated and extends the new.

#cleanup

PiperOrigin-RevId: 483732226
(cherry picked from commit ad52b68c738e8321b966b904d3cd2139f7a560ef)
2022-10-25 18:31:22 +00:00
samrobinson
8debe79333 Move AudioProcessor to common.
PiperOrigin-RevId: 483699606
(cherry picked from commit dda17db261758f7211ffa793ee9cc6fea842addb)
2022-10-25 16:40:38 +00:00
claincly
053e14aaaa Add GL utility methods to get 4x4 identity and set identity
PiperOrigin-RevId: 483671580
(cherry picked from commit f5ad4e098dd71bd4f99b87350e042acab4f95746)
2022-10-25 14:47:52 +00:00
samrobinson
154cd42437 Add CanIgnoreReturnValue to AudioProcessor#configure + implementations
Although it can be useful to check the output format, it's not required or needed.

For some AudioProcessor implementations, it is stated/obvious that
the output format will match the input, in which case there is no
a need to check the return value.

#cleanup

PiperOrigin-RevId: 483403679
(cherry picked from commit a7bfa12eecb42cbdd13bd7e612603a4d400ebda4)
2022-10-24 16:27:18 +00:00
michaelkatz
b97a9593fa Change areSizeAndRateSupported to use PerfomancePoint.covers
PiperOrigin-RevId: 482461219
(cherry picked from commit 0eb30eacc7f65f84e34e038567d0dd86dc4b6e2c)
2022-10-20 12:20:14 +00:00
Marc Baechinger
fc32f0ded3 Merge pull request #183 from jasper-apps:bugfix/make-download-notification-appear-immediately
PiperOrigin-RevId: 482165983
(cherry picked from commit 405455b06c6d596552c695670664309319f5570c)
2022-10-20 03:11:46 +00:00
tonihei
ed9bc9ad5d Ensure onMediaItemTransition is sent for repeats of the same item
Currently, repeating the same item (via seekNext/Previous) implicitly
results in a seek to the default position of the current item, which
looks exactly the same as a direct seek. As a result, we don't send
onMediaItemTransition as we would for every other seekNext/Previous
call.

This can be fixed by explicitly marking the repeat case in the internal
BasePlayer/ExoPlayerImpl methods, so that the callback can be triggered.

Issue: google/ExoPlayer#10667
PiperOrigin-RevId: 481951788
(cherry picked from commit 76ce0cc69fa12a9b2592103da97dd45c15bfe4d3)
2022-10-18 17:08:09 +00:00
claincly
df15f9c5c5 Use static import for Assertions in MCVR
PiperOrigin-RevId: 481122795
(cherry picked from commit 12f7174e1f8a2c2b1f36df749b43262efb88f60a)
2022-10-14 12:30:07 +00:00
Marc Baechinger
e13bbbcdd7 Merge pull request #10578 from thucngv:release-v2
PiperOrigin-RevId: 481115402
(cherry picked from commit 9861f88f3db419553b893efd98a5e1a0c8c6287c)
2022-10-20 02:08:44 +00:00
tonihei
b3627361f5 Ensure sessions without MediaPeriodId are ended after seek to new item
We already have logic to end all session except the current one if the
current one doesn't have a MediaPeriodId yet. This is assuming that this
only happens after a seek on the app side where the player doesn't have
detailled knowledge about the MediaPeriodIds yet.

Currently this logic isn't triggered if the window we are coming from
doesn't have its MediaPeriodId either as we run into another check that
keeps sessions around until we have a valid windowSequenceNumber.

Swapping both conditions fixes this case without breaking any of the
other known transition scenarios.

Issue: androidx/media#180
PiperOrigin-RevId: 480866465
(cherry picked from commit 6070d9110a9cec61f6073c7669f2f8185a635767)
2022-10-13 12:29:51 +00:00
tonihei
dc805232a3 Treat NO_VALUE as zero when adding up total required bitrate
We currently use the literal -1 (=NO_VALUE) when adding up the
total. Tracks without known bitrate can be ignored in the
calculation, but we should use an explicit value of 0.

#minor-release

Issue: google/ExoPlayer#10664
PiperOrigin-RevId: 480048126
(cherry picked from commit af19e0ea890e7b274b6f75f409f00f11e11c1c81)
2022-10-10 11:11:30 +00:00
michaelkatz
e8a5ac91ef Adjust track selection with Dolby Vision if display does not support
If the sample type is Dolby Vision and the display does not support Dolby Vision, then the capabilities DecoderSupport flag is set to DECODER_SUPPORT_FALLBACK_MIMETYPE. This denotes that the renderer will use a decoder for a fallback mimetype if possible. This alters track selection as tracks with DecoderSupport DECODER_SUPPORT_PRIMARY are preferred.

UnitTests included
-DefaultTrackSelector test that checks track selection reordering with DECODER_SUPPORT_FALLBACK_MIMETYPE
-MediaCodecVideoRenderer test that checks setting of DecoderSupport flag based on Display's Dolby Vision support

Issue: google/ExoPlayer#8944
PiperOrigin-RevId: 480040876
(cherry picked from commit a366590a0425ff138520752e2fc94c70429c20ab)
2022-10-10 10:35:17 +00:00
tianyifeng
d2f7fb1d50 Provide access to original media timestamps in AudioSink.
* Add `setOutputStreamOffsetUs(long)` method in `AudioSink`.
* Add private methods `setOutputStreamOffsetUs(long)` method in `MediaCodecRenderer` and `DecoderAudioRenderer`.
* Add protected method `onOutputStreamOffsetUs(long)` method in `MediaCodecRenderer`, in which:
  * `MediaCodecRenderer` itself will be no-op for this method.
  * `MediaCodecAudioRenderer` will propagate this value to its `audioSink`.
* Add logics in `DecoderAudioRenderer` to calculate `outputStreamOffsetUs`.

PiperOrigin-RevId: 479265429
(cherry picked from commit 4c73241058041fd978e9748b2158168d4e6e702d)
2022-10-06 09:58:37 +00:00
samrobinson
d348157777 Fix badly formatted AudioProcessor javadoc.
PiperOrigin-RevId: 476909855
(cherry picked from commit 9b1909e56362a5b44ba41d8cad9c3d927bdb650b)
2022-09-26 16:00:10 +00:00
tonihei
289d039410 Add setPreferredAudioDevice method to ExoPlayer
This allows to access the associated functionality of AudioTrack and
fills a feature gap to MediaPlayer, which has a similar method.

Issue: androidx/media#135
PiperOrigin-RevId: 476398964
(cherry picked from commit ccb820dd2f43ff20dff06a92a4e29c13676e647d)
2022-09-23 17:05:43 +00:00
Marc Baechinger
d648c1910c Merge pull request #123 from stoyicker:wrapping_media_source
PiperOrigin-RevId: 476376463
(cherry picked from commit 8623f1f01657abc6a1359f3677a59d1cbde07b37)
2022-10-19 23:42:52 +00:00
michaelkatz
9ac9322a45 Try alternative decoder for Dolby Vision if display does not support
If the sample type is dolby vision and the following conditions match
a)There is a supported alternative codec mimetype
b)Display does not support Dolby Vision
Then getDecoderInfos will return the alternative types.

Issue: google/ExoPlayer#9794
PiperOrigin-RevId: 476356223
(cherry picked from commit 94a88e93d91e86c93239639a65612eab297efa9b)
2022-09-23 13:43:21 +00:00
ibaker
eb496dabcd Work around a bug in the Android 13 ClearKey implementation
The ClearKey CDM will attach an 'invalid' URL in `KeyRequest` objects,
when the documentation states this should be an empty string if a
default URL is not known.

#minor-release

PiperOrigin-RevId: 476113513
(cherry picked from commit 331d4d626fcb1b65088c7ab849c0a0a3f5f6ba0e)
2022-09-22 15:59:44 +00:00
rohks
a6f58bdb29 Fix instrumentation tests not working via Gradle
PiperOrigin-RevId: 475560401
(cherry picked from commit 6015f052ba1b21bea4ded5bfc4924dc1c096b07a)
2022-09-20 15:25:38 +00:00
yschimke
3af297101c Fix tracing under offload.
Currently doSomeWork is never closed and so tracing is deceiving.

See https://screenshot.googleplex.com/eZDzn5APpBNnhe5

PiperOrigin-RevId: 474755816
(cherry picked from commit 005b73c82a1a3264a7167ffdf93a9387c4d22b95)
2022-09-16 08:26:54 +00:00
samrobinson
766b9cd385 Clarify the replaceOutputBuffer parameter because count is unclear.
PiperOrigin-RevId: 474279220
(cherry picked from commit 3e0ad6d8042c9e6604c281e283885b9e07eb8786)
2022-09-14 13:54:06 +00:00
bachinger
b47c7a37ac Add withAvailableAd for server side inserted ad groups
#minor-release

PiperOrigin-RevId: 472714732
(cherry picked from commit 072f376b4839b6d4e71bcd09366695b3b9fc2c02)
2022-09-07 14:01:26 +00:00
tonihei
8df931b1fe Discard backbuffer before playback gets stuck.
If the back buffer is using too much memory, there is a risk
playback could get stuck because LoadControl refuses to load
further data. This eventually results in a stuck-buffering
playback error.

We can detect this case, clear the back buffer and then ask
the LoadControl again to avoid failing playback in such a case.

PiperOrigin-RevId: 472679797
(cherry picked from commit 125646e4c98e80b35d1a8b195300d324a9aaf2b5)
2022-09-07 10:09:29 +00:00
bachinger
d7d75a0157 Update presentation time of metadata when the stream offset changes
The stream offset is used to calculate the presentation time of
a metadata object when reading and later when playing, to calculate
the current presentation time to decide whether to send the metadata
to the output.

Accordingly, the presentation time of a pending metadata that has been
calculated with a given offset needs to be recalculated when the
stream offset changes.

#minor-release

PiperOrigin-RevId: 472499943
(cherry picked from commit 5a1223777c4d4ee2faa4043be2079971e44093a9)
2022-09-06 17:40:52 +00:00
Marc Baechinger
d2623dda9b Merge pull request #10549 from ferhatparmak:release-requirementswatcher
PiperOrigin-RevId: 472488921
(cherry picked from commit 92cfa7467b8f74daab22276c6db4e885b76e7c28)
2022-10-19 21:14:45 +00:00
Marc Baechinger
0a0df93334 Merge pull request #10570 from Artemych:fix/progressive_downloader_infinite_loop
PiperOrigin-RevId: 472475124
(cherry picked from commit 9c56b2c4b631062731ccfc0d8e5b5c105449074c)
2022-10-19 21:10:57 +00:00
Googler
ec91dfc693 Fix 3 ErrorProneStyle findings:
* Non-standard parameter comment; prefer `/* paramName= */ arg`
  (see http://go/bugpattern/ParameterComment) (3 times)

This CL looks good? Just LGTM and Approve it!
This CL doesn’t look good? This is what you can do:
* Revert this CL, by replying "REVERT: <provide reason>"
* File a bug under go/error-prone-bug for category ErrorProneStyle if there's an issue with the CL content.
* File a bug under go/rosie-bug if there's an issue with how the CL was managed.
* 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/media/METADATA which is reachable following include_presubmits from //depot/google3/third_party/java_src/android_libs/media/METADATA.
Anything wrong with the signup? File a bug at go/clrobot-bug.

#codehealth

Tested:
    Local presubmit tests passed.
PiperOrigin-RevId: 472254253
(cherry picked from commit 83966478960ae6c0f882e523d73848edab95fd3a)
2022-09-05 12:08:04 +00:00
Googler
fc8edfcd48 Fix 19 ErrorProneStyle findings:
* Non-standard parameter comment; prefer `/* paramName= */ arg`
  (see http://go/bugpattern/ParameterComment) (19 times)

This CL looks good? Just LGTM and Approve it!
This CL doesn’t look good? This is what you can do:
* Revert this CL, by replying "REVERT: <provide reason>"
* File a bug under go/error-prone-bug for category ErrorProneStyle if there's an issue with the CL content.
* File a bug under go/rosie-bug if there's an issue with how the CL was managed.
* 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/media/METADATA which is reachable following include_presubmits from //depot/google3/third_party/java_src/android_libs/media/METADATA.
Anything wrong with the signup? File a bug at go/clrobot-bug.

#codehealth

Tested:
    Local presubmit tests passed.
PiperOrigin-RevId: 471022923
(cherry picked from commit 674b3d4575ae6fdb59ae9db58be52151bbcae3a6)
2022-08-30 17:07:31 +00:00
rohks
e74584e6a0 Switch incorrectly configured native multidex to legacy
Native multidex can only be used for binaries with minSdkVersion of 21 or higher, but minSdkVersion was specified to 16.

PiperOrigin-RevId: 470003836
(cherry picked from commit 142d1c062c4ed4fba450465588217ae5506fece3)
2022-08-25 16:07:42 +00:00
tonihei
d5710d3171 Define CueGroup.EMPTY_TIME_ZERO for convenience
We create an empty CueGroup in many places as default or
where none is needed. Instead, we can define a constant
for this purpose and reuse it.

PiperOrigin-RevId: 467944841
(cherry picked from commit 29208ec1ed4d78fa86af33b81a2b32f3151b9004)
2022-08-16 16:27:56 +00:00
christosts
909953b84a Increase max sample size for HEVC.
Increase the estimated max sample size for HEVC by 2x, and set a minimum
size of 2MB. The 2MB will be applied for resolutions up to 1080p, after
which the new calculation takes effect. This is in par with the
platform's HEVC software decoder.

PiperOrigin-RevId: 467641494
(cherry picked from commit d3d5ffce91452ebf1edf51a0c0c9d80ad29fe0b6)
2022-08-15 11:47:42 +00:00
yschimke
7218cb961b Make AudioTrackBufferSizeProvider public.
Was getting "java.lang.IllegalAccessError: Illegal class access" in debug app.

PiperOrigin-RevId: 465562541
(cherry picked from commit c09b34a61be80f250bac6a5e1f56e8180f68b9e2)
2022-08-05 14:51:07 +00:00
yschimke
6865cd4d07 Expose AudioOffload track state.
Adds a new event to AudioOffloadListener to get the offload state of the track, which indicates when software decoding is taking place.

PiperOrigin-RevId: 465264362
(cherry picked from commit fe2b846552e1dc0095a409a3407c328e38bd6a30)
2022-08-04 09:47:41 +00:00
yschimke
318d838258 AudioOffload recovery.
Avoids disabling Offload on a write error, and instead relies on this being disabled on the AudioTrack init. It will no longer recover by disabling offload.

PiperOrigin-RevId: 465248917
(cherry picked from commit 2fbe1bbfb3c533c370c07a4f45068c00ea9c6efb)
2022-08-04 08:00:57 +00:00
huangdarwin
6a3d7f6079 HDR: Centralize getting Colorinfo from MediaFormat
* Sets KEY_HDR_STATIC_INFO from MediaFormat in the DefaultCodec.
* Adds checks in mediaparser to ensure color space, range, and transfer are valid
  values.

PiperOrigin-RevId: 463921325
(cherry picked from commit 44c42fef2aaa65ba78c52883e3fcec94c8d7ad2d)
2022-07-28 21:07:43 +00:00
tonihei
f0e49e8c2c Ignore stale events in StreamEventCallbackV29.
Despite unregistering the callback and clearing pending Handler
messages, the callback may still receive pending calls if they
are already triggered by the AudioTrack. Instead of asserting
that the track is correct, we should gracefully ignore stale
events.

PiperOrigin-RevId: 463851393
(cherry picked from commit 3650c2970aebab16a1ced17f849631cea452085b)
2022-07-28 16:08:21 +00:00
christosts
d03163f172 Support ApplicationVersion = 1 for HDR10+
MediaCodecRenderer allows passing HDR10+ out-of-bound metadata
with ApplicationVersion = 1.

PiperOrigin-RevId: 463822315
(cherry picked from commit 81d1dafec60b1bacb28b61cda9ca74de1410ec0d)
2022-07-28 13:24:08 +00:00
Marc Baechinger
c262276686 Merge pull request #126 from stoyicker:cap_concurrent_remove_tasks
PiperOrigin-RevId: 463792127
(cherry picked from commit 3b5a53f1a618f698d476742ff7c88b45cb366d59)
2022-10-19 15:04:14 +00:00
Googler
95b0b9ccba DownloadService: Attempt to clarify the static map
PiperOrigin-RevId: 463315188
(cherry picked from commit 02eb6e96c58f104b9683f7f79fd47a7af6046406)
2022-07-26 12:49:34 +00:00
ibaker
57dbf22bfd Annotate methods that always return this with @CanIgnoreReturnValue
It's always safe to ignore the result of these methods, because the
caller already has a reference to the returned value.

PiperOrigin-RevId: 462388947
(cherry picked from commit 21cab6124de7b65f1af016cfc260555fa0b6e738)
2022-07-21 16:24:07 +01:00
olly
8f30563192 Expand setOutputSurface workaround to more FireOS devices
Issue: google/ExoPlayer#10454
PiperOrigin-RevId: 462375294
(cherry picked from commit e5a1e00b369b4d5ae7ac2c4c6a584b503098aa02)
2022-07-21 15:03:54 +01:00
ibaker
59fc51ea4c Add fail-fast null checks to the stable Player API
This will help developers self-diagnose issues like Issue: google/ExoPlayer#10392
where the NPE occurs far from the original null value because a field
gets assigned to null.

This change aims to ensure that every stable method on Player,
ExoPlayer and ExoPlayer.Builder that takes a non-null type will fail
with an NPE before returning.

#minor-release

PiperOrigin-RevId: 461846580
(cherry picked from commit 080db2a09b9ebc31fb346e0beb0ea7440df795a5)
2022-07-19 11:05:40 +00:00
tonihei
2d640e4953 Use SingleThreadExecutor to release AudioTracks
We currently start a simple Thread to release AudioTracks
asynchronously. If many AudioTracks are released at the same
time, this may lead to OOM situations because we attempt to
create multiple new threads.

This can be improved by using a shared SingleThreadExecutor.
In the simple case of one simmultaneous release, it's exactly
the same behavior as before: create a thread and release it
as soon as it's done. For multiple simultanous releases we
get the advantage of sharing a single thread to avoid creating
more than one at the same time.

Issue: google/ExoPlayer#10057
PiperOrigin-RevId: 460698942
(cherry picked from commit 1e8d163107283bbcd459aa787685fa4e1ab18531)
2022-07-13 13:24:04 +00:00
tonihei
63a0dd8bdd Add method to check if tunneling is enabled.
Issue: google/ExoPlayer#2518
PiperOrigin-RevId: 460482615
(cherry picked from commit ab1fff404c38241cd7e0ac9c201f0fb152bf723f)
2022-07-12 16:31:38 +00:00
tonihei
5729db9d6a Fix DefaultAudioSinkTest flakiness.
Some calls to handleBuffer return false while a previous
flush is still handled in the background.

Fix this by either asserting the method returns true if
we don't expect any delay, or calling it repeatedly until
it returns true (within a timeout).

PiperOrigin-RevId: 460474419
(cherry picked from commit 4289708323442f088258c67695b74eefa9a5fb83)
2022-07-12 15:54:18 +00:00
rohks
583c12f843 Make MetadataRenderer configurable to output metadata early.
PiperOrigin-RevId: 457974611
(cherry picked from commit 14f75c162f85ac083c8b19b74790b4a6f921c68f)
2022-06-29 14:47:12 +00:00