18729 Commits

Author SHA1 Message Date
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
tofunmi
0902fad55d Effect: split ending frame Processing and getting the output bitmap in tests
PiperOrigin-RevId: 527554408
2023-05-03 16:54:53 +01:00
tonihei
8c262d6c07 Fix leaks of media session service.
References to the service are kept from MediaSessionStub
and from a long-delayed Handler messages in ConnectionTimeoutHandler.

Remove strong references from these places by making the timeout
handler static and ensuring ConnectedControllersManager only keeps
a weak reference to the service (as it's part of MediaSessionStub).

Issue: androidx/media#346
PiperOrigin-RevId: 527543396
2023-05-03 16:53:44 +01:00
tonihei
e2bae0c50d Update build.gradle file with latest versions
PiperOrigin-RevId: 527504752
2023-04-27 12:29:59 +01:00
claincly
12cac0d69f Add a listener once one MediaItem is fully processed
Add `VideoFrameProcessor.registerInputStream()` to signal a new type of input.

And `InputHandler.signalEndOfCurrentInputStream()` to signal to `InputHandler`
partial input stream completion.

Fully processed means after FinalShaderProgramWrapper releases the last frame.

PiperOrigin-RevId: 527356646
2023-04-27 12:28:40 +01:00
huangdarwin
fdeeaba9d8 Effect: Call glFinish before providing VFP output texture
glFinish should be called before reading from a texture, to make sure it's been
properly rendered to.

PiperOrigin-RevId: 527302946
2023-04-27 12:27:40 +01:00
ibaker
85e449cd87 Downgrade back to Robolectric 4.8.1
This partially reverts 889f435a49
because our tests fail with 4.10 with an error like:

```
ShadowActivityThread.reset: ActivityThread not set
java.lang.NullPointerException: ShadowActivityThread.reset: ActivityThread not set
	at java.base/java.util.Objects.requireNonNull(Objects.java:246)
	at org.robolectric.shadows.ShadowActivityThread.reset(ShadowActivityThread.java:284)
	at org.robolectric.Shadows.reset(Shadows.java:2665)
	at org.robolectric.android.internal.AndroidTestEnvironment.resetState(AndroidTestEnvironment.java:657)
	at org.robolectric.RobolectricTestRunner.lambda$finallyAfterTest$0(RobolectricTestRunner.java:370)
	at org.robolectric.util.PerfStatsCollector.measure(PerfStatsCollector.java:86)
	at org.robolectric.RobolectricTestRunner.finallyAfterTest(RobolectricTestRunner.java:368)
	at org.robolectric.internal.SandboxTestRunner$2.lambda$evaluate$2(SandboxTestRunner.java:298)
	at org.robolectric.internal.bytecode.Sandbox.lambda$runOnMainThread$0(Sandbox.java:99)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
	at java.base/java.lang.Thread.run(Thread.java:830)
```

It looks like the code throwing this exception is new in Robolectric
4.10:
65654a76ce

PiperOrigin-RevId: 527290033
2023-04-27 12:26:41 +01:00
huangdarwin
3db4205ac6 Test: Add @Ignore to Analysis tests
In ASwB, all Transformer tests can be run by right-clicking on the project and
clicking "Run all tests". We cannot, however, select only some specific test
files within a project (ex. all non-analysis tests) to run tests on.

Add @Ignore to analysis tests, which are not intended to be run anyways
when determining whether Transformer is working on some device. These
tests also don't have proper skipping logic when a device doesn't support a
format, so they can't be run effectively on low-end devices anyways.

This eases manual testing, for example when debugging whether tests all pass
on a device.

When analysis tests are desired to be run, it should be easy to comment out
the @Ignore.

PiperOrigin-RevId: 527289600
2023-04-27 12:25:42 +01:00
tonihei
2cbab10419 Deprecate onPlayerCommandRequest
This method doesn't really serve a purpose that isn't handled
elsewhere. The return value is also not forwarded to anyone.

PiperOrigin-RevId: 527283166
2023-04-27 12:24:39 +01:00
bachinger
7938978b51 Allow MediaLibraryService to reject the resumption notification
To reliably reject the System UI playback resumption notification on
all API levels (specifically API 30), the backward compatibility layer
needs to return `null` for the library root.

This is not possible in the Media3 implementation. This change allows
an app to return a `LibraryResult.ofError(RESULT_ERROR_NOT_SUPPORTED)`
that then is translated to return null by the backwards compatibility
layer.

Issue: androidx/media#355
Issue: androidx/media#167
Issue: androidx/media#27

See https://developer.android.com/guide/topics/media/media-controls#mediabrowserservice_implementation

PiperOrigin-RevId: 527276529
2023-04-27 12:23:26 +01:00
tofunmi
178a323897 Update sdr internal fsh to accept input color transfer
PiperOrigin-RevId: 527271212
2023-04-27 12:22:24 +01:00
tonihei
3693ca4bbb Add MediaSession.getControllerForCurrentRequest
This is a helper method that can used to obtain information about
the controller that is currently calling a Player method.

PiperOrigin-RevId: 527268994
2023-04-27 12:21:19 +01:00
Ian Baker
fab134f0b3 Merge pull request #313 from pengbins:fix_ts_h265reader_parse_sps
PiperOrigin-RevId: 527259619
2023-04-26 15:53:58 +01:00
tonihei
9128244dc3 Use Util method for common UI play/pause button logic.
This ensures the logic is consistent and can also be easily
used from custom UIs.

PiperOrigin-RevId: 527249127
2023-04-26 15:52:50 +01:00
huangdarwin
97272c139c Effects: Output to texture without surface in VFP.
Allow the VideoFrameProcessor to output to a texture without an output surface.

Tested by updating texture output tests to no longer output to a surface.

PiperOrigin-RevId: 527244605
2023-04-26 15:51:06 +01:00
tonihei
889f435a49 Update dependencies to latest versions
The only dependencies that are not updated are the ones that need
to be kept in sync with other system (like Android source tree) or
would require a Kotlin dependency in common or exoplayer modules.

As a side effect, some demo apps now need a Kotlin config and some
additional modules require desugaring/multidex logic. To simplify
the setup, the desugaring and multidex steps are added to the common
config.

PiperOrigin-RevId: 527243950
2023-04-26 15:49:57 +01:00
huangdarwin
d8cf4449a4 Transformer: Reduce scope of createSupportedTransformationRequest
This was only used in EncoderWrapper, so move createSupportedTransformationRequest
from VideoSamplePipeline to EncoderWrapper to reduce its scope.

PiperOrigin-RevId: 527226578
2023-04-26 15:48:50 +01:00
claincly
19b979d817 Allow setting individual offset for bitmaps.
PiperOrigin-RevId: 527001582
2023-04-26 15:47:31 +01:00
tofunmi
8612d2820d Update image transcoding pipeline to signal input COLOR_TRANSFER_SRGB
The production code changes are in transformer, but the tests in effect have also been updated to confirm the is no color regression `inputColorInfo.colorTransfer=C.COLOR_TRANSFER_SRGB`

PiperOrigin-RevId: 526950435
2023-04-26 15:46:21 +01:00
tofunmi
42c9c28daf Update VideoSamplePipeline to take account of decoder colors
PiperOrigin-RevId: 526940261
2023-04-26 15:44:52 +01:00
claincly
c539cb8575 Add default impl for some InputHandler methods.
And minor fixes.

PiperOrigin-RevId: 526717927
2023-04-26 15:43:46 +01:00
sheenachhabra
67639cafd7 Open source muxer module
PiperOrigin-RevId: 526683141
2023-04-26 15:42:39 +01:00
huangdarwin
324115f6cf Effects: Allow BT2020 colors with SDR transfers
Previously, I assumed that SDR contents must be BT709, and HDR contents must be
BT2020. Turns out BT2020 is just wide-gamut, and SDR contents / transfers may be
represented in BT2020 color spaces.

Relax the check, so that we don't throw when valid BT2020 SMPTE 170M contents
are input into effects.

PiperOrigin-RevId: 526668347
2023-04-26 15:41:33 +01:00
sheenachhabra
b11dd106ae Replace MediaFormat with Format class in muxer module
PiperOrigin-RevId: 526655859
2023-04-26 15:40:40 +01:00
tofunmi
f1d9a0a819 Add nullness-compat-qual dependency for android tests
PiperOrigin-RevId: 526652129
2023-04-26 15:38:22 +01:00
claincly
f3c0256bb4 Abstract the interface of DefaultVideoFrameProcessor's input.
PiperOrigin-RevId: 526642898
2023-04-26 15:37:12 +01:00
ibaker
2d968a5d97 Rollback of 8d17faea33
*** Original commit ***

Rollback of d7983f9485

*** Original commit ***

Bump Guava version to 31.1

***

***

PiperOrigin-RevId: 526601244
2023-04-26 15:36:00 +01:00
claincly
fcec5a29c1 Fix not ignoring invalid color info.
PiperOrigin-RevId: 526595567
2023-04-26 15:34:52 +01:00
Ian Baker
171c224bc6 Add a release note for MPEG-TS H.265 SPS parsing fix
Also clean-up a comment about skipping the NAL start code
2023-04-25 18:17:44 +01:00