603 Commits

Author SHA1 Message Date
olly
4b30cca914 Update @SuppressWarnings annotations for go/nullness diagnostics
in preparation for upgrading the version of the Checker Framework in google3.

More information: go/checker-3110-lsc

PiperOrigin-RevId: 377925828
2021-06-08 13:02:47 +01:00
aquilescanta
af4b891c99 Use UnrecognizedFormatException for progressive media only
PiperOrigin-RevId: 377303025
2021-06-03 20:07:04 +01:00
tonihei
8ded11753e Fix issue where getFirstSampleIndex was called on spliced in chunks.
We need to avoid reading and skipping into preload chunks as they
may need to be discarded. The current code iterates over all chunks,
but this can be simplified by just checking the last chunk knowing
that the preload chunk must always be the last one.

As a result, we avoid calling getFirstSampleIndex on all chunks. This
is a bug since the method is not allowed to be called for chunks
that have been spliced in. This still leaves the smaller issue of
potentially calling this method for spliced-in preload chunks, which
will be solved separately.

Issue: #8937

#minor-release

PiperOrigin-RevId: 375053638
2021-05-21 12:05:23 +01:00
tonihei
08259f8987 Don't allow spliced-in preload chunks.
Preload chunks may still need to be discarded. However, we don't
currently support discarding spliced-in chunks. Thus, we need to
avoid loadng a preload chunk that needs to be spliced-in.

Issue: #8937

#minor-release

PiperOrigin-RevId: 374851661
2021-05-20 15:45:30 +01:00
tonihei
6fd20ddace Fix start position for non-precise startOffset and user-set liveOffset
Also added test cases covering this.

PiperOrigin-RevId: 374218514
2021-05-17 18:20:54 +01:00
Oliver Woodman
e20ea797ef Merge pull request #8767 from uvjustin:hls-start-from-independent-part
PiperOrigin-RevId: 373343326
2021-05-12 13:54:44 +01:00
olly
1da25f5979 Remove deprecated MediaSource.getTag
PiperOrigin-RevId: 373222158
2021-05-12 11:52:03 +01:00
bachinger
4c1a294b2e Format Java source files
PiperOrigin-RevId: 372127633
2021-05-06 13:32:25 +01:00
olly
67fc1f0c0a Remove deprecated Downloader constructors
PiperOrigin-RevId: 371307278
2021-04-30 18:54:32 +01:00
ibaker
dafea4e40f Re-format some javadoc
PiperOrigin-RevId: 369642047
2021-04-21 18:46:00 +01:00
Oliver Woodman
9fc3b48377 Merge pull request #8812 from TiVo:p-fix-iframe-only-implicit-init
PiperOrigin-RevId: 369215083
2021-04-20 00:10:13 +01:00
ibaker
fff7b8079a Replace Util.toUpperInvariant() with Ascii.toUpperCase()
Even when fixed to the US locale (and thus avoiding surprising behaviour
in e.g. Turkish locale with "i" and "I") there are unexpected behaviours
when upper and lower casing non-ASCII characters.

For example it's sometimes not symmetric, e.g.:
"ẞ".toLowerCase() -> "ß"
"ß".toUpperCase() -> "SS"

In all the ExoPlayer usages we are either dealing with known-ASCII
strings (e.g. MIME types) or comparing against ASCII constant strings
anyway, so it seems easier to just use Guava's ASCII-only class in these
cases.

Util.toUpperInvariant() is null-tolerant, while Ascii.toLowercase() is
not. Most usages in this change are clearly non-null. The BandwidthMeter
usages aren't annotated @Nullable, but the current code *would* work if
countryCode was null in both cases. These methods will now throw NPE if
they're passed null.

PiperOrigin-RevId: 368816287
2021-04-16 14:13:08 +01:00
ibaker
c50084e7ba Replace Util.toLowerInvariant() with Ascii.toLowerCase()
Even when fixed to the US locale (and thus avoiding surprising behaviour
in e.g. Turkish locale with "i" and "I") there are unexpected behaviours
when upper and lower casing non-ASCII characters.

For example it's sometimes not symmetric, e.g.:
"ẞ".toLowerCase() -> "ß"
"ß".toUpperCase() -> "SS"

In all the ExoPlayer usages we are either dealing with known-ASCII
strings (e.g. MIME types) or comparing against ASCII constant strings
anyway, so it seems easier to just use Guava's ASCII-only class in these
cases.

This change also includes some null-twiddling, because
Util.toLowerInvariant() is null tolerant, while Ascii.toLowerCase() is
not. Most of the usages were already non-null, and it was easy enough to
change the remaining ones to be so by simple reordering of statements.

I'll make an equivalent change for Util.toUpperInvariant() next.

PiperOrigin-RevId: 368419813
2021-04-15 10:51:48 +01:00
Steve Mayhew
0b557f3501 Adds test cases for iframe only with EXT-X-MAP
Adds a unit test case to cover EXT-X-MAP with byterange attribute.
2021-04-12 14:37:31 -07:00
marcbaechinger
14993c4139 Merge pull request #8764 from uvjustin:dev-v2
PiperOrigin-RevId: 367994410
2021-04-12 15:39:09 +01:00
olly
ce4c655c83 Fix 1 ErrorProneStyle finding:
* @Nullable is not a TYPE_USE annotation, so should appear before any modifiers and after Javadocs.
  (see go/java-style#s4.8.5-annotations)

This CL looks good? Just LGTM and Approve it!
This CL doesn’t look good? This is what you can do:
* Suggest a fix on the CL (go/how-to-suggest-fix).
* Revert this CL, by replying "REVERT: <provide reason>"
* File a bug under go/error-prone-bug for category ErrorProneStyle if the change looks generally problematic.
* Revert this CL and not get a CL that cleans up these paths in the future by
replying "BLOCKLIST: <provide reason>". This is not reversible! We recommend to
opt out the respective paths in your CL Robot configuration instead:
go/clrobot-opt-out.

This CL was generated by CL Robot - a tool that cleans up code findings
(go/clrobot). The affected code paths have been enabled for CL Robot in //depot/google3/java/com/google/android/libraries/exoplayer/METADATA which is reachable following include_presubmits from //depot/google3/third_party/java_src/android_libs/exoplayer/METADATA.
Anything wrong with the signup? File a bug at go/clrobot-bug.

#codehealth

PiperOrigin-RevId: 367053059
2021-04-09 13:18:07 +01:00
olly
a5c47243f4 HLS: Fix incorrect handling of byte ranges for EXT-X-MAP tags
Issue: #8783
#minor-release
PiperOrigin-RevId: 366265419
2021-04-06 16:13:52 +01:00
olly
1f54776024 HLS: Set initial SampleQueue start times
This ensures BUFFER_FLAG_DECODE_ONLY is set on samples that are
before the playback start position, in the case that the queue
is created after the start position is set.

#minor-release

PiperOrigin-RevId: 366249188
2021-04-01 16:07:07 +01:00
Justin Wong
b3c8ffeb50 Use #EXT-X-START PRECISE attribute 2021-03-29 00:48:10 +08:00
Justin Wong
1fe7fbc4cd Use most recent part for start position 2021-03-28 23:59:00 +08:00
Justin Wong
a3d6f03ff9 Use playlist start time for target live offset 2021-03-28 20:25:44 +08:00
aquilescanta
8337991be3 Avoid invalid extractors in DefaultHlsExtractorFactory
This change fixes playback of playlists where segments have the
extension and Content-Type of JPEG pictures (although in reality)
they are transport streams. File inferrence before this change will
cause an exception when assuming the inferred file type is one of
the allowed HLS containers.

#minor-release
Issue: #8733
PiperOrigin-RevId: 363641277
2021-03-24 18:04:17 +00:00
olly
2d9177b7c2 SampleStream/SampleQueue: Introduce read flags
- 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
2021-03-24 18:03:28 +00:00
olly
6f8a8fbc1c HLS: Allow audio variants to initialize the timestamp adjuster
This makes HLS playback less liable to become stuck if discontinuity
tags are inserted at different times across media playlists.

Issue: #8700
Issue: #8372
PiperOrigin-RevId: 362903428
2021-03-15 19:14:52 +00:00
aquilescanta
c8c51452cd Fallback to inferred file types when sniffing fails
If none of the extractors successfully sniff the content then we will fall back
to inferred file types in the following order:
- Webvtt if the media comes from a SUBTITLE EXT-X-MEDIA.
- The type of media declared in the HTTP "Content-Type" header.
- The type of the media according to the file extension.
- Transport stream.

Issue: #8700
PiperOrigin-RevId: 362519769
2021-03-15 19:14:06 +00:00
olly
2a22b347c4 Suppress SwitchIntDef warning where it makes sense
In both cases it's deliberate that all excluded constants should use
the default branch. Furthermore, there are quite a lot of excluded
constants missing, so it's probably better to suppress the warning
than to include them all.

#minor-release

PiperOrigin-RevId: 355426749
2021-02-04 00:24:04 +00:00
krocard
ec43735054 Split mutations method out of TrackSelection
`TrackSelection` had mutation methods which were to be called only
internally by ExoPlayer components but were exposed in the
public `Player` interface.

The mutation methods have been moved out of `TrackSelection`
to a new class `ExoTrackSelection`.

Current track related read-only method have also been moved out,
because they are actually something quite unclear.
Even for a single item playlist, it's the track being buffered rather
than the track being played, which is unclear.
But when you have a playlist it starts to get really confusing,
because if the next item is being buffered, then it's actually
the last track to be buffered in the currently playing item.
As a final aside, the implementations don't do proper thread synchronization
to ensure visibility of updated state by the calling thread.

Exposing those mutable methods in the public `Player` interface
was problematic because they leaking internal concepts of `ExoPlayer`.
This is also required to minimize the `Player` interface for long term
stability.

`ExoTrackSelection` is a subclass of `TrackSelection`.
This is not ideal as an `TrackSelection` implementation could
break the current immutability.
This was done in order for this refactor to be simpler.
A future patch will fully split the two classes.

All `MediaPeriod` and `Sources` had to be updated to use the new
`TrackSelection` dynamic aspect class name.
An alternative would have been to break ExoPlayer's public API, keeping
`TrackSelection` as the dynamic aspect name, and calling the public static
aspect class `TrackSelectionState` or similar.
Nevertheless, while it would have impacted less files, it would have
many more small apps and casual users of ExoPlayer.

#player-to-common

PiperOrigin-RevId: 353637924
2021-01-25 15:37:38 +00:00
ibaker
5b9fa7d7d9 Add MediaSourceFactory#setDrmSessionManagerProvider()
Deprecate other DRM config methods.

Issue: #8466
PiperOrigin-RevId: 353251452
2021-01-22 16:58:56 +00:00
ibaker
b2a42ea157 Rename MediaSourceDrmHelper to DefaultDrmSessionManagerProvider
Also move it to the `drm` package, and extract a
`DrmSessionManagerProvider` interface.

I'll add `MediaSourceFactory.setDrmSessionProvider()` in a follow-up
change.

Issue: #8466
PiperOrigin-RevId: 352582559
2021-01-19 19:24:06 +00:00
christosts
d4a84b88b5 Remove deprecated method setMinLoadableRetryCount().
Remove setMinLoadableRetryCount() from SingleSampleMediaSource,
DashMediaSource, HlsMediaSource and SsMediaSource factories.

PiperOrigin-RevId: 352008657
2021-01-17 21:51:13 +00:00
bachinger
6e8af81ddc Reload HLS media playlist when merging delta update fails
Issue: #5011
PiperOrigin-RevId: 350550204
2021-01-08 15:31:54 +00:00
bachinger
b05fa731d8 Propagate segment properties when merging HLS delta updates
Issue: #5011
PiperOrigin-RevId: 350540152
2021-01-08 15:31:22 +00:00
olly
d01093d711 Rollback of dd7b379dc0
*** Original commit ***

DataSource.open() throws if already opened.

Update DataSource implementations to throw an error if open() is called
when the DataSource is already open.

***

PiperOrigin-RevId: 348783425
2020-12-23 22:53:24 +00:00
christosts
dd7b379dc0 DataSource.open() throws if already opened.
Update DataSource implementations to throw an error if open() is called
when the DataSource is already open.

PiperOrigin-RevId: 348609860
2020-12-23 22:52:21 +00:00
tonihei
cf0a4e528e Disable delta updates until merging bug is fixed.
The delta updates loose information about previous init segments.
Until this is properly fixed, we can avoid the problem by not
using delta updates.

Issue: #5011
PiperOrigin-RevId: 348023895
2020-12-23 22:50:51 +00:00
tonihei
490519a49a Update HLS window duration with trailing parts.
If we have trailing parts the available window should reach to
the end of all trailing parts and not only to the last finished
segment.

Issue: #5011
PiperOrigin-RevId: 347996626
2020-12-23 22:48:38 +00:00
christosts
8da4eaa377 HlsPlaylistParser: ignore subtitles without URI
Issue: #8323
PiperOrigin-RevId: 347827615
2020-12-17 11:25:54 +00:00
bachinger
05c928f96d Add live configuration to Timeline.Window
Issue: #5011
PiperOrigin-RevId: 346828103
2020-12-14 10:17:23 +00:00
bachinger
734565a83c Use parts when choosing next chunk after track change
Issue: #5011
PiperOrigin-RevId: 346080748
2020-12-14 10:15:05 +00:00
bachinger
3b7aa1d5f1 Use HLS rendition report when changing primary playlist
Issue: #5011
PiperOrigin-RevId: 345440697
2020-12-03 17:12:41 +00:00
bachinger
4907c2153b Add FLAG_MIGHT_NOT_USE_FULL_NETWORK_SPEED to HLS preload media chunks
Issue: #5011
PiperOrigin-RevId: 345425048
2020-12-03 17:12:04 +00:00
bachinger
affdff65e3 Remove HLS chunks based on parts not in playlist anymore
Issue: #5011
PiperOrigin-RevId: 345275266
2020-12-03 17:11:22 +00:00
Oliver Woodman
b22b53f6f1 Merge pull request #8215 from TiVo:p-fix-apple-iframe-bug
PiperOrigin-RevId: 345202157
2020-12-03 17:11:03 +00:00
bachinger
1a5d79b78a Schedule load for non-primary playlist for low latency streams
Low latency streams potentially need to remove preload chunks in case they are removed from the playlist. Hence we need to schedule loading the next playlist even if the playlist is not a primary playlist.

Issue: #5011
PiperOrigin-RevId: 344995891
2020-12-03 17:10:10 +00:00
tonihei
8349d7849e Prevent reading into preload parts.
This is to ensure we can still discard the data if needed.

Issue: #5011
PiperOrigin-RevId: 344977548
2020-12-03 17:09:44 +00:00
bachinger
e6046a5c07 Discard HLS preload chunks when an HTTP 410 or 404 occurs
This change avoids an early fatal exception for replaced hinted parts.

Issue: #5011
PiperOrigin-RevId: 344828076
2020-12-03 17:09:17 +00:00
andrewlewis
4446e2637d Fix unexpected multiline comments
#exofixit

PiperOrigin-RevId: 344517105
2020-11-30 09:32:25 +00:00
ibaker
46598a46fd Audit usages of ParsableByteArray#reset(int)
This method should be assumed to clear the data of the underlying array
(it will do this if the new limit > data.length).

This means it should only be called (directly) before writing into the
backing array.

It shouldn't be used as a shorthand for position=0, limit=x - those
should be two explicit method calls.

Most of these changes are no-ops, but they make the code more correct.

The TS SectionReader can't be easily changed to be 'safe', because it
relies on sectionData maintaining state between iterations of the while
loop. Instead I've added comments justifying the existing code.

PiperOrigin-RevId: 344515340
2020-11-30 09:31:49 +00:00
bachinger
c17d1091f3 Remove "live" from fields in MediaItem.LiveConfiguraton
#exofixit

PiperOrigin-RevId: 344065519
2020-11-27 11:05:54 +00:00
bachinger
39f8c77568 Replace cancelled HLS preload parts
Issue: #5011
PiperOrigin-RevId: 343277357
2020-11-19 17:13:19 +00:00