Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for UDP data source #6036

Merged
merged 1 commit into from
Jun 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public final class DefaultDataSource implements DataSource {
private static final String SCHEME_ASSET = "asset";
private static final String SCHEME_CONTENT = "content";
private static final String SCHEME_RTMP = "rtmp";
private static final String SCHEME_UDP = "udp";
private static final String SCHEME_RAW = RawResourceDataSource.RAW_RESOURCE_SCHEME;

private final Context context;
Expand All @@ -66,6 +67,7 @@ public final class DefaultDataSource implements DataSource {
@Nullable private DataSource assetDataSource;
@Nullable private DataSource contentDataSource;
@Nullable private DataSource rtmpDataSource;
@Nullable private DataSource udpDataSource;
@Nullable private DataSource dataSchemeDataSource;
@Nullable private DataSource rawResourceDataSource;

Expand Down Expand Up @@ -139,6 +141,7 @@ public void addTransferListener(TransferListener transferListener) {
maybeAddListenerToDataSource(assetDataSource, transferListener);
maybeAddListenerToDataSource(contentDataSource, transferListener);
maybeAddListenerToDataSource(rtmpDataSource, transferListener);
maybeAddListenerToDataSource(udpDataSource, transferListener);
maybeAddListenerToDataSource(dataSchemeDataSource, transferListener);
maybeAddListenerToDataSource(rawResourceDataSource, transferListener);
}
Expand All @@ -161,6 +164,8 @@ public long open(DataSpec dataSpec) throws IOException {
dataSource = getContentDataSource();
} else if (SCHEME_RTMP.equals(scheme)) {
dataSource = getRtmpDataSource();
} else if(SCHEME_UDP.equals(scheme)){
dataSource = getUdpDataSource();
} else if (DataSchemeDataSource.SCHEME_DATA.equals(scheme)) {
dataSource = getDataSchemeDataSource();
} else if (SCHEME_RAW.equals(scheme)) {
Expand Down Expand Up @@ -199,6 +204,14 @@ public void close() throws IOException {
}
}

private DataSource getUdpDataSource(){
if (udpDataSource == null) {
udpDataSource = new UdpDataSource();
addListenersToDataSource(udpDataSource);
}
return udpDataSource;
}

private DataSource getFileDataSource() {
if (fileDataSource == null) {
fileDataSource = new FileDataSource();
Expand Down