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
b0a873df
authored
Jun 25, 2017
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Clean up okhttp datasource.
parent
ea2f5cce
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
30 deletions
extensions/okhttp/src/main/java/com/google/android/exoplayer2/ext/okhttp/OkHttpDataSource.java
extensions/okhttp/src/main/java/com/google/android/exoplayer2/ext/okhttp/OkHttpDataSourceFactory.java
extensions/okhttp/src/main/java/com/google/android/exoplayer2/ext/okhttp/OkHttpDataSource.java
View file @
b0a873df
...
@@ -16,8 +16,8 @@
...
@@ -16,8 +16,8 @@
package
com
.
google
.
android
.
exoplayer2
.
ext
.
okhttp
;
package
com
.
google
.
android
.
exoplayer2
.
ext
.
okhttp
;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.Nullable
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.upstream.DataSourceException
;
import
com.google.android.exoplayer2.upstream.DataSourceException
;
import
com.google.android.exoplayer2.upstream.DataSpec
;
import
com.google.android.exoplayer2.upstream.DataSpec
;
...
@@ -47,13 +47,14 @@ public class OkHttpDataSource implements HttpDataSource {
...
@@ -47,13 +47,14 @@ public class OkHttpDataSource implements HttpDataSource {
private
static
final
AtomicReference
<
byte
[]>
skipBufferReference
=
new
AtomicReference
<>();
private
static
final
AtomicReference
<
byte
[]>
skipBufferReference
=
new
AtomicReference
<>();
private
final
Call
.
Factory
callFactory
;
@NonNull
private
final
Call
.
Factory
callFactory
;
private
final
String
userAgent
;
@NonNull
private
final
RequestProperties
requestProperties
;
private
final
Predicate
<
String
>
contentTypePredicate
;
private
final
TransferListener
<?
super
OkHttpDataSource
>
listener
;
@Nullable
private
final
String
userAgent
;
private
final
CacheControl
cacheControl
;
@Nullable
private
final
Predicate
<
String
>
contentTypePredicate
;
private
final
RequestProperties
defaultRequestProperties
;
@Nullable
private
final
TransferListener
<?
super
OkHttpDataSource
>
listener
;
private
final
RequestProperties
requestProperties
;
@Nullable
private
final
CacheControl
cacheControl
;
@Nullable
private
final
RequestProperties
defaultRequestProperties
;
private
DataSpec
dataSpec
;
private
DataSpec
dataSpec
;
private
Response
response
;
private
Response
response
;
...
@@ -69,33 +70,34 @@ public class OkHttpDataSource implements HttpDataSource {
...
@@ -69,33 +70,34 @@ public class OkHttpDataSource implements HttpDataSource {
/**
/**
* @param callFactory A {@link Call.Factory} (typically an {@link okhttp3.OkHttpClient}) for use
* @param callFactory A {@link Call.Factory} (typically an {@link okhttp3.OkHttpClient}) for use
* by the source.
* by the source.
* @param userAgent An optional User-Agent string
that should be used
.
* @param userAgent An optional User-Agent string.
* @param contentTypePredicate An optional {@link Predicate}. If a content type is rejected by the
* @param contentTypePredicate An optional {@link Predicate}. If a content type is rejected by the
* predicate then a InvalidContentTypeException} is thrown from {@link #open(DataSpec)}.
* predicate then a InvalidContentTypeException} is thrown from {@link #open(DataSpec)}.
*/
*/
public
OkHttpDataSource
(
Call
.
Factory
callFactory
,
@Nullable
String
userAgent
,
public
OkHttpDataSource
(
@NonNull
Call
.
Factory
callFactory
,
@Nullable
String
userAgent
,
Predicate
<
String
>
contentTypePredicate
)
{
@Nullable
Predicate
<
String
>
contentTypePredicate
)
{
this
(
callFactory
,
userAgent
,
contentTypePredicate
,
null
);
this
(
callFactory
,
userAgent
,
contentTypePredicate
,
null
);
}
}
/**
/**
* @param callFactory A {@link Call.Factory} (typically an {@link okhttp3.OkHttpClient}) for use
* @param callFactory A {@link Call.Factory} (typically an {@link okhttp3.OkHttpClient}) for use
* by the source.
* by the source.
* @param userAgent An optional User-Agent string
that should be used
.
* @param userAgent An optional User-Agent string.
* @param contentTypePredicate An optional {@link Predicate}. If a content type is rejected by the
* @param contentTypePredicate An optional {@link Predicate}. If a content type is rejected by the
* predicate then a {@link InvalidContentTypeException} is thrown from
* predicate then a {@link InvalidContentTypeException} is thrown from
* {@link #open(DataSpec)}.
* {@link #open(DataSpec)}.
* @param listener An optional listener.
* @param listener An optional listener.
*/
*/
public
OkHttpDataSource
(
Call
.
Factory
callFactory
,
@Nullable
String
userAgent
,
public
OkHttpDataSource
(
@NonNull
Call
.
Factory
callFactory
,
@Nullable
String
userAgent
,
Predicate
<
String
>
contentTypePredicate
,
TransferListener
<?
super
OkHttpDataSource
>
listener
)
{
@Nullable
Predicate
<
String
>
contentTypePredicate
,
@Nullable
TransferListener
<?
super
OkHttpDataSource
>
listener
)
{
this
(
callFactory
,
userAgent
,
contentTypePredicate
,
listener
,
null
,
null
);
this
(
callFactory
,
userAgent
,
contentTypePredicate
,
listener
,
null
,
null
);
}
}
/**
/**
* @param callFactory A {@link Call.Factory} (typically an {@link okhttp3.OkHttpClient}) for use
* @param callFactory A {@link Call.Factory} (typically an {@link okhttp3.OkHttpClient}) for use
* by the source.
* by the source.
* @param userAgent An optional User-Agent string
that should be used
.
* @param userAgent An optional User-Agent string.
* @param contentTypePredicate An optional {@link Predicate}. If a content type is rejected by the
* @param contentTypePredicate An optional {@link Predicate}. If a content type is rejected by the
* predicate then a {@link InvalidContentTypeException} is thrown from
* predicate then a {@link InvalidContentTypeException} is thrown from
* {@link #open(DataSpec)}.
* {@link #open(DataSpec)}.
...
@@ -104,9 +106,10 @@ public class OkHttpDataSource implements HttpDataSource {
...
@@ -104,9 +106,10 @@ public class OkHttpDataSource implements HttpDataSource {
* @param defaultRequestProperties The optional default {@link RequestProperties} to be sent to
* @param defaultRequestProperties The optional default {@link RequestProperties} to be sent to
* the server as HTTP headers on every request.
* the server as HTTP headers on every request.
*/
*/
public
OkHttpDataSource
(
Call
.
Factory
callFactory
,
@Nullable
String
userAgent
,
public
OkHttpDataSource
(
@NonNull
Call
.
Factory
callFactory
,
@Nullable
String
userAgent
,
Predicate
<
String
>
contentTypePredicate
,
TransferListener
<?
super
OkHttpDataSource
>
listener
,
@Nullable
Predicate
<
String
>
contentTypePredicate
,
CacheControl
cacheControl
,
RequestProperties
defaultRequestProperties
)
{
@Nullable
TransferListener
<?
super
OkHttpDataSource
>
listener
,
@Nullable
CacheControl
cacheControl
,
@Nullable
RequestProperties
defaultRequestProperties
)
{
this
.
callFactory
=
Assertions
.
checkNotNull
(
callFactory
);
this
.
callFactory
=
Assertions
.
checkNotNull
(
callFactory
);
this
.
userAgent
=
userAgent
;
this
.
userAgent
=
userAgent
;
this
.
contentTypePredicate
=
contentTypePredicate
;
this
.
contentTypePredicate
=
contentTypePredicate
;
...
...
extensions/okhttp/src/main/java/com/google/android/exoplayer2/ext/okhttp/OkHttpDataSourceFactory.java
View file @
b0a873df
...
@@ -15,8 +15,8 @@
...
@@ -15,8 +15,8 @@
*/
*/
package
com
.
google
.
android
.
exoplayer2
.
ext
.
okhttp
;
package
com
.
google
.
android
.
exoplayer2
.
ext
.
okhttp
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.Nullable
;
import
com.google.android.exoplayer2.upstream.DataSource
;
import
com.google.android.exoplayer2.upstream.DataSource
;
import
com.google.android.exoplayer2.upstream.HttpDataSource
;
import
com.google.android.exoplayer2.upstream.HttpDataSource
;
import
com.google.android.exoplayer2.upstream.HttpDataSource.BaseFactory
;
import
com.google.android.exoplayer2.upstream.HttpDataSource.BaseFactory
;
...
@@ -30,32 +30,32 @@ import okhttp3.Call;
...
@@ -30,32 +30,32 @@ import okhttp3.Call;
*/
*/
public
final
class
OkHttpDataSourceFactory
extends
BaseFactory
{
public
final
class
OkHttpDataSourceFactory
extends
BaseFactory
{
private
final
Call
.
Factory
callFactory
;
@NonNull
private
final
Call
.
Factory
callFactory
;
private
final
String
userAgent
;
@Nullable
private
final
String
userAgent
;
private
final
TransferListener
<?
super
DataSource
>
listener
;
@Nullable
private
final
TransferListener
<?
super
DataSource
>
listener
;
private
final
CacheControl
cacheControl
;
@Nullable
private
final
CacheControl
cacheControl
;
/**
/**
* @param callFactory A {@link Call.Factory} (typically an {@link okhttp3.OkHttpClient}) for use
* @param callFactory A {@link Call.Factory} (typically an {@link okhttp3.OkHttpClient}) for use
* by the sources created by the factory.
* by the sources created by the factory.
* @param userAgent An optional User-Agent string
that should be used
.
* @param userAgent An optional User-Agent string.
* @param listener An optional listener.
* @param listener An optional listener.
*/
*/
public
OkHttpDataSourceFactory
(
Call
.
Factory
callFactory
,
@Nullable
String
userAgent
,
public
OkHttpDataSourceFactory
(
@NonNull
Call
.
Factory
callFactory
,
@Nullable
String
userAgent
,
TransferListener
<?
super
DataSource
>
listener
)
{
@Nullable
TransferListener
<?
super
DataSource
>
listener
)
{
this
(
callFactory
,
userAgent
,
listener
,
null
);
this
(
callFactory
,
userAgent
,
listener
,
null
);
}
}
/**
/**
* @param callFactory A {@link Call.Factory} (typically an {@link okhttp3.OkHttpClient}) for use
* @param callFactory A {@link Call.Factory} (typically an {@link okhttp3.OkHttpClient}) for use
* by the sources created by the factory.
* by the sources created by the factory.
* @param userAgent An optional User-Agent string
that should be used
.
* @param userAgent An optional User-Agent string.
* @param listener An optional listener.
* @param listener An optional listener.
* @param cacheControl An optional {@link CacheControl} for setting the Cache-Control header.
* @param cacheControl An optional {@link CacheControl} for setting the Cache-Control header.
*/
*/
public
OkHttpDataSourceFactory
(
Call
.
Factory
callFactory
,
public
OkHttpDataSourceFactory
(
@NonNull
Call
.
Factory
callFactory
,
@Nullable
String
userAgent
,
@Nullable
String
userAgent
,
@Nullable
TransferListener
<?
super
DataSource
>
listener
,
TransferListener
<?
super
DataSource
>
listener
,
CacheControl
cacheControl
)
{
@Nullable
CacheControl
cacheControl
)
{
this
.
callFactory
=
callFactory
;
this
.
callFactory
=
callFactory
;
this
.
userAgent
=
userAgent
;
this
.
userAgent
=
userAgent
;
this
.
listener
=
listener
;
this
.
listener
=
listener
;
...
...
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