966 Commits

Author SHA1 Message Date
bachinger
fd81d2a1b2 Use a better sample video for testing
The replaced one had barely no movement and audio in
the first second.

PiperOrigin-RevId: 584283388
2023-11-21 04:21:07 -08:00
ibaker
8d83d491f1 Add @OptIn to fields in demo PlayerActivity now this is supported
This is possible now we use `annotation-experimental:1.3.1`.

#minor-release

PiperOrigin-RevId: 582315579
2023-11-14 07:33:45 -08:00
ibaker
aa1ec981a3 Remove recommendation to pin annotation-experimental to version 1.2.0
This was intended to avoid bringing in a transitive dependency on the
Kotlin standard library, but Gradle no longer flags lint errors on
`@RequiresOptIn` violations with `annotation-experimental:1.2.0` (1.3.0
is needed), making this recommendation dangerous. See also
https://issuetracker.google.com/310651921.

#minor-release

PiperOrigin-RevId: 582276430
2023-11-14 04:38:38 -08:00
sheenachhabra
5db9a66b3b Implement resume API in Transformer
Changes includes:
1. Add resume flow.
2. Change demo app code to resume export.
3. Changes in test infra to trigger resume.
4. E2E Test cases

PiperOrigin-RevId: 579895744
2023-11-06 11:01:04 -08:00
tonihei
312203d38b Deprecate Bundleable and Bundleable.Creator
Both interfaces are not really needed as the methods can be called
on the respective classes directly. This also avoid error-prone
situations where classes define to/fromBundle methods with parameters
that should be used instead of the parameter-less version.

Also deprecate all existing CREATOR static instances and make the
corresponding fromBundle method public where needed.

PiperOrigin-RevId: 579189766
2023-11-03 08:27:21 -07:00
sheenachhabra
5b0be4e8b0 Create unique name for export output file.
With pause/resume functionality coming in, we need the output file
path to be different from the previous one.

PiperOrigin-RevId: 577175540
2023-10-27 06:12:23 -07:00
ibaker
dd6306e1ba Rollback of a19f577976
PiperOrigin-RevId: 577139027
2023-10-27 03:12:19 -07:00
simakova
beb1711d4c Remove CompositionPlayer activity from the transformer demo app
The CompositionPlayer is not ready yet.

Issue: androidx/media#741
PiperOrigin-RevId: 574859927
2023-10-19 07:19:15 -07:00
tonihei
db86932781 Use DataSourceBitmapLoader by default
This replaces the SimpleBitmapLoader that can now be deprecated
as it's fully unused and doesn't provide any additional functionality.

#minor-release

PiperOrigin-RevId: 574454636
2023-10-18 06:18:32 -07:00
tianyifeng
43e6882fb4 Add PreloadMediaSource and PreloadMediaPeriod
The `PreloadMediaSource` has below two new public methods that suppose to be called by the app:

* `preload(long)` allows the apps to preload the source at the passed start position before playback. The preload efforts include preparing the source for a `Timeline`, creating and caching a `MediaPeriod`, preparing the period, selecting tracks on the period and continuing loading the data on the period.
* `releasePreloadMediaSource()` allows the apps to release the preloaded progress.

The `PreloadMediaPeriod` is designed to facilitate the `PreloadMediaSource` for the preloading work. It has a new package-private method `selectTracksForPreloading` which will cache the `SampleStream` that corresponds to the track selection made during the preloading, and when the `PreloadMediaPeriod.selectTracks` is called for playback, it will uses the preloaded streams if the new selection is equal to the selection made during the preloading.

Also add a shortform demo module to demo the usage of `PreloadMediaSource` with the short-form content use case.

PiperOrigin-RevId: 574439529
2023-10-18 04:57:06 -07:00
tonihei
00425dbe80 Expand MediaItems in session demo instead of just replacing them
When MediaItems are added from the controller, we currently completely
replace the item with the one from our database, overriding any
potential additional information the controller may have set.

Also forward the onAddMediaItems/onSetMediaItems callbacks to common
helper methods instead of redirecting them through super methods

#minor-release
Issue: androidx/media#706
PiperOrigin-RevId: 573799351
2023-10-16 07:05:28 -07:00
ibaker
a19f577976 Remove the 'super speed' SmoothStreaming PlayReady stream from demo
This content is no longer available, the manifest is returning a 404.

Issue: google/ExoPlayer#11309

#minor-release

