150 Commits

Author SHA1 Message Date
ibaker
ad99a44083 Add empty sdk-version node to all AndroidManifest.xml files
PiperOrigin-RevId: 397772916
2021-09-21 14:17:33 +01:00
kimvde
040a45f310 Remove deprecated getDefaultRequestProperties from HttpDataSource
#exo-fixit

PiperOrigin-RevId: 396329591
2021-09-14 12:02:18 +01:00
claincly
0bf40f8978 Fix some ErrorCode assigning cases.
DefaultHttpDataSource and OkHttpDataSource can share the same error code
assigning logic.

Fixes CronetDataSource's handling of closed connection.

PiperOrigin-RevId: 387791679
2021-08-02 10:59:30 +01:00
claincly
df49f90b7f Simplify the error code handling.
PiperOrigin-RevId: 387786273
2021-08-02 10:58:11 +01:00
andrewlewis
9c27cfcda7 Fix parameter names on overridden methods
The dokka javadoc generation tool complains when parameter names don't match between a method and its override. This change updates occurrences where there is currently a mismatch.

Notable renamings that might be controversial:
- `onPlaybackStateChanged(int state)` to `onPlaybackStateChanged(int playbackState)` affected a lot of lines but seems more consistent with other '-Changed' methods.
- `handleMessage(int messageType, Object payload)` to `handleMessage(int messageType, Object message)`
- `ExtractorInput` and `DataSource` inherit `DataReader` which had `read(byte[] target, ...`, while data sources normally called the first parameter `buffer`. I have standardized these all to use `buffer` even though it looks out of place in the `ExtractorInput` interface (which has more `read` methods with `target`).

PiperOrigin-RevId: 387290360
2021-07-28 09:15:29 +01:00
aquilescanta
0df62a4f20 Add ERROR_CODE_FAILED_RUNTIME_CHECK for failed checks
PiperOrigin-RevId: 387143625
2021-07-27 18:56:25 +01:00
aquilescanta
d4975415f9 Remove calls to initCause
In favor of setting the cause in the constructor, which allows
some code simplifications.

PiperOrigin-RevId: 387062636
2021-07-27 12:30:19 +01:00
claincly
ca28d6a041 Move TYPE definition out from DataSourceException.
The types (open/close/read) does not provide extra information about the thrown
playback exception, and they are not utilized at higher levels.

PiperOrigin-RevId: 384219870
2021-07-13 10:03:01 +01:00
ibaker
0df0df9aee Remove @DoNotInstrument from test classes
This isn't needed now we've updated to Robolectric 4.6

PiperOrigin-RevId: 383109343
2021-07-09 08:58:38 +01:00
claincly
747b0f057b Make DataSourceException use PlaybackException error codes.
- Use `PlaybackException.ErrorCode` IntDef for `DataSourceException` error code
- Deprecate `DataSourceException.POSITION_OUT_OF_RANGE`
- All other changes are related to replacing the deprecated constant and
  constructor

PiperOrigin-RevId: 382683522
2021-07-09 08:43:22 +01:00
olly
a55c0654fb Improve Cronet and OkHttp READMEs
PiperOrigin-RevId: 382279955
2021-06-30 13:54:16 +01:00
olly
dea52048cb Bump dependency versions
PiperOrigin-RevId: 382277352
2021-06-30 13:53:01 +01:00
olly
6fe2f25fe9 Update DataSource extension documentation
Also upgrade the RTMP extension to use an inner class
for its factory.

PiperOrigin-RevId: 381469114
2021-06-30 13:39:09 +01:00
olly
ec9f512fee OkHttp: Upgrade to 4.9.1 (minSdkVersion 21)
Until now, we have stuck with the 3.12 long-term branch so as
to keep support for older API levels. However, this means that
the version we're using is 2.5 years old at this point. The
3.12 branch will stop receiving critical updates in December
2021.

Since use of the OkHttp extension is optional anyway, it seems
preferable to move to a modern version of OkHttp at this point.

