18461 Commits

Author SHA1 Message Date
andrewlewis
0b40bc37ab Release sample pipelines before asset loaders
The video asset loader renders decoder output to a surface texture, and if the
video sample pipeline is in the process of updating the surface texture image
at the moment when the asset loader video decoder is released this seems to
cause `MediaCodec.release` to get stuck.

Swap the release order so that we stop updating the texture before trying to
release the codec.

PiperOrigin-RevId: 523401619
2023-04-12 16:49:30 +01:00
andrewlewis
ba2c32738f Improve error logging
Log at debug level immediately when MediaCodec throws. This logging will be
output closer to the time when the error actually happened so should make it
easier to identify the order of components failing.

Downgrade logging of errors after export ends to warning level, as output may
still be fine if there was a problem after exporting completed (though it's
still worth logging a warning as the device may not be in a good state).

PiperOrigin-RevId: 523370457
2023-04-12 16:48:33 +01:00
tonihei
be85684dc9 Replace deprecated onBackPressed call
PiperOrigin-RevId: 523361561
2023-04-12 16:47:33 +01:00
huangdarwin
e4bb1045ef Test: Restrict visibility of string constants.
Turns out these could have been private, so not sure why they were public.

PiperOrigin-RevId: 522545698
2023-04-11 10:36:27 +01:00
huangdarwin
b4e7e74a2c effect: Remove duplicate javadoc.
This javadoc is also clear from the Builder.setEnableColorTransfers javadoc, so omit it here to avoid duplication.

PiperOrigin-RevId: 522404884
2023-04-11 10:35:30 +01:00
huangdarwin
0d30edae75 Test: Add TextureOutputListener for texture output tests
Before this CL, SurfaceTexture.onFrameAvailable was used to tell whether a frame
was available in the VideoFrameProcessor's output texture. This was incorrect, as
it would rely on having the texture be written to before the
SurfaceTexture.onFrameAvailableListener is invoked, leading to null-pointer-
exceptions on timeouts.

Instead of using DefaultVideoFrameProcessor different interfaces to set that we
want to output to a texture, and get that output texture, use one interface that
sets a listener, and renders to a texture iff that listener is set. As this
listener is executed on the GL thread, this also allows us to no longer need to
expand visibility for the GL task executor and tasks.

PiperOrigin-RevId: 522362101
2023-04-11 10:34:38 +01:00
tofunmi
54ebfa986a disable transfer colors in DefaultShaderProgram.createApplyingOetf
PiperOrigin-RevId: 522347729
2023-04-11 10:33:41 +01:00
bachinger
24ca6828eb Do not select unprepared media period in getMediaPeriodForEvent
There is a race with the ad period preparation having completed
and `onDownstreamFormatChanged` being called when a live stream
is joined in an ad period. In this case the stream event metadata
of the period is immediately emitted and causing an ad media period
being created that is selected in `getMediaPeriodForEvent` before
being prepared (1 out of 4).

Using an `isPrepared` flag makes sure we don't hand out the media
period to early in `getMediaPeriodForEvent`.

PiperOrigin-RevId: 522340046
2023-04-11 10:32:20 +01:00
sheenachhabra
a677cc21b0 Read H265 profile info from CSD-0 data
To set the chroma format and depth information for H265 format,the csd-0 data
needs to be parsed. The previous implementation skipped parsing
csd-0 data and hard coded values based on "profile" field in MediaFormat.

Along with above mention changes, corrected some of the comments
as per spec.

PiperOrigin-RevId: 522335595
2023-04-11 10:31:16 +01:00
bachinger
76e195ff5a Correct ad durations when timeline moves more than a single period
This change improves `ImaUtil.maybeCorrectPreviouslyUnknownAdDuration` to
handles the case when the timeline moves forward more than a single period
while an ad group with unknown period duration is being played.

PiperOrigin-RevId: 522292612
2023-04-11 10:30:27 +01:00
tonihei
14ba173dfe Add missing initial update to the subtitle button in the session demo
The button gets only updated after an onTracksChanged callback but
isn't set to the initial state similar to other changes triggered
by callbacks (e.g. updateRepeatSwitchUI)

PiperOrigin-RevId: 522274800
2023-04-11 10:29:32 +01:00
tonihei
3fc61bb7c7 Deprecate MediaMetadata folderType and stabilize mediaType+isBrowsable
PiperOrigin-RevId: 522058915
2023-04-11 10:28:39 +01:00
bachinger
e4194fc862 Make period durations of FakeMultiPeriodLiveTimeline configurable
PiperOrigin-RevId: 522046876
2023-04-05 15:27:31 +01:00
bachinger
5442c33ac7 Make migration script work with OSX bash and zsh
`sed` has a different in-place command line syntax in FreeBsd
than GNU tools. This change makes the `sed` commands work with
FreeBSD `sed` on OSX in bash and zsh shells.

Issue: androidx/media#217
PiperOrigin-RevId: 522043938
2023-04-05 15:13:42 +01:00
christosts
6c55f25bfd Small clean-up on BaseRenderer
PiperOrigin-RevId: 522039856
2023-04-05 14:52:15 +01:00
tonihei
5b1370e686 Set duration in QueueTimeline
If the duration is reported in MediaMetadataCompat, it should
also be set in the QueueTimeline to match controller.getDuration()

PiperOrigin-RevId: 522022953
2023-04-05 13:17:58 +01:00
tofunmi
d66dd50263 Change output color transfers when rendering Frame To Debug Surface
PiperOrigin-RevId: 522010318
2023-04-05 12:00:06 +01:00
tonihei
502969a42b Implement missing broadcastCustomCommand to legacy controller
And also mention a few restrictions regarding legacy components
in Javadoc.

#minor-release

Issue: androidx/media#293
PiperOrigin-RevId: 522005562
2023-04-05 11:30:55 +01:00
tofunmi
5d6ffaaf55 Fix HDR effect pipeline
NPE in toneMap_hlgFrame_matchesGoldenFile and toneMap_pqFrame_matchesGoldenFile was created because a uEnableColorTransfer uniform was being created on the HDR path, when HDR shader files don't have this uniform. (they don't support disable color transfers right now)

Fix: only create the uniform when input is SDR.

manually tested on failing tests

PiperOrigin-RevId: 522002603
2023-04-05 11:14:04 +01:00
tonihei
219967c5a3 Allow duplicated MediaItems in a legacy session
MediaItems are not meant to be unique in a playlist. If a legacy
session publishes multiple items that get converted to equal MediaItems,
the current code fails because we look up queue ids in a Map (that
doesn't allow duplicate entries).

Fix this by storing a simple list of items with additional data.

#minor-release

Issue: androidx/media#290
PiperOrigin-RevId: 521993802
2023-04-05 15:49:43 +01:00
rohks
e4cb583af2 Remove Javadoc TODO from README of decoder extensions
As most classes are used via interface only and people depending on it locally can always find the Javadoc in Android Studio directly, we don't plan to add Javadocs for these extensions module in developer.android.com.

PiperOrigin-RevId: 521993756
2023-04-05 15:48:58 +01:00
tofunmi
08a9ccc743 Effect: Add support for disabling color transfers for SDR
PiperOrigin-RevId: 521805477
2023-04-05 15:48:10 +01:00
samrobinson
c3f25651bd Use AudioFormat in SilentAudioGenerator.
PiperOrigin-RevId: 521790733
2023-04-05 15:47:24 +01:00
tonihei
ff919fe74d Mark MediaSession methods final to prevent accidental overrides
It's currently not possible to even subclass MediaSession because
the constructor is package-private. To avoid any accidental usage or
future indirect subclassing, all methods can be marked as final.

PiperOrigin-RevId: 521775373
2023-04-05 15:46:40 +01:00
sheenachhabra
28aa5e847b Move NAL unit utility classes into common
Need to use NAL unit util methods in muxer module.

PiperOrigin-RevId: 521772831
2023-04-05 15:45:35 +01:00
ibaker
69618b4819 Add a test to enforce Player remains unstable-for-implementors
This ensures that anybody implementing `Player` (which is relatively
unusual) must override at least one `@UnstableApi` method, and therefore
opt-in to the unstable API.

PiperOrigin-RevId: 521769675
2023-04-05 15:44:49 +01:00
sheenachhabra
b219be0fdd Remove edit box functionality from Mp4Muxer
PiperOrigin-RevId: 521731485
2023-04-05 15:44:04 +01:00
bachinger
e6b9bde1dd Use SKIPPED ad status when a playing ad period has been removed
PiperOrigin-RevId: 521476767
2023-04-05 15:43:17 +01:00
tianyifeng
7babcf28dc Propagate audio capabilities changes out from the audio renderers
* Add a new event `onAudioCapabilitiesChanged` in `AudioSink.Listener` interface.
* Add an interface `RendererCapabilities.Listener`, which will listen to `onRendererCapabilitiesChanged` events from the renderer.
* Add `getRendererCapabilitiesReceiver` method for `TrackSelector`, and register/unregister the `TrackSelector` as the `RendererCapabilitiesReceiver` (if implemented) when the `ExoPlayer` is initialized/released.
* Trigger the `AudioSink.Listener.onAudioCapabilitiesChanged` and further `RendererCapabilities.Listener.onRendererCapabilitiesChanged` events when the audio capabilities changes are detected in `DefaultAudioSink`.

PiperOrigin-RevId: 521427567
2023-04-05 15:42:19 +01:00
huangdarwin
167677ec84 HDR: Fix exportUnexpectedColorInfo.
PiperOrigin-RevId: 521427239
2023-04-05 15:41:37 +01:00
tonihei
694d690bc0 Improve check for invalid connection request
The check currently relies on the default value of 0 returned if the
Bundle doesn't define a pid. But in some cases, like Robolectric unit tests,
0 is a possible pid. The check can be improved by directly asserting that
the value is defined.

PiperOrigin-RevId: 521414649
2023-04-05 15:40:55 +01:00
kimvde
0bfe43866a Add test for clipped media items concatenation
This was broken and has been fixed in <unknown commit>.

PiperOrigin-RevId: 521380415
2023-04-05 15:40:09 +01:00
bachinger
95e0763ef1 Add live ad breaks for DASH multi-period streams
This includes:

- Add an ad for each LOADED event of the SDK by taking the duration
  of the ad from the media structure to exactly match the start position
  of ads and then use `addLiveAdBreak()` that is used for HLS live already.
- When the refreshed content timeline arrives, possibly correct
  the duration of an ad that has been inserted while the period duration was
  still unknown (last period of the live timeline).
- When an ad period is removed the ad group needs to be put into a condition
  that allows continuing playback.

PiperOrigin-RevId: 520919236
2023-04-05 15:39:11 +01:00
kimvde
3a5c4277a7 Fix and simplify timestamps handling
Handling of the stream offset and start position was unnecessarily
complex and even incorrect. It was going to be an issue for
concatenation of video and image input.

The stream offset is the offset added before decoding/encoding to
make sure it doesn’t fail in case of negative timestamps (which do
rarely occur).
The start position is equal to the stream offset, plus the clipping
start time if the media is clipped.

Before this change:
- Samples were offset by the start position before decoding, and this
offset was removed before muxing.
- The startPosition of the first MediaItem in a sequence was used for
all the MediaItems in this sequence (which is incorrect).
- The stream offset was removed before applying the GL effects and
added back before encoding so that it was not visible to the OpenGL
processing.

After this change:
- The start position is subtracted in the AssetLoader, so that the
downstream components don’t have to deal with the stream offsets and
start positions.
- Decoded samples with negative timestamps are not passed to the
SamplePipelines. The MediaMuxer doesn’t handle negative timestamps
well. If a stream is 10 secondes long and starts at timestamp -2
seconds, the output will only contain the samples corresponding to the
first 8 (10 - 2) seconds. It won’t contain the last 2 seconds of the
stream. It seems acceptable to remove the first 2 seconds instead.

PiperOrigin-RevId: 520916464
2023-04-05 15:38:27 +01:00
sheenachhabra
bf2d311bf1 Remove adjustable ftyp functionality from Mp4Muxer
PiperOrigin-RevId: 520886975
2023-04-05 15:37:39 +01:00
kimvde
9cdf60d791 Fix emulator tests flakiness
Releasing the player once a sequence has ended seems to make our
emulator tests flaky. Comment out until we find the cause. The player
will still be released from TransformerInternal, when the export ends.

PiperOrigin-RevId: 520886181
2023-04-05 15:36:52 +01:00
ibaker
7ca9668421 Add warning logs if DefaultDrmSessionManager is used on wrong thread
Issue: google/ExoPlayer#11008
PiperOrigin-RevId: 520864579
2023-04-05 15:36:09 +01:00
Googler
5af28a980d ...Suppress MissingSuperCall warnings on onBackPressed()...
PiperOrigin-RevId: 520709134
2023-04-05 15:35:22 +01:00
bachinger
d7010da614 Remove mediaTimeOffsetMs from EventDispatcher
The `DashMediaSource` wrongly added an offset to the media times set
to the `MediaLoadData`. With this the `startTimeMS` and `endTimeMs`
don't represent the positions in the period but in the stream.

`DashMediaSource` was the only call site that was setting the offset
to a non-zero value. So if we are using 0 for the `DashMediaSource`
as well, the offset is redundant and we can remove it everywhere.

PiperOrigin-RevId: 520682026
2023-04-05 15:34:35 +01:00
rohks
2ca9050134 Add media3 guide entries in README files
PiperOrigin-RevId: 520650881
(cherry picked from commit 766e7d7d35f20b91a2c72635ac13b10ad9d22dac)
2023-03-31 13:36:24 +01:00
rohks
d1d16659a6 Fix javadoc links in media README files
Also fixed the javadoc link in devsite and removed javadoc links from decoder extensions as it is not published yet on developer.android.com.

#minor-release

PiperOrigin-RevId: 520636868
(cherry picked from commit 6a928805d4b0f52f5f07b1f7cd75e2a7357e9397)
2023-03-31 13:35:43 +01:00
kimvde
104cfc322c Clarify and fix SequenceAssetLoader threading
PiperOrigin-RevId: 520663415
2023-03-30 17:28:46 +00:00
rohks
766e7d7d35 Add media3 guide entries in README files
PiperOrigin-RevId: 520650881
2023-03-30 17:28:03 +00:00
ibaker
2e4f49fef7 Temporarily use exoplayer2-hosted SVGs in media3 javadoc
The media3-hosted versions of these SVGs were removed due to a change in
the way the reference docs are generated. While work on getting them
hosted on developer.android.com, this change simply links to the
(identical) exoplayer2 versions in order to fix the media3 docs.

#minor-release

PiperOrigin-RevId: 520647905
2023-03-30 17:27:20 +00:00
rohks
6a928805d4 Fix javadoc links in media README files
Also fixed the javadoc link in devsite and removed javadoc links from decoder extensions as it is not published yet on developer.android.com.

#minor-release

PiperOrigin-RevId: 520636868
2023-03-30 17:26:40 +00:00
tianyifeng
cb578fcf25 Rollback of 26aee812d5
*** Original commit ***

Rollback of 6109a0eb62

*** Original commit ***

Intercept audio capabilities change in `DefaultAudioSink`

***

***

PiperOrigin-RevId: 520619600
2023-03-30 17:26:03 +00:00
ibaker
43ad45dbef Remove all RawCC references from media3
RawCC is a Google-internal subtitle format that is no longer directly
supported by this library (since 4f616d6003).

PiperOrigin-RevId: 520591591
2023-03-30 17:25:20 +00:00
tonihei
b3788ce568 Remove deprecated stop(boolean)
This method has been deprecated for over 2 years.

PiperOrigin-RevId: 520586238
2023-03-30 17:24:35 +00:00
ibaker
f4a3478d84 Use Future.get() @Deterministic annotation in OfflineLicenseHelper
This means we don't need to manually store the result of `get()` into a
local to convince the nullness checker that it remains non-null.

PiperOrigin-RevId: 520576719
2023-03-30 17:23:55 +00:00
bachinger
f599a9b8f9 Keep content timeline and ad playback states together
For multi-period live streams the content timeline for
which the global ad playback state has been split needs
to be kept together to not run into a race between
timeline refreshes and ad events.

PiperOrigin-RevId: 520358964
2023-03-30 17:23:14 +00:00