2356 Commits

Author SHA1 Message Date
Rohit Singh
1ab91a64c2 Refactor and add release notes 2024-04-30 16:31:50 +01:00
ibaker
96bc9e9652 Propagate ID3 TCON frame to MediaMetada.genre
This change also includes mapping the numeric ID3v1 codes to their
string equivalents before setting them into `MediaMetadata`. This
mapping already existed, but it was previously only used when parsing
MP4 `gnre` atoms.

Issue: androidx/media#1305
PiperOrigin-RevId: 629113480
2024-04-29 10:38:51 -07:00
ibaker
e194225b32 Fix parsing some MP4 metadata fields we wrongly assumed were 1 byte
This fixes parsing the `gnre` and `tmpo` values, as seen in the test
dump changes in this CL.

Issue: androidx/media#1305
PiperOrigin-RevId: 628352773
2024-04-26 03:30:14 -07:00
ibaker
3322092070 Fix MP4 ID3 sort tag mapping
The ID3 tags are documented here:
https://wiki.hydrogenaud.io/index.php?title=Foobar2000:ID3_Tag_Mapping

The MP4 fourcc types are documented here:
https://mutagen.readthedocs.io/en/latest/api/mp4.html#mutagen.mp4.MP4Tags

From the field definitions at the top of this file:

* `TYPE_SORT_ALBUM = 0x736f616c = 'soal'`
* `TYPE_SORT_ARTIST = 0x736f6172 = 'soar'`
* `TYPE_SORT_ALBUM_ARTIST = 0x736f6161 = 'soaa'`

Issue: androidx/media#1302

#minor-release

PiperOrigin-RevId: 627486902
2024-04-23 13:29:40 -07:00
Googler
f2276f613d Fix SocketTimeoutException in CronetDataSource.
In some versions of Cronet, the request provided by the callback is not always the same. This leads to callback not completing and request timing out.

The fix changes from having one `UrlRequestCallback` per `CronetDataSource` to one `UrlRequestCallback` per `UrlRequest`. Everytime a current request is canceled, the current callback is closed.

PiperOrigin-RevId: 627379153
2024-04-23 07:21:20 -07:00
Googler
a43ffa8898 Add replaceAdTagParameters() to ImaServerSideAdInsertion.AdsLoader.
PiperOrigin-RevId: 627114711
2024-04-22 12:09:59 -07:00
tofunmi
fb037b9847 TimestampWrapper: fix signaling input capacity
fixes https://github.com/androidx/media/issues/821

PiperOrigin-RevId: 626407880
2024-04-19 10:40:59 -07:00
bachinger
09f2cda43c Promote IMA DAI API to stable
PiperOrigin-RevId: 626064956
2024-04-18 09:49:48 -07:00
tianyifeng
50fefe698d Avoid non-primary playlists continuously reloading for LL-HLS streams
For LL-HLS, the non-primary playlists originally keep reloading even after the primary playlist has been changed to another one. The reason being this is to check if the hinted(#EXT-X-PRELOAD-HINT) resource has been published or removed. If removed, the loading of it should be canceled, per the suggestion in the HLS spec:

"A Client SHOULD cancel a request for a hinted resource if it is not present in a subsequent Playlist update, such as in an EXT-X-PRELOAD-HINT tag or as part of another tag such as EXT-X-PART.  The client SHOULD ignore the results of such requests."

However, keeping the non-primary playlists reloading is not optimal. As a solution, we trigger the playlist reloading only when there is a preload chunk loading instead of every time after we have processed the playlist. Compared to the original implementation, this will save the requests of reloading non-primary playlist after we have taken action upon the preload chunk being published or removed.

Issue: androidx/media#1240
PiperOrigin-RevId: 626038032
2024-04-18 08:11:19 -07:00
andrewlewis
a58a99e84d Don't constrain audio for playout in Transformer
Transformer's input shouldn't be constrained to the number of playable audio channels on the current device because the media may be edited (to mix channels for example) or encoded for playback on another device (a server for example).

PiperOrigin-RevId: 625604243
2024-04-17 01:55:51 -07:00
michaelkatz
83d1600c7e Fix typos in 1.4.0-alpha01 release notes
PiperOrigin-RevId: 625332081
2024-04-16 08:03:17 -07:00
andrewlewis
3be49a5841 Work around incorrect channel count for raw audio
The raw audio decoder's output audio format is stereo when the number of input
channels is (for example) 10 channels. Add a temporary workaround that uses the
input channel count for raw audio. This code should be removed in future when
we bypass the decoder entirely for raw audio.

Tested manually on a WAVE file with 18 audio channels.

PiperOrigin-RevId: 625307624
2024-04-16 06:21:31 -07:00
Ian Baker
5fd1dc2e4e Add release note 2024-04-16 11:44:07 +01:00
Copybara-Service
236c341168 Merge pull request #1266 from hubert-mazur:looped_playback
PiperOrigin-RevId: 625260110
2024-04-16 02:54:47 -07:00
Marc Baechinger
a6b540545d Minor cleanup 2024-04-16 10:54:45 +02:00
tonihei
11257ecacb Forward presumed no-op seeks to handler methods in (Simple)BasePlayer
Some seek operations are currently filtered in the base classes if
the target index is not explicitly specified and the implicitly
assumed operation doesn't have an obvious target index. (Example:
calling seekToNext() at the last item in a playlist)

