1839 Commits

Author SHA1 Message Date
tonihei
0a8ae74217 Update DownloadHelper to use MediaSource and MediaPeriod directly.
This requires to prepare the media source and the periods in a small helper similar
to the metadata retriever. It also gets rid of the need to have abstract protected
methods to load the manifest, to extract the track groups and to convert to stream keys,
as this can now be handled by the media period.

PiperOrigin-RevId: 231385590
2019-01-29 16:44:56 +00:00
tonihei
92bf8e918c Change getStreamKeys to take a list of TrackSelections.
Converting a single track selection to stream keys is only possible if the output
is independent from other track selections being made.

This is not the case for DASH and HLS embedded track groups which should select the
already selected primary track if possible (and thus needs to know  whether a primary
track group is selected).

Also, update the test method to take a period index.

PiperOrigin-RevId: 231385490
2019-01-29 16:44:15 +00:00
tonihei
f74e0eb992 Add back deprecated MediaSource.prepareSource for ExoPlayerSampleExtractor.
This should be removed after releasing.

PiperOrigin-RevId: 231380393
2019-01-29 16:44:04 +00:00
olly
39505452de Make VersionTable static
The way it is currently, it's very unclear that an operation on the
version table will correctly belong to a transaction in code such as
this, taken from DefaultDownloadIndex:

writableDatabase.beginTransaction();
try {
  writableDatabase.execSQL(...);
  versionTable.setVersion(...);
  writableDatabase.setTransactionSuccessful();
} finally {
  writableDatabase.endTransaction();
}

This change explicitly passes the database, to make it obvious that
the operation will really go into the same transaction:

writableDatabase.beginTransaction();
try {
  writableDatabase.execSQL(....);
  VersionTable.setVersion(writableDatabase, ...);
  writableDatabase.setTransactionSuccessful();
} finally {
  writableDatabase.endTransaction();
}

PiperOrigin-RevId: 231374933
2019-01-29 16:43:52 +00:00
eguven
bac8dfea12 Add DownloadState not met requirement stop flags
PiperOrigin-RevId: 231223201
2019-01-29 16:43:42 +00:00
olly
19144c4c73 Allow to disable libyuv dependency on LIBVPX
Goal: reduce binary size.
PiperOrigin-RevId: 231198579
2019-01-29 16:43:32 +00:00
andrewlewis
866835ea03 Fix float output capability check
Float output is only possible from API 21, but the high-res int
to float conversion path was checking for 32-bit PCM not float
output capability.

PiperOrigin-RevId: 231172495
2019-01-29 16:43:20 +00:00
olly
6b068c6ffb Clarify LoopingMediaSource documentation
PiperOrigin-RevId: 231171425
2019-01-29 16:43:11 +00:00
olly
3c6b72ee29 Fix nullness test
PiperOrigin-RevId: 230889470
2019-01-29 16:43:00 +00:00
olly
a1c13ca6f5 Hack to instantiate ExoDatabaseProvider without a context
This will allow CachedContentIndex to start using database
storage without us having to change the SimpleCache and
CachedContentIndex constructors to require a Context or a
DatabaseProvider.

PiperOrigin-RevId: 230884501
2019-01-29 16:42:50 +00:00
tonihei
582adb748a Decouple end position from MediaPeriodId again.
If are allowing changing durations of periods, we shouldn't use the end position
of clipped content as part of the id as it may change. This change moves the end
position back to MediaPeriodInfo and adds the next ad group index to the id
instead to ensure we still have unique ids for all content parts.

PiperOrigin-RevId: 230878389
2019-01-29 16:42:29 +00:00
aquilescanta
642a0275d8 Propagate ExoCast errors receiver from the receiver app
PiperOrigin-RevId: 230717561
2019-01-29 16:41:55 +00:00
olly
355b3d6334 Increase minSdkVersion to 16
The combination of pre-16 API levels accounting for ~0.5% of the device
population, and that the most important components in ExoPlayer (e.g.
the MediaCodec renderers) have always required API level 16, mean it's
very unlikely this will negatively impact on anyone.

PiperOrigin-RevId: 230701808
2019-01-29 16:41:45 +00:00
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
ybai001
e462c6aab7 Add AC-4 format support
* Add AC-4 MIME type definition
 * Add AC-4 format support in Mp4Extractor and TsExtractor
 * Add AC-4 Extractor
 * Add AC-4 playback support in MPEG-4, MPEG-DASH, TS and HLS
2019-01-25 16:32:45 +08: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