2075 Commits

Author SHA1 Message Date
olly
56520b7c73 Move DownloadManager internal logic into isolated inner class
There are no logic changes here. It's just moving code around and removing
the "internal" part of names where no longer required.

PiperOrigin-RevId: 245407238
2019-04-26 18:41:46 +01:00
olly
d187d9ec8f Post maxParallelDownload and minRetryCount changes
PiperOrigin-RevId: 245405316
2019-04-26 18:41:40 +01:00
olly
9d03ae4109 Add missing getters and clarify STATE_QUEUED documentation
PiperOrigin-RevId: 245401274
2019-04-26 18:41:30 +01:00
eguven
fc35d5fca6 Add simpler DownloadManager constructor
PiperOrigin-RevId: 245397736
2019-04-26 18:41:17 +01:00
eguven
c97ee9429b Allow content id to be set in DownloadHelper.getDownloadRequest
PiperOrigin-RevId: 245388082
2019-04-26 18:41:03 +01:00
eguven
4da14e46fa Add DownloadService SET_REQUIREMENTS action
PiperOrigin-RevId: 245014381
2019-04-26 18:38:56 +01:00
eguven
f7f6489f57 Add option to add entries in an ActionFile to DownloadIndex as completed
PiperOrigin-RevId: 244864742
2019-04-26 18:38:24 +01:00
tonihei
6155139856 Fix bug which logs errors twice if stack traces are disabled.
Disabling stack trackes currently logs messages twice, once with and once
without stack trace.

PiperOrigin-RevId: 244853127
2019-04-26 18:38:16 +01:00
tonihei
3d6407a58e Always update loading period in handleSourceInfoRefreshed.
This ensures we keep the loading period in sync with the the playing period in
PlybackInfo, when the latter changes to something new.

PiperOrigin-RevId: 244838123
2019-04-26 18:37:43 +01:00
olly
0d8146cbca Further improve DownloadService action names & methods
- We had buildAddRequest and sendNewDownload. Converged to
  buildAddDownload and sendAddDownload.
- Also fixed a few more inconsistencies, and brought the
  action constants into line as well.

PiperOrigin-RevId: 244274041
2019-04-18 23:47:19 +01:00
olly
b8cdd7e40b Fix lint warnings for 2.10
PiperOrigin-RevId: 244268855
2019-04-18 23:43:07 +01:00
olly
b30efe968b Clean up database tables for launch
PiperOrigin-RevId: 244267255
2019-04-18 23:43:02 +01:00
olly
54a5d6912b Improve progress reporting logic
- Listener based reporting of progress allows the content length
  to be persisted into the download index (and notified via a
  download state change) as soon as it's available.
- Moved contentLength back into Download proper. It should only
  ever change once, so I'm not sure it belongs in the mutable part
  of Download.
- Made a DownloadProgress class, for naming sanity.

PiperOrigin-RevId: 244242487
2019-04-18 23:42:57 +01:00
olly
7d67047e94 Support multiple DefaultDownloadIndex instances
PiperOrigin-RevId: 244226680
2019-04-18 23:42:51 +01:00
olly
38c5350c2c Simplify DownloadManager constructors
PiperOrigin-RevId: 244223870
2019-04-18 23:42:45 +01:00
olly
8c62408120 Rename start/stopDownloads to resume/pauseDownloads
PiperOrigin-RevId: 244216620
2019-04-18 23:42:40 +01:00
olly
138da6d519 Rename manualStopReason to stopReason
PiperOrigin-RevId: 244210737
2019-04-18 23:42:33 +01:00
eguven
6d8bd34590 Add missing DownloadService build*Intent and startWith* methods
PiperOrigin-RevId: 244196081
2019-04-18 23:42:20 +01:00
aquilescanta
b6337adc47 Avoid selecting a forced text track that doesn't match the audio selection
Assuming there is no text language preference.

PiperOrigin-RevId: 244176667
2019-04-18 23:41:15 +01:00
eguven
a501f8c245 Fix flaky DownloadManagerDashTest
PiperOrigin-RevId: 244170179
2019-04-18 23:41:04 +01:00
andrewlewis
c2bbf38ee8 Extend Bluetooth dead audio track workaround to Q
PiperOrigin-RevId: 244139959
2019-04-18 23:40:36 +01:00
olly
0748566482 Remove TODOs we're not going to do
1. customCacheKey for DASH/HLS/SS is now asserted against
   in DownloadRequest
2. Merging of event delivery in DownloadManager is very
   tricky to get right and probably not a good idea