This is too opinionated because the actual player implementation
using this base class may be able to handle this seek request (e.g.
by adding new items on the fly or using other logic to select
the most suitable next item).

This can be solved by forwarding all seek requests to the respective
handler methods even if they are a presumed no-op. Also clarify the
Javadoc that the provided index is just an assumption if it wasn't
provided explicitly in the method call.

PiperOrigin-RevId: 624887116
2024-04-15 02:38:29 -07:00
Marc Baechinger
20e98ca125 Add release notes 2024-04-15 11:01:04 +02:00
Copybara-Service
f13c879cd0 Merge pull request #1255 from phcannesson:fix-cast-media-item-conversion
PiperOrigin-RevId: 624147863
2024-04-12 05:45:50 -07:00
bachinger
fc1d60beb9 Do not set a duration for live streams
A live window with changing duration can't be properly
displayed in a media notification. The duration constantly
changes and creates a nervous jumping seekbar that is not
really useful.

This change sets the duration for live streams to `C.TIME_UNSET`
when publishing the player state to the platform session. This
way no duration is sent to the platform session which prevents
media controls from drawing a seekbar.

Issue: androidx/media#1256
PiperOrigin-RevId: 624112541
2024-04-12 03:14:41 -07:00
bachinger
5a84e09a0e Use zero offset when delegating EMSG sample data
When delegating EMSG samples in `HlsSampleStreamWrapper`,
the offset passed into `sampleMetadata(..)` of the delegate
`TrackOutput` must be zero because it is called immediately
after `sampleData(..)` is called.

The condition to trigger this issue is that more than one
metadata samples are pending in `pendingMetadataSampleInfos`
of `FragmentedMp4Extractor` which produces non-zero offsets.

Issue: androidx/media#1002
Issue: androidx/media#1203
PiperOrigin-RevId: 623210835
2024-04-09 10:32:35 -07:00
Marc Baechinger
14fb3860e0 Update release notes 2024-04-09 17:35:40 +02:00
michaelkatz
2c015a5417 Update RELEASENOTES for 1.4.0-alpha01
#minor-release

PiperOrigin-RevId: 623158370
2024-04-09 07:20:18 -07:00
tianyifeng
9c72fa8a7a Add reset to BasePreloadManager to release all the holding sources
Compared to `release`, the `reset` method doesn't release the preload manager instance. This applies to the use case that an app wants to discard all the sources but keep the preload manager active for later usage.

Also rename the `releaseSourceInternal` to `removeSourceInternal`, as the latter sounds more generic for different preload manager implementations.

PiperOrigin-RevId: 623148723
2024-04-09 06:30:32 -07:00
michaelkatz
5e85823ea0 Use the onPresentationEnded callback to detect end of offloaded audio
In offloaded audio playback, the `DefaultAudioSink` should use the `AudioTrack.StreamEventCallback` `onPresentationEnded` to note whether the AudioTrack has completed playing all pending data.

