201 Commits

Author SHA1 Message Date
olly
e160649d9c README updates for MediaSource, DataSource and UI modules
PiperOrigin-RevId: 401793145
2021-10-09 18:21:54 +01:00
olly
e4a5c07b5f Mechanical README cleanups 2
PiperOrigin-RevId: 401777730
2021-10-09 18:18:12 +01:00
olly
e7c6ed5e7f Mechanical README cleanups
PiperOrigin-RevId: 401767060
2021-10-09 18:14:36 +01:00
olly
046fb1d71e Documentation tweak
PiperOrigin-RevId: 401764435
2021-10-09 18:06:26 +01:00
olly
b03ebbeb89 Stop setting custom user agent in demo app
PiperOrigin-RevId: 401741202
2021-10-09 17:39:03 +01:00
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
aquilescanta
7375fe3105 Simplify network-related error codes
This change removes ERROR_CODE_IO_NETWORK_UNAVAILABLE,
ERROR_CODE_IO_NETWORK_CONNECTION_CLOSED, and ERROR_CODE_IO_DNS_FAILED
in favor of keeping only ERROR_CODE_IO_NETWORK_CONNECTION_FAILED.

PiperOrigin-RevId: 388715972
2021-08-04 18:47:32 +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
aquilescanta
5bc1c4837f Assign CronetDataSource error codes
PiperOrigin-RevId: 387301144
2021-07-29 21:08:02 +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
cdf26a01cf Remove error code inference in DataSourceException.
The inference is used when nesting DataSourceExceptions. It is removed because
nesting does not add additional value in surfacing the exceptions, and it is
better to assign an error code at the throw site (in the "leaf" or the bottom
most data source).

PiperOrigin-RevId: 386919118
2021-07-27 12:26:07 +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
7b0a7f1295 Remove stray space
PiperOrigin-RevId: 382297051
2021-07-09 08:24:44 +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
ea99c3fa94 Add ability to set Cronet request priority
PiperOrigin-RevId: 381833403
2021-06-30 13:42:42 +01:00
olly
bb82e7df9d Cronet: Align terminology with documentation
PiperOrigin-RevId: 381472436
2021-06-30 13:40:24 +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
bcd4bb87e5 Deprecate CronetEngineWrapper
PiperOrigin-RevId: 381239971
2021-06-30 13:32:43 +01:00
olly
1e9b6d66a3 [CronetDataSource] Support keeping the POST method and body for 302
Currently when a HTTP POST request receives a 302, CronetDataSource will change the request method from POST to GET for the redirected request, and drop the post body. This aligns with the behaviours of many user agents, but our use case would like to keep the POST method and the post body.

org.chromium.net.UrlRequest.followRedirect also changes POST to GET for 302, so should be avoided here.

PiperOrigin-RevId: 381233011
2021-06-30 13:28:50 +01:00
olly
75c06cc4e7 Cronet: Cleanup and simplify CronetEngineWrapper
A subsequent change will deprecate CronetEngineWrapper and move
all of the logic into a utility class for obtaining a suitable
CronetEngine.

This change also deprioritizes use of unknown cronet providers.

PiperOrigin-RevId: 381051164
2021-06-30 13:24:01 +01:00
olly
116e50f365 Cronet: Deprecate internal fallback
The way CronetDataSource.Factory can internally fall back to another
factory is confusing and unnecessary. In the case the application cannot
instantiate a CronetEngine, it should directly use another factory.

This makes CronetDataSource more consistent with OkHttpDataSource. In
both cases, their factory constructors take the component that the
respective libraries advise should only be created once by the application,
which are CronetEngine and OkHttpClient respectively.

CronetEngineWrapper will be deprecated in a subsequent change.

PiperOrigin-RevId: 381016504
2021-06-30 13:21:39 +01:00
olly
a3dbd61239 Remove obsolete Checker Framework suppression strings
More information: go/checker-3130-lsc

Tested:
    Some test failures are present, but the CL author has decided to mail the change anyway
PiperOrigin-RevId: 379622938
2021-06-21 21:56:37 +01:00
olly
4b30cca914 Update @SuppressWarnings annotations for go/nullness diagnostics
in preparation for upgrading the version of the Checker Framework in google3.

More information: go/checker-3110-lsc

