Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
099bbe04
authored
Dec 12, 2014
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Correctly handle audio and video only DASH streams.
parent
3e33fddb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
27 deletions
demo/src/main/java/com/google/android/exoplayer/demo/full/player/DashRendererBuilder.java
demo/src/main/java/com/google/android/exoplayer/demo/full/player/DashRendererBuilder.java
View file @
099bbe04
...
@@ -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,20 +162,22 @@ public class DashRendererBuilder implements RendererBuilder,
...
@@ -145,20 +162,22 @@ public class DashRendererBuilder implements RendererBuilder,
}
}
// Determine which video representations we should use for playback.
// Determine which video representations we should use for playback.
int
maxDecodableFrameSize
=
MediaCodecUtil
.
maxH264DecodableFrameSize
();
List
<
Representation
>
videoRepresentations
=
videoAdaptationSet
.
representations
;
ArrayList
<
Integer
>
videoRepresentationIndexList
=
new
ArrayList
<
Integer
>();
ArrayList
<
Integer
>
videoRepresentationIndexList
=
new
ArrayList
<
Integer
>();
for
(
int
i
=
0
;
i
<
videoRepresentations
.
size
();
i
++)
{
if
(
videoAdaptationSet
!=
null
)
{
Format
format
=
videoRepresentations
.
get
(
i
).
format
;
int
maxDecodableFrameSize
=
MediaCodecUtil
.
maxH264DecodableFrameSize
();
if
(
filterHdContent
&&
(
format
.
width
>=
1280
||
format
.
height
>=
720
))
{
List
<
Representation
>
videoRepresentations
=
videoAdaptationSet
.
representations
;
// Filtering HD content
for
(
int
i
=
0
;
i
<
videoRepresentations
.
size
();
i
++)
{
}
else
if
(
format
.
width
*
format
.
height
>
maxDecodableFrameSize
)
{
Format
format
=
videoRepresentations
.
get
(
i
).
format
;
// Filtering stream that device cannot play
if
(
filterHdContent
&&
(
format
.
width
>=
1280
||
format
.
height
>=
720
))
{
}
else
if
(!
format
.
mimeType
.
equals
(
MimeTypes
.
VIDEO_MP4
)
// Filtering HD content
&&
!
format
.
mimeType
.
equals
(
MimeTypes
.
VIDEO_WEBM
))
{
}
else
if
(
format
.
width
*
format
.
height
>
maxDecodableFrameSize
)
{
// Filtering unsupported mime type
// Filtering stream that device cannot play
}
else
{
}
else
if
(!
format
.
mimeType
.
equals
(
MimeTypes
.
VIDEO_MP4
)
videoRepresentationIndexList
.
add
(
i
);
&&
!
format
.
mimeType
.
equals
(
MimeTypes
.
VIDEO_WEBM
))
{
// Filtering unsupported mime type
}
else
{
videoRepresentationIndexList
.
add
(
i
);
}
}
}
}
}
...
@@ -184,19 +203,19 @@ public class DashRendererBuilder implements RendererBuilder,
...
@@ -184,19 +203,19 @@ 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
>();
List
<
Representation
>
audioRepresentations
=
audioAdaptationSet
.
representations
;
if
(
audioAdaptationSet
!=
null
)
{
for
(
int
i
=
0
;
i
<
audioRepresentations
.
size
();
i
++)
{
DataSource
audioDataSource
=
new
UriDataSource
(
userAgent
,
bandwidthMeter
);
Format
format
=
audioRepresentations
.
get
(
i
).
format
;
FormatEvaluator
audioEvaluator
=
new
FormatEvaluator
.
FixedEvaluator
();
audioTrackNameList
.
add
(
format
.
id
+
" ("
+
format
.
numChannels
+
"ch, "
+
List
<
Representation
>
audioRepresentations
=
audioAdaptationSet
.
representations
;
format
.
audioSamplingRate
+
"Hz)"
);
for
(
int
i
=
0
;
i
<
audioRepresentations
.
size
();
i
++)
{
audioChunkSourceList
.
add
(
new
DashChunkSource
(
manifestFetcher
,
audioAdaptationSetIndex
,
Format
format
=
audioRepresentations
.
get
(
i
).
format
;
new
int
[]
{
i
},
audioDataSource
,
audioEvaluator
,
LIVE_EDGE_LATENCY_MS
));
audioTrackNameList
.
add
(
format
.
id
+
" ("
+
format
.
numChannels
+
"ch, "
+
format
.
audioSamplingRate
+
"Hz)"
);
audioChunkSourceList
.
add
(
new
DashChunkSource
(
manifestFetcher
,
audioAdaptationSetIndex
,
new
int
[]
{
i
},
audioDataSource
,
audioEvaluator
,
LIVE_EDGE_LATENCY_MS
));
}
}
}
// Build the audio renderer.
// Build the audio renderer.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment