Propagate erors to ChunkSource implementations.

This can help custom ChunkSource implementations to act on
this information. For example an adaptive implementation may
choose to blacklist a problematic format if loads of that
format keep failing.
This commit is contained in:
Oliver Woodman 2014-07-04 01:06:20 +01:00
parent 4fd4c89518
commit 47c0bbd6b5
6 changed files with 30 additions and 0 deletions

View File

@ -430,6 +430,7 @@ public class ChunkSampleSource implements SampleSource, Loader.Listener {
currentLoadableExceptionCount++;
currentLoadableExceptionTimestamp = SystemClock.elapsedRealtime();
notifyUpstreamError(e);
chunkSource.onChunkLoadError(currentLoadableHolder.chunk, e);
updateLoadControl();
}

View File

@ -100,4 +100,13 @@ public interface ChunkSource {
*/
IOException getError();
/**
* Invoked when the {@link ChunkSampleSource} encounters an error loading a chunk obtained from
* this source.
*
* @param chunk The chunk whose load encountered the error.
* @param e The error.
*/
void onChunkLoadError(Chunk chunk, Exception e);
}

View File

@ -102,4 +102,9 @@ public class MultiTrackChunkSource implements ChunkSource, ExoPlayerComponent {
}
}
@Override
public void onChunkLoadError(Chunk chunk, Exception e) {
selectedSource.onChunkLoadError(chunk, e);
}
}

View File

@ -192,6 +192,11 @@ public class DashMp4ChunkSource implements ChunkSource {
return null;
}
@Override
public void onChunkLoadError(Chunk chunk, Exception e) {
// Do nothing.
}
private static Chunk newInitializationChunk(Representation representation,
FragmentedMp4Extractor extractor, DataSource dataSource, int trigger) {
DataSpec dataSpec = new DataSpec(representation.uri, 0, representation.indexEnd + 1,

View File

@ -173,6 +173,11 @@ public class DashWebmChunkSource implements ChunkSource {
return null;
}
@Override
public void onChunkLoadError(Chunk chunk, Exception e) {
// Do nothing.
}
private static Chunk newInitializationChunk(Representation representation,
WebmExtractor extractor, DataSource dataSource, int trigger) {
DataSpec dataSpec = new DataSpec(representation.uri, 0, representation.indexEnd + 1,

View File

@ -196,6 +196,11 @@ public class SmoothStreamingChunkSource implements ChunkSource {
return null;
}
@Override
public void onChunkLoadError(Chunk chunk, Exception e) {
// Do nothing.
}
private static MediaFormat getMediaFormat(StreamElement streamElement, int trackIndex) {
TrackElement trackElement = streamElement.tracks[trackIndex];
String mimeType = trackElement.mimeType;