1724 Commits

Author SHA1 Message Date
olly
2c54b83464 Move CachedContentIndex storage behind an interface
This interface will get an SQLite implementation in a subsequent CL

PiperOrigin-RevId: 230693881
2019-01-29 16:41:34 +00:00
olly
f182c0c116 Centralize serialization in CachedContentIndex
We need to support serialization to/from an SQLite table. The
model of passing something around for each class to write into
doesn't work well for SQL, and it would be messy to have two
different structural designs for serialization. This change
centralizes the logic in CachedContentIndex, where a centralized
SQL based version can more easily sit alongside it.

PiperOrigin-RevId: 230692291
2019-01-29 16:41:24 +00:00
tonihei
49b9775d08 Add getReadingPositionUs to Renderer.
This method is a generalization of the existing hasReadStreamToEnd. It is
useful to determine whether a renderer already read beyond a new duration of
a period.

PiperOrigin-RevId: 230689165
2019-01-29 16:41:13 +00:00
tonihei
d7b3820175 Make updateQueuedPeriods more readable and fix bug.
1. The method kept track of the current period index to check if the next
period is still in the correct period. This is unneccessary since we no longer
use the period index but the actual uid in MediaPeriodId and mismatches are
already detected by canKeepMediaPeriodHolder.
2. We updated the MediaPeriodIndfo twice: once in getFollowingMediaPeriodInfo
and once in getUpdatedMediaPeriodInfo. That's confusing and difficult to
follow. The only difference is that getUpdatedMediaPeriodInfo keeps the
content position while getFollowingMediaPeriodInfo resets it. This is made more
explicit for readability.
3. The durations compatibility check for all following periods was broken as
it compared the same durations (partly due to the confusion caused by 2.)

PiperOrigin-RevId: 230519295
2019-01-29 16:40:51 +00:00
olly
3a54d744b9 Default to respecting the DataSpec cache fragmentation flag
Issue: #4253
PiperOrigin-RevId: 230497544
2019-01-29 16:40:41 +00:00
olly
de3a749b97 Fix scheduler NPE in DownloadService
PiperOrigin-RevId: 230260266
2019-01-29 16:40:09 +00:00
tonihei
923aa420df Use loading period event time for fatal load errors.
ExoPlaybackExceptions of type SOURCE are always associated with the loading
period and thus we can use the event time for the loading period in
onPlayerError. Renderer and unexpected exceptions are still associated with the
currently playing period.

Issue:#5407
PiperOrigin-RevId: 230216253
2019-01-21 14:10:49 +00:00
olly
c2f6dd6b0a Only allow one layer of sub-directories in the cache for now
PiperOrigin-RevId: 230209898
2019-01-21 12:58:16 +00:00
tonihei
e4eaaedad3 Add max video size workaround for Amlogic decoder.
The Amlogic awesome decoder reduces the video size of interlaced videos by half
if the internal configuration isn't force reset with new maximum input size
values. The product of these new values must exceed 1920x1088 to force the
reset.

Issue:#5003
PiperOrigin-RevId: 230206675
2019-01-21 12:58:06 +00:00
olly
fb6154a905 Wipe database on downgrade
PiperOrigin-RevId: 230203593
2019-01-21 12:57:56 +00:00
aquilescanta
93e24561bb Add DefaultTsPayloadReaderFactory flag to ignore HDMV DTS streams
Prevents collisions with SCTE-35 subtitles.

Issue:#5330
PiperOrigin-RevId: 230195494
2019-01-21 12:57:46 +00:00
olly
82da627c1a Split out shared database components for reuse in caching
PiperOrigin-RevId: 229946997
2019-01-21 12:57:35 +00:00
tonihei
02dc937c78 Fix flaky DownloadIndexUtilTest.
PiperOrigin-RevId: 229934901
2019-01-21 12:57:25 +00:00
olly
14eb561e38 Use MediaCrypto.setMediaDrmSession to avoid black flicker
Issue: #3561
PiperOrigin-RevId: 229934093
2019-01-21 12:57:04 +00:00
tonihei
23c07e5c4d Update buffer-based ABR to not select track in constructor.
This mimicks a similar change in the default AdaptiveTrackSelection.
Also adds an option to cap initial format height.

PiperOrigin-RevId: 229923149
2019-01-21 12:56:33 +00:00
tonihei
ac86d3b5f6 Add missing @Nullable to SimpleExoPlayer fields and methods.
Issue:#5402
PiperOrigin-RevId: 229758525
2019-01-17 17:26:35 +00:00
tonihei
22413b8037 Add start position to MediaSource.createPeriod.
That's the same position set in MediaPeriod.prepare (where it may be removed
in the future).

Having the position at an earlier point is necessary to fix an
issue with lazy preparation in ConcatenatingMediaSource where the prepare
position was assumed to be known but MediaPeriod.prepare hasn't been called
yet.

Issue:#5350
PiperOrigin-RevId: 229756637
2019-01-17 17:26:24 +00:00
eguven
f2139d1b71 Add DownloadIndexUtil
This class includes helper methods to upgrade ActionFiles
and custom download records to DownloadIndex.

PiperOrigin-RevId: 229744441
2019-01-17 17:26:01 +00:00
eguven
ec77f737ee Make DownloadManager watch requirements directly
PiperOrigin-RevId: 229544734
2019-01-17 14:37:12 +00:00
olly
36883e6277 Bump version for 2.9.4 release
PiperOrigin-RevId: 229364563
2019-01-15 15:03:35 +00:00
Oliver Woodman
3b5e8ada31 Merge pull request #5355 from zsmatyas:dev-v2
PiperOrigin-RevId: 229364147
2019-01-15 15:03:24 +00:00
tonihei
b97b35e2e0 Add buffer flag for last sample to improve buffered position calculation.
The buffered position is currently based on the mimimum queued timestamp of
all AV tracks. If the tracks have unequal lengths, one track continues loading
without bounds as the "buffered position" will always stay at the shorter
track's duration.

This change adds an optional buffer flag to mark the last sample of the
stream. This is set in the Mp4Extractor only so far. ExtractorMediaSource
uses this flag to ignore AV streams in the buffered duration calculation if
they already finished loading.

Issue:#3670
PiperOrigin-RevId: 229359899
2019-01-15 14:29:07 +00:00
tonihei
fcda01eb5c Remove messages on release of ConcatenatingMediaSource.
That was previously handled by the player. But since we switched to Handler
messages instead of player messages, we should do that manually.

PiperOrigin-RevId: 229341747
2019-01-15 14:28:56 +00:00
tonihei
1900e94144 Do not select a track in AdaptiveTrackSelection constructor.
This is not necessary as the track selection needs to be updated with
updateSelectedTrack anyway. It's also error-prone as the selection code
calls into a protected method of a not fully initialized class.

PiperOrigin-RevId: 229331669
2019-01-15 14:28:46 +00:00
olly
0bfbcea632 Reset requiresSecureDecoder boolean on codec release
PiperOrigin-RevId: 229253065
2019-01-14 23:58:35 +00:00
olly
1b62277a0b Disable cache fragmentation except for progressive
DataSpec.FLAG_ALLOW_CACHE_FRAGMENTATION is added to indicate to the
cache when fragmentation is allowed. This flag is set for progressive
requests only.

To avoid breaking changes, CacheDataSink defaults to ignoring the flag
(and enabling fragmentation) for now. Respecting the flag can be
enabled manually. DownloaderConstructorHelper enables respecting of
the flag.

Issue: #4253
PiperOrigin-RevId: 229176835
2019-01-14 23:58:25 +00:00
tonihei
86637facdd Don't forget isSeekable in ExtractorMediaSource.
We currently forget whether a source is seekable at re-preparation. This was
implemented intentionally this way under the assumption that we really can't seek
until we have loaded the seek map again. However, seek operations are only
allowed after a media period is prepared. So there is no harm in remembering
whether a source is seekable.

This problem currently prevents reusing ClippingMediaSources with
ExtractorMediaSource and a non-zero start clip position.

Issue: #5351
PiperOrigin-RevId: 229169441
2019-01-14 23:58:15 +00:00
andrewlewis
f44fc542bb Blacklist OMX.SEC.mp3.dec for more devices
Issue: #4519
PiperOrigin-RevId: 229145790
2019-01-14 23:58:05 +00:00
olly
1f03093dc5 DRM: Pass sessionId rather than MediaCrypto
ExoMediaCrypto.requiresSecureDecoderComponent() is removed, and
FrameworkMediaCrypto.forceAllowInsecureDecoderComponents is made
public to allow determining whether a secure decoder is required
to be implemented in MediaCodecRenderer.

PiperOrigin-RevId: 228909771
2019-01-14 23:57:55 +00:00
olly
2d30d66746 Fix release of DRM sessions
There were some edge cases in which we'd forget to release DRM
sessions. For example if we read a format and acquired a
pendingDrmSession (in onInputFormatChanged), then immediately
read another format and overwrote pendingDrmSession, we'd
forget to release the one that's been overwritten.

This change hopefully makes release much clearer. We keep a list
of all drm sessions we're currently holding. Whenever we update
either drmSession or pendingDrmSession, we release any other
sessions that are in the list.

PiperOrigin-RevId: 228905465
2019-01-14 23:57:45 +00:00
eguven
71d4f39400 Call Listener methods on the thread started RequirementsWatcher
PiperOrigin-RevId: 228701917
2019-01-14 23:57:34 +00:00
eguven
92bec21c03 Add DownloadIndex and DefaultDownloadIndex
DownloadIndex will be used to store and query DownloadStates.

PiperOrigin-RevId: 228673766
2019-01-14 23:57:24 +00:00
tonihei
637b52ae0e Add missing call to timeline.getWindow.
The window object is used without being filled with data. This used to work
well for most cases as the same live stream is sending regular updates and the
first update is almost never used if it's not the first item in a playlist.

It causes problems when the first timeline update of a live stream is actually
used for playback (e.g. when the live stream is lazily prepared in a playlist
and played first).

PiperOrigin-RevId: 228530232
2019-01-14 23:57:14 +00:00
Zsolt Matyas
fff602358f CEA608: Limiting duplicated command checks to immediate frames
Reported in https://github.com/google/ExoPlayer/issues/3860
For failing examples see the github link above.

[Problem]
We drop matching control codes even if they are not received on
consecutive frames.

The specification says
"(4) If the first transmission of a control code pair passes parity,
it is acted upon within one video frame. If the NEXT frame contains
a perfect repeat of the same pair, the redundant code is ignored."

Keyword is the NEXT. The frames must arrive immediately after
each other.

See https://www.law.cornell.edu/cfr/text/47/79.101

[Solution]
Set an additional flag when any data is processed. Control code
duplication checks should be limited only for the first control
byte pairs processed after any control code.

[Test]
Sarnoff tests have equivalent CEA708 and CEA608 Streams.
2019-01-10 12:15:14 -08:00
Oliver Woodman
e0c6f538af Merge pull request #5201 from zsmatyas:dev-v2
PiperOrigin-RevId: 228341073
2019-01-08 17:17:59 +00:00
eguven
0b56a03880 Use stop flag to prevent download start when not initialization/released
PiperOrigin-RevId: 228324452
2019-01-08 17:17:47 +00:00
olly
255a34d367 Noop cleanup of Cea608Decoder.CueBuilder
PiperOrigin-RevId: 228309236
2019-01-08 17:17:37 +00:00
olly
6e127d0152 SimpleCache: Scan sub-directories during initialization
This is the initialization part of mitigating issue #4253. The
remaining work is on the writing side, and is simply a case of
having startFile return File instances that are sharded into
sub-directories. We still need to decide what scheme we want
to use for doing that.

Issue: #4253
PiperOrigin-RevId: 228306327
2019-01-08 17:17:27 +00:00
olly
194caf23e5 Doc fix.
PiperOrigin-RevId: 228296962
2019-01-08 17:17:16 +00:00
olly
8c47b02083 Reduce number of calls to File.length()
Calls to File.length() can be O(N) where N is the number of files
in the containing folder. This is believed to be true for at least
FAT32. Repeated calls for the same file tend to be faster,
presumably due to caching in the file system, however are still
surprisingly expensive. Hence minimizing the number of calls is
preferable.

Issue: #4253
PiperOrigin-RevId: 228179921
2019-01-08 07:38:31 +00:00
aquilescanta
147deafd01 Increase search size in mp4 sniffing once moov has been found
Issue:#5320
PiperOrigin-RevId: 228142567
2019-01-08 07:38:11 +00:00
tonihei
e8a7cb2546 Remove player and isTopLevelSource parameters from MediaSource.prepare.
They are not longer needed anywhere, are error-prone (because of threading
requirements), and complicate testing and using MediaSources without a player.

PiperOrigin-RevId: 227871157
2019-01-08 07:38:00 +00:00
tonihei
6828797555 Pass Handler together with Runnable callbacks for playlist commands.
We currently either use the app thread returned by the player or the thread
the commands are called on depending on whether the media source is already
prepared or not.

This change lets the application decide which callback thread to use. As a
side effect, we also don't longer need access the player instance passed to
MediaSource.prepare.

PiperOrigin-RevId: 227871111
2019-01-08 07:37:50 +00:00
andrewlewis
14027bc98e Treat AVERROR_INVALIDDATA as non-fatal
Also configure the FFmpeg context to ignore errors as far as possible (this
appears to have an effect only for certain decoders).

Issue: #5293
PiperOrigin-RevId: 227851397
2019-01-08 07:37:30 +00:00
andrewlewis
5efbcb4443 Fix nullness issue
PiperOrigin-RevId: 227822937
2019-01-08 07:37:13 +00:00
andrewlewis
ed1f41db1b Parse frame rate from 'mdta' metadata
PiperOrigin-RevId: 227813461
2019-01-08 07:37:01 +00:00
aquilescanta
d30375c9a1 Prevent IllegalStateException in Mp4 sniffing
If a negative value is read, sniffing should just fail.

PiperOrigin-RevId: 227689568
2019-01-08 07:34:33 +00:00
eguven
a940d8bc9d Use removing and restarting state internally in DownloadManager
PiperOrigin-RevId: 227682159
2019-01-08 07:34:14 +00:00
tonihei
c130723929 Replace isTopLevelSource check by period count check in AdsMediaSource.
The top level requirement only tried to ensure that the entire timeline only
has one period. This is already asserted by ImaAdsLoader. AdsMediaSource
itself works fine as long as the wrapped timeline has one period only. This
is now asserted instead.

PiperOrigin-RevId: 227682141
2019-01-08 07:34:03 +00:00
tonihei
e4ad90efd0 Set Player separately in AdsLoader interface.
Passing the player through MediaSource.prepare is only needed for the AdsLoader
and complicates other usages of MediaSource. Providing the player directly to
the AdsLoader is also in line with the usage pattern of PlayerView and other
components.

Also rename methods to start/stop to better reflect their usage.

PiperOrigin-RevId: 227682112
2019-01-08 07:33:52 +00:00