PiperOrigin-RevId: 377925828
2021-06-08 13:02:47 +01:00
olly
e9f66fc5d1 Replace internal dependencies on monolithic module
PiperOrigin-RevId: 375054051
2021-05-21 12:05:56 +01:00
bachinger
a9fc3185fe Do not mock NetworkException
PiperOrigin-RevId: 372321626
2021-05-06 13:36:00 +01:00
bachinger
4c1a294b2e Format Java source files
PiperOrigin-RevId: 372127633
2021-05-06 13:32:25 +01:00
bachinger
a3e06f7d4e Add @DoNotIntrument to test classes of the CroNet extension
PiperOrigin-RevId: 372092122
2021-05-06 13:31:08 +01:00
christosts
bc69509aba CronetDataSource: fix overflow bug
There is a bug when CronetDataSource opens an asset with a length
bigger that Integer.MAX_INT  (2147483647 bytes, ~2GB). In read(),
`bytesRemaining` is cast to int, which overflows and evaluates to a
negative number, causing `bytesRead` to be negative too.

PiperOrigin-RevId: 370434368
2021-04-26 18:28:50 +01:00
ibaker
dafea4e40f Re-format some javadoc
PiperOrigin-RevId: 369642047
2021-04-21 18:46:00 +01:00
andrewlewis
a6e9a9c6d2 Remove mocking executor in CronetDataSourceTest
Other tests in this file already use `Executors.newSingleThreadExecutor` so do the same for the ones that currently use `mockExecutor`.

PiperOrigin-RevId: 368859470
2021-04-20 00:07:39 +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
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
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
christosts
086d8f3a8e Contract test for TransferListener callbacks
PiperOrigin-RevId: 357190780
2021-02-12 16:40:40 +00:00
olly
e98f5f34ce Fix gradle conflict resolution for Cronet tests
This resolves the following constraint resolution issue when running our release script:

> Cannot find a version of 'org.chromium.net:cronet-api' that satisfies the version constraints:
    Dependency path 'com.google.android.exoplayer:extension-cronet:unspecified' --> 'com.google.android.gms:play-services-cronet:17.0.0' --> 'org.chromium.net:cronet-api:72.3626.96'
    Constraint path 'com.google.android.exoplayer:extension-cronet:unspecified' --> 'org.chromium.net:cronet-api:{strictly 72.3626.96}' because of the following reason: debugRuntimeClasspath uses version 72.3626.96
    Dependency path 'com.google.android.exoplayer:extension-cronet:unspecified' --> 'org.chromium.net:cronet-embedded:76.3809.111' --> 'org.chromium.net:cronet-common:76.3809.111' --> 'org.chromium.net:cronet-api:76.3809.111'

#minor-release

PiperOrigin-RevId: 355414968
2021-02-04 00:23:55 +00:00
olly
35b99d634f Make Cronet extension depend only on common
This also moves DefaultHttpDataSource to common, which seems
sensible, else non-player components that need a DataSource
don't have any useful concrete implementations. We should
think about moving some of the other concrete implementations
to common as well.

PiperOrigin-RevId: 354738925
2021-02-01 18:11:23 +00:00
christosts
3b08a792bb Fix bug in CronetDataSource
This change fixes a bug in CronetDataSource when it makes a Range
request but the server does not support Range requests and returns the
entire resource. Before the fix, the CronetDataSource would read more
bytes than the intended range.

PiperOrigin-RevId: 353614477
2021-01-25 15:37:08 +00:00
olly
bfc736986e Migrate CronetDataSourceFactory to DefaultHttpDataSource.Factory
We normally wouldn't do this kind of thing, given CronetDataSourceFactory is
deprecated, but it's needed to change the cronet --> core dependency to a
cronet --> common dependency.

PiperOrigin-RevId: 353609198
2021-01-25 15:36:49 +00:00
christosts
0a3542e50e Add contract test for CronetDataSource
PiperOrigin-RevId: 353290124
2021-01-25 15:35:59 +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
Oliver Woodman
953e4e89e2 Merge pull request #8414 from tidoemanuele:tidoemanuele-improve-non-2xx-message
PiperOrigin-RevId: 350797551
2021-01-08 19:09:15 +00:00
bachinger
62720858ed Make CronetDataSourceFactory an inner class of CronetDataSource
#exofixit

PiperOrigin-RevId: 348444280
2020-12-23 22:51:38 +00:00
bachinger
a335c96450 Deprecate HttpDataSource.Factory.getDefaultRequestProperties
#exofixit

PiperOrigin-RevId: 347375323
2020-12-17 11:25:52 +00:00