PiperOrigin-RevId: 381465269
2021-06-30 13:37:58 +01:00
bachinger
4c1a294b2e Format Java source files
PiperOrigin-RevId: 372127633
2021-05-06 13:32:25 +01:00
bachinger
39ac09e7c6 Add @DoNotInstrument for unit test classes of extensions
PiperOrigin-RevId: 372101509
2021-05-06 13:32:05 +01:00
ibaker
dafea4e40f Re-format some javadoc
PiperOrigin-RevId: 369642047
2021-04-21 18:46:00 +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
olly
1affbf9357 DataSources: Enforce that opening at end-of-resource succeeds
- Update the three `HttpDataSource` implementations to use the
  Content-Range response header to determine when this is the
  case. The Content-Range header is included when the status
  code is 416. See [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/416).
- Update `ByteArrayDataSource` to conform to the requirement.
- Update `DataSourceContractTest` to enforce the requirement.

PiperOrigin-RevId: 363642114
2021-03-24 18:04:27 +00:00
olly
675b81e5f7 DataSource: Tighten contract to return -1 on premature end-of-input
PiperOrigin-RevId: 363001266
2021-03-24 18:02:17 +00:00
olly
b563b82787 Add HttpUtil for tasks common to HttpDataSource implementations
Part of aligning HttpDataSource behavior will require adding
logic that's common across the DataSource implementations. This
change establishes a util class to house it, and moves a bit of
existing logic that's related and can be easily shared into it.

There is one small behavior change in this CL, which is that our
handling of Content-Range response headers can now parse the body
length if the "document size" part of the Content-Range is unknown,
for example "bytes 5-9/*". Previously the pattern we were matching
to required the "size" part to be set, for example "bytes 5-9/100",
despite the fact we don't need or use it.

PiperOrigin-RevId: 362396976
2021-03-12 10:44:40 +00:00
olly
3de81c6d31 HttpDataSources: Remove unused protected methods
PiperOrigin-RevId: 361109018
2021-03-12 10:39:11 +00:00
olly
759b0431bb DataSource: Tighten contract to throw if opened beyond end-of-input
Includes fixes for the HTTP implementations, which previously
broke this contract specifically in the case when a server
responds to a range request with a HTTP 200 response. To fix
this case, skipping to the requested position is moved from
read() to open(). As a side effect, this nicely simplifies
CronetDataSource!

PiperOrigin-RevId: 359737301
2021-03-02 17:03:14 +00:00
olly
3fcc14b3c2 OkHttp/Rtmp extensions: Remove dependency on core
They only require common. This allows their use for non-playback networking
without requiring the user to depend on the whole of core. I will also make
the same change for Cronet, although this needs a little more work.

PiperOrigin-RevId: 353649388
2021-01-25 17:38:36 +00:00
christosts
c808751009 Add contract tests for OkHttpDataSource
PiperOrigin-RevId: 352554949
2021-01-19 19:23:31 +00:00
olly
2a5f6d8f62 Improve user-agent configuration
- Support setting the user-agent in CronetDataSource
- Support setting the default user-agent in CronetEngineWrapper
- Use the underlying network stack's default user-agent by
  default. Many applications will configure the underlying
  CronetEngine or OkHttpClient with a user-agent that they
  expect to be used throughout their app, so always overriding
  this with our own default, on reflection, is not the best
  thing to do!

Issue: #8395
PiperOrigin-RevId: 350921963
2021-01-11 18:04:43 +00:00
Emanuele Tidó
6d4b364530
Update OkHttpDataSource.java 2021-01-06 00:19:06 +00:00
Emanuele Tidó
91a09ea320
Update OkHttpDataSource.java
set responseBody to Util.EMPTY_BYTE_ARRAY when an IOException occurs trying to get his value from inputStream
2021-01-06 00:12:55 +00:00
Emanuele Tidó
15a59d93ee
throw exception improved
if responseCode and responseMessage ara available always throws an InvalidResponseCodeException instead of HttpDataSourceException, so in onPlayerError method the http status code and message can be used to decide what will be the next step.
2020-12-30 16:57:50 +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
bachinger
6114c894df Make OkHttpDataSourceFactory an inner class of OkHttpDataSource
#exofixit