PiperOrigin-RevId: 622885399
2024-04-08 10:23:55 -07:00
ibaker
fad3257072 Rollback of c5e894e2d6
PiperOrigin-RevId: 622866208
2024-04-08 09:21:23 -07:00
Googler
c2356e3989 Rollback of c5e894e2d6
PiperOrigin-RevId: 622292092
2024-04-05 15:11:29 -07:00
sheenachhabra
5fc35a6045 Update release notes for 1.3.1 bug fix release
PiperOrigin-RevId: 622189733
2024-04-05 08:50:27 -07:00
tianyifeng
28c70e5e54 Add remove(MediaSource) to BasePreloadManager
Both `remove(MediaItem)` and `remove(MediaSource)` return a boolean suggesting that whether the preload manager is holding the corresponding `MediaSource` and it has been removed.

PiperOrigin-RevId: 622185427
2024-04-05 08:27:27 -07:00
tonihei
e0fa697edf Refine "join" mode in video renderer for surface changes.
The join mode is used for two cases: surface switching and mid-playback
enabling of video.

In both cases, we want to pretend to be ready despite not having rendered
a new "first frame". So far, we also avoided force-rendering the first
frame immediately because it causes a stuttering effect for the
mid-playback enable case. The surface switch case doesn't have this
stuttering issue as the same codec is used without interruption. Not
force-rendering the frame immediately causes the first-frame rendered
callback to arrive too early though, which may lead to cases where
apps hide shutter views too quickly.

This problem can be solved by only avoiding the force-render for the
mid-playback enabling case, but not for the surface switching case.

PiperOrigin-RevId: 622105916
2024-04-05 01:50:14 -07:00
tianyifeng
8867642681 Use DefaultPreloadManager in shortform demo app
The `MediaSourceManager` is removed and its functionalities are replaced by `DefaultPreloadManager`.

PiperOrigin-RevId: 621884502
2024-04-04 09:39:23 -07:00
bachinger
617f9898c3 Add isPlaybackOngoing and stopMediaSessionService
This API additions help an app to implement the lifecycle of a MediaSessionService
properly and in consistency with the `MediaSessionService` being in the foreground
or not.

Not properly implementing `onTaskRemoved` is the main reason for crashes and
confusion. This change provides `MediaSessionService` with a default
implementation that avoids crashes of the service. This default implementation
uses the new API provided with this change just as an app can do.

Issue: androidx/media#1219
PiperOrigin-RevId: 621874838
2024-04-04 09:01:55 -07:00
tofunmi
896d147444 Overlay: fix the overlay anchor translation
Makes OverlayFrameAnchor works as described in the OverlaySettings documentation. Currently the code does the opposite e.g setting the anchor to (+1,-1) makes the code anchor to the top left rather than the bottom right.

PiperOrigin-RevId: 621585558
2024-04-03 11:27:43 -07:00
ibaker
c5e894e2d6 Ensure DownloadHelper doesn't leak unreleased Renderer instances
Issue: androidx/media#1224
PiperOrigin-RevId: 619935786
2024-03-28 08:17:18 -07:00
ibaker
b60cd2c033 Rollback of e665e2aee8
PiperOrigin-RevId: 619871653
2024-03-28 04:04:01 -07:00
kimvde
04a3889998 Reset maxPositionOfRemovedSources in DefaultAudioMixer
If the mixer is reset without resetting maxPositionOfRemovedSources and
then reused, the value of maxPositionOfRemovedSources can be outdated,
leading to an incorrect number of bytes being output by the mixer.

PiperOrigin-RevId: 619832502
2024-03-28 01:22:25 -07:00
Copybara-Service
8fe70332ee Merge pull request #1054 from jekopena:main
PiperOrigin-RevId: 619573181
2024-03-27 10:24:32 -07:00
tianyifeng
8f2f3bb7e4 Allow target preload status to be null to indicate not to preload
PiperOrigin-RevId: 619246259
2024-03-26 11:03:10 -07:00
tofunmi
f4fefd19f7 Document and test multi asset ultraHDR support
PiperOrigin-RevId: 619200688
2024-03-26 08:39:44 -07:00
ibaker
d00ca1e343 Plumb MP3 average bitrate from metadata frames into Format
Issue: androidx/media#1081

#minor-release

PiperOrigin-RevId: 619185083
2024-03-26 07:40:08 -07:00
tonihei
6e0f8e3b0d Remove decode-only flag
No known component is using this flag anymore and it has been
deprecated for a while for custom renderers and decoders.