PiperOrigin-RevId: 244048392
2019-04-18 23:38:43 +01:00
eguven
289a8ffe4c Small javadoc fix for DownloadManager constructors
PiperOrigin-RevId: 244009343
2019-04-18 23:38:37 +01:00
olly
afd72839dc Disable cache span touching for offline
Currently SimpleCache will touch cache spans whenever it reads
from them. With legacy SimpleCache setups this involves a potentially
expensive file rename. With new SimpleCache setups it involves
a more efficient but still non-free database write.

For offline use cases, and more generally any use case where the
eviction policy doesn't use last access timestamps, touching is
not useful. This change allows the evictor to specify whether it
needs cache spans to be touched or not. SimpleCache will only touch
spans if the evictor requires it.

Note: There is a potential change in behavior in cases where a
cache uses an evictor that doesn't need cache spans to be touched,
but then later switches to an evictor that does. The new evictor
may temporarily make sub-optimal eviction decisions as a result.
I think this is a very fair trade-off, since this scenario is
unlikely to occur much, if at all, in practice, and even if it
does occur the result isn't that bad.
PiperOrigin-RevId: 244005682
2019-04-18 23:38:30 +01:00
olly
e15e6212f2 Fix playback of badly clipped MP3 streams
Issue: #5772
PiperOrigin-RevId: 243987497
2019-04-18 23:37:36 +01:00
olly
721e1dbfaf Add WritableDownloadIndex interface
One goal we forgot about a little bit was to allow applications
to provide their own index implementation. This requires the
writable side to also be defined by an interface.

PiperOrigin-RevId: 243979660
2019-04-18 23:37:28 +01:00
andrewlewis
6b0fd51378 Reset playback info but not position/state in release
ImaAdsLoader gets the player position after the app releases
the player to support resuming ads at their current position
if the same ads loader is reused.

PiperOrigin-RevId: 243969916
2019-04-18 23:37:06 +01:00
eguven
dcb8417a3c Assert customCacheKey is null for DASH, HLS and SmoothStreaming downloads
PiperOrigin-RevId: 243954989
2019-04-18 23:36:08 +01:00
tonihei
8e7a2ba958 Don't reset masking position when prepare fails.
The removed condition only applies when prepare fails and no timeline was or
is known. We should keep a pending seek position in such a case. The internal
player does the same thing already.

PiperOrigin-RevId: 243819466
2019-04-18 15:12:07 +01:00
eguven
5856e75781 Rename DownloadAction to DownloadRequest
PiperOrigin-RevId: 243806888
2019-04-16 16:41:29 +01:00
olly
9c759a867b Prepare SimpleCache for 2.10.0 release
- Expose constructors that take DatabaseProvider. Deprecate those
  that do not.
- Expose Cache.getUid. This will likely be used for naming of the
  tables accessed by DefaultDownloadIndex .

PiperOrigin-RevId: 243637786
2019-04-16 15:28:01 +01:00
andrewlewis
45348a97a9 Fix Atom ConstantCaseForConstant suppression
PiperOrigin-RevId: 243636923
2019-04-16 15:27:41 +01:00
aquilescanta
68bd5da3cb Fix DecryptionResource.Owner#onLastReferenceReleased type
PiperOrigin-RevId: 243632134
2019-04-16 15:27:22 +01:00
olly
7b84a1ead7 DownloadManager.getCurrentDownloads: Return list instead of array
- Allows enforcing immutability, which in a future CL will allow
  avoiding allocating a new array/list on every call.
- Also some left over doc cleanup from the DownloadState rename.

PiperOrigin-RevId: 243627352
2019-04-16 15:27:03 +01:00
aquilescanta
9ddd39c1c0 Add the HlsMetadataEntry from the Master playlist to the Hls tracks
PiperOrigin-RevId: 243624081
2019-04-16 15:26:44 +01:00
eguven
ba91501751 Add DownloadService.invalidateForegroundNotification
ISSUE: #4563
PiperOrigin-RevId: 243616444
2019-04-16 15:26:05 +01:00
olly
18dd3fdb46 Bump release to 2.10.0 and update release notes
PiperOrigin-RevId: 243592790
2019-04-16 15:25:47 +01:00
tonihei
1ee51518ae Use new exoplayer.dev domain everywhere.
The old domain automatically forwards to the new one. For consistency, change
all doc and code references regardless.

Also adds GitHub CNAME config file which configures our page for the custom
domain.