PiperOrigin-RevId: 347389531
2020-12-17 11:25:53 +00:00
olly
2fbad2105e Make special exception for cleartext-not-permitted
#exofixit

PiperOrigin-RevId: 344246408
2020-11-27 11:07:07 +00:00
ibaker
2371b024dd Switch to an 'api' dependency on Guava
The 'implementation' dependency causes problems when resolving
ListenableFuture in contexts that also include the
com.google.guava:listenablefuture:1.0 dependency.

Issue: #7905
Issue: #7997
Issue: #7993
PiperOrigin-RevId: 337093024
2020-10-17 01:34:15 +01:00
olly
cdcb30ed21 Exclude Guava transitive annotation dependencies
PiperOrigin-RevId: 331148067
2020-09-11 16:01:15 +01:00
olly
b2b08ade99 Make User-Agent optional
PiperOrigin-RevId: 330593247
2020-09-09 09:41:51 +01:00
ibaker
fda3b3d8ec Use static imports for methods that make sense without their class name
PiperOrigin-RevId: 323349585
2020-07-27 23:59:52 +01:00
ibaker
478f59fd08 Replace ExoPlayer's functional types with Guava alternatives
This removes Supplier, Function and Predicate. Consumer is kept because
Guava doesn't have an equivalent (Java 8 does, but we can't use that
yet).

#exofixit

PiperOrigin-RevId: 323324392
2020-07-27 23:59:25 +01:00
ibaker
23d680a4b4 Suppress deprecation warnings in deprecated places
PiperOrigin-RevId: 320970814
2020-07-24 10:30:53 +01:00
tonihei
4138e28d62 Move common gradle setup to a setting file.
This removes a lot of duplication from the module configuration,
avoids divergence, and makes sure that only the important differences
to the default are visible in each module file.

PiperOrigin-RevId: 318024823
2020-06-26 11:13:25 +01:00
ibaker
a6f79901e7 Migrate OkHttpDataSourceTest from Mockito to MockWebServer
PiperOrigin-RevId: 317637058
2020-06-23 11:07:25 +01:00
Ian Baker
8b89a5ed6d Merge pull request #6861 from chrisfillmore:feature/responseBodyForInvalidResponseCodeException_6853
PiperOrigin-RevId: 314105612
2020-06-01 15:00:08 +01:00
olly
62e1000df4 Upgrade OkHttp to 3.12.11.
PiperOrigin-RevId: 310114401
2020-05-06 20:56:55 +01:00
olly
429bdfb974 Improve logging
- Make sure logging of UnknownHostException indicates the failure reason
- Indent stack traces inside event blocks in EventLogger
- Don't log media URLs

PiperOrigin-RevId: 302007601
2020-03-20 12:49:20 +00:00
tonihei
b5976a55ff Upgrade Kotlin annotations and fix gradle warnings
The new version fixes some warnings in Gradle builds. Also
add missing indirect compileOnly dependencies to fix some more warnings

Issue:issue:#7007
PiperOrigin-RevId: 298855510
2020-03-10 10:19:19 +00:00
olly
1cbe3f72e6 DataSpec: Deprecate most constructors
Keeping (Uri) and (Uri, position, length) to avoid needing
Builder for the trivial case.

PiperOrigin-RevId: 294530226
2020-02-13 15:43:54 +00:00
Fillmore, Christopher
78740bcac6 Update OkHttpDataSource with response body on bad HTTP status
This change supplies the response body in OkHttpDataSource to
InvalidResponseCodeException.

Issue #6853
2020-02-12 16:40:47 -05:00
olly
d312b6d4c2 Upgrade OkHttp dependency to 3.12.8
OkHttp 3.12.7 introduced a regression, which was fixed in 3.12.8.

PiperOrigin-RevId: 291695577
2020-01-27 18:21:57 +00:00
olly
70fe6b4590 Upgrade OkHttp library to fix HTTP2 issue
Issue: #4078
PiperOrigin-RevId: 288651166
2020-01-08 15:58:04 +00:00
andrewlewis
fefb1a17a0 Fix typos
PiperOrigin-RevId: 287810018
2020-01-02 19:23:42 +00:00