659 Commits

Author SHA1 Message Date
kimvde
e5e17d6f2c Add EditedMediaItemSequence and Composition objects
PiperOrigin-RevId: 505047245
2023-02-01 13:59:32 +00:00
kimvde
9759849001 Make setResolution package private
- Usages in 1P apps have been removed.
- setResolution should be removed when refactoring fallback.

PiperOrigin-RevId: 505043425
2023-02-01 13:55:11 +00:00
kimvde
341f2d6b3a Move flattenForSlowMotion to EditedMediaItem
PiperOrigin-RevId: 504867150
2023-02-01 13:50:59 +00:00
samrobinson
728619018b Move audio buffer/array test utility methods to TestUtil.
PiperOrigin-RevId: 504611069
2023-01-25 20:37:34 +00:00
kimvde
5ed72efbe0 Move removeAudio/Video to EditedMediaItem
Also add a Builder to EditedMediaItem to avoid having a constructor with
many optional parameters, or a chain of constructors.

PiperOrigin-RevId: 504588544
2023-01-25 20:25:23 +00:00
samrobinson
7abbd6aa1f Use EMPTY_BUFFER in SpeedChangingAudioProcessorTest.
PiperOrigin-RevId: 504264862
2023-01-25 19:56:51 +00:00
samrobinson
a010ebf7b6 Consolidate TransformationResult.transformationException test usage.
PiperOrigin-RevId: 504257627
2023-01-25 19:48:31 +00:00
samrobinson
f440fea738 Move AudioMixer classes from transformer.audio to transformer package.
Transformer convention has been to avoid splitting into packages unless
necessary.

See https://jlbp.dev/JLBP-2: "Prefer fewer packages over more packages
to avoid unnecessarily publicizing internal details, since any
dependency across package boundaries needs to be public.

PiperOrigin-RevId: 503463294
2023-01-23 13:52:28 +00:00
samrobinson
3055de94ac Don't use transformationResult with timeout/unexpected exceptions.
PiperOrigin-RevId: 503187291
2023-01-23 13:34:51 +00:00
kimvde
4f6b83e2c3 Remove usages of deprecated startTransformation
PiperOrigin-RevId: 503138745
2023-01-23 13:21:42 +00:00
kimvde
45596fcd1e Make startTransformation methods take an EditedMediaItem
Usages of the deprecated methods in Transformer.Builder will be removed
in a follow-up CL.

PiperOrigin-RevId: 502889423
2023-01-23 13:12:54 +00:00
kimvde
a043c8c204 Avoid re-encoding if video effects are no-op
This is to avoid regressions introduced by removing the convenience
methods from TransformationRequest.

PiperOrigin-RevId: 502864512
2023-01-23 13:08:38 +00:00
samrobinson
a44032c59b Add ColorInfo to TransformationResult.
TESTED: Manually verified the ColorInfo is propagated when VSP is used.
PiperOrigin-RevId: 502843773
2023-01-23 12:59:59 +00:00
samrobinson
76af4270a9 Generate silent audio if no audio track is available.
To always generate silent audio, `removeAudio(true)` can be used in conjunction.

PiperOrigin-RevId: 502814315
2023-01-18 13:21:57 +00:00
kimvde
6b6e4993b9 Add EditedMediaItem class
This class will be used in a follow-up CL.

PiperOrigin-RevId: 502615323
2023-01-18 13:16:48 +00:00
samrobinson
2cc64a037c Add resolution fallback for 25% of requested.
If a device only supports 1920x1080 as maximum resolution, then adding
the 25% case ensures 8k is reduced correctly.

PiperOrigin-RevId: 502588364
2023-01-18 13:06:39 +00:00
samrobinson
5da086fe01 Add a unit test to check 2/3 resolution supported.
PiperOrigin-RevId: 502573469
2023-01-18 13:01:35 +00:00
kimvde
55aeb76e0c Add CompositeAssetLoader
This is an AssetLoader that wraps a sequence of AssetLoaders. It will
be used for constrained multi-asset.

This class can currently only concatenate media items with the exact
same format.

PiperOrigin-RevId: 502525796
2023-01-18 12:51:50 +00:00
kimvde
89e14989b3 Remove setScale and setRotationDegrees from TransformationRequest
Also remove usages of TransformationRequest convenience methods
(setScale, setRotationDegrees and setResolution).

