public interface HttpDataSource extends DataSource
DataSource.| 限定符和类型 | 接口和说明 |
|---|---|
static class |
HttpDataSource.BaseFactory
Base implementation of
HttpDataSource.Factory that sets default request properties. |
static class |
HttpDataSource.CleartextNotPermittedException
Thrown when cleartext HTTP traffic is not permitted.
|
static interface |
HttpDataSource.Factory
A factory for
HttpDataSource instances. |
static class |
HttpDataSource.HttpDataSourceException
Thrown when an error is encountered when trying to read from a
HttpDataSource. |
static class |
HttpDataSource.InvalidContentTypeException
Thrown when the content type is invalid.
|
static class |
HttpDataSource.InvalidResponseCodeException
Thrown when an attempt to open a connection results in a response code not in the 2xx range.
|
static class |
HttpDataSource.RequestProperties
Stores HTTP request properties (aka HTTP headers) and provides methods to modify the headers
in a thread safe way to avoid the potential of creating snapshots of an inconsistent or
unintended state.
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
clearAllRequestProperties()
Clears all request headers that were set by
setRequestProperty(String, String). |
void |
clearRequestProperty(java.lang.String name)
Clears the value of a request header.
|
void |
close()
Closes the source.
|
int |
getResponseCode()
When the source is open, returns the HTTP response status code associated with the last
open(tv.danmaku.ijk.media.drm.upstream.DataSpec) call. |
java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
getResponseHeaders()
When the source is open, returns the response headers associated with the last
DataSource.open(tv.danmaku.ijk.media.drm.upstream.DataSpec)
call. |
long |
open(DataSpec dataSpec)
Opens the source to read the specified data.
|
int |
read(byte[] buffer,
int offset,
int readLength)
Reads up to
length bytes of data from the input. |
void |
setRequestProperty(java.lang.String name,
java.lang.String value)
Sets the value of a request header.
|
addTransferListener, getUrilong open(DataSpec dataSpec) throws HttpDataSource.HttpDataSourceException
Note: HttpDataSource implementations are advised to set request headers passed via
(in order of decreasing priority) the dataSpec, setRequestProperty(java.lang.String, java.lang.String) and the
default parameters set in the HttpDataSource.Factory.
open 在接口中 DataSourcedataSpec - Defines the data to be read.DataSpec.length equals C.LENGTH_UNSET) this value
is the resolved length of the request, or C.LENGTH_UNSET if the length is still
unresolved. For all other requests, the value returned will be equal to the request's
DataSpec.length.HttpDataSource.HttpDataSourceExceptionvoid close()
throws HttpDataSource.HttpDataSourceException
DataSource
Note: This method must be called even if the corresponding call to DataSource.open(DataSpec)
threw an IOException. See DataSource.open(DataSpec) for more details.
close 在接口中 DataSourceHttpDataSource.HttpDataSourceExceptionint read(byte[] buffer,
int offset,
int readLength)
throws HttpDataSource.HttpDataSourceException
DataReaderlength bytes of data from the input.
If readLength is zero then 0 is returned. Otherwise, if no data is available because
the end of the opened range has been reached, then C.RESULT_END_OF_INPUT is returned.
Otherwise, the call will block until at least one byte of data has been read and the number of
bytes read is returned.
read 在接口中 DataReaderbuffer - A target array into which data should be written.offset - The offset into the target array at which to write.readLength - The maximum number of bytes to read from the input.C.RESULT_END_OF_INPUT if the input has ended. This
may be less than length because the end of the input (or available data) was
reached, the method was interrupted, or the operation was aborted early for another reason.HttpDataSource.HttpDataSourceExceptionvoid setRequestProperty(java.lang.String name,
java.lang.String value)
Note: If the same header is set as a default parameter in the HttpDataSource.Factory, then the
header value set with this method should be preferred when connecting with the data source. See
open(tv.danmaku.ijk.media.drm.upstream.DataSpec).
name - The name of the header field.value - The value of the field.void clearRequestProperty(java.lang.String name)
name - The name of the header field.void clearAllRequestProperties()
setRequestProperty(String, String).int getResponseCode()
open(tv.danmaku.ijk.media.drm.upstream.DataSpec) call. Otherwise, returns a negative value.java.util.Map<java.lang.String,java.util.List<java.lang.String>> getResponseHeaders()
DataSourceDataSource.open(tv.danmaku.ijk.media.drm.upstream.DataSpec)
call. Otherwise, returns an empty map.
Key look-up in the returned map is case-insensitive.
getResponseHeaders 在接口中 DataSource