The new onPositionDiscontinuity callback contains sufficient information, so
that this former workaround to obtain the position before a seek is no longer
needed.
PiperOrigin-RevId: 365993937
Aims to achieve visibility parity with MediaCodecRenderer#onQueueInputBuffer.
Allows measuring the time when the codec queue the first input buffer in the codec. Which means the Codec has been initialized and is about to start decoding.
It also allows measuring how long it takes for the Codec to render its first frame.
PiperOrigin-RevId: 365906756
If the player is created on a background thread (which is allowed
as the only exception to the access-on-one-thread-only rule), it
may happen that a callback on the main thread tries to access the
player before the constructor even finished. This is dangerous and
can cause exceptions due to uninitialized variables.
To solve this, we can make sure that every player access is blocked
until the constructor finished. Blocking is safe because the
constructor itself is not doing any blocking work or acquiring locks.
The thread verification method is already called on every entry
point to the player, so we can reuse the same method for checking.
PiperOrigin-RevId: 365792949
The extended onPositionDiscontinuity callback can be used to improve some
listener classes:
- Listening to onTimelineChanged to detect discontinuities is no longer needed.
- Listening to onSeekStarted is no longer needed as the start position is part
of the onPositionDiscontinuty callback.
- The exact old position is also useful for media time history logging.
As a side effect, removing onSeekStarted handling from PlaybackStatsListener
fixes Issue: #8675 that was caused by the special EventTime handling for
onSeekStarted.
PiperOrigin-RevId: 365558959
The hacky workaround for APIs 29/30 doesn't work on API 31. Instead,
we can use the onDisplayInfoChanged callback, that is accessible from
API 31.
PiperOrigin-RevId: 364997282
The BasePlayer implementation of add/remove
Listener knows about Components.
As those are removed from the Player
interface, the implementation of those
methods needs to be moved down in Player
implementations.
This commit makes no functional change.
PiperOrigin-RevId: 364985291
Null was an alias for DEFAULT. Remove this for nullness
safety in the API.
The ExoPlayer implementation still checks for null and
replaces it by DEFAULT, so this is ABI compatible.
PiperOrigin-RevId: 364370017
The main user of the Util method is the bandwidth meter to set the
initial network type. If this is the first call to the
NetworkTypeObserver, then we should also allow the first update to
a known network type even if no reset on network type is activated.
The other uses are analytics listeners that check the network type
at certain events. This can just use the lookup method of the
NetworkTypeObserver.
PiperOrigin-RevId: 363670771
- Update the three `HttpDataSource` implementations to use the
Content-Range response header to determine when this is the
case. The Content-Range header is included when the status
code is 416. See [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/416).
- Update `ByteArrayDataSource` to conform to the requirement.
- Update `DataSourceContractTest` to enforce the requirement.
PiperOrigin-RevId: 363642114
- SampleQueue.peek is replaced with SampleQueue.read with
FLAG_PEEK. This also exposes peek functionality through
SampleStream.
- Use of DecoderInputBuffer.isFlagsOnly is replaced with
FLAG_OMIT_SAMPLE_DATA. This flag can be used with or
without FLAG_PEEK, where-as previously the read position
would never be advanced for an isFlagsOnly buffer.
- formatRequired is replaced with FLAG_FORMAT_REQUIRED.
PiperOrigin-RevId: 363460105
In order to detect 5G-NSA, we need to remove Util.getNetworkType
and replace it with a class that is actively listening to changes.
The network type observation in DefaultBandwidthMeter already provides
the right framework to integrate this and in order to facilitate
further changes we move it to a separate Util class.
The overall effect of this change should be a complete no-op.
PiperOrigin-RevId: 363384567
Assert that opening the DataSource at the end of the resource
results in only RESULT_END_OF_INPUT being read.
open() and read() are still permitted to throw, although this
permissiveness will be removed in subsequent commits.
PiperOrigin-RevId: 362905314
According to the spec (section 8.4.2), high numeric values represent low
priorities, so we need to flip this sort.
Issue: #8704
#minor-release
PiperOrigin-RevId: 362558370
`ImaAdsLoader` clears its `AdPlaybackState` when it's released but this could
cause `AdsMediaSource` to look up information in the ad playback state that is
no longer in bounds.
Issue: #8693
#minor-release
PiperOrigin-RevId: 362556286
When comparing stream bitrate with available (allocated) bandwidth,
we need to take the playback speed into account. In the current
calculation, this can happen on both sides of the equation, but we
take the time to first byte into account, we need to move the speed
into the available, allocated bandwidth.
This change moves the speed adjustment to the bandwidth calculation
side in AdaptiveTrackSelection.
PiperOrigin-RevId: 362540071