18607 Commits

Author SHA1 Message Date
sheenachhabra
65d5132f76 Create InAppMuxer in transformer
To use the InAppMuxer, the client needs to pass InAppMuxer Factory.

PiperOrigin-RevId: 530684007
2023-05-11 09:56:46 +00:00
tofunmi
00d5031dcf Disable texture input when input is HDR
Verified by running all the tests in mh (excluding the analysis tests) on a pixel 7 pro

PiperOrigin-RevId: 530655237
2023-05-11 09:54:55 +00:00
kimvde
dc4c6daf0b Fix HDR tone mapping stuck on SM device
Tone-mapping an HDR video with MediaCodec on sm-s908u1 was timing out.
The reason for that is that the decoder was dropping frames, and the
ExternalTextureManager was therefore never propagating the end-of-stream
signal.

There was already a workaround for a similar issue but restricted to
sm-f936b. Removed the model check as the bug is probably present on more
devices.

PiperOrigin-RevId: 530639437
2023-05-11 09:53:25 +00:00
bachinger
5e4421c2ba Add MediaSession.setSessionActivity(PendingIntent)
The session activity is already sent to the controller with the
`ConnectionState` when it connects. This change adds the ability to update the
activity.

This allows an app to change the intent that is used to open an activity
for the notification. An app is likely to want to change the session activity
just before the session is released. This allows to use a different activity or
more importantly the back stack of the activity for while the app is running
and when used for the playback resumption notification.

PiperOrigin-RevId: 530627102
2023-05-11 09:52:04 +00:00
kimvde
1105f194ca Avoid swallowing exceptions when switching AssetLoader
Exceptions thrown when switching AssetLoader were not reported through
the error listener. Therefore, the resources were not released and the
export was not ending.

PiperOrigin-RevId: 530626300
2023-05-11 09:50:43 +00:00
tofunmi
7875131e2a Effect: Support input via texture ID
PiperOrigin-RevId: 530624195
2023-05-11 09:49:26 +00:00
huangdarwin
2db2de5993 Transformer: Add codec support for Dolby Vision HDR video
Allow use of H265/H264 codecs for Dolby Vision video.

Also, reflow ExoPlayer code to use this new utility class

PiperOrigin-RevId: 530619388
2023-05-11 09:47:52 +00:00
kimvde
129a6e0cc6 Fix encoder expecting HDR while tone-mapping requested
If tone-mapping was requested for a device supporting HDR encoding,
isToneMapped was false in VideoSamplePipeline.EncoderWrapper. This was
causing the encoder to expect HDR.

Also did some renamings to improve readability

PiperOrigin-RevId: 530584010
2023-05-11 09:45:09 +00:00
tofunmi
b1ebd0e2a6 Change order of operations in videoSamplePipeline
similar error to 9baa6f6be5L `registerInputStream` sets the textureManager, so reordering makes sure the textureManager is set before you set the frame info. This is important for texture input, where the frame info provides the width and height.

PiperOrigin-RevId: 530579584
2023-05-11 09:43:40 +00:00
tofunmi
477994461d Image transcoding: Add support for heic/heif image formats
PiperOrigin-RevId: 530578549
2023-05-11 09:42:12 +00:00
tonihei
99dac0be0f Ensure behavior of add/setMediaItems is consistent on empty playlist
Adding items to an empty playlist is slightly different from adding
items to a non-empty playlist, because the former usually requires to
handle a change in the current item, position and playback state,
while the latter is not expected to affect the current item, position
or state.

The current ExoPlayer and SimpleBasePlayer code doesn't account for
this difference, leading to inconsistent behavior between
setMediaItem(s) and addMediaItem(s) when called on an empty playlist.

PiperOrigin-RevId: 530549928
2023-05-11 09:40:47 +00:00
andrewlewis
f0ff57882a Remove stray stuck debug logging line
PiperOrigin-RevId: 530314222
2023-05-11 09:39:17 +00:00
tofunmi
9baa6f6be5 Fix operations order in RenderingTest
For DefaultVideoFrameProcessorVideoFrameRenderingTest: `registerInputStream` sets the textureManager, so reordering makes sure the textureManager is set before you set the frame info. This is important for texture input, where the frame info provides the width and height.

PiperOrigin-RevId: 529753404
2023-05-08 15:20:14 +00:00
ibaker
eb58d20067 Add tests for MediaLibraryInfo version code consistency
`VERSION_INT` is quite long with several sections, and it's easy to make
a mistake when updating it - this should help since it checks it against
`VERSION`, which is more easily human readable/writable.

PiperOrigin-RevId: 529747023
2023-05-08 15:18:59 +00:00
tofunmi
8c5e1974f2 Version bump to media3:1.1.0-alpha01
#minor-release

PiperOrigin-RevId: 529735598
2023-05-05 17:00:08 +00:00
huangdarwin
38d3fb5382 HDR: Don't register unsupported HDR bitmap input.
Minimal fix for HDR test postsubmit breakage

PiperOrigin-RevId: 529734521
2023-05-05 16:58:34 +00:00
bachinger
f28a588809 Fix value type when unbundling LibraryResult without expected type
Calling LibraryResult.toBundle() could have caused a CastClassException.
This was because when unbundled with UNKNOWN_TYPE_CREATOR.fromBundle(Bundle),
the valueType was set to VALUE_TYPE_ITEM_LIST for all types and the MediaItem
was attempted to be casted to a list.

PiperOrigin-RevId: 529717688
2023-05-05 16:57:22 +00:00
tofunmi
f1f07dc82a Update Release Notes for media3 1.1.0-alpha01
PiperOrigin-RevId: 529715517
2023-05-05 16:56:00 +00:00
kimvde
30957df635 Remove B-frame setting from DefaultEncoderFactory
This setting is buggy on some devices (for example sm-n960f)

PiperOrigin-RevId: 529712770
2023-05-05 16:54:27 +00:00
bachinger
511b1358cd Downgrade IMA SDK to 3.29.0
#minor-release

PiperOrigin-RevId: 529710928
2023-05-05 16:53:06 +00:00
michaelkatz
b69b3423c3 Use provided Format in shouldUseBypass check
#minor-release

PiperOrigin-RevId: 529708020
2023-05-05 16:51:27 +00:00
sheenachhabra
954b694b42 Improve documentation for metadataSampleEntry method
PiperOrigin-RevId: 529693415
2023-05-05 16:49:39 +00:00
claincly
c2da310718 Remove unused variables in DVFP.
PiperOrigin-RevId: 529685584
2023-05-05 16:48:28 +00:00
ibaker
78f20257bd Javadoc tweaks for MediaSession.MediaItemsWithPosition
Also change some type parameter names in `MediaSession.BuilderBase`
because `C` now clashes with the import of `androidx.media3.common.C`.

#minor-release

PiperOrigin-RevId: 529665698
2023-05-05 16:46:48 +00:00
claincly
83b5f824f8 Add a tracing utility for debugging video related muxer timeout
PiperOrigin-RevId: 529632886
2023-05-05 16:45:38 +00:00
claincly
213740c456 Enable switching input types via InputMultiplexer.
PiperOrigin-RevId: 529624205
2023-05-05 16:43:58 +00:00
bachinger
e48dec5f2c Add MediaButtonReceiver for Media3
The media button has API support with
`Callback.getPlaybackResumption()` that apps need to override to provide
a playlist to resume playback with.

Issue: androidx/media#167
PiperOrigin-RevId: 529495845
2023-05-05 16:42:44 +00:00
tonihei
804b57ea7b Add LeakCanary to session demo app debug builds
This helps to detect accidental service/activity leaks.

PiperOrigin-RevId: 529391523
2023-05-05 16:41:33 +00:00
ibaker
0f398d511d Temporarily suppress missing permission lint in session demo
#minor-release

PiperOrigin-RevId: 529370535
2023-05-04 13:05:49 +00:00
ibaker
09b474a519 Use a for-each loop instead of forEach in PlaybackService.kt
The current code flags a lint error:

```
Error: Call requires API level 24 (current min is 16): java.lang.Iterable#forEach [NewApi]
```

I think this is a bit confusing because this is calling the Java
[`Iterable.forEach`](https://developer.android.com/reference/java/lang/Iterable#forEach(java.util.function.Consumer%3C?%20super%20T%3E))
method which was added in Java 8 (and therefore is only available on
API 24 and up), but there is **also** a Kotlin
[`List.forEach`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/for-each.html)
method which is available in all versions of Kotlin (and therefore all
Android versions). Since this is a Kotlin file, at first glance you
would assume this is the Kotlin method - but it's not.

This also doesn't seem to be flagged by Android Studio, but is caught
by Gradle lint on the command line.

#minor-release

PiperOrigin-RevId: 529112610
2023-05-03 17:30:52 +00:00
ibaker
ebcdd983e2 Fix demo app UnsafeOptInUsageError lint errors
This change:
* Adds missing `@OptIn` annotation to demo app's `ErrorMessageProvider`
* Switches from `Util.SDK_INT` to `Build.VERSION.SDK_INT` in
  `SampleChooserActivity` (`PlayerActivity` is already using this).

This code hasn't changed recently, and it doesn't fail on the `release`
branch, but it failed when I checked the `main` branch just now - so I
assume lint has updated to detect more cases where unstable APIs are
being used without opt-in. I suspect the difference is due to different
Android Gradle Plugin versions between the branches.

#minor-release

PiperOrigin-RevId: 529111669
2023-05-03 17:29:41 +00:00
huangdarwin
93e3fe418e Effect: Fix concurrent access null pointer exception
A list was being accessed from one thread when it wasn't guaranteed to be empty.

PiperOrigin-RevId: 529102141
2023-05-03 17:16:06 +01:00
tofunmi
bba760f6e5 Update translations
PiperOrigin-RevId: 529069808
2023-05-03 17:15:08 +01:00
tianyifeng
480ff93f85 Reselect track when renderer capabilities change
* Implement RendererCapabilities.Listener in DefaultTrackSelector.
* Add new methods TrackSelector.invalidateForRendererCapabilitiesChange and TrackSelector.InvalidateListener.onRendererCapabilitiesChanged.
* Add new field allowInvalidateSelectionsOnRendererCapabilitiesChange to DefaultTrackSelector.Parameter to allow opt-in of the renderer capabilities detection feature.
* Add logics of triggering track reselection when renderer capabilities change.

PiperOrigin-RevId: 529067433
2023-05-03 17:14:09 +01:00
bachinger
eac26b1838 Fix type annotation of MockPlayer.notifyPlayWhenReadyChanged
PiperOrigin-RevId: 529030412
2023-05-03 17:13:19 +01:00
tofunmi
3011a29940 Update InternetConnection check to skip check when uri scheme is null
When we created androidTests, in the past, they always had a URI pointing to a resource, therefore we always had a URI scheme. With texture input, this will not longer be the case (EditedMediaItems's may have URI.EMPTY, which have a null scheme) so we need to check for this so tests don't falsely fail.

PiperOrigin-RevId: 528848411
2023-05-03 17:12:29 +01:00
sheenachhabra
d5fc9e9627 Skip writing 0 sized samples in Mp4Muxer
The existing logic to drop (actually fail on) 0 sized samples seems no op if
if 2 out of 10 samples are of size 0.

Checked same scenario with MediaMuxer where
1. If input file has 300 samples.
2. Make every 5th sample as an empty byte buffer.
3. Output file is generated without error.
4. Output file has 240 samples.
5. Exoplayer is able to play output file (blurry).

The new change is in line with MediaMuxer behaviour.

PiperOrigin-RevId: 528798046
2023-05-03 17:11:40 +01:00
ibaker
b4b7e0e7c0 Add DataSource contract test checking scheme case insensitivity
Systems accepting URIs should treat schemes as case-insensitive
([RFC 3986 Section 3.1](https://www.rfc-editor.org/rfc/rfc3986#section-3.1)):
>  An implementation should accept uppercase letters as equivalent to
>  lowercase in scheme names (e.g., allow "HTTP" as well as "http") for
>  the sake of robustness

PiperOrigin-RevId: 528735287
2023-05-03 17:10:47 +01:00
claincly
ad2d4f5008 Mark @CallSuper on some BaseGlShaderProgram methods.
PiperOrigin-RevId: 528734663
2023-05-03 17:09:11 +01:00
ibaker
25581384e9 Add rootProject.name to decouple the AS name from the directory
By default Android Studio will name the project based on the root
directory it's opened from. This gives a consistent (and clear) name
regardless of what root directory the project is located in on the
filesystem.

Explicitly defining `rootProject.name` is recommended here:
https://docs.gradle.org/current/userguide/multi_project_builds.html#naming_recommendations

PiperOrigin-RevId: 528729078
2023-05-03 17:06:16 +01:00
ibaker
dab0260ae0 Relax some copybara transform regexes
This means that comments like `//copybara:media3-only` are now detected
(no space between `//` and `copybara`) which will ensure that lines like
this are correctly transformed for the media3 and exoplayer2 GitHub
repos:
aa4e008014/library/effect/build.gradle (L33)
PiperOrigin-RevId: 527919649
2023-05-03 17:05:25 +01:00
michaelkatz
06ac2f7990 Add UTF-16 encoded subtitle support to SsaDecoder
Issue: androidx/media#319
PiperOrigin-RevId: 527891646
2023-05-03 17:04:35 +01:00
bachinger
336d4b386f Add JavaDoc to some undocumented methods and move them
PiperOrigin-RevId: 527870443
2023-05-03 17:03:40 +01:00
claincly
349eca7ae2 Add an input switcher to switch between input types.
Also make FinalShaderProgramWrapper always receive internal texture.

This means it does not sample from a input texture, and its input color is
always linear, hence the input type does not matter.

PiperOrigin-RevId: 527869045
2023-05-03 17:02:43 +01:00
tofunmi
4b75397f4e Rollback of 5c02210305
*** Original commit ***

Effect: glFlush instead of glFinish on tex output

This is much faster (~2-3x) than glFlush. While there's a risk that GL commands
queued to the GL server may not be complete by the time non-GL commands access
the texture, this should be unlikely as we only access the texture from GL.

If we see stability issues in the future, we can reconsider and move this back
to glFinish (or GL synchronization mechanisms like fences, which are more
complex)

***

PiperOrigin-RevId: 527848094
2023-05-03 17:01:54 +01:00
huangdarwin
24343f55af effect: Rename VFP frame release to render.
renderOutputFrame actually renders frames to an output surface. We'll soon have
a releaseOutputFrame method, that would release resources associated with an
output time, so rename this to disambiguate the two methods.

Also rename onOutputFrameAvailable to onOutputFrameAvailableForRendering, to
make it clear this is not available for "release"

This change should be a renaming-only change and have no functional differences.

PiperOrigin-RevId: 527844947
2023-05-03 17:00:48 +01:00
tofunmi
3a3322dbc5 Remove volatile from boolean in BitmapTextureManager
The field is only accessed on the GL thread.

PiperOrigin-RevId: 527844674
2023-05-03 16:59:49 +01:00
bachinger
9b3a5df5ef Remove nullness warnings in session module
PiperOrigin-RevId: 527666416
2023-05-03 16:58:29 +01:00
huangdarwin
5c02210305 Effect: glFlush instead of glFinish on tex output
This is much faster (~2-3x) than glFlush. While there's a risk that GL commands
queued to the GL server may not be complete by the time non-GL commands access
the texture, this should be unlikely as we only access the texture from GL.

PiperOrigin-RevId: 527641520
2023-05-03 16:57:00 +01:00
tonihei
655c727043 Remove empty lines in release notes.
These were introduced by the auto-formatter.

PiperOrigin-RevId: 527575832
2023-05-03 16:56:15 +01:00