2927 Commits

Author SHA1 Message Date
krocard
a99ab62241 Tunneling timestamp use Message instead of Runnable
This avoids allocating a Runnable.

PiperOrigin-RevId: 290079660
2020-01-16 20:35:22 +00:00
olly
cb8391a526 Start service in foreground if allowed
This fixes an issue where a DownloadService implementation
that allows foreground but doesn't provide a scheduler would
not be restarted in the case that it was still in memory but
classed as idle by the platform.

It also speeds up service restart in the case that a
scheduler is provided.

Issue: #6798
PiperOrigin-RevId: 290068960
2020-01-16 20:35:13 +00:00
olly
775a17c498 Split SampleQueue.advanceTo for advance & seek use cases
This method has two use cases:

1. Seeking. Calls are immediately preceded by a call to rewind(), and
   the returned value isn't important unless it's ADVANCED_FAILED (i.e.
   the caller is only interested in success and failure).
2. Advancing. The return value is important unless it's ADVANCED_FAILED,
   in which case the caller wants to treat it as 0.

This change creates separate methods for each use case. The new seekTo
methods automatically rewind and return a boolean. The updated advanceTo
method returns 0 directly in cases where ADVANCED_FAILED was returned.
Arguments that were always hard-coded to true by callers have also been
removed.

This change is a step toward one possible solution for #6155. How we'll
solve that issue is still up for discussion, but this change seems like
one we should make regardless!

Issue: #6155
PiperOrigin-RevId: 290053743
2020-01-16 20:35:04 +00:00
olly
51f2723b90 Fix DownloadService resumption
- DownloadManagerHelper now passes all downloads to the
  DownloadService when the service is attached (and once
  the downloads are known). The service then starts the
  foreground notification updater if necessary. This fixes
  the ref'd issue.
- Don't call getScheduler() if the service is background
  only. This was already documented to be the case on the
  DownloadService constructor.
- If the service is started in the foreground on SDK level
  26 and higher, satisfy the condition to move the service
  to the foreground in onStartCommand rather than in stop().
  It's much more obviously correct, and should produce the
  same end result.

Issue: #6798
PiperOrigin-RevId: 290050024
2020-01-16 13:52:47 +00:00
Oliver Woodman
1ec05199d4 Merge pull request #6603 from TiVo:fix-tunneling-stuck-release
PiperOrigin-RevId: 290041295
2020-01-16 13:52:37 +00:00
tonihei
2e7978a0e2 Reorder renderer changes at period transitions
Currently the following sequence of events happens at automatic period transitions:
1. Update queue (=release old playing period)
2. Disable unused renderers
3. Enable newly needed renderers

This order requires difficult to follow workarounds in AnalyticsCollector for all
events related to step 2 (disable renderers). The current media period has already
been advanced so can't be used. The current workaround saves the last known playing
media period that was published as part of a PlaybackInfo update in ExoPlayerImpl.
This works in most cases, but is inherently wrong because the published state in
ExoPlayerImpl may be completely unrelated to the updates happening on the playback
thread (e.g. if many other operations are pending).

Simplify and fix this problem by changing the order of the events above:
1. Disable unused renderers.
2. Update queue
3. Enable newly needed renderers.
This way the current playing media period can be used for both renderer disable
and renderer enable events, thus it's correct in all cases and the workaround
in AnalyticsCollector can be removed.

PiperOrigin-RevId: 290037225
2020-01-16 13:52:26 +00:00
tonihei
8d2fd383f9 Fix setting maskingPeriodIndex in ExoPlayerImpl
Whenever we set the maskingWindowIndex, we also need to set the masking period index
and the masking position. Otherwise it may cause exception when the period index
is used together with the masking timeline.

PiperOrigin-RevId: 290036973
2020-01-16 13:52:18 +00:00
Oliver Woodman
17d1343375 Merge pull request #6678 from phhusson:feature/enable-multi-metadata-tracks
PiperOrigin-RevId: 290032841
2020-01-16 13:52:08 +00:00
olly
090aed3aca Add non-null by default to source.chunk
PiperOrigin-RevId: 289859343
2020-01-16 13:51:50 +00:00
olly
4a5d788fa6 DASH: Output Format before InitializationChunk load completes
This optimization allows a ChunkSampleStream to output track
formats as soon as they're parsed during an InitializationChunk
load, rather than waiting until after the InitializationChunk
load is completed.

In DASH VOD, a single InitializationChunk typically loads the
moov and sidx atoms in that order. Hence for long form content
where the sidx is a non-trivial size, this may result in the
track formats being output a non-negligible period of time
sooner than was previously the case. This allows downstream
renderers to start codec initialization sooner, potentially
decreasing startup latency.

For a single test stream on a fast & stable network, this
pretty consistently reduced elapsed time until both audio and
video codecs have been initialized from ~0.5s to ~0.3 seconds
on a Galaxy S8. For 5 test runs without and with these patches,
the eventTime logged by EventLogger for the second decoder
init were:

Without (secs): 0.47 0.47 0.45 0.48 0.46
With (secs)   : 0.32 0.33 0.34 0.31 0.40

PiperOrigin-RevId: 289845089
2020-01-16 13:51:42 +00:00
olly
7d0f0b69a3 Optimize chunks to init their outputs before opening the DataSource
The current order of operations means that the Format is only passed
to the chunk's output after the DataSource has been opened. This
means that establishing the network connection and the downstream
renderers initializing their codecs are effectively serialized to
occur one after the other.

In the new order, the Format is passed to the chunk's output before
the DataSource has been opened. This allows the downstream renderers
to initialize their codecs in parallel with the network connection
being established, and hence latency at the start of playback is
reduced.

PiperOrigin-RevId: 289841854
2020-01-16 13:51:34 +00:00
olly
4b234388c8 Move @Nullable annotations to correct positions
PiperOrigin-RevId: 289838473
2020-01-16 13:51:26 +00:00
samrobinson
96c648c2d6 Improve customisability of FakeSampleStream.
PiperOrigin-RevId: 289829592
2020-01-16 13:51:18 +00:00
olly
a225e887fa Move @MonotonicNonNull annotations to their correct positions
PiperOrigin-RevId: 289823804
2020-01-16 13:51:09 +00:00
olly
cea37c60f8 Use customCacheKey in DownloadHelper.createMediaSource
Issue: #6870
PiperOrigin-RevId: 289658261
2020-01-16 13:51:01 +00:00
andrewlewis
4c74f3cffd Make tests independent
PiperOrigin-RevId: 289521837
2020-01-16 13:50:44 +00:00
olly
ccce9948a9 Align media2 extension tests with other tests
PiperOrigin-RevId: 289494365
2020-01-16 13:50:36 +00:00
olly
f0ce1c3bbb Rename ID3 tag to Afro-Punk
PiperOrigin-RevId: 289490708
2020-01-16 13:50:27 +00:00
tonihei
c0ee312a30 Simplify keeping track of current id in DefaultPlaybackSessionManager
We currently have a currentMediaPeriodId and an activeSessionId that are more
or less tracking the same thing unless the current media period isn't "active" yet.

Simplify this logic by using a single currentSessionId field and the respective
isActive flag of this session. Also move all session creation and activation code in
the same method to make it easier to reason about the code.

This change also fixes a subtle bug where events after a seek to a new window
are not ignored as they should.

PiperOrigin-RevId: 289432181
2020-01-13 19:58:00 +00:00
olly
ad7bcab4c5 DownloadService: No-op cleanup
Issue: #6798
PiperOrigin-RevId: 289424582
2020-01-13 19:57:52 +00:00
tonihei
3c5c43c979 Add a clarifying comment to shouldContinueLoading handling.
PiperOrigin-RevId: 289424321
2020-01-13 19:57:44 +00:00
olly
d7643acd52 Deprecate DownloadService state change methods
As discovered whilst investigating #6798, there are cases
where these methods are not correctly. They were added as
convenience methods that could be overridden by concrete
DownloadService implementations, but since they don't work
properly it's preferable to require application code to
listen to their DownloadManager directly instead.

Notes:

- The original proposal to fix #6798 stored the state change
events in memory until they could be delivered. This approach
is not ideal because the events still end up being delivered
later than they should be. We also want to fix the root cause
in a different way that does not require doing this.
- This change does not fix #6798. It's a preparatory step.

Issue: #6798
PiperOrigin-RevId: 289418555
2020-01-13 19:57:36 +00:00
tonihei
01e661f21a Add NTP client to get time offset for live streams without UTCTiming.
Dash live streams require that the client has an accurate wall clock
time and in absence of a UTCTiming element, this is assumed to be the
NTP time.

This change adds NTP time offset resolution for DASH live streams
without such timing elements.

PiperOrigin-RevId: 289098796
2020-01-13 19:57:10 +00:00
Oliver Woodman
3e08e42168 Merge pull request #6797 from DolbyLaboratories:dev-v2-ac4-drm
PiperOrigin-RevId: 289092332
2020-01-10 15:57:40 +00:00
olly
d24188f663 Add tests to validate FLAC decoder output
PiperOrigin-RevId: 289091494
2020-01-10 15:57:23 +00:00
olly
7e5d6debcc Avoid OMX.qti.audio.decoder.flac
Unfortunately devices such as the MI 8 do not provide an alternative
working decoder. Some Vivo devices do provide one though.

PiperOrigin-RevId: 288911897
2020-01-10 15:56:54 +00:00
krocard
95f1dbec1b More @nullable in SimpleDecoderAudioRenderer
Some members are nullable but were not marked as
such.

