4077 Commits

Author SHA1 Message Date
ibaker
d76ee54ca6 Add two MP4 samples with metadata
The first has a string genre, and various other values set, generated
from `sample.mp4` with the command below [1].

The second has a numeric genre, to test `gnre` atom parsing. This
parsing is currently broken, the fix is in a follow-up change. This
file was also generated from `sample.mp4` with the command below [2].

This change also includes `CommentFrame.text` in its `toString`
representation, otherwise there's no difference between e.g. different
levels of `ITUNESADVISORY` in the extractor dump files.

Issue: androidx/media#1305

-----

[1]

```shell
$ AP_PADDING="DEFAULT_PAD=0" \
    AtomicParsley sample.mp4 \
    --artist "Test Artist" \
    --album "Test Album" \
    --tracknum 2/12 \
    --disk 2/3 \
    --year 2024  \
    --genre "Gorpcore" \
    --bpm 120 \
    --compilation true \
    --advisory clean \
    --gapless true \
    --sortOrder artist "Sorting Artist" \
    --sortOrder album "Sorting Album" \
    --preventOptimizing \
    -o sample_with_metadata.mp4
```

[2]
```shell
$ AP_PADDING="DEFAULT_PAD=0" \
    AtomicParsley sample.mp4 \
    --genre "Metal" \
    --preventOptimizing \
    -o sample_with_numeric_genre.mp4
```

PiperOrigin-RevId: 628345458
2024-04-26 02:53:33 -07:00
ibaker
acb3a54dee Add MediaMetadata to playback test dump files
This change also adds some runtime redirection of calls to
`Dumper.add(String, Object)` to `add(String, byte[])` if
`value instanceof byte[]`. This simplifies the implementation of
`PlaybackOutput.dumpIfNotEqual` and seems like a reasonable amound of
'magic' for a test utility.

Issue: androidx/media#1305
PiperOrigin-RevId: 628119473
2024-04-25 10:35:18 -07:00
tofunmi
5ee6c9b16d ultraHdr test: add checks for devices with invalid color formats
PiperOrigin-RevId: 628101730
2024-04-25 09:37:16 -07:00
kimvde
bf266c96a9 Set stream offset on video sink
PiperOrigin-RevId: 628084729
2024-04-25 08:32:23 -07:00
kimvde
a6eef7b8d8 Set clock on VideoSink
PiperOrigin-RevId: 628083794
2024-04-25 08:28:14 -07:00
kimvde
c87940eb27 AudioGraph refactoring: configure mixer and add sources in one place
PiperOrigin-RevId: 628076773
2024-04-25 08:02:00 -07:00
tonihei
13a3aa7e77 Add TestPlayerRunHelper run(player).untilBackgroundThreadCondition(..)
This method is useful for cases where the target condition can
become true outside of a message on the main thread. To ensure we
don't execute the rest of the test method in parallel with other
code, we have to introduce artifical messages on the main thread
that check the target condition.

PiperOrigin-RevId: 628072444
2024-04-25 07:43:19 -07:00
kimvde
00ce572a4f Always reconfigure video sink for video after image
Before this CL, the video sink was not reconfigured for the second video
in a sequence with video-image-video. For example, the stream offset
and listener were not set for the second video.

PiperOrigin-RevId: 628065991
2024-04-25 07:19:07 -07:00
bachinger
0e3b05c67d Add metadata field durationMs
PiperOrigin-RevId: 628038241
2024-04-25 05:05:42 -07:00
tonihei
ed1cf35f30 Extend async crypto flag to audio
This is only supported from API 35

PiperOrigin-RevId: 628014091
2024-04-25 03:07:44 -07:00
tonihei
d0d6ce52a5 Import androidx.media
This imports all the classes and resources needed by our code.

We still have the nominal dependency on the artifact as we need
to access the Parcelable CREATORs of MediaSessionCompat.Token,
MediaDescriptionCompat, RatingCompat and MediaBrowserCompat.MediaItem.

Mechanical import steps:
 - Put all files under a new 'legacy' package and change all import
   statements accordingly.
 - Reformat to adhere to Media3 java style guide
 - Remove all existing @RestrictTo annotations and replace them with
   top-level @RestrictTo(LIBRARY) on all classes in the new package.
 - Remove @NonNull annotations and fixed nullability test errors
 - Fix HTML javadoc build errors
 - Fix Lint errors (but not warnings)

The code still contains many lint warnings that will be fixed
separately.

PiperOrigin-RevId: 627999285
2024-04-25 01:56:23 -07:00
tonihei
43d1fa933c Remove flakiness from MCCPlaybackStateCompatActionsWithMediaSessionTest
The tests were reigstering a listener to wait for the first event, but
this first even may have happened already by the time the listener is
registered. Instead we can wait until the controller is connected and
assume that the initial state already arrived.

PiperOrigin-RevId: 627683245
2024-04-24 04:27:44 -07:00
tonihei
f9ea4f0444 Fix error-prone warning comparing CharSequence with String
PiperOrigin-RevId: 627679923
2024-04-24 04:11:56 -07:00
kimvde
579386ff27 Set VideoFrameMetadataListener on VideoSink
PiperOrigin-RevId: 627652670
2024-04-24 02:04:23 -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
claincly
124c70ac26 Add MIME type to match any image
PiperOrigin-RevId: 627486539
2024-04-23 13:27:42 -07:00
rohks
8ff9e4a838 Add test for H.264 I-frames only track in TsExtractorTest
Sample is created by re-encoding the existing H.264 sample with `ffmpeg`.

PiperOrigin-RevId: 627470063
2024-04-23 12:30:11 -07:00
kimvde
abd0ff7352 Remove configure methods
Pass the parameters to the constructor instead

PiperOrigin-RevId: 627420999
2024-04-23 09:59:56 -07:00
tonihei
bf9f8a3719 Treat playback after stop as a new playback
This implies we should report it as STATE_JOINING_FOREGROUND
instead of STATE_BUFFERING.

PiperOrigin-RevId: 627406584
2024-04-23 09:09:15 -07:00
tofunmi
73f614b14d Effect: support disabling color transfers when HDR->SDR tonemapping
also makes the setter more flexible by ignoring the value of the setter when the output is hdr rather than throwing (since all HDR content must be have a linear color space)

PiperOrigin-RevId: 627388436
2024-04-23 08:02:30 -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
sheenachhabra
b813bd3976 Use silence audio in RawAssetLoader tests
This is avoid dependency on `MediaExtractor` whose
behaviour is not consistent across different API versions.

PiperOrigin-RevId: 627330485
2024-04-23 03:38:31 -07:00
bachinger
4091303c7e Read device volume directly from binder with legacy session
PiperOrigin-RevId: 627328652
2024-04-23 03:31:33 -07:00
bachinger
e866cb02d6 Make replaceAdTagParameters unstable API for now
PiperOrigin-RevId: 627323264
2024-04-23 03:04:51 -07:00
kimvde
8da6938782 Always initialize VideoSink in renderer
Instead of initializing the video sink outside the renderer with an
empty format for composition preview, we initialize it in the renderer
with the input format for video.

PiperOrigin-RevId: 627313708
2024-04-23 02:20:18 -07:00
kimvde
e3caed1441 Move VideoSinkProvider.initialize to VideoSink
PiperOrigin-RevId: 627290721
2024-04-23 00:37:01 -07:00
Googler
a43ffa8898 Add replaceAdTagParameters() to ImaServerSideAdInsertion.AdsLoader.
PiperOrigin-RevId: 627114711
2024-04-22 12:09:59 -07:00
claincly
7aed9d40a0 Clean up nullness annotation
PiperOrigin-RevId: 627114088
2024-04-22 12:07:07 -07:00
Googler
430fafded6 Boxes: Update STTS duration calculation.
Update the function convertPresentationTimestampsToDurationsVu
to return a list of duration in decoding order,used in the
creation of STTS boxes.

PiperOrigin-RevId: 627052898
2024-04-22 08:59:06 -07:00
sheenachhabra
03a041c452 Pass BufferInfo in writeSampleData() method in Transformer/Muxer.java
This is to eventually replace Transformer/Muxer.java with Muxer/Muxer.java

PiperOrigin-RevId: 627043808
2024-04-22 08:23:34 -07:00
sheenachhabra
86ef571644 Replace trackIndex with TrackToken in Transformer
This is to eventually replace Transformer/Muxer.java with Muxer/Muxer.java

PiperOrigin-RevId: 627027254
2024-04-22 07:20:38 -07:00
sheenachhabra
7c7e7ea629 Add API to disable sample copy in Mp4Muxer
PiperOrigin-RevId: 627002635
2024-04-22 05:26:39 -07:00
tofunmi
8ae9e81196 add test for speed adjustments, audio removed and a forced audio track
add coverage for key use case for speed adjustments

PiperOrigin-RevId: 626957912
2024-04-22 02:00:46 -07:00
claincly
716aedd019 Fix image up-side-down in when playing a Composition
When playing a Composition, the color transfer of an image is incorrectly
passed down to be SMPTE170M, but it should be SRGB.

PiperOrigin-RevId: 626425396
2024-04-19 11:37:15 -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
tofunmi
0bc5ac24b0 Effect: remove duplicate inputColorInfo checks
We currently check certain properties about inputColorInfo twice: once in checkColors in the DVFP and once when creating the samplers in the defaultshaderprogam. The inputcolorinfo shouldn't change between these two components so removing the checks in the shader program to have one source of truth for inputColorInfo checks, which will make the code simpler when it comes to adding to color-related features (like the ones related to removing de-gamma-ing)

PiperOrigin-RevId: 626400960
2024-04-19 10:18:33 -07:00
bachinger
09f2cda43c Promote IMA DAI API to stable
PiperOrigin-RevId: 626064956
2024-04-18 09:49:48 -07:00
tofunmi
300e83414d Effect: Change link in shader ahead of deletion
PiperOrigin-RevId: 626044561
2024-04-18 08:38:41 -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
tonihei
e1c62df256 Remove media1 public API dependencies from session module
This is the preparation to import the media1 classes as
private copies into media3.

- Reword Javadoc to use @code instead of @link to media1 types. This
  avoids accidentally linking to the future internal types.
- Use fully qualified names for the converter methods to and from
  MediaSessionCompat.Token to ensure they keep the publicly available
  type.
- Add new public variable that is directly referenced from our code
  instead of referring the the media1 equivalent.
- Clean up tests that are using media1 types to make assertions on
  media3 fields and vice versa (mostly when using LegacyConversions
  in the test method). This also makes the tests more DAMP than DRY.
  (also moved LegacyConversionsTest to a unit test as it doesn't test
  cross-process communication)

PiperOrigin-RevId: 626000082
2024-04-18 05:33:10 -07:00
kimvde
34c31b0a33 Fix SequenceAssetLoader incorrectly reporting MediaItem change
Before this CL, if all the video (resp. audio) samples were fed before
the audio (resp. video) output format was reported, the
SequenceAssetLoader was incorrectly reporting a MediaItem change with a
null format.

PiperOrigin-RevId: 625978268
2024-04-18 03:44:18 -07:00
sheenachhabra
4aa2fb883f Add RawAssetLoader and deprecate TextureAssetLoader
All the changes are based on existing implementations
and their related tests.

No new functionality is being added.

PiperOrigin-RevId: 625756836
2024-04-17 11:48:43 -07:00
andrewlewis
2f8ce053b9 Avoid crash when testing spatialization of high channel count audio
For audio with more than 12 channels, no channel mask was determined, which
meant that the code to check spatializability would throw because of creating
an invalid audio format.

Return early if the channel mask was invalid instead (and assume spatialization
isn't possible).

PiperOrigin-RevId: 625618683
2024-04-17 03:03:01 -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
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
Copybara-Service
ea48fe579e Merge pull request #1272 from stevemayhew:p-add-hook-for-load-error-handler
PiperOrigin-RevId: 625285300
2024-04-16 04:48:27 -07:00
sheenachhabra
794900bfb8 Update addMetadata method in Transformer/Muxer.java
This is to align the interface with Muxer/Muxer.java and
then finally replace it.

PiperOrigin-RevId: 625283725
2024-04-16 04:40:13 -07:00
Ian Baker
e13d7e632e Fix javadoc link reference 2024-04-16 11:49:06 +01:00
Ian Baker
001ebb68f3 Formatting, nullness and javadoc rewording 2024-04-16 11:42:31 +01:00
Steve Mayhew
566c0b3eea Allows setting LoadErrorHandlingPolicy for DRM
The `DefaultDrmSessionManager` allows setting this policy.  This change
simply plumbs the setting up to the `DefaultDrmSessionManagerProvider`
2024-04-16 11:42:31 +01:00