PiperOrigin-RevId: 619154299
2024-03-26 05:28:27 -07:00
tonihei
ab0391167c Include nullness of MediaMetadata.extras in equals method
This ensures MediaMetadata with just non-null extras is not
considered equal to MediaMetadata.EMPTY. This makes sure the
contents are bundled when a controller sets the extras in a
new MediaItem

Issue: androidx/media#1176

#minor-release

PiperOrigin-RevId: 618876642
2024-03-25 10:05:15 -07:00
tonihei
73c0ebb214 Additional clean-up and formatting 2024-03-25 15:02:31 +00:00
tonihei
3a7d31a599 Don't set codec color info for default SDR
Some media can read color info values from the bitstream
and may partially set some of the SDR default values in
Format.ColorInfo. Setting these default values for SDR can
confuse some codecs and may also prevent adaptive ABR
switches if not all ColorInfo values are set in exactly the
same way.

We can avoid any influence of HDR color info handling by
disabling setting the color info MediaFormat keys for SDR
video and also avoid codec reset at format changes if both
formats are SDR with slightly different ColorInfo settings.

To identify "SDR" ColorInfo instances, we need to do some
fuzzy matching as many of the default values are assumed to
match the SDR profile even if not set.

Issue: androidx/media#1158
PiperOrigin-RevId: 617473937
2024-03-20 04:58:13 -07:00
huangdarwin
b126bae93d Effect: Add EGL_EXT_gl_colorspace_bt2020_hlg support, on API 34+
Confirmed that the HLG extension displays properly on Pixel 7 Pro, API 34 and Samsung S24, API 34. On these devices, this fixes the washed out HLG preview issue on API 34, where the PQ ext had a washed out look, and where the HLG ext is supported (this bug didn't occur on API 33, only 34).

More info on manual tests done to sanity-check:
* Test cases: Transformer debug SurfaceView and ExoPlayer.setVideoEffects
* Test inputs: HLG and PQ
* Test devices: Pixel 7 Pro (API 33 & 34), Samsung Galaxy S24 (API 34)
* Added debugging: Logging colorInfo used in GlUtil.createEglSurface

No regressions were seen. HLG extension is used more in API 34, and behavior stays the same on API 33. Only human-visible change without logging is that HLG content looks better on API 34, for Samsung S24 and Pixel 7 Pro.

PiperOrigin-RevId: 616131192
2024-03-15 08:06:49 -07:00
ibaker
48cffc849a Fix proguard rule for DefaultVideoFrameProcess.Factory.Builder.build()
Issue: androidx/media#1187

#minor-release

PiperOrigin-RevId: 616112879
2024-03-15 06:50:16 -07:00
ibaker
e9ed874e51 Don't emit a CuesWithTiming for zero-duration Subtitle events
It's a bit arguable whether the `Subtitle` implementation supports
zero-duration events, since `getEventTimeCount` is documented as
effectively "the number of times the cues returns by `getCues(long)`
changes", and zero-duration events violate that. However, the current
`WebvttSubtitle` impl **does** produce zero-duration events, so it
seems safer to handle them gracefully here and then, as a possible
follow-up, fix the `WebvttSubtitle` impl (or remove it completely).

Issue: androidx/media#1177

#minor-release

PiperOrigin-RevId: 616095798
2024-03-15 05:26:21 -07:00
tofunmi
f39fe82bba Support ultra HDR in effect
adding sending gainmap to shader program and applying gainmap to base in shader

PiperOrigin-RevId: 616070582
2024-03-15 03:22:54 -07:00
Copybara-Service
e9a28beb44 Merge pull request #1117 from loliball:dev_wav_align_fix
PiperOrigin-RevId: 615820438
2024-03-14 10:17:49 -07:00
tonihei
cbed80ecf3 Always set PARAMETER_KEY_TUNNEL_PEEK when tunneling
This should already be the default, but some devices seem
to not adhere to this contract and assume the default is unset.

Issue: androidx/media#1169
PiperOrigin-RevId: 614697283
2024-03-11 09:49:09 -07:00
tonihei
0e42c8945f Automatically add icon drawables for icon constants
Having a default icon available allows apps to only specify the
icon constant without having to define an icon drawable themselves
as Media3 can fill in the icon resource for backwards compatibility.

The switch util method allows R8 to easily remove unused icons, so
having default icons won't affect APK size unless the constants are
used to set up the CommandButtons.

PiperOrigin-RevId: 614623909
2024-03-11 05:06:21 -07:00