Commit 099bbe04 by Oliver Woodman

Correctly handle audio and video only DASH streams.

parent 3e33fddb
...@@ -119,11 +119,27 @@ public class DashRendererBuilder implements RendererBuilder, ...@@ -119,11 +119,27 @@ public class DashRendererBuilder implements RendererBuilder,
LoadControl loadControl = new DefaultLoadControl(new BufferPool(BUFFER_SEGMENT_SIZE)); LoadControl loadControl = new DefaultLoadControl(new BufferPool(BUFFER_SEGMENT_SIZE));
DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(mainHandler, player); DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(mainHandler, player);
boolean hasContentProtection = false;
int videoAdaptationSetIndex = period.getAdaptationSetIndex(AdaptationSet.TYPE_VIDEO); int videoAdaptationSetIndex = period.getAdaptationSetIndex(AdaptationSet.TYPE_VIDEO);
AdaptationSet videoAdaptationSet = period.adaptationSets.get(videoAdaptationSetIndex); int audioAdaptationSetIndex = period.getAdaptationSetIndex(AdaptationSet.TYPE_AUDIO);
AdaptationSet videoAdaptationSet = null;
AdaptationSet audioAdaptationSet = null;
if (videoAdaptationSetIndex != -1) {
videoAdaptationSet = period.adaptationSets.get(videoAdaptationSetIndex);
hasContentProtection |= videoAdaptationSet.hasContentProtection();
}
if (audioAdaptationSetIndex != -1) {
audioAdaptationSet = period.adaptationSets.get(audioAdaptationSetIndex);
hasContentProtection |= audioAdaptationSet.hasContentProtection();
}
// Fail if we have neither video or audio.
if (videoAdaptationSet == null && audioAdaptationSet == null) {
callback.onRenderersError(new IllegalStateException("No video or audio adaptation sets"));
return;
}
// Check drm support if necessary. // Check drm support if necessary.
boolean hasContentProtection = videoAdaptationSet.hasContentProtection();
boolean filterHdContent = false; boolean filterHdContent = false;
DrmSessionManager drmSessionManager = null; DrmSessionManager drmSessionManager = null;
if (hasContentProtection) { if (hasContentProtection) {
...@@ -137,7 +153,8 @@ public class DashRendererBuilder implements RendererBuilder, ...@@ -137,7 +153,8 @@ public class DashRendererBuilder implements RendererBuilder,
V18Compat.getDrmSessionManagerData(player, drmCallback); V18Compat.getDrmSessionManagerData(player, drmCallback);
drmSessionManager = drmSessionManagerData.first; drmSessionManager = drmSessionManagerData.first;
// HD streams require L1 security. // HD streams require L1 security.
filterHdContent = !drmSessionManagerData.second; filterHdContent = videoAdaptationSet != null && videoAdaptationSet.hasContentProtection()
&& !drmSessionManagerData.second;
} catch (Exception e) { } catch (Exception e) {
callback.onRenderersError(e); callback.onRenderersError(e);
return; return;
...@@ -145,9 +162,10 @@ public class DashRendererBuilder implements RendererBuilder, ...@@ -145,9 +162,10 @@ public class DashRendererBuilder implements RendererBuilder,
} }
// Determine which video representations we should use for playback. // Determine which video representations we should use for playback.
ArrayList<Integer> videoRepresentationIndexList = new ArrayList<Integer>();
if (videoAdaptationSet != null) {
int maxDecodableFrameSize = MediaCodecUtil.maxH264DecodableFrameSize(); int maxDecodableFrameSize = MediaCodecUtil.maxH264DecodableFrameSize();
List<Representation> videoRepresentations = videoAdaptationSet.representations; List<Representation> videoRepresentations = videoAdaptationSet.representations;
ArrayList<Integer> videoRepresentationIndexList = new ArrayList<Integer>();
for (int i = 0; i < videoRepresentations.size(); i++) { for (int i = 0; i < videoRepresentations.size(); i++) {
Format format = videoRepresentations.get(i).format; Format format = videoRepresentations.get(i).format;
if (filterHdContent && (format.width >= 1280 || format.height >= 720)) { if (filterHdContent && (format.width >= 1280 || format.height >= 720)) {
...@@ -161,6 +179,7 @@ public class DashRendererBuilder implements RendererBuilder, ...@@ -161,6 +179,7 @@ public class DashRendererBuilder implements RendererBuilder,
videoRepresentationIndexList.add(i); videoRepresentationIndexList.add(i);
} }
} }
}
// Build the video renderer. // Build the video renderer.
final MediaCodecVideoTrackRenderer videoRenderer; final MediaCodecVideoTrackRenderer videoRenderer;
...@@ -184,12 +203,11 @@ public class DashRendererBuilder implements RendererBuilder, ...@@ -184,12 +203,11 @@ public class DashRendererBuilder implements RendererBuilder,
} }
// Build the audio chunk sources. // Build the audio chunk sources.
int audioAdaptationSetIndex = period.getAdaptationSetIndex(AdaptationSet.TYPE_AUDIO);
AdaptationSet audioAdaptationSet = period.adaptationSets.get(audioAdaptationSetIndex);
DataSource audioDataSource = new UriDataSource(userAgent, bandwidthMeter);
FormatEvaluator audioEvaluator = new FormatEvaluator.FixedEvaluator();
List<ChunkSource> audioChunkSourceList = new ArrayList<ChunkSource>(); List<ChunkSource> audioChunkSourceList = new ArrayList<ChunkSource>();
List<String> audioTrackNameList = new ArrayList<String>(); List<String> audioTrackNameList = new ArrayList<String>();
if (audioAdaptationSet != null) {
DataSource audioDataSource = new UriDataSource(userAgent, bandwidthMeter);
FormatEvaluator audioEvaluator = new FormatEvaluator.FixedEvaluator();
List<Representation> audioRepresentations = audioAdaptationSet.representations; List<Representation> audioRepresentations = audioAdaptationSet.representations;
for (int i = 0; i < audioRepresentations.size(); i++) { for (int i = 0; i < audioRepresentations.size(); i++) {
Format format = audioRepresentations.get(i).format; Format format = audioRepresentations.get(i).format;
...@@ -198,6 +216,7 @@ public class DashRendererBuilder implements RendererBuilder, ...@@ -198,6 +216,7 @@ public class DashRendererBuilder implements RendererBuilder,
audioChunkSourceList.add(new DashChunkSource(manifestFetcher, audioAdaptationSetIndex, audioChunkSourceList.add(new DashChunkSource(manifestFetcher, audioAdaptationSetIndex,
new int[] {i}, audioDataSource, audioEvaluator, LIVE_EDGE_LATENCY_MS)); new int[] {i}, audioDataSource, audioEvaluator, LIVE_EDGE_LATENCY_MS));
} }
}
// Build the audio renderer. // Build the audio renderer.
final String[] audioTrackNames; final String[] audioTrackNames;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment