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
87138cee
authored
Sep 26, 2019
by
ibaker
Committed by
Oliver Woodman
Oct 13, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Reshuffle {audio,video}SampleQueue{Index,MappingDone} into fields mapped by type
PiperOrigin-RevId: 271364200
parent
ad59304f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
37 deletions
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsSampleStreamWrapper.java
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsSampleStreamWrapper.java
View file @
87138cee
...
@@ -17,6 +17,7 @@ package com.google.android.exoplayer2.source.hls;
...
@@ -17,6 +17,7 @@ package com.google.android.exoplayer2.source.hls;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.os.Handler
;
import
android.os.Handler
;
import
android.util.SparseIntArray
;
import
androidx.annotation.Nullable
;
import
androidx.annotation.Nullable
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.Format
;
...
@@ -87,6 +88,10 @@ import java.util.Map;
...
@@ -87,6 +88,10 @@ import java.util.Map;
public
static
final
int
SAMPLE_QUEUE_INDEX_NO_MAPPING_FATAL
=
-
2
;
public
static
final
int
SAMPLE_QUEUE_INDEX_NO_MAPPING_FATAL
=
-
2
;
public
static
final
int
SAMPLE_QUEUE_INDEX_NO_MAPPING_NON_FATAL
=
-
3
;
public
static
final
int
SAMPLE_QUEUE_INDEX_NO_MAPPING_NON_FATAL
=
-
3
;
private
static
final
Set
<
Integer
>
MAPPABLE_TYPES
=
Collections
.
unmodifiableSet
(
new
HashSet
<>(
Arrays
.
asList
(
C
.
TRACK_TYPE_AUDIO
,
C
.
TRACK_TYPE_VIDEO
)));
private
final
int
trackType
;
private
final
int
trackType
;
private
final
Callback
callback
;
private
final
Callback
callback
;
private
final
HlsChunkSource
chunkSource
;
private
final
HlsChunkSource
chunkSource
;
...
@@ -106,10 +111,8 @@ import java.util.Map;
...
@@ -106,10 +111,8 @@ import java.util.Map;
private
SampleQueue
[]
sampleQueues
;
private
SampleQueue
[]
sampleQueues
;
private
int
[]
sampleQueueTrackIds
;
private
int
[]
sampleQueueTrackIds
;
private
boolean
audioSampleQueueMappingDone
;
private
Set
<
Integer
>
sampleQueueMappingDoneByType
;
private
int
audioSampleQueueIndex
;
private
SparseIntArray
sampleQueueIndicesByType
;
private
boolean
videoSampleQueueMappingDone
;
private
int
videoSampleQueueIndex
;
private
int
primarySampleQueueType
;
private
int
primarySampleQueueType
;
private
int
primarySampleQueueIndex
;
private
int
primarySampleQueueIndex
;
private
boolean
sampleQueuesBuilt
;
private
boolean
sampleQueuesBuilt
;
...
@@ -176,8 +179,8 @@ import java.util.Map;
...
@@ -176,8 +179,8 @@ import java.util.Map;
loader
=
new
Loader
(
"Loader:HlsSampleStreamWrapper"
);
loader
=
new
Loader
(
"Loader:HlsSampleStreamWrapper"
);
nextChunkHolder
=
new
HlsChunkSource
.
HlsChunkHolder
();
nextChunkHolder
=
new
HlsChunkSource
.
HlsChunkHolder
();
sampleQueueTrackIds
=
new
int
[
0
];
sampleQueueTrackIds
=
new
int
[
0
];
audioSampleQueueIndex
=
C
.
INDEX_UNSET
;
sampleQueueMappingDoneByType
=
new
HashSet
<>(
MAPPABLE_TYPES
.
size
())
;
videoSampleQueueIndex
=
C
.
INDEX_UNSET
;
sampleQueueIndicesByType
=
new
SparseIntArray
(
MAPPABLE_TYPES
.
size
())
;
sampleQueues
=
new
SampleQueue
[
0
];
sampleQueues
=
new
SampleQueue
[
0
];
sampleQueueIsAudioVideoFlags
=
new
boolean
[
0
];
sampleQueueIsAudioVideoFlags
=
new
boolean
[
0
];
sampleQueuesEnabledStates
=
new
boolean
[
0
];
sampleQueuesEnabledStates
=
new
boolean
[
0
];
...
@@ -766,8 +769,7 @@ import java.util.Map;
...
@@ -766,8 +769,7 @@ import java.util.Map;
*/
*/
public
void
init
(
int
chunkUid
,
boolean
shouldSpliceIn
,
boolean
reusingExtractor
)
{
public
void
init
(
int
chunkUid
,
boolean
shouldSpliceIn
,
boolean
reusingExtractor
)
{
if
(!
reusingExtractor
)
{
if
(!
reusingExtractor
)
{
audioSampleQueueMappingDone
=
false
;
sampleQueueMappingDoneByType
.
clear
();
videoSampleQueueMappingDone
=
false
;
}
}
this
.
chunkUid
=
chunkUid
;
this
.
chunkUid
=
chunkUid
;
for
(
SampleQueue
sampleQueue
:
sampleQueues
)
{
for
(
SampleQueue
sampleQueue
:
sampleQueues
)
{
...
@@ -786,30 +788,19 @@ import java.util.Map;
...
@@ -786,30 +788,19 @@ import java.util.Map;
public
TrackOutput
track
(
int
id
,
int
type
)
{
public
TrackOutput
track
(
int
id
,
int
type
)
{
int
trackCount
=
sampleQueues
.
length
;
int
trackCount
=
sampleQueues
.
length
;
// Audio and video tracks are handled manually to ignore ids.
if
(
MAPPABLE_TYPES
.
contains
(
type
))
{
if
(
type
==
C
.
TRACK_TYPE_AUDIO
)
{
// Track types in MAPPABLE_TYPES are handled manually to ignore IDs.
if
(
audioSampleQueueIndex
!=
C
.
INDEX_UNSET
)
{
int
sampleQueueIndex
=
sampleQueueIndicesByType
.
get
(
type
,
C
.
INDEX_UNSET
);
if
(
audioSampleQueueMappingDone
)
{
if
(
sampleQueueIndex
!=
C
.
INDEX_UNSET
)
{
return
sampleQueueTrackIds
[
audioSampleQueueIndex
]
==
id
if
(
sampleQueueMappingDoneByType
.
contains
(
type
))
{
?
sampleQueues
[
audioSampleQueueIndex
]
return
sampleQueueTrackIds
[
sampleQueueIndex
]
==
id
:
createDummyTrackOutput
(
id
,
type
);
?
sampleQueues
[
sampleQueueIndex
]
}
audioSampleQueueMappingDone
=
true
;
sampleQueueTrackIds
[
audioSampleQueueIndex
]
=
id
;
return
sampleQueues
[
audioSampleQueueIndex
];
}
else
if
(
tracksEnded
)
{
return
createDummyTrackOutput
(
id
,
type
);
}
}
else
if
(
type
==
C
.
TRACK_TYPE_VIDEO
)
{
if
(
videoSampleQueueIndex
!=
C
.
INDEX_UNSET
)
{
if
(
videoSampleQueueMappingDone
)
{
return
sampleQueueTrackIds
[
videoSampleQueueIndex
]
==
id
?
sampleQueues
[
videoSampleQueueIndex
]
:
createDummyTrackOutput
(
id
,
type
);
:
createDummyTrackOutput
(
id
,
type
);
}
else
{
sampleQueueMappingDoneByType
.
add
(
type
);
sampleQueueTrackIds
[
sampleQueueIndex
]
=
id
;
return
sampleQueues
[
sampleQueueIndex
];
}
}
videoSampleQueueMappingDone
=
true
;
sampleQueueTrackIds
[
videoSampleQueueIndex
]
=
id
;
return
sampleQueues
[
videoSampleQueueIndex
];
}
else
if
(
tracksEnded
)
{
}
else
if
(
tracksEnded
)
{
return
createDummyTrackOutput
(
id
,
type
);
return
createDummyTrackOutput
(
id
,
type
);
}
}
...
@@ -835,13 +826,8 @@ import java.util.Map;
...
@@ -835,13 +826,8 @@ import java.util.Map;
sampleQueueIsAudioVideoFlags
[
trackCount
]
=
type
==
C
.
TRACK_TYPE_AUDIO
sampleQueueIsAudioVideoFlags
[
trackCount
]
=
type
==
C
.
TRACK_TYPE_AUDIO
||
type
==
C
.
TRACK_TYPE_VIDEO
;
||
type
==
C
.
TRACK_TYPE_VIDEO
;
haveAudioVideoSampleQueues
|=
sampleQueueIsAudioVideoFlags
[
trackCount
];
haveAudioVideoSampleQueues
|=
sampleQueueIsAudioVideoFlags
[
trackCount
];
if
(
type
==
C
.
TRACK_TYPE_AUDIO
)
{
sampleQueueMappingDoneByType
.
add
(
type
);
audioSampleQueueMappingDone
=
true
;
sampleQueueIndicesByType
.
append
(
type
,
trackCount
);
audioSampleQueueIndex
=
trackCount
;
}
else
if
(
type
==
C
.
TRACK_TYPE_VIDEO
)
{
videoSampleQueueMappingDone
=
true
;
videoSampleQueueIndex
=
trackCount
;
}
if
(
getTrackTypeScore
(
type
)
>
getTrackTypeScore
(
primarySampleQueueType
))
{
if
(
getTrackTypeScore
(
type
)
>
getTrackTypeScore
(
primarySampleQueueType
))
{
primarySampleQueueIndex
=
trackCount
;
primarySampleQueueIndex
=
trackCount
;
primarySampleQueueType
=
type
;
primarySampleQueueType
=
type
;
...
...
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