PiperOrigin-RevId: 243592110
2019-04-16 15:25:27 +01:00
tonihei
75238e5e4f Remove duplications from handleSourceInfoRefreshed.
handleSourceInfoRefreshed checks for various conditions which may trigger a
change in position. In all cases, we need to resolve the new position for ads,
and if the corresponding MediaPeriods already exist, perform the seek to the new
position.

This change simplified the code by
 1. Moving all conditions in a single if-else structure which just determines
    the new playback position. This makes it easier to read and to follow.
 2. Doing the subsequent seek and position update in one final step to remove
    duplicated code.

As a side effect, it also improves some edge cases. For example when skipping
an ad to an already prebuffered period, we now properly update the existing
prebuffered period.

PiperOrigin-RevId: 243588014
2019-04-16 15:25:08 +01:00
olly
2e3eac25b7 Cleanly detach DownloadThreads on release
- Make a best effort to avoid posting MSG_DOWNLOAD_THREAD_STOPPED
  if the internal thread has already quit. Doing so is harmless,
  but causes an error in Logcat. We used to generate this warning
  quite a bit in ExoPlayerImplInternal as well, and we got quite
  a few issues filed about it, so best to avoid it if possible.
- Null out the back reference DownloadThread holds to its manager
  on release. This avoids a potential issue where a download thread
  can prevent GC of its manager if it doesn't cancel quickly.
  There's similar logic (with a similar comment) in Loader.LoadTask.

PiperOrigin-RevId: 243365143
2019-04-13 01:45:59 +01:00
olly
b2c29da6b3 Finalize DownloadManager interface
- Rename getAllDownloads to getCurrentDownloads to make it clear
  that it doesn't include completed and failed downloads
- Change getDownloadCount to isWaitingForRequirements, which is
  what it's used for. Added TODO to make it returns the right thing

PiperOrigin-RevId: 243257856
2019-04-13 01:43:02 +01:00
olly
a588717b46 Move download state transitions into DownloadManager
Non-trivial download state transitions are currently split across
DownloadManager and Download. These transitions are part of the
same state machine, so it's clearer if they're all in the same place
(i.e. DownloadManager, since this is the component that transitions
downloads between states).

PiperOrigin-RevId: 243249915
2019-04-13 01:42:22 +01:00
olly
f623a9dea0 Reduce use of DownloadInternal in DownloadManager
The only state DownloadInternal holds is duplicate of state contained
in Download, but can confusingly be temporarily out of sync. This is
error prone because it's easy to use the wrong variable (e.g.
download.state vs state). DownloadInternals methods are called into
and call out into DownloadManager, which makes some code paths that
are quite hard to follow.

It's possible to simplify DownloadManager quite a lot by removing the
duplicated state in DownloadInternal, at which point DownloadInternal's
methods flatten into DownloadManager, which can just hold an internal
list of Downloads directly.

This is a first step, which makes it clear that DownloadThready only
needs its immutable DownloadAction + an isRemove flag.

PiperOrigin-RevId: 243245288
2019-04-13 01:42:02 +01:00
aquilescanta
bd841b18f2 Add DecryptionResource to FormatHolder
PiperOrigin-RevId: 243243975
2019-04-13 01:41:42 +01:00
aquilescanta
9cfac7ea07 Rename CryptoResource to DecryptionResource
PiperOrigin-RevId: 243237265
2019-04-13 01:41:03 +01:00
andrewlewis
53934c13b2 Select non-primary tunneling decoder
Issue: #3100
Issue: #5547
PiperOrigin-RevId: 243181217
2019-04-13 01:40:43 +01:00
olly
b84c51434f Deprecate ActionFile and simplify upgrading
PiperOrigin-RevId: 243085292
2019-04-13 01:40:24 +01:00
olly
112117a1ac Reorder DownloadManager methods
Put methods into a more sensible order (the same order as
in the switch statement, which is a more natural order with
e.g. initialize coming first and release coming last).

PiperOrigin-RevId: 242891742
2019-04-13 01:40:04 +01:00
olly
9779d71a1d Fix stopping downloads
- Changed startDownloads/stopDownloads back to their previous behavior
  of starting and stopping all downloads at the manager level.
- Made setManualStopReason methods for the new case of setting a manual
  stop reason or some or all downloads.
- Added plumbing to specify an initial manual stop reason when adding a
  new download, without also overwriting the manual stop reasons of all
  other preexisting downloads. Using the value is left as a TODO pending
  a bit of further cleanup that'll make it easier.

PiperOrigin-RevId: 242891688
2019-04-13 01:39:44 +01:00
olly
30beb9b300 Add DownloadAction merge tests
PiperOrigin-RevId: 242851294
2019-04-13 01:38:45 +01:00