17426 Commits

Author SHA1 Message Date
michaelkatz
4854e771d7 Encapsulate Opus frames in Ogg during audio offload
PiperOrigin-RevId: 508053559
2023-02-08 14:12:06 +00:00
kimvde
16db2bd0a1 Add an API entry point to pass a Composition
PiperOrigin-RevId: 508031337
2023-02-08 14:11:13 +00:00
tonihei
bbacb3cc70 Advance position across transition for readahead renderer error
If a renderer error happens while processing readahead data for the
next item in the playlist, we currently throw the error immediately
and only set the item id in the error details. This makes it harder
to associate the error to the right item. For example, the user
facing UI is likely not updated to show the failing item when the
error is reported.

This can be improved slighly by force setting the position to the
failing item. The playback still fails immediately, but this can't
be avoided because the renderer itself went into an error state.

PiperOrigin-RevId: 507808635
2023-02-08 14:09:30 +00:00
microkatz
ecd91d865c Merge pull request #248 from lemondoglol:update-segment-size
PiperOrigin-RevId: 507784608
2023-02-08 14:08:36 +00:00
huangdarwin
0c0c972ea0 Effect: Create GlEffect.isNoOp to simplify Transformer.
This will also allow us to skip transcodes in the future for other effects, like
cropping, color effects, etc.

PiperOrigin-RevId: 507765618
2023-02-08 14:07:41 +00:00
kimvde
c434cc0c9f Rename TransformationResult to ExportResult
Also replace some usages of deprecated Transformer listeners with the new
ones.

PiperOrigin-RevId: 507743860
2023-02-08 14:06:51 +00:00
tonihei
01d7bc7279 Fix AudioTrackPositionTracker logic for playback speed adjustments
The AudioTrackPositionTracker needs to correct positions by
the speed set on the AudioTrack itself whenever it makes
estimations based on real-time (=the real-time playout
duration is not equal to the media duration played).

This happens for the main playback path already, but not for
the mode in which the position is estimated from the playback
head position and also not in the phase after the track has
been stopped. Both cases are not very noticeable during
normal playback, but become relevant when playing in offload
mode.

PiperOrigin-RevId: 507736408
2023-02-08 14:05:56 +00:00
claincly
cccb2f07b7 Remove debug print.
Checked there's no other occurrence.

PiperOrigin-RevId: 507534909
2023-02-08 14:05:03 +00:00
huangdarwin
ca4d2be1fa Effect: Rename TextureProcessor to ShaderProgram.
Also, replace instances of "texture processor" to "shader program", with capitalization retained.

PiperOrigin-RevId: 507515655
2023-02-08 14:04:09 +00:00
tofunmi
9224a36add Update CompositeAssetLoader to override queueInputBitmap
PiperOrigin-RevId: 507515587
2023-02-08 14:03:17 +00:00
christosts
a50ea94525 Detect HEVC HDR10 codec profile more accurately
In MediaCodecUtil, use Format.colorInfo, besides the codec string,
to accurately map to a 10bit HEVC profile.

PiperOrigin-RevId: 507500071
2023-02-08 14:02:22 +00:00
claincly
f630315af5 Flush FrameProcessor when appropriate.
PiperOrigin-RevId: 507461550
2023-02-08 14:01:27 +00:00
bachinger
afa3c628c1 Create an AdEventListener for each supported stream type
This is a refactoring to separate and simplify the logic
of VOD and live streams when handling IMA ad events. An
additional listener will be required for DASH live stream
in a follow-up CL.

PiperOrigin-RevId: 507435741
2023-02-08 14:00:33 +00:00
kimvde
0eb11e269c Rename startTransformation to start
Also update some Javadoc in Transformer

PiperOrigin-RevId: 507395956
2023-02-08 13:59:41 +00:00
tofunmi
4e3c6c6167 Update sample pipelines and frame processors to handle image input.
PiperOrigin-RevId: 506965394
2023-02-08 13:58:50 +00:00
huangdarwin
c45859dde1 HDR: Move codec errors from VideoSamplePipeline
It doesn't actually make sense for them to be placed in the Transformer, because the error's root causes are actually only in codecs. Also, a few codec errors were
repeated, so deduplicate these instances

