Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 1 addition & 7 deletions demos/cast/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ apply from: '../../constants.gradle'
apply plugin: 'com.android.application'

android {
compileSdkVersion project.ext.compileSdkVersion
compileSdkVersion 25
buildToolsVersion project.ext.buildToolsVersion

defaultConfig {
Expand All @@ -42,10 +42,4 @@ android {
}

dependencies {
compile project(modulePrefix + 'library-core')
compile project(modulePrefix + 'library-dash')
compile project(modulePrefix + 'library-hls')
compile project(modulePrefix + 'library-smoothstreaming')
compile project(modulePrefix + 'library-ui')
compile project(modulePrefix + 'extension-cast')
}
3 changes: 3 additions & 0 deletions demos/main/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE"/>

<uses-feature android:name="android.software.leanback" android:required="false"/>
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="26"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,18 @@
package com.google.android.exoplayer2.demo;

import android.app.Application;
import android.util.Log;

import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter;
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory;
import com.google.android.exoplayer2.upstream.HttpDataSource;
import com.google.android.exoplayer2.upstream.RtpDataSource;
import com.google.android.exoplayer2.upstream.RtpDataSourceFactory;
import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.util.rtp.AluRtpDistributionFeedback;
import com.google.android.exoplayer2.util.rtp.RtpDistributionFeedback;

/**
* Placeholder application to facilitate overriding Application methods for debugging and testing.
Expand All @@ -30,6 +36,50 @@ public class DemoApplication extends Application {

protected String userAgent;

protected RtpDistributionFeedback.RtpFeedbackEventListener eventListener =
new RtpDistributionFeedback.RtpFeedbackEventListener () {

@Override
public void onRtpFeedbackEvent(
RtpDistributionFeedback.RtpFeedbackEvent event) {

if (event instanceof AluRtpDistributionFeedback.AluRtpFeedbackConfigDiscoveryStarted) {

Log.v("AluRtpFeedback", "ALU RTP Feedback Configuration Discovery Started");
}
else if (event instanceof AluRtpDistributionFeedback.AluRtpFeedbackConfigDiscoveryEnded) {

Log.v("AluRtpFeedback", "ALU RTP Feedback Configuration Discovery Ended");
}
else if (event instanceof AluRtpDistributionFeedback.AluDefaultRtpBurstServerEvent) {

AluRtpDistributionFeedback.AluDefaultRtpBurstServerEvent serverEvent =
(AluRtpDistributionFeedback.AluDefaultRtpBurstServerEvent) event;

Log.v("AluRtpFeedback", "default burst=[" + serverEvent.getBurstServer() + "]");
}
else if (event instanceof AluRtpDistributionFeedback.AluDefaultRtpRetransmissionServerEvent) {

AluRtpDistributionFeedback.AluDefaultRtpRetransmissionServerEvent serverEvent =
(AluRtpDistributionFeedback.AluDefaultRtpRetransmissionServerEvent) event;

Log.v("AluRtpFeedback", "default retransmission=[" + serverEvent.getRetransmissionServer() + "]");
}
else if (event instanceof AluRtpDistributionFeedback.AluRtpMulticastGroupInfoEvent) {

AluRtpDistributionFeedback.AluRtpMulticastGroupInfoEvent groupInfo =
(AluRtpDistributionFeedback.AluRtpMulticastGroupInfoEvent) event;

Log.v("AluRtpFeedback", "mcast=[" + groupInfo.getMulticastGroup() + "], " +
"first burst=[" + groupInfo.getFirstBurstServer() + "], " +
"second burst=[" + groupInfo.getSecondBurstServer() + "], " +
"first retrans=[" + groupInfo.getFirstRetransmissionServer() + "], " +
"second retrans=[" + groupInfo.getSecondRetransmissionServer() + "]");
}
}
};


@Override
public void onCreate() {
super.onCreate();
Expand All @@ -45,6 +95,49 @@ public HttpDataSource.Factory buildHttpDataSourceFactory(DefaultBandwidthMeter b
return new DefaultHttpDataSourceFactory(userAgent, bandwidthMeter);
}


public RtpDataSource.Factory buildRtpDataSourceFactory(DefaultBandwidthMeter bandwidthMeter,
String vendor, boolean feedback_events,
String burst_uri,
String retransmission_uri) {

RtpDataSourceFactory dataSourceFactory = new RtpDataSourceFactory(bandwidthMeter);

if ((vendor != null) && ("alu".equalsIgnoreCase(vendor))) {

dataSourceFactory.setFeedbackProperty(RtpDistributionFeedback.Properties.FB_VENDOR,
RtpDistributionFeedback.Providers.ALU);

if (feedback_events) {
dataSourceFactory.setFeedbackProperty(RtpDistributionFeedback.Properties.FB_EVENTS_CALLBACK,
eventListener);
}

int flagsScheme = 0;

if (burst_uri != null) {
dataSourceFactory.setFeedbackProperty(RtpDistributionFeedback.Properties.FB_RAMS_URI,
burst_uri);

flagsScheme |= RtpDistributionFeedback.Schemes.FB_RAMS;
}

if (retransmission_uri != null) {
dataSourceFactory.setFeedbackProperty(
RtpDistributionFeedback.Properties.FB_CONGESTION_CONTROL_URI,
retransmission_uri);

flagsScheme |= RtpDistributionFeedback.Schemes.FB_CONGESTION_CONTROL;
}

dataSourceFactory.setFeedbackProperty(RtpDistributionFeedback.Properties.FB_SCHEME,
flagsScheme);

}

return dataSourceFactory;
}

public boolean useExtensionRenderers() {
return BuildConfig.FLAVOR.equals("withExtensions");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter;
import com.google.android.exoplayer2.upstream.HttpDataSource;
import com.google.android.exoplayer2.upstream.RtpDataSource;
import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.util.rtp.RtpExtractorsFactory;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.net.CookieHandler;
Expand All @@ -93,6 +96,10 @@ public class PlayerActivity extends Activity implements OnClickListener, EventLi

public static final String ACTION_VIEW = "com.google.android.exoplayer.demo.action.VIEW";
public static final String EXTENSION_EXTRA = "extension";
public static final String VENDOR_EXTRA = "vendor";
public static final String FEEDBACK_EVENTS_EXTRA = "feedback_events";
public static final String BURST_URI_EXTRA = "burst_uri";
public static final String RETRANSMISSION_URI_EXTRA = "retransmission_uri";

public static final String ACTION_VIEW_LIST =
"com.google.android.exoplayer.demo.action.VIEW_LIST";
Expand Down Expand Up @@ -329,8 +336,13 @@ private void initializePlayer() {
}
MediaSource[] mediaSources = new MediaSource[uris.length];
for (int i = 0; i < uris.length; i++) {
mediaSources[i] = buildMediaSource(uris[i], extensions[i]);
mediaSources[i] = buildMediaSource(uris[i], extensions[i],
intent.getStringExtra(VENDOR_EXTRA),
intent.getBooleanExtra(FEEDBACK_EVENTS_EXTRA, false),
intent.getStringExtra(BURST_URI_EXTRA),
intent.getStringExtra(RETRANSMISSION_URI_EXTRA));
}

MediaSource mediaSource = mediaSources.length == 1 ? mediaSources[0]
: new ConcatenatingMediaSource(mediaSources);
String adTagUriString = intent.getStringExtra(AD_TAG_URI_EXTRA);
Expand All @@ -357,7 +369,9 @@ private void initializePlayer() {
updateButtonVisibilities();
}

private MediaSource buildMediaSource(Uri uri, String overrideExtension) {
private MediaSource buildMediaSource(Uri uri, String overrideExtension, String vendor,
boolean feedback_events, String burst_uri,
String retransmission_uri) {
int type = TextUtils.isEmpty(overrideExtension) ? Util.inferContentType(uri)
: Util.inferContentType("." + overrideExtension);
switch (type) {
Expand All @@ -370,6 +384,13 @@ private MediaSource buildMediaSource(Uri uri, String overrideExtension) {
case C.TYPE_HLS:
return new HlsMediaSource(uri, mediaDataSourceFactory, mainHandler, eventLogger);
case C.TYPE_OTHER:
if (uri.getScheme().equals("rtp")) {
return new ExtractorMediaSource(uri, buildRtpDataSourceFactory(true, vendor,
feedback_events, burst_uri,retransmission_uri), new RtpExtractorsFactory(),
mainHandler, eventLogger);

}

return new ExtractorMediaSource(uri, mediaDataSourceFactory, new DefaultExtractorsFactory(),
mainHandler, eventLogger);
default: {
Expand Down Expand Up @@ -440,6 +461,22 @@ private HttpDataSource.Factory buildHttpDataSourceFactory(boolean useBandwidthMe
.buildHttpDataSourceFactory(useBandwidthMeter ? BANDWIDTH_METER : null);
}

/**
+ * Returns a new RtpDataSource factory.
+ *
+ * @param useBandwidthMeter Whether to set {@link #BANDWIDTH_METER} as a listener to the new
+ * DataSource factory.
+ * @param vendor RTP distribution and feedback vendor architecture identifier.
+ * @return A new RtpDataSource factory.
+ */
private RtpDataSource.Factory buildRtpDataSourceFactory(boolean useBandwidthMeter, String vendor,
boolean feedback_events, String burst_uri,
String retransmission_uri) {
return ((DemoApplication) getApplication())
.buildRtpDataSourceFactory(useBandwidthMeter ? BANDWIDTH_METER : null, vendor,
feedback_events, burst_uri, retransmission_uri);
}

/**
* Returns an ads media source, reusing the ads loader if one exists.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ private void readSampleGroup(JsonReader reader, List<SampleGroup> groups) throws
private Sample readEntry(JsonReader reader, boolean insidePlaylist) throws IOException {
String sampleName = null;
String uri = null;
String vendor = null;
boolean feedback_events = false;
String burst_uri = null;
String retransmission_uri = null;
String extension = null;
UUID drmUuid = null;
String drmLicenseUrl = null;
Expand All @@ -196,6 +200,18 @@ private Sample readEntry(JsonReader reader, boolean insidePlaylist) throws IOExc
case "uri":
uri = reader.nextString();
break;
case "vendor":
vendor = reader.nextString();
break;
case "feedback_events":
feedback_events = "yes".equalsIgnoreCase(reader.nextString()) ? true : false;
break;
case "burst_uri":
burst_uri = reader.nextString();
break;
case "retransmission_uri":
retransmission_uri = reader.nextString();
break;
case "extension":
extension = reader.nextString();
break;
Expand Down Expand Up @@ -250,7 +266,8 @@ private Sample readEntry(JsonReader reader, boolean insidePlaylist) throws IOExc
preferExtensionDecoders, playlistSamplesArray);
} else {
return new UriSample(sampleName, drmUuid, drmLicenseUrl, drmKeyRequestProperties,
preferExtensionDecoders, uri, extension, adTagUri);
preferExtensionDecoders, uri, vendor, feedback_events, burst_uri, retransmission_uri,
extension, adTagUri);
}
}

Expand Down Expand Up @@ -405,14 +422,23 @@ public Intent buildIntent(Context context) {
private static final class UriSample extends Sample {

public final String uri;
public final String vendor;
public final boolean feedback_events;
public final String burst_uri;
public final String retransmission_uri;
public final String extension;
public final String adTagUri;

public UriSample(String name, UUID drmSchemeUuid, String drmLicenseUrl,
String[] drmKeyRequestProperties, boolean preferExtensionDecoders, String uri,
String extension, String adTagUri) {
String vendor, boolean feedback_events, String burst_uri, String retransmission_uri,
String extension, String adTagUri) {
super(name, drmSchemeUuid, drmLicenseUrl, drmKeyRequestProperties, preferExtensionDecoders);
this.uri = uri;
this.vendor = vendor;
this.feedback_events =feedback_events;
this.burst_uri = burst_uri;
this.retransmission_uri = retransmission_uri;
this.extension = extension;
this.adTagUri = adTagUri;
}
Expand All @@ -421,6 +447,10 @@ public UriSample(String name, UUID drmSchemeUuid, String drmLicenseUrl,
public Intent buildIntent(Context context) {
return super.buildIntent(context)
.setData(Uri.parse(uri))
.putExtra(PlayerActivity.VENDOR_EXTRA, vendor)
.putExtra(PlayerActivity.FEEDBACK_EVENTS_EXTRA, feedback_events)
.putExtra(PlayerActivity.BURST_URI_EXTRA, burst_uri)
.putExtra(PlayerActivity.RETRANSMISSION_URI_EXTRA, retransmission_uri)
.putExtra(PlayerActivity.EXTENSION_EXTRA, extension)
.putExtra(PlayerActivity.AD_TAG_URI_EXTRA, adTagUri)
.setAction(PlayerActivity.ACTION_VIEW);
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
limitations under the License.
-->

<manifest package="com.google.android.exoplayer2.core"/>
<manifest package="com.google.android.exoplayer2.core"/>
Loading