Skip to content

Commit

Permalink
Generalize manifest parser parameters in DASH and SmoothStreaming Med…
Browse files Browse the repository at this point in the history
…iaSources

This allows custom parsers to be used.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=152005477
  • Loading branch information
erdemguven authored and ojw28 committed Apr 6, 2017
1 parent 107e0eb commit dd2914f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public interface Parser<T> {
public final int type;

private final DataSource dataSource;
private final Parser<T> parser;
private final Parser<? extends T> parser;

private volatile T result;
private volatile boolean isCanceled;
Expand All @@ -71,7 +71,7 @@ public interface Parser<T> {
* @param type See {@link #type}.
* @param parser Parses the object from the response.
*/
public ParsingLoadable(DataSource dataSource, Uri uri, int type, Parser<T> parser) {
public ParsingLoadable(DataSource dataSource, Uri uri, int type, Parser<? extends T> parser) {
this.dataSource = dataSource;
this.dataSpec = new DataSpec(uri, DataSpec.FLAG_ALLOW_GZIP);
this.type = type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public final class DashMediaSource implements MediaSource {
private final int minLoadableRetryCount;
private final long livePresentationDelayMs;
private final EventDispatcher eventDispatcher;
private final DashManifestParser manifestParser;
private final ParsingLoadable.Parser<? extends DashManifest> manifestParser;
private final ManifestCallback manifestCallback;
private final Object manifestUriLock;
private final SparseArray<DashMediaPeriod> periodsById;
Expand Down Expand Up @@ -200,15 +200,17 @@ public DashMediaSource(Uri manifestUri, DataSource.Factory manifestDataSourceFac
* @param eventListener A listener of events. May be null if delivery of events is not required.
*/
public DashMediaSource(Uri manifestUri, DataSource.Factory manifestDataSourceFactory,
DashManifestParser manifestParser, DashChunkSource.Factory chunkSourceFactory,
int minLoadableRetryCount, long livePresentationDelayMs, Handler eventHandler,
ParsingLoadable.Parser<? extends DashManifest> manifestParser,
DashChunkSource.Factory chunkSourceFactory, int minLoadableRetryCount,
long livePresentationDelayMs, Handler eventHandler,
AdaptiveMediaSourceEventListener eventListener) {
this(null, manifestUri, manifestDataSourceFactory, manifestParser, chunkSourceFactory,
minLoadableRetryCount, livePresentationDelayMs, eventHandler, eventListener);
}

private DashMediaSource(DashManifest manifest, Uri manifestUri,
DataSource.Factory manifestDataSourceFactory, DashManifestParser manifestParser,
DataSource.Factory manifestDataSourceFactory,
ParsingLoadable.Parser<? extends DashManifest> manifestParser,
DashChunkSource.Factory chunkSourceFactory, int minLoadableRetryCount,
long livePresentationDelayMs, Handler eventHandler,
AdaptiveMediaSourceEventListener eventListener) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public final class SsMediaSource implements MediaSource,
private final int minLoadableRetryCount;
private final long livePresentationDelayMs;
private final EventDispatcher eventDispatcher;
private final SsManifestParser manifestParser;
private final ParsingLoadable.Parser<? extends SsManifest> manifestParser;
private final ArrayList<SsMediaPeriod> mediaPeriods;

private Listener sourceListener;
Expand Down Expand Up @@ -171,15 +171,17 @@ public SsMediaSource(Uri manifestUri, DataSource.Factory manifestDataSourceFacto
* @param eventListener A listener of events. May be null if delivery of events is not required.
*/
public SsMediaSource(Uri manifestUri, DataSource.Factory manifestDataSourceFactory,
SsManifestParser manifestParser, SsChunkSource.Factory chunkSourceFactory,
int minLoadableRetryCount, long livePresentationDelayMs, Handler eventHandler,
ParsingLoadable.Parser<? extends SsManifest> manifestParser,
SsChunkSource.Factory chunkSourceFactory, int minLoadableRetryCount,
long livePresentationDelayMs, Handler eventHandler,
AdaptiveMediaSourceEventListener eventListener) {
this(null, manifestUri, manifestDataSourceFactory, manifestParser, chunkSourceFactory,
minLoadableRetryCount, livePresentationDelayMs, eventHandler, eventListener);
}

private SsMediaSource(SsManifest manifest, Uri manifestUri,
DataSource.Factory manifestDataSourceFactory, SsManifestParser manifestParser,
DataSource.Factory manifestDataSourceFactory,
ParsingLoadable.Parser<? extends SsManifest> manifestParser,
SsChunkSource.Factory chunkSourceFactory, int minLoadableRetryCount,
long livePresentationDelayMs, Handler eventHandler,
AdaptiveMediaSourceEventListener eventListener) {
Expand Down

0 comments on commit dd2914f

Please sign in to comment.