mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
HttpDataSources: Remove unused protected methods
PiperOrigin-RevId: 361109018
This commit is contained in:
parent
49c282d6fa
commit
3de81c6d31
2 changed files with 9 additions and 87 deletions
|
|
@ -180,8 +180,6 @@ public class OkHttpDataSource extends BaseDataSource implements HttpDataSource {
|
||||||
@Nullable private Response response;
|
@Nullable private Response response;
|
||||||
@Nullable private InputStream responseByteStream;
|
@Nullable private InputStream responseByteStream;
|
||||||
private boolean opened;
|
private boolean opened;
|
||||||
|
|
||||||
private long bytesSkipped;
|
|
||||||
private long bytesToRead;
|
private long bytesToRead;
|
||||||
private long bytesRead;
|
private long bytesRead;
|
||||||
|
|
||||||
|
|
@ -275,7 +273,6 @@ public class OkHttpDataSource extends BaseDataSource implements HttpDataSource {
|
||||||
public long open(DataSpec dataSpec) throws HttpDataSourceException {
|
public long open(DataSpec dataSpec) throws HttpDataSourceException {
|
||||||
this.dataSpec = dataSpec;
|
this.dataSpec = dataSpec;
|
||||||
this.bytesRead = 0;
|
this.bytesRead = 0;
|
||||||
this.bytesSkipped = 0;
|
|
||||||
transferInitializing(dataSpec);
|
transferInitializing(dataSpec);
|
||||||
|
|
||||||
Request request = makeRequest(dataSpec);
|
Request request = makeRequest(dataSpec);
|
||||||
|
|
@ -372,38 +369,6 @@ public class OkHttpDataSource extends BaseDataSource implements HttpDataSource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the number of bytes that were skipped during the most recent call to {@link
|
|
||||||
* #open(DataSpec)}.
|
|
||||||
*
|
|
||||||
* @return The number of bytes skipped.
|
|
||||||
*/
|
|
||||||
protected final long bytesSkipped() {
|
|
||||||
return bytesSkipped;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the number of bytes that have been read since the most recent call to
|
|
||||||
* {@link #open(DataSpec)}.
|
|
||||||
*
|
|
||||||
* @return The number of bytes read.
|
|
||||||
*/
|
|
||||||
protected final long bytesRead() {
|
|
||||||
return bytesRead;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the number of bytes that are still to be read for the current {@link DataSpec}.
|
|
||||||
* <p>
|
|
||||||
* If the total length of the data being read is known, then this length minus {@code bytesRead()}
|
|
||||||
* is returned. If the total length is unknown, {@link C#LENGTH_UNSET} is returned.
|
|
||||||
*
|
|
||||||
* @return The remaining length, or {@link C#LENGTH_UNSET}.
|
|
||||||
*/
|
|
||||||
protected final long bytesRemaining() {
|
|
||||||
return bytesToRead == C.LENGTH_UNSET ? bytesToRead : bytesToRead - bytesRead;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Establishes a connection. */
|
/** Establishes a connection. */
|
||||||
private Request makeRequest(DataSpec dataSpec) throws HttpDataSourceException {
|
private Request makeRequest(DataSpec dataSpec) throws HttpDataSourceException {
|
||||||
long position = dataSpec.position;
|
long position = dataSpec.position;
|
||||||
|
|
@ -471,8 +436,8 @@ public class OkHttpDataSource extends BaseDataSource implements HttpDataSource {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
byte[] skipBuffer = new byte[4096];
|
byte[] skipBuffer = new byte[4096];
|
||||||
while (bytesSkipped != bytesToSkip) {
|
while (bytesToSkip > 0) {
|
||||||
int readLength = (int) min(bytesToSkip - bytesSkipped, skipBuffer.length);
|
int readLength = (int) min(bytesToSkip, skipBuffer.length);
|
||||||
int read = castNonNull(responseByteStream).read(skipBuffer, 0, readLength);
|
int read = castNonNull(responseByteStream).read(skipBuffer, 0, readLength);
|
||||||
if (Thread.currentThread().isInterrupted()) {
|
if (Thread.currentThread().isInterrupted()) {
|
||||||
throw new InterruptedIOException();
|
throw new InterruptedIOException();
|
||||||
|
|
@ -480,7 +445,7 @@ public class OkHttpDataSource extends BaseDataSource implements HttpDataSource {
|
||||||
if (read == -1) {
|
if (read == -1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bytesSkipped += read;
|
bytesToSkip -= read;
|
||||||
bytesTransferred(read);
|
bytesTransferred(read);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -222,8 +222,6 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou
|
||||||
@Nullable private InputStream inputStream;
|
@Nullable private InputStream inputStream;
|
||||||
private boolean opened;
|
private boolean opened;
|
||||||
private int responseCode;
|
private int responseCode;
|
||||||
|
|
||||||
private long bytesSkipped;
|
|
||||||
private long bytesToRead;
|
private long bytesToRead;
|
||||||
private long bytesRead;
|
private long bytesRead;
|
||||||
|
|
||||||
|
|
@ -338,7 +336,6 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou
|
||||||
public long open(DataSpec dataSpec) throws HttpDataSourceException {
|
public long open(DataSpec dataSpec) throws HttpDataSourceException {
|
||||||
this.dataSpec = dataSpec;
|
this.dataSpec = dataSpec;
|
||||||
this.bytesRead = 0;
|
this.bytesRead = 0;
|
||||||
this.bytesSkipped = 0;
|
|
||||||
transferInitializing(dataSpec);
|
transferInitializing(dataSpec);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
@ -455,7 +452,9 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou
|
||||||
try {
|
try {
|
||||||
@Nullable InputStream inputStream = this.inputStream;
|
@Nullable InputStream inputStream = this.inputStream;
|
||||||
if (inputStream != null) {
|
if (inputStream != null) {
|
||||||
maybeTerminateInputStream(connection, bytesRemaining());
|
long bytesRemaining =
|
||||||
|
bytesToRead == C.LENGTH_UNSET ? C.LENGTH_UNSET : bytesToRead - bytesRead;
|
||||||
|
maybeTerminateInputStream(connection, bytesRemaining);
|
||||||
try {
|
try {
|
||||||
inputStream.close();
|
inputStream.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
@ -473,48 +472,6 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the current connection, or null if the source is not currently opened.
|
|
||||||
*
|
|
||||||
* @return The current open connection, or null.
|
|
||||||
*/
|
|
||||||
@Nullable
|
|
||||||
protected final HttpURLConnection getConnection() {
|
|
||||||
return connection;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the number of bytes that were skipped during the most recent call to {@link
|
|
||||||
* #open(DataSpec)}.
|
|
||||||
*
|
|
||||||
* @return The number of bytes skipped.
|
|
||||||
*/
|
|
||||||
protected final long bytesSkipped() {
|
|
||||||
return bytesSkipped;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the number of bytes that have been read since the most recent call to
|
|
||||||
* {@link #open(DataSpec)}.
|
|
||||||
*
|
|
||||||
* @return The number of bytes read.
|
|
||||||
*/
|
|
||||||
protected final long bytesRead() {
|
|
||||||
return bytesRead;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the number of bytes that are still to be read for the current {@link DataSpec}.
|
|
||||||
* <p>
|
|
||||||
* If the total length of the data being read is known, then this length minus {@code bytesRead()}
|
|
||||||
* is returned. If the total length is unknown, {@link C#LENGTH_UNSET} is returned.
|
|
||||||
*
|
|
||||||
* @return The remaining length, or {@link C#LENGTH_UNSET}.
|
|
||||||
*/
|
|
||||||
protected final long bytesRemaining() {
|
|
||||||
return bytesToRead == C.LENGTH_UNSET ? bytesToRead : bytesToRead - bytesRead;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Establishes a connection, following redirects to do so where permitted.
|
* Establishes a connection, following redirects to do so where permitted.
|
||||||
*/
|
*/
|
||||||
|
|
@ -742,8 +699,8 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
byte[] skipBuffer = new byte[4096];
|
byte[] skipBuffer = new byte[4096];
|
||||||
while (bytesSkipped != bytesToSkip) {
|
while (bytesToSkip > 0) {
|
||||||
int readLength = (int) min(bytesToSkip - bytesSkipped, skipBuffer.length);
|
int readLength = (int) min(bytesToSkip, skipBuffer.length);
|
||||||
int read = castNonNull(inputStream).read(skipBuffer, 0, readLength);
|
int read = castNonNull(inputStream).read(skipBuffer, 0, readLength);
|
||||||
if (Thread.currentThread().isInterrupted()) {
|
if (Thread.currentThread().isInterrupted()) {
|
||||||
throw new InterruptedIOException();
|
throw new InterruptedIOException();
|
||||||
|
|
@ -751,7 +708,7 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou
|
||||||
if (read == -1) {
|
if (read == -1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bytesSkipped += read;
|
bytesToSkip -= read;
|
||||||
bytesTransferred(read);
|
bytesTransferred(read);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue