2250 Commits

Author SHA1 Message Date
andrewlewis
990f7ef5b5 Select codecs without util methods
`findDecoder/EncoderForFormat` seem to be more restrictive than querying
`MediaCodecList` as done for playback, and it's not clear that the cases where
no codec is found correspond to actual cases that would fail given that it
seems this returns an empty string for many cases in production.

Switch to using `MediaCodecUtil` and `EncoderUtil` for querying codecs instead.

PiperOrigin-RevId: 525078321
2023-04-18 18:08:18 +01:00
kimvde
23b1cab56c Fix video timestamp 0 set to large value in some cases
PiperOrigin-RevId: 525064269
2023-04-18 18:07:19 +01:00
Googler
ffa969f97c Expose MssimCaluclator for use in Duetdev tests
Child: <unknown commit>

PiperOrigin-RevId: 524876651
2023-04-18 18:06:01 +01:00
tonihei
6f4fca8cbf Delete unused and unfinished legacy MediaPlayer wrapper
This was just for testing and finishing this class is not useful
as it can't wrap an existing MediaPlayer without owning it to
track its state.

PiperOrigin-RevId: 524851654
2023-04-17 17:22:18 +01:00
sheenachhabra
3b9ee1c1a1 Add NAL unit start code in csd0/csd1 test data
The actual csd data contains NAL units so it should always start with
a NAL unit start code (00 00 00 01).
This issue was not caught before because in the code there was no
validation to check whether its a valid NAL unit.

PiperOrigin-RevId: 524849867
2023-04-17 17:21:32 +01:00
tonihei
ffa3743069 Fix thread access when creating notifications for media sessions
The sessions may have different application threads for their players,
and the service with its notification provider runs on the main thread.
To ensure everything runs on the correct thread, this change labels
methods where needed and fixes thread access in some places.

Issue: androidx/media#318
PiperOrigin-RevId: 524849598
2023-04-17 17:20:36 +01:00
christosts
9081c70788 Publish experimental bandwidth meter classes
PiperOrigin-RevId: 524846153
2023-04-17 17:19:44 +01:00
tonihei
e0bb23d463 Remove unnecessary check for currentMediaItem in legacy session stub
This check was a leftover from when the metadata was generated from
the MediaItem only. Since we moved to the actual MediaMetadata fields,
the check is completely unnecessary and prevents accessing metadata
when the GET_CURRENT_MEDIA_ITEM command is not available.

#minor-release

PiperOrigin-RevId: 524837587
2023-04-17 17:18:57 +01:00
ibaker
6f89ddfe8e Rollback of a358ccb046
*** Original commit ***

Fix double initialisation of createIsoLanguageReplacementMap

In the absence of any lock `createIsoLanguageReplacementMap`
method was getting called twice due to race condition.
Used Suppliers.memoize() which is by default thread safe.

***

PiperOrigin-RevId: 524794650
2023-04-17 17:16:11 +01:00
claincly
29fc16484a Handle seek after playback ends
Reusing the loader wrappers allows us to use the current RTSP connection
without having to set up a new RTSP connection. Consequently, the Extractors,
RTP readers are also preserved.

PiperOrigin-RevId: 524663012
2023-04-17 17:14:21 +01:00
andrewlewis
011fc9d5d3 Fix possible lost end of stream notification
In `ExternalTextureManager` in seemingly rare cases end of stream is signaled
at the point where a frame is currently pending processing. In that case the
video end of stream signal was lost.  If the muxer timeout was enabled this
case would result in throwing an exception, but otherwise the operation would
get stuck

Add code to signal end of stream in `onInputFrameProcessed` as well, so that we
signal end of stream when the pending frame is handled.

Tested by running
`TransformerEndToEndTest.loopingTranscodedVideo_producesExpectedResult` several
times.

PiperOrigin-RevId: 524361069
2023-04-17 17:13:22 +01:00
huangdarwin
0e85491d4e Transformer: Update TODOs to use new bug link
PiperOrigin-RevId: 524349341
2023-04-17 17:12:28 +01:00
ibaker
b834e49f9f Use @link instead of @value
Dackka doesn't support `@value`

#minor-release

PiperOrigin-RevId: 524309695
2023-04-17 17:10:49 +01:00
kimvde
9c5fca8e65 Fix muxer failing in test
MediaMuxer does not support out-of-order video frames API 25. Use
a test file with frames in order in
loopingTranscodedAudio_producesExpectedResult. This is necessary for
tests that transmux video samples.

PiperOrigin-RevId: 524309318
2023-04-17 17:10:03 +01:00
huangdarwin
9835e58e4c HDR: Add comment describing HDR_MODE_KEEP_HDR behavior.
PiperOrigin-RevId: 524301315
2023-04-17 17:07:53 +01:00
huangdarwin
e0314f3041 HDR: Add HDR passthrough effect pixel tests.
A passthrough effect allows for testing having an intermediate
effect injected, which uses different OpenGL shaders from having no
effects.

PiperOrigin-RevId: 524276991
2023-04-17 17:06:05 +01:00
claincly
cb28960c07 Set encoded level in DefaultDecoderFactory.
PiperOrigin-RevId: 524248369
2023-04-17 17:05:03 +01:00
Googler
52a9ce3265 Shader portion is bloat given we're scaling and biasing the colors. Swap out implementation.
PiperOrigin-RevId: 524113489
2023-04-17 17:04:19 +01:00
tofunmi
2f23774d53 Add FrameDropping GlEffect
PiperOrigin-RevId: 524030672
2023-04-17 17:03:21 +01:00
sheenachhabra
a358ccb046 Fix double initialisation of createIsoLanguageReplacementMap
In the absence of any lock `createIsoLanguageReplacementMap`
method was getting called twice due to race condition.
Used Suppliers.memoize() which is by default thread safe.

PiperOrigin-RevId: 524007754
2023-04-17 17:01:41 +01:00
michaelkatz
165f4f2fd4 Use default profile-level-id if absent in Describe SDP for MPEG4-LATM
PiperOrigin-RevId: 524003092
2023-04-17 17:00:52 +01:00
tonihei
1c557e2fd1 Ensure TrackSelectionParameters overrides match existing groups
The overrides specified by a MediaController may not use the exact
same TrackGroup instances as known to the Player because the groups
have been bundled to and from the controller. This bundling may
alter the instance slightly depending on the version used on each
side of the communication and the fields set (e.g. Format.metadata
is not supported for bundling).

This issue can be solved by creating unique track group ids for
each group on the session side before bundling. On the way back,
the groups in the track selection parameters can be mapped backed
to their original instances based on this id.

#minor-release

Issue: androidx/media#296
PiperOrigin-RevId: 523986626
2023-04-13 16:30:45 +01:00
rohks
596a7c7033 Update colr box values to be overridden by bitstream boxes
#minor-release

PiperOrigin-RevId: 523983688
2023-04-13 16:30:45 +01:00
jbibik
c71e4bf1ff Extend Player interface, overloading 4 device-volume methods with flags
Previously, ExoPlayerImpl had volume flags hardcoded to SHOW_UI, but now the developer can choose what happens on volume change. The old methods have been deprecated.

PiperOrigin-RevId: 523974358
2023-04-13 16:30:30 +01:00
rohks
e033dbac03 Bump version numbers to Media3 1.0.1 and ExoPlayer 2.18.6
#minor-release

PiperOrigin-RevId: 523959161
2023-04-13 14:59:24 +01:00
ibaker
642d34ffc7 Update comment on Track.nalUnitLengthFieldLength
This field is also non-zero for h.265 tracks.

PiperOrigin-RevId: 523676455
2023-04-12 17:01:21 +01:00
sheenachhabra
6182201265 Remove cache term from TestUtil methods
PiperOrigin-RevId: 523675327
2023-04-12 17:00:36 +01:00
tonihei
c5baf2388c Rename misleading COMMAND_GET/SET_MEDIA_ITEMS_METADATA
The setter command is only used for setPlaylistMetadata and can
be named COMMAND_SET_PLAYLIST_METADATA. The getter commnad is
used to access getMediaMetadata and getPlaylistMetadata and can
be better named COMMAND_GET_METADATA to reflect this usage.

PiperOrigin-RevId: 523673286
2023-04-12 16:59:38 +01:00
andrewlewis
affc237055 Channel mix to 16-bit int not float
Previously `ChannelMixingAudioProcessor` output float because it was
implemented using the audio mixer's float mixing support.

Move the implementation over to just using the `ChannelMixingMatrix` and make
it publicly visible in the common module so it can be used by apps for both
playback and export.

Also resolve a TODO that no longer had a bug attached by implementing support
for putting multiple mixing matrices to handle different input audio channel
counts, and fix some nits in the test code.

Tested via unit tests and manually configuring a `ChannelMixingAudioProcessor`
in the transformer demo app and playing an audio stream that identifies
channels, and verifying that they are remapped as expected.

