822 Commits

Author SHA1 Message Date
tofunmi
535af35511 Add heif extractor
PiperOrigin-RevId: 563340591
2023-09-07 00:31:04 -07:00
rohks
8dcafa0398 Add nullness annotations to MediaCodecVideoRenderer
#fixit

PiperOrigin-RevId: 562926813
2023-09-05 16:36:04 -07:00
tianyifeng
2554fe8f70 Recreate AudioTrack when ERROR_DEAD_OBJECT throws as writing PCM data
We have an existing logic for recovering the `AudioTrack` from the [ERROR_DEAD_OBJECT](https://developer.android.com/reference/android/media/AudioTrack#ERROR_DEAD_OBJECT)
throws. However, this only applies to the situation when the
`writtenEncodedFrames > 0`.

However, we have a case when `ERROR_DEAD_OBJECT` throws while writing
PCM data. When the `tunneling` is turned on, the `AudioTrack` is set the
flag `AUDIO_OUTPUT_FLAG_HW_AV_SYNC`, and further because of this flag,
it is forced the flag `AUDIO_OUTPUT_FLAG_DIRECT`. When the platform
invalidates the `AudioTrack`, the `AudioTrack` won't be restored by the
platform due to `AUDIO_OUTPUT_FLAG_DIRECT` flag, and `ERROR_DEAD_OBJECT`
is thrown.

Issue: androidx/media#431
PiperOrigin-RevId: 562582451
2023-09-04 10:41:48 -07:00
christosts
5b19e08ea9 Rollback of 51fd06482b
PiperOrigin-RevId: 562550636
2023-09-04 07:13:59 -07:00
christosts
51fd06482b Make Timeline and MediaPeriodId visible to Renderers
This is so CompositionPlayer can customize the Renderers and figure
out when a transition to a MediaItem is made hence it can configure the
effects pipeline with the effects that are specific to the MediaItem.

PiperOrigin-RevId: 562530774
2023-09-04 05:12:13 -07:00
michaelkatz
9d58788d86 Add AudioSink#setOffloadDelayPadding to offload play gapless Opus
Created new method `AudioSink#setOffloadDelayPadding` that will set delay and padding data onto an `AudioTrack` using `AudioTrack#setOffloadDelayPadding`. This feature adds support for offloaded, gapless Opus playback as the content requires the capability to set padding data post-`AudioSink#configure`.

PiperOrigin-RevId: 562518193
2023-09-04 04:02:44 -07:00
tofunmi
e15c05fc3c Flip input buffer in the ImageRenderer
also improves tests to hash bitmap now that we know the bitmaps are decoded in roboelectic tests,
as well as some minor fixes in the DefaultImageDecoder

PiperOrigin-RevId: 561946073
2023-09-01 07:12:57 -07:00
tonihei
f6be4bc526 Document C.TIME_UNSET on Player.setMediaItem(.., startPositonMs)
This wasn't properly documented yet (unlike the longer setMediaItems
method that already includes this documentation).

Issue: androidx/media#607
PiperOrigin-RevId: 561910073
2023-09-01 03:44:36 -07:00
tofunmi
5944adcc78 Add image e2e test
PiperOrigin-RevId: 561887238
2023-09-01 01:31:45 -07:00
Copybara-Service
bbfba27cac Merge pull request #594 from Tolriq:sink_format
PiperOrigin-RevId: 561611655
2023-08-31 04:08:54 -07:00
rohks
206a663dca Add functionality to transmit CMCD data using query parameters
Currently, we only support sending Common Media Client Data (CMCD) data through custom HTTP request headers, added capability to configure and transmit it as HTTP query parameters.

PiperOrigin-RevId: 561591246
2023-08-31 02:11:12 -07:00
Tolriq
4e93db4d0a Format passed to audioSink.configure is missing information.
AudioSink might require the identifying data and metadata to be able to take decisions.
2023-08-30 18:23:18 +01:00
ibaker
64792dfda2 Rollback of 25253698bc
PiperOrigin-RevId: 561352515
2023-08-30 08:53:49 -07:00
tofunmi
6a5d5aef92 Add limited ImageRenderer
At this stage, the image renderer is designed to be able to render one input stream containing one sample. The renderer supports seeking inside that stream, which is a no-op because the stream comprises for exactly one sample.

PiperOrigin-RevId: 561307859
2023-08-30 05:15:38 -07:00
tianyifeng
86f919e7d4 Fix flaky tests in PlaylistPlaybackTest
If the loading thread of the second media item progresses slow, then when the playback of the first item approaches to the end before the second item is prepared, the stream will be set "final" and the renderers are disabled during such transition. In this case, `AudioSink.handleDiscontinuity` never gets called, which introduces the flakiness into the `test_bypassOffThenOn`.

Similarly for `test_subtitle`, if the loading thread of extracting the subtitle is slow, then when the renderer attempts to queue the input buffer, the data hasn't been available in the stream. And when the extracting finished, the renderer already advanced to the time after the subtitle end time.

To de-flake the tests, we have to make sure that the period of the second item has fully loaded before starting the playback.

PiperOrigin-RevId: 560080119
2023-08-25 07:04:26 -07:00
huangdarwin
dccbc7e459 ExoPlayer: Remove tone-mapping workaround.
PiperOrigin-RevId: 560069496
2023-08-25 06:07:44 -07:00
claincly
930e538aca Allow re-configuring DVFP in a (mostly) non-blocking manner
The first call to method `registerInputStream` doesn't block.

Later successive calls to the method blocks until the previous register call
finishes.

PiperOrigin-RevId: 559694490
2023-08-24 02:55:54 -07:00
rohks
2ad37d2e37 Add nullness annotations to MediaPeriodQueue
#fixit

PiperOrigin-RevId: 559395027
2023-08-24 09:27:43 +01:00
rohks
bfa32b3998 Add nullness annotations to MediaCodeAudioRenderer
#fixit

PiperOrigin-RevId: 559175846
2023-08-24 09:19:34 +01:00
christosts
398809e4e2 Replace Queue<Long> with a queue for long primitives
Replace Queue<Long> with LongArrayQueue which provides queue semantics
for long primitives. LongArrayQueue is forked from IntArrayQueue which
in turn was forked from Androidx CircularIntArray.

IntArrayQueue is deleted and we now use CircularIntArray directly from
Androidx Collection.

PiperOrigin-RevId: 559129744
2023-08-24 09:14:44 +01:00
rohks
0541e1953c Add nullness annotations to SampleQueue
#fixit

PiperOrigin-RevId: 559058211
2023-08-22 15:44:50 +01:00
christosts
4fad529433 Rollback of f5a6ecdda1
PiperOrigin-RevId: 558779068
2023-08-22 15:31:43 +01:00
rohks
e0d3cad8bb Add fields next object request (nor) and next range request (nrr)
Added this CMCD-Request fields to Common Media Client Data (CMCD) logging.

PiperOrigin-RevId: 558317146
2023-08-22 15:25:03 +01:00
rohks
b6b16b2895 Sort Common Media Client Data keys to reduce fingerprinting surface
Based on the Common Media Client Data (CMCD) specification key-value pairs should be sequenced in alphabetical order of the key name in order to reduce the fingerprinting surface exposed by the player.

PiperOrigin-RevId: 558296264
2023-08-22 15:23:33 +01:00
rohks
afb8d6c9e2 Make custom data adhere to Common Media Client Data(CMCD) specification
Added more comprehensive Javadoc around setting custom data and verification on key format.

Changed adding custom data as a `String` to `List<String>`. This would enable us to sort all keys to reduce the fingerprinting surface.

PiperOrigin-RevId: 558291240
2023-08-22 15:22:08 +01:00
samturci
6566387f70 Add a waveform audio buffer sink.
This can be used together with TeeAudioProcessor to draw an audio waveform.

PiperOrigin-RevId: 558213516
2023-08-22 15:20:47 +01:00
tianyifeng
7f1ee0b390 Use TrackGroup.equals when determining equality of BaseTrackSelection
PiperOrigin-RevId: 558150684
2023-08-22 15:16:38 +01:00
ibaker
450d1cd3e9 Add MediaParserExtractorAdapter.enableConstantBitrateSeeking
PiperOrigin-RevId: 557859297
2023-08-18 15:19:20 +01:00
tofunmi
a8944ef2f0 Add BitmapDecoder interface
PiperOrigin-RevId: 557827954
2023-08-18 15:15:14 +01:00
tofunmi
a801f8d3f5 Add ImageDecoder.Factory
PiperOrigin-RevId: 557498045
2023-08-16 21:56:47 +01:00
tonihei
7b663eea2f Remove MediaPeriodId from common module
It was moved there temporarily to support another temporary move
of ExoPlaybackException. See <unknown commit>.

Since then, ExoPlaybackException has been moved back to ExoPlayer
and we can do the same with MediaPeriodId, which only makes sense
in the context of the ExoPlayer module.

PiperOrigin-RevId: 557159381
2023-08-16 14:30:08 +01:00
tofunmi
cacf9b33b6 Add image decoding interfaces and capabilities
PiperOrigin-RevId: 557108362
2023-08-15 14:36:41 +01:00
tofunmi
e65d104330 Add image package-info.java
PiperOrigin-RevId: 557080845
2023-08-15 14:35:13 +01:00
tonihei
3ccb920930 Update bypass decode-only logic to timestamp-based pattern
This aligns the bypass code with the MediaCodec logic to not
use buffer.isDecodeOnly and instead rely on a timestamp
comparison with the last reset time. Overall, the change should
not introduce a functional difference and is covered by existing
end-to-end tests with bypass playbacks.

Splitting bypass batch buffers by decoder-only flag is
technically wrong for formats where not every buffer is a
keyframe, and this change also leaves a TODO to explain this
known shortcoming.

PiperOrigin-RevId: 556800038
2023-08-14 17:21:10 +01:00
tianyifeng
08067eff14 Fix several API level checks
PiperOrigin-RevId: 556751372
2023-08-14 17:18:41 +01:00
Googler
db6f043cb1 Rollback of f5a6ecdda1
PiperOrigin-RevId: 556718678
2023-08-14 11:06:30 +00:00
tonihei
418edda285 Fix capacity overflow logic in findSampleAfter
The method was recently introduced and only searched for matching
samples up to index==length. However, SampleQueue uses a circular
array to index its data and the search should continue until
relativeStartIndex+length, while also handling the overflow
in the circular array.

The tests for seeking didn't cover these overflow cases yet
because they always started writing data in an empty SampleQueue.
This can be fixed by prewarming the queue with placeholder data
to force using the overflow logic in the various seek methods.

PiperOrigin-RevId: 555963011
2023-08-11 20:38:05 +00:00
rohks
45348f1576 Utilise existing rate unset representation C.RATE_UNSET_INT
Use `C.RATE_UNSET_INT` instead of introducing `Long.MIN_VALUE` as the default value for rate parameters. Modifies default behaviour of the `TrackSelection.getLatestBitrateEstimate()` method and the `measuredThroughputInKbps` parameter in `CmcdHeadersFactory.CmcdRequest`.

PiperOrigin-RevId: 555939420
2023-08-11 20:32:41 +00:00
rohks
1e2e225c01 Refactor CMCD headers construction for efficiency and readability
Optimises the construction of Common Media Client Data (CMCD) headers by eliminating the use of trailing commas. Instead of appending values directly to a StringBuilder, it now adds values to a list and joins them using a comma separator. While the primary focus is on enhancing readability and robustness, it's worth noting that in certain instances, removing usages of `formatInvariant`, there are also performance improvements.