PiperOrigin-RevId: 288873481
2020-01-10 15:56:38 +00:00
christosts
f47d06e7b3 Set ExoPlayer's MediaCodecOperationMode
PiperOrigin-RevId: 288868298
2020-01-10 15:56:30 +00:00
krocard
91d2b8581e Make MediaCodecRenderer.codec nullable
Also fix annotation style of the surrounding functions.

PiperOrigin-RevId: 288865420
2020-01-10 15:56:22 +00:00
ibaker
2c02f787bd Remove unused styles from TTML test data
PiperOrigin-RevId: 288862795
2020-01-10 15:56:13 +00:00
olly
1a9b301f52 Fix extension FLAC decoder to correctly handle non-16-bit depths
PiperOrigin-RevId: 288860159
2020-01-10 15:55:49 +00:00
andrewlewis
017a7cf38c Resolve TrueHD spec TODO
PiperOrigin-RevId: 288855515
2020-01-10 15:55:40 +00:00
ybai001
74e01f4e97 Add protected AC-4 fmp4 test case 2020-01-10 14:19:30 +08:00
ybai001
4ce72d9d6d Update AC-4 DRM code based on comments
Update cleardatasize[0] in extractor rather than sampleDataQueue.
2020-01-09 15:23:05 +08:00
ybai001
0ea49df901 Merge branch 'google-dev-v2' into dev-v2-ac4-drm 2020-01-09 09:40:28 +08:00
ybai001
65e6d50e73 Merge branch 'dev-v2' of https://github.com/google/ExoPlayer into google-dev-v2 2020-01-09 09:08:07 +08:00
Oliver Woodman
4f15cfaa78 Merge pull request #6836 from DolbyLaboratories:dev-v2-refineAC4
PiperOrigin-RevId: 288772277
2020-01-08 22:15:53 +00:00
kimvde
79edf7cce2 FlacExtractor: add condition for zero-length reads
This improves readability by making clearer that reading no bytes from
the input in readFrames() is an expected case if the buffer is full.

PiperOrigin-RevId: 288711841
2020-01-08 22:15:43 +00:00
tonihei
fa9bf9c828 Ensure seeks to new windows are reported as seeking.
Currently, seeks are only tracked if both the start and the end of the seek
is within the same window. This means no seeking state is reported if the
playback switches to a new window during the seek.

This problem is fixed by tracking seek start and end events in all cases,
but only report seeking state once the window becomes the foreground window.

PiperOrigin-RevId: 288706674
2020-01-08 22:15:18 +00:00
ibaker
14e401f53a Update TtmlDecoder to keep only one Span of each type
The current code relies on Android's evaluation order of spans, which
doesn't seem to be defined anywhere.

PiperOrigin-RevId: 288700011
2020-01-08 22:15:10 +00:00
ibaker
8e26505ee8 Fix what I think is a typo in WebVTT test data
Without the CSS tweak the additional test assertion fails.

PiperOrigin-RevId: 288698323
2020-01-08 22:15:02 +00:00
andrewlewis
762bc18a28 Fix TrueHD chunking in Matroska
Issue: #6845
PiperOrigin-RevId: 288688716
2020-01-08 15:58:28 +00:00
ibaker
448db89446 Add TypefaceSpan and hasNoFooSpanBetween() support to SpannedSubject
Use these to migrate the last WebvttDecoderTest method to SpannedSubject

PiperOrigin-RevId: 288688620
2020-01-08 15:58:20 +00:00
kimvde
ee091e6a45 Use FlacLibrary.isAvailable in FlacExtractor selection
PiperOrigin-RevId: 288667790
2020-01-08 15:58:12 +00:00
olly
63f90adef0 Add package level NonNull to extractor.ts
Also remove most classes from the nullness blacklist

PiperOrigin-RevId: 288494712
2020-01-08 15:57:56 +00:00
christosts
fb42f818ec Add start() method in MediaCodecAdapter
PiperOrigin-RevId: 288476415
2020-01-08 15:57:48 +00:00
ibaker
c5535e825e Fix null-checker suppression introduced by 3.0.1 upgrade
Suppression added in 6f9baffa0c

PiperOrigin-RevId: 288475120
2020-01-08 15:57:39 +00:00
ibaker
181606137d Remove assertCues() helper methods from WebvttDecoderTest
These make the interesting bits of each assertion harder to follow imo.

Also remove all the assertWithMessage() calls at the same time, Olly
convinced me these are rarely useful since you can click from the stack
trace to the failing line in the IDE.

PiperOrigin-RevId: 288470704
2020-01-08 15:57:31 +00:00
olly
692c8ee0ac Fix playback for Vivo codecs that output non-16-bit audio
PiperOrigin-RevId: 288468497
2020-01-08 15:57:22 +00:00
ibaker
09ca5c0783 Remove assertWithMessage() calls from SsaDecoderTest
As discussed with Olly, these don't add much info and are liable
to go stale.

PiperOrigin-RevId: 288463027
2020-01-08 15:57:06 +00:00