PiperOrigin-RevId: 506937695
2023-02-08 13:57:57 +00:00
tofunmi
f67569d2dd Update FrameProcessor.create() to accept an input track type.
Based on [this conversation thread](https://chat.google.com/room/AAAA--f88ao/76Rem_cRCK8), I've opted to update the existing FrameProcessor.create() rather than deprecate it, as it is unlikely to be in use by apps outside google3.

PiperOrigin-RevId: 506920930
2023-02-08 13:57:02 +00:00
huangdarwin
c4faae6b03 Demo: Request READ_MEDIA_VIDEO on API 33+
More info in: https://developer.android.com/about/versions/13/behavior-changes-13#granular-media-permissions

PiperOrigin-RevId: 506908079
2023-02-08 13:56:06 +00:00
kimvde
9cb2b6e196 Update Composition structure to take List instead of ImmutableList
This is more flexible for apps and more consitent with the Player API.

PiperOrigin-RevId: 506901645
2023-02-08 13:55:14 +00:00
samrobinson
e2adb567bf Expand createNoSupportedMimeTypeException for HDR ColorInfo case.
PiperOrigin-RevId: 506900817
2023-02-08 13:54:22 +00:00
kimvde
9fdc64785a Adapt TransformationResult for multi-asset
PiperOrigin-RevId: 506898392
2023-02-08 13:53:27 +00:00
samrobinson
2754529ce7 Refactor TransformationException.createForCodec method overloads.
* Overload added `(cause, errorCode, isVideo, isDecoder, details)`,
where `details` is a string of values to be added to the error message
of the `TransformationException`.
* Overload with `MediaFormat` and `mediaCodecName` moved to
`DefaultCodec`, because all usages of that overload were from
`DefaultCodec`, and this allows a simplified API because of internally
stored values.
* `mediaCodecName` removed from overload that takes a `Format`.
* Reordered `createForCodec` parameters.

PiperOrigin-RevId: 506895268
2023-02-08 13:52:32 +00:00
kimvde
dce83d70c5 Rename Transformer callbacks
PiperOrigin-RevId: 506890459
2023-02-08 13:51:40 +00:00
samrobinson
0b7679ed88 Implement a ChannelMixingAudioProcessor.
PiperOrigin-RevId: 506886903
2023-02-08 13:50:45 +00:00
claincly
3b7ebecf16 Prefer hardware encoders in EncoderSelector.
In encoding small and odd-numbered resolutions, like `316x61` ([this image](https://upload.wikimedia.org/wikipedia/commons/6/65/100winners.png)), the current fallback logic prefers a software encoder to hardware ones. The assumption was, the encoder factory applies the encoder size alignment and changes the resolution to `316x60` for SW encoders and `316x64` for HW ones. SW encoders is selected because the supported resolution 60 is closer to requested 61, than the hardware supported 64.

This change changes the default encoder selection process to only expose hardware encoders if there is any.

PiperOrigin-RevId: 506879983
2023-02-08 13:49:52 +00:00
kimvde
4094aef9a5 Rename inputFormat to firstInputFormat in multiple places
With multi-asset, the sample pipelines can process more than one
MediaItem. The renaming makes it clear that the format passed to the
SamplePipeline constructors is the one corresponding to the first
MediaItem. Indeed, the first format is the one used to configure the
SamplePipelines.

PiperOrigin-RevId: 506879260
2023-02-08 13:48:59 +00:00
samrobinson
ed5af63227 Turn off ExoPlayer metrics reporting when used by Transformer.
This avoids affecting ExoPlayer metrics with non-typical usage.

PiperOrigin-RevId: 506878231
2023-02-08 13:48:06 +00:00
tofunmi
bffa6a9653 Update duration & frame rate javadoc in EditedMediaItem
PiperOrigin-RevId: 506874799
2023-02-08 13:47:10 +00:00
kimvde
b5bb6e7619 Add MediaItem change listener
PiperOrigin-RevId: 506868341
2023-02-08 13:46:17 +00:00
kimvde
77ae41354e Use CompositeAssetLoader in Transformer
PiperOrigin-RevId: 506863538
2023-02-08 13:45:22 +00:00
huangdarwin
f2cfb14be4 HDR: Fix debug surface by setting correct output color.
Set the correct output color on the debug SurfaceViewWrapper, so that SDR contents
can have an output transfer of either GAMMA_2_2 (Gamma 2.2) or SDR (SMPTE 170M).

This fixes an issue where in-app tone-mapping would output gamma 2.2, and the
SDR value incorrectly hardcoded here would lead to an error in the OpenGL, which
does not support SMPTE 170M.

PiperOrigin-RevId: 506684602
2023-02-08 13:44:31 +00:00
tofunmi
47b59f98e1 Add ImageAssetLoader and ImageConfiguration.
PiperOrigin-RevId: 506619637
2023-02-08 13:43:40 +00:00
christosts
ebe7ece1eb Session: advertise legacy FLAG_HANDLES_QUEUE_COMMANDS
This change includes 3 things:
- when the legacy media session is created, FLAG_HANDLES_QUEUE_COMMANDS
  is advertised if the player has the COMMAND_CHANGE_MEDIA_ITEMS
  available.
- when the player changes its available commands, a new
  PlaybackStateCompat is sent to the remote media controller to
  advertise the updated PlyabackStateCompat actions.
- when the player changes its available commands, the legacy media
  session flags are sent accoridingly: FLAG_HANDLES_QUEUE_COMMANDS is
  set only if the COMMAND_CHANGE_MEDIA_ITEMS is available.

#minor-release

PiperOrigin-RevId: 506605905
2023-02-02 15:38:04 +00:00
claincly
a817bd42e2 Fix end of stream handling for previewing.
Before this CL, the `renderedLastFrame` flag is not set if the last frame is released immediately (force render), or when it's dropped.

PiperOrigin-RevId: 506358626
2023-02-02 15:37:01 +00:00
claincly
0f4fcc1110 Report flushing completed after all pending frames are decoded.
With the current ExtTexMgr,

it can happen that

- `x` frames are registered, but haven't arrived yet
- flush
  - need to drop `x` frames when they arrive on SurfaceTexture
  - status is reset to 0 pending, 0 available, drop `x` when frames arrive
- register one frame
  - status is set to 1 pending, 0 available, drop `x` when frames arrive
- flush
  - now the number of frame to drop is reset to `pending - available = 1`
  - but it should be `x+1`

This CL solves the issue by reporting (by running the afterFlushTask) flush completes only after all the pending frames before calling flush are accounted for.

PiperOrigin-RevId: 506310671
2023-02-02 15:36:02 +00:00
samrobinson
656a1d9475 Clarify case where HDR encoder and muxer have no shared mime type.
The prior version (with the call to createEncodingException) could
never occur as select...SupportedMimeType already checks for HDR
editing support. This change ensures we throw before creating an
encoder, gives a better error code and allows future simplifications
around createForCodec (see child CL).

PiperOrigin-RevId: 506308290
2023-02-02 15:35:00 +00:00
kimvde
1c912e5c50 Pass a Composition to Transformer callbacks
PiperOrigin-RevId: 506304101
2023-02-02 15:34:03 +00:00
claincly
4a1cf3d839 Support flushing in FrameProcessor
Flushing resets all the texture processors within the `FrameProcessor`. This
includes:

- At the back, the FinalMatrixTextureProcessorWrapper, and its MatrixTextureProcessor
- At the front, the ExternalTextureManager
- All the texture processors in between
- All the ChainingGlTextureProcessorListeners in between texture processors
- All the internal states in the aforementioned components

The flush process follows the order, from `GlEffectsFrameProcessor.flush()`

1. Flush the `FrameProcessingTaskExecutor`, so that after it returns, all tasks queued before calling `flush()` completes
2. Post to `FrameProcessingTaskExecutor`, to flush the `FinalMatrixTextureProcessorWrapper`
3. Flushing the `FinalMatrixTextureProcessorWrapper` will propagate flushing through, via the `ChainingGlTextureProcessorListener`

Startblock:
   has LGTM from christosts
   and then
   add reviewer andrewlewis
PiperOrigin-RevId: 506296469
2023-02-02 15:33:05 +00:00
tofunmi
eb6c1a5254 Add sRGB eotf to overlay fragment shader.
The eotf is needed so that overlay (image) colors are correctly interpreted and mixed the linear video colors.

Also replaces the 100winners.png with "homemade" image file.

Added GlEffectsFrameProcessor test to justify that the color looks correct at the end of frame processing.

PiperOrigin-RevId: 506290309
2023-02-02 15:32:08 +00:00
bachinger
fcd3af6431 Publish ConcatenatingMediaSource2
Can be used to combine multiple media items into a single timeline window.

Issue: androidx/media#247
Issue: google/ExoPlayer#4868
PiperOrigin-RevId: 506283307
2023-02-02 15:31:12 +00:00
christosts
c6569a36fb Merge pull request #10793 from fraunhoferfokus:dash-thumbnail-support
PiperOrigin-RevId: 506261584
2023-02-02 15:30:08 +00:00
Balachandar KM
3c09cbd8d4
Handle SQLiteException when trying to accessing DatabaseProvider#getReadableDatabase() 2023-02-02 10:54:06 +00:00
bachinger
eb8fffba15 Publish ConcatenatingMediaSource2
Can be used to combine multiple media items into a single timeline window.

Issue: androidx/media#247
Issue: google/ExoPlayer#4868
PiperOrigin-RevId: 506283307
2023-02-01 15:36:40 +00:00
christosts
107e0c6e42 Merge pull request #10793 from fraunhoferfokus:dash-thumbnail-support
PiperOrigin-RevId: 506261584
2023-02-01 15:32:27 +00:00
claincly
6ce23f6eee Render PQ to DebugSurface in transformer.
For HLG input in transformer, FinalWrapper is configured to only output HLG to
encoder. But since DebugPreview is configured to take PQ for HDR content, the
color will not look correct.

This CL allows overriding the MatrixTP output transfer function, so
that FinalWrapper can output

- HLG to encoder
- PQ to debug preview

PiperOrigin-RevId: 506022840
2023-02-01 15:28:10 +00:00
huangdarwin
b57d5dd3fa Effect: Allow SingleFrameGlTextureProcessor to throw errors.
Implementations outside media3 should be able to throw FrameProcessingException if they come across an error during configure().

PiperOrigin-RevId: 506020149
2023-02-01 15:23:55 +00:00
ibaker
736f090cce Fix (another) LeanbackPlayerAdapter param name mismatch
I missed this when fixing `positionInMs` for Dackka in d2a3d8f6fa

This time I manually verified that all the `@Override` methods have
parameter names that match [the docs](https://developer.android.com/reference/androidx/leanback/media/PlayerAdapter).

#minor-release

PiperOrigin-RevId: 506017063
2023-02-01 15:19:45 +00:00
claincly
f0b7dfc71d Don't release a frame when not force rendering when paused.
And rename method `releaseOutputFrame` to `releaseProcessedFrameInternal` for consistency.

Removed misplaced comment.

PiperOrigin-RevId: 506005744
2023-02-01 15:15:38 +00:00
kimvde
c67cfbf8ce Undeprecate startTransformation(MediaItem, String)
This overload is helpful to apps transcoding a MediaItem without edits.

PiperOrigin-RevId: 505987852
2023-02-01 15:11:33 +00:00
kimvde
8caf836053 Make Composition fields public
Transformer callbacks will take a Composition instead of a MediaItem.
Apps should be able to see what this Composition contains.

PiperOrigin-RevId: 505976561
2023-02-01 15:07:31 +00:00