PiperOrigin-RevId: 555911498
2023-08-11 20:30:06 +00:00
christosts
f5a6ecdda1 Implement the CompositingVideoSinkProvider
This is the first iteration for the CompositingVideoSinkProvider which
is basically a copy of MediaCodecVideoRenderer's
VieoFrameProcessorManager.

The MediaCodecVideoRenderer now instantiates a
CompositingVideoSinkProvider instead of a VieoFrameProcessorManager.

PiperOrigin-RevId: 555903928
2023-08-11 20:28:52 +00:00
rohks
171e1a1e42 Allow UNSET values in CmcdHeadersFactory's nested class setters
Also added `checkArgument()` in setters that lacked it.

PiperOrigin-RevId: 555900170
2023-08-11 20:27:32 +00:00
rohks
a9f9537e5f Use utility method Util.usToMs(timeUs) to convert durations to Ms
PiperOrigin-RevId: 555578906
2023-08-11 20:24:54 +00:00
rohks
4282a6ecd7 Add buffer starvation(bs), deadline(dl), playback rate(pr), startup(su)
Enhanced the Common Media Client Data (CMCD) logging by incorporating additional fields:
* buffer starvation (bs) : CMCD-Status
* deadline (dl) and startup (su) : CMCD-Request
* playback rate (pr) : CMCD-Session

PiperOrigin-RevId: 555553357
2023-08-11 20:23:23 +00:00
tofunmi
d4b452d475 Use ProgressiveMediaSource and period for images
PiperOrigin-RevId: 555424664
2023-08-10 12:30:29 +00:00
kimvde
266dc5a6d6 Add video speed change effect
This adds an effect to change the speed of the video track. The speed
of the audio track can already be changed using a SonicAudioProcessor.

Issue: androidx/media#559
PiperOrigin-RevId: 555155418
2023-08-10 12:24:41 +00:00
rohks
cf9f048a3d Enhance getNextChunk() API to allow passing more information
Modifies the `ChunkSource.getNextChunk(long, long, List, ChunkHolder)` method in the `ChunkSource` interface to `ChunkSource.getNextChunk(LoadingInfo, long, List, ChunkHolder)`.

LoadingInfo contains additional parameters, including `playbackRate` and `lastRebufferRealtimeMs` in addition to the existing `playbackPositionUs`. The additional parameters will allow us to pass these information to Common Media Client Data (CMCD) logging.

PiperOrigin-RevId: 555148768
2023-08-10 12:23:37 +00:00
rohks
481ea4a274 Enhance continueLoading() API to allow passing more information
Modifies the `SequenceableLoader.continueLoading(long)` method in the `SequenceableLoader` interface to `SequenceableLoader.continueLoading(LoadingInfo)`.

`LoadingInfo` contains additional parameters, including `playbackSpeed` and `lastRebufferRealtimeMs` in addition to the existing `playbackPositionUs`. The additional parameters will allow us to pass these information to Common Media Client Data (CMCD) logging.

By using the `LoadingInfo` object, we ensure future flexibility to add more fields without causing any breaking changes to the API.

PiperOrigin-RevId: 555123961
2023-08-10 12:16:41 +00:00
samturci
821ec49049 Preserve the byte order when using read-only ByteBuffers.
`asReadOnlyBuffer` doesn't copy the original byte order but always sets it to big-endian. Replace calls to it with a utility method that manually sets the byte order after creating the read-only copy.

This fixes `TeeAudioProcessor` providing a `ByteBuffer` always in big-endian and hence causing `AudioBufferSink` to read wrong data.

PiperOrigin-RevId: 554861402
2023-08-10 12:08:19 +00:00
rohks
3ec462d1cf Add field object type (ot)
Added this CMCD-Object field to Common Media Client Data (CMCD) logging.

#minor-release

PiperOrigin-RevId: 554843305
2023-08-10 12:06:13 +00:00
christosts
cba027c3b4 Util.getMaxPendingFramesCountForMediaCodecDecoders(): Remove unused arguments
PiperOrigin-RevId: 554838494
2023-08-10 12:05:08 +00:00