Some usages of setResolution can't be removed yet because they are used
for fallback.

PiperOrigin-RevId: 502415748
2023-01-17 03:38:19 +00:00
kimvde
a4f9f9487b Add the possility to shift frame timestamps in SampleConsumer
This is needed for constrained multi-asset to shift the timestamps of
the media items that are not the first in the sequence.

PiperOrigin-RevId: 502409923
2023-01-17 03:30:32 +00:00
claincly
c86d70a98b Allow forcing duration in FrameworkMuxer.
PiperOrigin-RevId: 501865706
2023-01-17 03:02:43 +00:00
huangdarwin
4ade37c48d HDR: Implement PQ to SDR tone-mapping.
Tested manually on the Pixel 7 and Samsung S10.

PiperOrigin-RevId: 501626354
2023-01-17 02:46:59 +00:00
huangdarwin
4f4f28b923 Transformer: Clarify setResolution javadoc.
This class may be removed soon, but in the meantime clarify this method's
javadoc summary fragment to make it marginally clearer that this only affects
the "displayed" height instead of the "encoded" height.

PiperOrigin-RevId: 501582219
2023-01-17 02:39:07 +00:00
huangdarwin
27e71d2f91 Transformer: Simplify EncoderWrapper rotationDegrees logic.
Small refactoring change to simplify the logic a tiny bit by removing one
unnecessary variable. No functional change intended.

PiperOrigin-RevId: 501566533
2023-01-17 02:31:20 +00:00
samrobinson
8fe90562a6 Allow Muxer.writeSampleData to take @C.BufferFlag int flags.
PiperOrigin-RevId: 501314812
2023-01-17 02:11:33 +00:00
kimvde
bbffa8ae27 Remove setDecoderFactory from Transformer
It makes more sense to have it in the AssetLoader now that decoding is
done there, particularly as the decoder factory should rarely be
customized.

Also remove the setter from the AssetLoader.Factory because it's
uncommon to have setters in a factory.

PiperOrigin-RevId: 501244974
2023-01-17 01:59:37 +00:00
kimvde
a5288a20fb Add a queue at the start of the buffer SamplePipelines
This improves performance and makes the code more intuitive.

PiperOrigin-RevId: 501220234
2023-01-17 01:55:45 +00:00
kimvde
4a91a234a8 Remove setters from AssetLoader.Factory
It's unusual to have setters on a Factory.

PiperOrigin-RevId: 501212264
2023-01-17 01:51:45 +00:00
steveanton
25fdc4ed47 Add an audio mixer that combines concurrent audio sources
Design document: go/me-android-audio-mixer

PiperOrigin-RevId: 501048758
2023-01-10 21:03:03 +00:00
samrobinson
2693b6025f Make EncoderBitrateProvider and implementations package private.
There is no API to allow applications to use these currently. Until
that exists, these classes do not need to be public.

PiperOrigin-RevId: 500792401
2023-01-10 20:47:24 +00:00
samrobinson
8cac27a77c Add audio and video values from Format to TransformationResult.
PiperOrigin-RevId: 500789076
2023-01-10 20:43:34 +00:00
samrobinson
8ad26c0d8b Split IAE and ISE cases in MuxerWrapper and improve javadoc.
PiperOrigin-RevId: 500786191
2023-01-10 20:39:43 +00:00
samrobinson
b3831778ef Improve docs and split audio/video order in TransformationResult.
PiperOrigin-RevId: 500776260
2023-01-10 20:35:52 +00:00
kimvde
886063d649 Rename SampleConsumer dequeueInputBuffer to getInputBuffer
This makes more sense as SampleConsumer.dequeueInputBuffer returns the
same buffer as long as it is not queued.

PiperOrigin-RevId: 500631982
2023-01-10 20:31:59 +00:00
kimvde
c642f811a6 Fix sample interleaving
Whether to write a sample or not was based on the timestamp of the
previous sample, rather than the current sample.

PiperOrigin-RevId: 500195279
2023-01-10 20:28:01 +00:00
kimvde
ee37b453dd Split ExoPlayerAssetLoaderRenderer
Split ExoPlayerAssetLoaderRenderer into audio and video renderers.

PiperOrigin-RevId: 500102256
2023-01-10 20:24:03 +00:00
samrobinson
03bb91401d Refactor MuxerWrapper handling of track details.
This brings together the multiple details about a muxer track, and
reduces the need for additional variables and more complicated track
tracking.

PiperOrigin-RevId: 499872145
2023-01-10 20:12:05 +00:00
kimvde
827bd6b8f1 Rename the SamplePipelines
The old names are not really correct anymore because:
- The Audio/VideoTranscodingSamplePipelines do not decode anymore.
- The pipelines now mux the encoded data.

PiperOrigin-RevId: 499498446
2023-01-04 19:59:05 +00:00
samrobinson
7d727c88af Improve encoder resolution capability checking.
Whilst testing fallback functionality, I found that we were
aggressively reducing the resolution if it was not supported. A quick
test found that we could reduce by a much smaller increments.
Performance wise it appears these checks are incredibly quick.

The code for checking supported sizes was duplicated, with one case
having a bug because of this duplication (2/3 case). This CL abstracts
this into a loop.

PiperOrigin-RevId: 499497646
2023-01-04 19:54:54 +00:00
kimvde
e6527ec1dd Merge BaseSamplePipeline and SamplePipeline
PiperOrigin-RevId: 499469006
2023-01-04 19:50:56 +00:00
kimvde
8a8c81d57f Move video decoding to AssetLoader
PiperOrigin-RevId: 499454273
2023-01-04 19:43:10 +00:00
kimvde
09d431147d Remove unnecessary exceptions in tests
PiperOrigin-RevId: 499160043
2023-01-04 19:30:59 +00:00
kimvde
220a5b9ff3 Misc small fixes
- Improve AssetLoader Javadoc
- Fix Javadoc of sample pipelines
- Improve Javadoc of Transformer.startTransformation
- Move thread hops for Transformer listener callbacks to
  TransformerInternal

PiperOrigin-RevId: 499156604
2023-01-04 19:27:01 +00:00
samrobinson
46f5654643 Deprecated onTransformationError methods are not called.
When a listener method is deprecated, the new method should (by
default) called through to the deprecated one. This is because any
class that implements the method that is now deprecated needs to still
receive that callback.

It appears when onTransformationError(MediaItem, Exception) was
deprecated in favour of onTransformationError(MediaItem,
TransformationException), this deprecation was the wrong way round, and
the newer callback - onTransformationError(MediaItem,
TransformationResult, TransformationException) continued this mistake.

This CL now corrects this.

PiperOrigin-RevId: 498221504
2023-01-04 19:22:56 +00:00
kimvde
8e6daec955 Remove mentions of player in TransformationException
PiperOrigin-RevId: 497921432
2023-01-04 19:19:04 +00:00
samrobinson
2716ff89db Simplify TransformerEndToEndTest and TransformerTestRunner.
PiperOrigin-RevId: 497335605
2023-01-04 19:11:17 +00:00
samrobinson
c0bbfe929a Add a MuxerWrapper listener for events.
Events on the wrapper should be propagated to TransformerInternal as
soon as they occur, switching round the process so TransformerInternal
does not have to query MuxerWrapper.

This CL is a prerequisite for the child CL, where MuxerWrapper can
simplify the internal state and logic.

PiperOrigin-RevId: 497267202
2023-01-04 19:07:29 +00:00
tofunmi
7ce7e0aefd Specify units for VideoEncoderSettings.
PiperOrigin-RevId: 497113780
2023-01-04 18:52:15 +00:00
kimvde
7c980f12db Ensure AssetLoader callbacks are always called in the right order
Before, it was possible for onDurationUs() and onAllTracksRegistered()
to be called before onTrackAdded() because they are called from
different threads. onDurationUs() and onAllTracksRegistered() are called
from the Transformer internal thread, and onTrackAdded() is called from
the playback thread.

PiperOrigin-RevId: 497102556
2023-01-04 18:44:50 +00:00
kimvde
4dddcb00ff Specify the types of samples output by AssetLoader
This is useful if an app passes a custom AssetLoader that can only
output encoded or decoded samples.

PiperOrigin-RevId: 497097492
2023-01-04 18:40:57 +00:00