PiperOrigin-RevId: 573202175
2023-10-13 06:31:39 -07:00
ibaker
c7a091a973 Request notification permission when starting session demo app
#minor-release

PiperOrigin-RevId: 572556101
2023-10-11 06:27:59 -07:00
ibaker
d60596cfca Use package-level @OptIn for demo apps
This demonstrates that `@OptIn` can now be used at the package-level
(since [`androidx.annotation:annotation-experimental:1.3.0`](https://developer.android.com/jetpack/androidx/releases/annotation#annotation-experimental-1.3.0)).

PiperOrigin-RevId: 572187729
2023-10-10 03:02:25 -07:00
tonihei
fe7c62afe0 Add missing Future cancellation checks
Future.isDone and getDone doesn't imply the Future was successful
and it may have been cancelled or failed.

In case where we handle failure, we should also handle cancellation
to avoid CancellationException to bubble up unchecked.

In demo app code where we use isDone for field initialization, we
want to crash in the failure case (usually security exception where
the connection is disallowed), but we want to gracefully handle
cancellation. Cancellation of these variables usually happens in
Activity.onDestroy/onStop, but methods may be called after this point.

#minor-release

PiperOrigin-RevId: 572178018
2023-10-10 02:14:24 -07:00
tonihei
fd81c904e1 Use more targeted listening in session PlayerActivity
The current metadata updates are triggered by item transitions,
but depending on the speed of loading the playlist, the first
metadata may only be known later via metadata-change callbacks.

Slow playlist loading also means the UI stays empty and it's
beneficial to show a placeholder to avoid the impressions the
UI hangs.

Finally, clean-up by removing unused string constants and merging
all listeners into onEvents

#minor-release

PiperOrigin-RevId: 571951529
2023-10-09 09:01:14 -07:00
simakova
67e10e9362 Cleanup layout files in Transformer demo
* Update AOSP copywright headers in all xml files in the Transformer demo app
* Use "end/start" instead of "right/left" to ensure correct behavior in right-to-left locales
* Simplify contrast_options and trim_options layout

PiperOrigin-RevId: 571933637
2023-10-09 07:38:33 -07:00
bachinger
78f403aa7b Add MEDIA_PLAY_FROM_SEARCH to manifest of session demo app
This is required to make GMS send voice commands to the app.

#minor-release

PiperOrigin-RevId: 571326122
2023-10-06 06:59:19 -07:00
simakova
d9cf350eb0 Add CompositionPlayer to the Transformer demo app
PiperOrigin-RevId: 571284291
2023-10-06 03:05:56 -07:00
bachinger
52d9fbff73 Update playlist UI when playlist is updated
When changing the playlist on Android Auto the UI of the
activity needs to be kept in sync.

PiperOrigin-RevId: 569528785
2023-09-29 10:42:58 -07:00
bachinger
cbd23925d5 Add demos/session-automotive module
This change also enables Android Auto support for the
session demo.

PiperOrigin-RevId: 569448376
2023-09-29 04:00:58 -07:00
bachinger
2debf0187a Split demo service into its own module for reuse
To support Automotive with the session demo, we need a separate app module.
To do this we need to split the service into its own module and make it
usable from different modules.

PiperOrigin-RevId: 568975271
2023-09-27 15:21:23 -07:00
bachinger
99086b4007 Add default implementation of Callback.onSubscribe
The library already maintains the subscribed controllers internally. This
change adds `MediaLibrarySession.getSubscribedControllers(mediaId)` to
access subscribed controllers for a given media ID.

To accept a subscription, `MediaLibraryService.Callback.onSubscribe` is
required to return `RESULT_SUCCESS`. So far, this isn't the case for the
default implementation of the library.

This change implements `Callback.onSubscribe` to conditionally
provide `RESULT_SUCCESS`. The default calls `Callback.onGetItem(mediaId)` to
assess the availability of the media item. If the app retruns `RESULT_SUCCESS`
with a browsable item, the subscription is accepted. If receiving a valid item
fails, the subscription is rejected.

Issue: androidx/media#561
PiperOrigin-RevId: 568925079
2023-09-27 12:19:34 -07:00
bachinger
742410d517 Use proxy controller to maintain platform session and notification
With this change, the notification controller that is connected by
`MediaNotificationManager`, is used as a proxy controller of the
System UI controller. An app can use the proxy at connection time
and during the lifetime of the session for configuration of the
platform session and the media notification on all API levels.

This includes using custom layout and available player and session
commands of the proxy to maintain the platform session (actions,
custom actions, session extras) and the `MediaNotification.Provider`.

The legacy System UI controller is hidden from the public API,
instead the app interacts with the Media3 proxy:

- System UI is hidden from `MediaSession.getConnectedControllers()`.
- Calls from System UI to methods of `MediaSession.Callback`/
  `MediaLibrarySession.Callback` are mapped to the `ControllerInfo`
  of the proxy controller.
- When `getControllerForCurrentRequest()` is called during an operation of
  System UI the proxy `ControllerInfo` is returned.

PiperOrigin-RevId: 567606117
2023-09-22 06:36:22 -07:00
huangdarwin
2bdda35731 Overlay: Rename videoFrameAnchor to backgroundFrameAnchor.
Overlays may be overlaid over:
* In VideoFrameProcessor, videos or images (or texture input).
* In Compositor, other videos.

In Compositor, Overlays may consist of video, so it could be confusing
for videoFrameAnchor to contrast with overlayAnchor.

Also, rename overlayAnchor to overlayFrameAnchor, since it's modifying
the anchor in the overlay's frame, so this name seems slightly more precise.

PiperOrigin-RevId: 562004292
2023-09-01 11:28:19 -07:00
huangdarwin
6da70c842e Overlay: Rename alpha to alphaScale.
The actual logic scales the alpha, instead of setting it, so rename
this to what it does.

We would also prefer alpha to be scaled here, to not lose alpha information
(for example for PNGs with transparent regions).

PiperOrigin-RevId: 560121708
2023-08-25 10:00:50 -07:00
tonihei
7899241daf Fix period indexing for multi-period DASH DAI live streams
The period index was calculated relative to the contentTimeline
of the DAI stream, but then used with the full timeline of the
player. This means it currently only works when the stream is the
only or first item in the playlist.

Issue: androidx/media#571
PiperOrigin-RevId: 560023412
2023-08-25 02:05:46 -07:00
sheenachhabra
d5f8487fe2 Add pause and resume button in demo app
Currently the resume button will restart the export from
the beginning.

PiperOrigin-RevId: 559787856
2023-08-24 10:05:51 -07:00
tonihei
25cd13b3a2 Remove unused values
PiperOrigin-RevId: 559357691
2023-08-24 09:20:33 +01:00
ibaker
3ced1cbaa2 Update annotation-experimental version
This picks up a fix to ensure Android Studio puts the `@OptIn`
annotation in the correct place:
https://issuetracker.google.com/251172715

This also introduces a transitive dependency from `media3-common` on
the Kotlin standard library, so this CL also includes some updates to
the dev guide to document how apps can avoid including this dep if
they want.

PiperOrigin-RevId: 558821673
2023-08-22 15:40:46 +01:00
samrobinson
99ac6feeee Add varargs convenience constructors to Sequence & Composition.Builder
Improves API ease-of-use & readability and reduces verbose boilerplate.

PiperOrigin-RevId: 558163557
2023-08-22 15:17:55 +01:00
claincly
c6804e40a3 Display more accurate time in demo app
PiperOrigin-RevId: 558077709
2023-08-18 15:21:53 +01:00
ibaker
a48b99214e Enable @UnstableApi lint in session demo app and add needed @OptIn
PiperOrigin-RevId: 556779020
2023-08-14 17:19:58 +01:00
claincly
c1913e8d89 Deprecate SingleFrameShaderProgram
PiperOrigin-RevId: 555450958
2023-08-11 20:22:03 +00:00
ibaker
133bf29668 Add demo app test stream with overlapping SSA subtitles muxed in MKV
This doesn't currently work by default, but upcoming changes in
`TextRenderer` will make it work as expected.

Issue: google/ExoPlayer#10295
PiperOrigin-RevId: 553161628
2023-08-07 11:26:18 +00:00
samrobinson
fec6252065 Add basic volume scaling to the Transformer demo app.
PiperOrigin-RevId: 553086635
2023-08-07 11:23:14 +00:00
simakova
415b17c1e1 Allow an empty video effects array
PiperOrigin-RevId: 551829203
2023-08-01 14:21:20 +01:00
Googler
465e7c1277 Rewrite tracing to be more flexible and provide more info.
For each event, the timestamp and presentation time is logged. The trace can
then be dumped to a tsv file and easily imported in a spreadsheet.

PiperOrigin-RevId: 550839156
2023-08-01 13:59:51 +01:00
tofunmi
7eee15ecb4 Update OverlaySettings to explicitly state overlay transformations
Alters the OverlayShaderProgram implementation to support rotations, however we need to apply the transformations separately in order for them to work as expected so the matrix is removed from the interface in favour of explicit methods.

Adds a rotation test to ensure this ability doesn't regress

PiperOrigin-RevId: 549890847
2023-08-01 13:45:22 +01:00
ibaker
1ccedf8414 Tighten the demo app's handling of DrmInitData for downloads
This code is Widevine specific. `OfflineLicenseHelper.downloadLicense`
requires the passed `Format` to have a `DrmInitData.SchemeData` with
Widevine UUID and non-null `data` field. The demo app tries to check
this in advance (to avoid an exception later), but its checks are
looser than those made by `OfflineLicenseHelper`. This change tightens
the checks to match.

Issue: androidx/media#512
PiperOrigin-RevId: 549587506
2023-08-01 13:31:57 +01:00
tonihei
5c5e7cd257 Update storage access in main demo app
The main demo app was still targeting API 29 to avoid scoped storage
restrictions. It is now updated to 34 (like the rest of the demo apps)
and handles scoped storage as it should handle it.

More specifically:
 - We need to request READ_MEDIA_... permissions instead of
   READ_EXTERNAL_STORAGE from API33.
 - The legacy scoped storage opt-out can be removed
 - READ_MEDIA_... permissions don't allow arbitrary file access
   if the file doesn't end in a typical media file extension, so
   this change adds a remark on the guide page to place samples
   in the app-specific directory.
 - We also don't have to request permissions for the app-specific
   directories.
 - Custom json files can't be placed in arbitray local locations
   because they don't end in a media file extension, as there is
   no way we can request a permission to load them. This means we
   can remove the storage request logic in SampleChooserActivity.

Issue: google/ExoPlayer#6045
PiperOrigin-RevId: 549252474
2023-07-20 10:29:02 +01:00
tonihei
8064c6df83 Declare foreground service type for DownloadService
This ensures the DownloadService stays functional on Android 14
where defining this type is required. On Android 14 and above,
the app also needs to define the DATA_SYNC permission, which is
added to the demo app as well. In the future, this service type
will no longer be supported and DownloadService needs to be
rewritten with another background scheduling framework.

Issue: google/ExoPlayer#11239
PiperOrigin-RevId: 548994842
2023-07-20 10:23:56 +01:00
tonihei
2d3f464008 Update demo app target SDKs to 34
This helps to highlight and document new requirements for apps,
e.g. to add the FOREGROUND_SERVICE_MEDIA_PLAYBACK permission for
background playback.

Issue: google/ExoPlayer#11239
PiperOrigin-RevId: 548666056
2023-07-20 10:11:18 +01:00
samrobinson
aa1ca747de Add channel mixing effect to demo application.
PiperOrigin-RevId: 547465758
2023-07-13 15:52:43 +01:00
bachinger
ea21d27a69 Add custom layout to the state of the MediaController
This change also marks the buttons of the custom layout as
enabled/disabled according to available commands in the controller.
Accordingly, `CommandButton.Builder.setEnabled(boolean)` is deprecated
because the value is overridden by the library.

Issue: androidx/media#38

#minor-release

PiperOrigin-RevId: 547272588
2023-07-13 15:47:50 +01:00
andrewlewis
22b7a7dc39 Tidy handling of package not found exception in demo
PiperOrigin-RevId: 546900066
2023-07-13 15:34:37 +01:00
andrewlewis
bdbf3e29a1 Fix incorrect class name for MediaPipe demo
Issue: androidx/media#500

#minor-release

PiperOrigin-RevId: 545942450
2023-07-13 15:03:46 +01:00
Googler
5050171ff6 Rename "useHdr" to "useHighPrecisionColorComponents."
BaseGlShaderProgram and SingleFrameGlShaderProgram are technically color space agnostic. useHdr is passed to the TexturePool, which only uses the value to choose between high/regular precision. useHdr is therefore a bit misleading and should be generalized to "useHighPrecisionColorComponents."

PiperOrigin-RevId: 545726629
2023-07-13 14:56:37 +01:00
huangdarwin
7a368b9a11 Effect: Remove GlTextureInfo accessor methods.
The extra check was a bit excessive, especially as it's called multiple times
per frame.

PiperOrigin-RevId: 545657102
2023-07-13 14:51:38 +01:00
kimvde
81c83e4213 Remove HDR modes from TransformationRequest
PiperOrigin-RevId: 545352306
2023-07-05 09:16:52 +00:00