PiperOrigin-RevId: 523653901
2023-04-12 16:58:43 +01:00
tonihei
2a6472f930 Mark MediaController methods final to prevent accidental overrides
It's currently not possible to even subclass MediaController because
the constructor is package-private. To avoid any accidental usage or
future indirect subclassing, all methods can be marked as final.

PiperOrigin-RevId: 523648114
2023-04-12 16:57:44 +01:00
bachinger
e54a934398 Precedence for app provided media button receiver
This change selects the best suited media button receiver
component and pending intent when creating the legacy
session. This is important to ensure that a service can
be started with a media button event from BT headsets
after the app has been terminated.

The `MediaSessionLegacyStub` selects the best suited
receiver to be passed to the `MediaSessionCompat`
constructor.

1. When the app has declared a broadcast receiver for
 `ACTION_MEDIA_BUTTON` in the manifest, this broadcast
 receiver is used.
2. When the session is housed in a service, the service
 component is used as a fallback.
3. As a last resort a receiver is created at runtime.

When the `MediaSessionLegacyStub` is released, the media
button receiver is removed unless the app has provided a
media button receiver in the manifest. In this case we
assume the app supports resuming when the BT play intent
arrives at `MediaSessionService.onStartCommand`.

#minor-release

Issue: androidx/media#167
Issue: androidx/media#27
Issue: androidx/media#314
PiperOrigin-RevId: 523638051
2023-04-12 16:56:44 +01:00
tonihei
ae875648a7 Update available commands when setting a new player in MediaSession
#minor-release

PiperOrigin-RevId: 523633865
2023-04-12 16:55:47 +01:00
tonihei
7ee53219ff Rename ExoTrackSelection.blacklist to excludeTrack
It is not possible to provide a safe deprecation path because
BaseTrackSelection can't easily know which of the methods is
implemented by subclasses.

PiperOrigin-RevId: 523471578
2023-04-12 16:54:45 +01:00
christosts
baf1aa1cdb Change format logged when AudioSink throws InitializationException
Change what format is logged from MediaCodecAudioRenderer when
AudioSink throws InitializationException. We printed the
AudioSink's format, which most of the times is audio/raw (PCM)
and not the renderer's format. With this change both formats are
logged.

#minor-release

Issue: google/ExoPlayer#11066
PiperOrigin-RevId: 523456840
2023-04-12 16:53:43 +01:00
claincly
32be985c7c Remove setters for streamOffset.
In addition to the changes in 3a5c4277a7

This change essentially reverts 30e5bc9837 (Merged Jul 2022).

From this CL on, `VideoFrameProcessor` takes in non-offset, monotonically
increasing timestamps. For example, with one 5s and one 10s video,

- `VideoFrameProcessor`'s input should start from 0
- On switching to the second video (10s), the timestamp of the first frame in
  the second video should be at 5s.

In ExoPlayer however, `streamOffset` is managed differently and thus needs
correction before sending the frames to `VideoFrameProcessor`:
- The timestamp of the first video is offset by a large int, so the first frame
  of the first media item has timestamp (assuming) 10000000000000000
- The last frame of the first media item has 10000005000000000
- At this point the stream off set is updated to 10000005000000000
- The pts of the first frame of the second video starts from 0 again.

PiperOrigin-RevId: 523444236
2023-04-12 16:52:48 +01:00
huangdarwin
acdb7ee921 HDR: Add HDR pixel tests.
Implement HDR input support for texture output, and add HDR pixel tests.

PiperOrigin-RevId: 523417701
2023-04-12 16:51:51 +01:00
Googler
509830f38f Make PlayerView fold aware
PiperOrigin-RevId: 523413988
2023-04-12 16:51:04 +01:00
andrewlewis
d43fe3470f Fix audio encode timestamp off by one
Simplify the audio encoder input timestamp calculation. The new calculation
avoids drifting by tracking the total number of bytes encoded rather than
tracking the timestamp and remainder separately, and also makes the timestamps
match the decoder output buffer timestamps.

Also switch one of the export tests that was passing through AMR samples over
to using WAVE audio. The problem with using AMR is that the compressed samples
are not necessarily an integer number of audio frames and the shadow decoder
would pass them from input to output, so the audio encoder was receiving
non-integer numbers of audio frames.

Tested by logging the timestamps at the decoder output and encoder input with
forcing transcoding audio, and verifying that after this change the audio
timestamps are no longer off by one.

PiperOrigin-RevId: 523409869
2023-04-12 16:50:25 +01:00
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
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
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
christosts
6c55f25bfd Small clean-up on BaseRenderer
PiperOrigin-RevId: 522039856
2023-04-05 14:52:15 +01:00