Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
8edce41f
authored
May 15, 2019
by
olly
Committed by
Oliver Woodman
May 15, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add simpler HttpDataSource constructors
PiperOrigin-RevId: 248350557
parent
cf389268
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
6 deletions
extensions/cronet/src/main/java/com/google/android/exoplayer2/ext/cronet/CronetDataSource.java
extensions/okhttp/src/main/java/com/google/android/exoplayer2/ext/okhttp/OkHttpDataSource.java
library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultHttpDataSource.java
testutils_robolectric/src/main/java/com/google/android/exoplayer2/testutil/FakeMediaChunk.java
extensions/cronet/src/main/java/com/google/android/exoplayer2/ext/cronet/CronetDataSource.java
View file @
8edce41f
...
...
@@ -113,7 +113,7 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource {
private
final
CronetEngine
cronetEngine
;
private
final
Executor
executor
;
private
final
Predicate
<
String
>
contentTypePredicate
;
@Nullable
private
final
Predicate
<
String
>
contentTypePredicate
;
private
final
int
connectTimeoutMs
;
private
final
int
readTimeoutMs
;
private
final
boolean
resetTimeoutOnRedirects
;
...
...
@@ -153,12 +153,26 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource {
* hop from Cronet's internal network thread to the response handling thread. However, to
* avoid slowing down overall network performance, care must be taken to make sure response
* handling is a fast operation when using a direct executor.
*/
public
CronetDataSource
(
CronetEngine
cronetEngine
,
Executor
executor
)
{
this
(
cronetEngine
,
executor
,
/* contentTypePredicate= */
null
);
}
/**
* @param cronetEngine A CronetEngine.
* @param executor The {@link java.util.concurrent.Executor} that will handle responses. This may
* be a direct executor (i.e. executes tasks on the calling thread) in order to avoid a thread
* hop from Cronet's internal network thread to the response handling thread. However, to
* avoid slowing down overall network performance, care must be taken to make sure response
* handling is a fast operation when using a direct executor.
* @param contentTypePredicate An optional {@link Predicate}. If a content type is rejected by the
* predicate then an {@link InvalidContentTypeException} is thrown from {@link
* #open(DataSpec)}.
*/
public
CronetDataSource
(
CronetEngine
cronetEngine
,
Executor
executor
,
Predicate
<
String
>
contentTypePredicate
)
{
CronetEngine
cronetEngine
,
Executor
executor
,
@Nullable
Predicate
<
String
>
contentTypePredicate
)
{
this
(
cronetEngine
,
executor
,
...
...
@@ -188,7 +202,7 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource {
public
CronetDataSource
(
CronetEngine
cronetEngine
,
Executor
executor
,
Predicate
<
String
>
contentTypePredicate
,
@Nullable
Predicate
<
String
>
contentTypePredicate
,
int
connectTimeoutMs
,
int
readTimeoutMs
,
boolean
resetTimeoutOnRedirects
,
...
...
@@ -225,7 +239,7 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource {
public
CronetDataSource
(
CronetEngine
cronetEngine
,
Executor
executor
,
Predicate
<
String
>
contentTypePredicate
,
@Nullable
Predicate
<
String
>
contentTypePredicate
,
int
connectTimeoutMs
,
int
readTimeoutMs
,
boolean
resetTimeoutOnRedirects
,
...
...
@@ -246,7 +260,7 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource {
/* package */
CronetDataSource
(
CronetEngine
cronetEngine
,
Executor
executor
,
Predicate
<
String
>
contentTypePredicate
,
@Nullable
Predicate
<
String
>
contentTypePredicate
,
int
connectTimeoutMs
,
int
readTimeoutMs
,
boolean
resetTimeoutOnRedirects
,
...
...
extensions/okhttp/src/main/java/com/google/android/exoplayer2/ext/okhttp/OkHttpDataSource.java
View file @
8edce41f
...
...
@@ -77,6 +77,15 @@ public class OkHttpDataSource extends BaseDataSource implements HttpDataSource {
* @param callFactory A {@link Call.Factory} (typically an {@link okhttp3.OkHttpClient}) for use
* by the source.
* @param userAgent An optional User-Agent string.
*/
public
OkHttpDataSource
(
Call
.
Factory
callFactory
,
@Nullable
String
userAgent
)
{
this
(
callFactory
,
userAgent
,
/* contentTypePredicate= */
null
);
}
/**
* @param callFactory A {@link Call.Factory} (typically an {@link okhttp3.OkHttpClient}) for use
* by the source.
* @param userAgent An optional User-Agent string.
* @param contentTypePredicate An optional {@link Predicate}. If a content type is rejected by the
* predicate then a {@link InvalidContentTypeException} is thrown from {@link
* #open(DataSpec)}.
...
...
library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultHttpDataSource.java
View file @
8edce41f
...
...
@@ -89,6 +89,11 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou
private
long
bytesSkipped
;
private
long
bytesRead
;
/** @param userAgent The User-Agent string that should be used. */
public
DefaultHttpDataSource
(
String
userAgent
)
{
this
(
userAgent
,
/* contentTypePredicate= */
null
);
}
/**
* @param userAgent The User-Agent string that should be used.
* @param contentTypePredicate An optional {@link Predicate}. If a content type is rejected by the
...
...
testutils_robolectric/src/main/java/com/google/android/exoplayer2/testutil/FakeMediaChunk.java
View file @
8edce41f
...
...
@@ -27,7 +27,7 @@ import java.io.IOException;
/** Fake {@link MediaChunk}. */
public
final
class
FakeMediaChunk
extends
MediaChunk
{
private
static
final
DataSource
DATA_SOURCE
=
new
DefaultHttpDataSource
(
"TEST_AGENT"
,
null
);
private
static
final
DataSource
DATA_SOURCE
=
new
DefaultHttpDataSource
(
"TEST_AGENT"
);
public
FakeMediaChunk
(
Format
trackFormat
,
long
startTimeUs
,
long
endTimeUs
)
{
this
(
new
DataSpec
(
Uri
.
EMPTY
),
trackFormat
,
startTimeUs
,
endTimeUs
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment