823 Commits

Author SHA1 Message Date
samrobinson
5a86644547 Add audio and video values from Format to TransformationResult.
PiperOrigin-RevId: 500789076
2023-01-10 18:38:11 +00:00
samrobinson
77f26264a3 Split IAE and ISE cases in MuxerWrapper and improve javadoc.
PiperOrigin-RevId: 500786191
2023-01-10 18:37:21 +00:00
samrobinson
ee5e3c0243 Improve docs and split audio/video order in TransformationResult.
PiperOrigin-RevId: 500776260
2023-01-10 18:36:43 +00:00
kimvde
b4f820d2af 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 18:35:57 +00:00
kimvde
98bc817fe7 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 18:35:11 +00:00
kimvde
b11fe97f66 Split ExoPlayerAssetLoaderRenderer
Split ExoPlayerAssetLoaderRenderer into audio and video renderers.

PiperOrigin-RevId: 500102256
2023-01-10 18:34:26 +00:00
samrobinson
f32b632b09 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 18:31:40 +00:00
kimvde
cfc61655ce 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 21:56:14 +00:00
samrobinson
37f8a0bb6b 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 21:55:15 +00:00
kimvde
2eb255431f Merge BaseSamplePipeline and SamplePipeline
PiperOrigin-RevId: 499469006
2023-01-04 21:54:06 +00:00
kimvde
d4491427de Move video decoding to AssetLoader
PiperOrigin-RevId: 499454273
2023-01-04 21:50:58 +00:00
kimvde
2cda644915 Remove unnecessary exceptions in tests
PiperOrigin-RevId: 499160043
2023-01-04 21:47:57 +00:00
kimvde
bd0d61d80d 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 21:46:59 +00:00
samrobinson
4541db3541 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 21:45:49 +00:00
kimvde
310434a8f9 Remove mentions of player in TransformationException
PiperOrigin-RevId: 497921432
2023-01-04 21:44:40 +00:00
samrobinson
88fd9e18f5 Simplify TransformerEndToEndTest and TransformerTestRunner.
PiperOrigin-RevId: 497335605
2023-01-04 21:42:37 +00:00
samrobinson
d09fdd1b52 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 21:41:41 +00:00
tofunmi
283cbcb464 Specify units for VideoEncoderSettings.
PiperOrigin-RevId: 497113780
2023-01-04 21:37:18 +00:00
kimvde
e8572be6d5 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 21:35:35 +00:00
kimvde
431108063c 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 21:34:25 +00:00
kimvde
f67849afa1 Add IntRange annotation to onTrackCount
PiperOrigin-RevId: 496942702
2023-01-04 21:28:49 +00:00
kimvde
5c4d85c2ed Change MuxerWrapper registerTrack to setTrackCount
AssetLoader declares the tracks with a setTrackCount() method. Setting
the track count on the MuxerWrapper is easier than calling
registerTrack() as many times as the number of tracks.

PiperOrigin-RevId: 496933501
2023-01-04 21:27:39 +00:00
kimvde
7c3cffdebe Change FallbackListener registerTrack to setTrackCount
AssetLoader declares the tracks with a setTrackCount() method. Setting
the track count on the FallbackListener is easier than calling
registerTrack() as many times as the number of tracks.

PiperOrigin-RevId: 496919969
2023-01-04 21:25:44 +00:00
samrobinson
59166cce9c Ensure supported request only updates changes fields.
The TransformationRequest passed to FallbackListener (and
createSupportedTransformationRequest) can have null for values that
are inferred from source. Within fallback, this can be height, width,
video mime type and audio mime type (HDR mode is not linked to source).
requestedFormat has these values populated from source, and
supportedFormat then finds the closest supported values to the
requested.

If any of the values in supportedFormat do not match the
requestedFormat, then this method would build upon the
TransformationRequest and update ALL possible fallback fields. This is
a problem because the fallback listener compares the original request
to the fallback one and notifies about all the fields that have
changed.

This CL changes this so that only the values that are not the same as
requested are changed in the supported request that is given to the
fallback listener.

PiperOrigin-RevId: 496908492
2022-12-21 15:38:48 +00:00
kimvde
cad713d0a3 Fix AS warnings and errors in FloatAudioMixingAlgorithmTest
When trying to run the test on Android Studio, error "incompatible
types: Buffer cannot be converted to ByteBuffer" is logged. This is
because ByteBuffer.flip() returns a Buffer (and not a ByteBuffer).
Annotation @CovariantReturnType on ByteBuffer.flip() should resolve this
automatically but it doesn't seem supported at the moment.
PiperOrigin-RevId: 496894723
2022-12-21 15:38:02 +00:00
kimvde
a4c3038b16 Simplify AssetLoader.Listener interface
Replace onTrackRegistered and onAllTracksRegistered with onTrackCount.

PiperOrigin-RevId: 496853037
2022-12-21 15:34:58 +00:00
huangdarwin
99b665ca3f HDR: Add Transformer GL tone mapping test.
PiperOrigin-RevId: 496727803
2022-12-21 15:32:50 +00:00
huangdarwin
84c81b8575 HDR: Implement Transformer HDR to SDR GL tone-mapping API
Note that we simply use GlEffectsFrameProcessor in-app / GL tone-mapping, so PQ->SDR tone-mapping isn't yet implemented.

Tested manually using the demo on Pixel 7, to confirm that device and in-app tone
mapping behave similarly.

PiperOrigin-RevId: 496700231
2022-12-21 15:30:54 +00:00
steveanton
9465fe2f98 Add low level audio mixing algorithms
Adds the AudioMixerAlgorithm interface which allows for specialized
implementations of audio mixing that also efficiently convert between
source and mixing formats.

Initial implementation has two algorithms:
1. Float -> float (with channel mixing)
2. S16 -> float (with channel mixing)

PiperOrigin-RevId: 496686805
2022-12-21 15:29:47 +00:00
tofunmi
81ffe47b23 Create local fallbackDetails to remove checkNotNull.
PiperOrigin-RevId: 496664711
2022-12-21 15:27:49 +00:00
tofunmi
e1775eeb21 Add fallback details to analysis json.
PiperOrigin-RevId: 496660388
2022-12-21 15:25:48 +00:00
kimvde
97e49ac312 Make AssetLoader progress not Transformer specific
To do that, rename PROGRESS_STATE_NO_TRANSFORMATION to
PROGRESS_STATE_NOT_STARTED and update Javadoc of ProgressState to not be
Transformer specific.

PiperOrigin-RevId: 496653460
2022-12-21 15:24:47 +00:00
andrewlewis
0744a52b8d Fix local asset naming
PiperOrigin-RevId: 496410502
2022-12-21 15:22:27 +00:00
huangdarwin
b8f88a8bae HDR: Use local instead of remote file for testing.
This should allow us to focus on HDR failures instead of network buffering
failures when debugging HDR issues.

These files are each used on several files, so it should be more worth the
test binary impact to move these files to local first.

Locally, tests did take less time after this diff

PiperOrigin-RevId: 496398130
2022-12-21 15:20:29 +00:00
kimvde
f7f6e25392 Move setMediaSourceFactory to ExoPlayerAssetLoader
The MediaSourceFactory won't be used by the other AssetLoaders

In order to do that, ExoPlayerAssetLoader has been made public, and the
DefaultAssetLoaderFactory has become a wrapper around
ExoPlayerAssetLoader.

PiperOrigin-RevId: 496386853
2022-12-21 15:19:26 +00:00
tonihei
8ee8910788 Rollback of 7e63997459
*** Original commit ***

Add TransformerTestBuilderFactory to make transformer testable by apps

***

PiperOrigin-RevId: 496342997
2022-12-21 15:13:24 +00:00
samrobinson
def6ca581e Make clear video encoder HighQualityTargeting is experimental.
PiperOrigin-RevId: 495860300
2022-12-21 15:08:24 +00:00
samrobinson
8d15116478 Pass required value into TransformationTestResult.Builder constructor
PiperOrigin-RevId: 495842393
2022-12-21 15:04:23 +00:00
tofunmi
7e63997459 Add TransformerTestBuilderFactory to make transformer testable by apps
PiperOrigin-RevId: 495821660
2022-12-21 15:03:31 +00:00
samrobinson
63cc0338e1 Create and return a TransformationResult regardless of success.
The TransformationResult has some useful values that are set in error
cases, such as the codecs used.

PiperOrigin-RevId: 495568259
2022-12-15 16:15:40 +00:00
claincly
b3571b71b5 Make Codec release frames to frame processor.
PiperOrigin-RevId: 495406734
2022-12-15 16:13:00 +00:00
kimvde
21ae403049 Pass CapturingDecoderFactory to AssetLoader
Otherwise, the decoders are not captured. It works at the moment for the
video decoder because decoding is still done on the sample pipeline but
it will moved to the AssetLoader soon.

PiperOrigin-RevId: 495275575
2022-12-15 16:08:08 +00:00
andrewlewis
f2cf952f68 Output direct buffers from SilentAudioGenerator
`AudioProcessor`s expect direct buffers. This shouldn't make any functional difference in our code, but a custom audio processor might try to access the buffer from JNI in which case a direct byte buffer is more efficient.

PiperOrigin-RevId: 495241669
2022-12-15 16:06:15 +00:00
andrewlewis
3060b97180 Take format for SilentAudioGenerator
This simplifies the caller slightly.

PiperOrigin-RevId: 495234339
2022-12-15 16:05:17 +00:00
claincly
b1425aa6f4 Fix method name to return all encode-able MIME types
PiperOrigin-RevId: 495093939
2022-12-15 16:04:28 +00:00
kimvde
5759eda37e Add AssetLoader.Factory
This is so that apps can customise AssetLoader

PiperOrigin-RevId: 494998497
2022-12-15 16:00:55 +00:00
andrewlewis
beee4732fb Generate complete silent audio frames
`SilentAudioGenerator` could output a fractional audio frame, and this could cause downstream components to throw because of trying to read a complete audio frame but only seeing a partial one.

Calculate the output buffer size based on the frame size (which is a no-op for stereo 16-bit audio) and calculate a total number of frames to output then multiple by the frame size.

PiperOrigin-RevId: 494992941
2022-12-15 15:58:50 +00:00
samrobinson
6c7e892d2f Add codec names to TransformationResult
PiperOrigin-RevId: 494736085
2022-12-15 15:56:02 +00:00
samrobinson
36e52691bb Move SetFrameEditTest into TransformationTest.
PiperOrigin-RevId: 494651985
2022-12-12 11:45:45 +00:00
kimvde
c8d8ff5578 Add AssetLoader interface
This is a step towards allowing apps to inject a custom AssetLoader

PiperOrigin-RevId: 494185078
2022-12-12 11:44:50 +00:00