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
f946ade1
authored
Nov 18, 2021
by
tonihei
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Set LogSessionId on MediaParser for progressive playbacks.
PiperOrigin-RevId: 410766492
parent
f6f03866
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
7 deletions
library/core/src/main/java/com/google/android/exoplayer2/source/MediaParserExtractorAdapter.java
library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaExtractor.java
library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaSource.java
library/core/src/main/java/com/google/android/exoplayer2/source/mediaparser/MediaParserUtil.java
library/core/src/test/java/com/google/android/exoplayer2/source/ProgressiveMediaPeriodTest.java
library/core/src/main/java/com/google/android/exoplayer2/source/MediaParserExtractorAdapter.java
View file @
f946ade1
...
@@ -26,12 +26,15 @@ import android.net.Uri;
...
@@ -26,12 +26,15 @@ import android.net.Uri;
import
android.util.Pair
;
import
android.util.Pair
;
import
androidx.annotation.RequiresApi
;
import
androidx.annotation.RequiresApi
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.analytics.PlayerId
;
import
com.google.android.exoplayer2.extractor.Extractor
;
import
com.google.android.exoplayer2.extractor.Extractor
;
import
com.google.android.exoplayer2.extractor.ExtractorOutput
;
import
com.google.android.exoplayer2.extractor.ExtractorOutput
;
import
com.google.android.exoplayer2.extractor.PositionHolder
;
import
com.google.android.exoplayer2.extractor.PositionHolder
;
import
com.google.android.exoplayer2.source.mediaparser.InputReaderAdapterV30
;
import
com.google.android.exoplayer2.source.mediaparser.InputReaderAdapterV30
;
import
com.google.android.exoplayer2.source.mediaparser.MediaParserUtil
;
import
com.google.android.exoplayer2.source.mediaparser.OutputConsumerAdapterV30
;
import
com.google.android.exoplayer2.source.mediaparser.OutputConsumerAdapterV30
;
import
com.google.android.exoplayer2.upstream.DataReader
;
import
com.google.android.exoplayer2.upstream.DataReader
;
import
com.google.android.exoplayer2.util.Util
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -52,7 +55,7 @@ public final class MediaParserExtractorAdapter implements ProgressiveMediaExtrac
...
@@ -52,7 +55,7 @@ public final class MediaParserExtractorAdapter implements ProgressiveMediaExtrac
private
String
parserName
;
private
String
parserName
;
@SuppressLint
(
"WrongConstant"
)
@SuppressLint
(
"WrongConstant"
)
public
MediaParserExtractorAdapter
()
{
public
MediaParserExtractorAdapter
(
PlayerId
playerId
)
{
// TODO: Add support for injecting the desired extractor list.
// TODO: Add support for injecting the desired extractor list.
outputConsumerAdapter
=
new
OutputConsumerAdapterV30
();
outputConsumerAdapter
=
new
OutputConsumerAdapterV30
();
inputReaderAdapter
=
new
InputReaderAdapterV30
();
inputReaderAdapter
=
new
InputReaderAdapterV30
();
...
@@ -61,6 +64,9 @@ public final class MediaParserExtractorAdapter implements ProgressiveMediaExtrac
...
@@ -61,6 +64,9 @@ public final class MediaParserExtractorAdapter implements ProgressiveMediaExtrac
mediaParser
.
setParameter
(
PARAMETER_IN_BAND_CRYPTO_INFO
,
true
);
mediaParser
.
setParameter
(
PARAMETER_IN_BAND_CRYPTO_INFO
,
true
);
mediaParser
.
setParameter
(
PARAMETER_INCLUDE_SUPPLEMENTAL_DATA
,
true
);
mediaParser
.
setParameter
(
PARAMETER_INCLUDE_SUPPLEMENTAL_DATA
,
true
);
parserName
=
MediaParser
.
PARSER_NAME_UNKNOWN
;
parserName
=
MediaParser
.
PARSER_NAME_UNKNOWN
;
if
(
Util
.
SDK_INT
>=
31
)
{
MediaParserUtil
.
setLogSessionIdOnMediaParser
(
mediaParser
,
playerId
);
}
}
}
@Override
@Override
...
...
library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaExtractor.java
View file @
f946ade1
...
@@ -17,6 +17,7 @@ package com.google.android.exoplayer2.source;
...
@@ -17,6 +17,7 @@ package com.google.android.exoplayer2.source;
import
android.net.Uri
;
import
android.net.Uri
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.analytics.PlayerId
;
import
com.google.android.exoplayer2.extractor.Extractor
;
import
com.google.android.exoplayer2.extractor.Extractor
;
import
com.google.android.exoplayer2.extractor.ExtractorOutput
;
import
com.google.android.exoplayer2.extractor.ExtractorOutput
;
import
com.google.android.exoplayer2.extractor.PositionHolder
;
import
com.google.android.exoplayer2.extractor.PositionHolder
;
...
@@ -31,8 +32,12 @@ public interface ProgressiveMediaExtractor {
...
@@ -31,8 +32,12 @@ public interface ProgressiveMediaExtractor {
/** Creates {@link ProgressiveMediaExtractor} instances. */
/** Creates {@link ProgressiveMediaExtractor} instances. */
interface
Factory
{
interface
Factory
{
/** Returns a new {@link ProgressiveMediaExtractor} instance. */
/**
ProgressiveMediaExtractor
createProgressiveMediaExtractor
();
* Returns a new {@link ProgressiveMediaExtractor} instance.
*
* @param playerId The {@link PlayerId} of the player this extractor is used for.
*/
ProgressiveMediaExtractor
createProgressiveMediaExtractor
(
PlayerId
playerId
);
}
}
/**
/**
...
...
library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaSource.java
View file @
f946ade1
...
@@ -77,7 +77,7 @@ public final class ProgressiveMediaSource extends BaseMediaSource
...
@@ -77,7 +77,7 @@ public final class ProgressiveMediaSource extends BaseMediaSource
* Factory(dataSourceFactory, () -> new BundledExtractorsAdapter(extractorsFactory)}.
* Factory(dataSourceFactory, () -> new BundledExtractorsAdapter(extractorsFactory)}.
*/
*/
public
Factory
(
DataSource
.
Factory
dataSourceFactory
,
ExtractorsFactory
extractorsFactory
)
{
public
Factory
(
DataSource
.
Factory
dataSourceFactory
,
ExtractorsFactory
extractorsFactory
)
{
this
(
dataSourceFactory
,
()
->
new
BundledExtractorsAdapter
(
extractorsFactory
));
this
(
dataSourceFactory
,
playerId
->
new
BundledExtractorsAdapter
(
extractorsFactory
));
}
}
/**
/**
...
@@ -105,7 +105,7 @@ public final class ProgressiveMediaSource extends BaseMediaSource
...
@@ -105,7 +105,7 @@ public final class ProgressiveMediaSource extends BaseMediaSource
@Deprecated
@Deprecated
public
Factory
setExtractorsFactory
(
@Nullable
ExtractorsFactory
extractorsFactory
)
{
public
Factory
setExtractorsFactory
(
@Nullable
ExtractorsFactory
extractorsFactory
)
{
this
.
progressiveMediaExtractorFactory
=
this
.
progressiveMediaExtractorFactory
=
()
->
playerId
->
new
BundledExtractorsAdapter
(
new
BundledExtractorsAdapter
(
extractorsFactory
!=
null
?
extractorsFactory
:
new
DefaultExtractorsFactory
());
extractorsFactory
!=
null
?
extractorsFactory
:
new
DefaultExtractorsFactory
());
return
this
;
return
this
;
...
@@ -313,7 +313,7 @@ public final class ProgressiveMediaSource extends BaseMediaSource
...
@@ -313,7 +313,7 @@ public final class ProgressiveMediaSource extends BaseMediaSource
return
new
ProgressiveMediaPeriod
(
return
new
ProgressiveMediaPeriod
(
localConfiguration
.
uri
,
localConfiguration
.
uri
,
dataSource
,
dataSource
,
progressiveMediaExtractorFactory
.
createProgressiveMediaExtractor
(),
progressiveMediaExtractorFactory
.
createProgressiveMediaExtractor
(
getPlayerId
()
),
drmSessionManager
,
drmSessionManager
,
createDrmEventDispatcher
(
id
),
createDrmEventDispatcher
(
id
),
loadableLoadErrorHandlingPolicy
,
loadableLoadErrorHandlingPolicy
,
...
...
library/core/src/main/java/com/google/android/exoplayer2/source/mediaparser/MediaParserUtil.java
View file @
f946ade1
...
@@ -17,7 +17,10 @@ package com.google.android.exoplayer2.source.mediaparser;
...
@@ -17,7 +17,10 @@ package com.google.android.exoplayer2.source.mediaparser;
import
android.media.MediaFormat
;
import
android.media.MediaFormat
;
import
android.media.MediaParser
;
import
android.media.MediaParser
;
import
android.media.metrics.LogSessionId
;
import
androidx.annotation.RequiresApi
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.analytics.PlayerId
;
/**
/**
* Miscellaneous constants and utility methods related to the {@link MediaParser} integration.
* Miscellaneous constants and utility methods related to the {@link MediaParser} integration.
...
@@ -57,4 +60,27 @@ public final class MediaParserUtil {
...
@@ -57,4 +60,27 @@ public final class MediaParserUtil {
}
}
return
mediaFormat
;
return
mediaFormat
;
}
}
/**
* Calls {@link MediaParser#setLogSessionId(LogSessionId)}.
*
* @param mediaParser The {@link MediaParser} to call the method on.
* @param playerId The {@link PlayerId} to obtain the {@link LogSessionId} from.
*/
@RequiresApi
(
31
)
public
static
void
setLogSessionIdOnMediaParser
(
MediaParser
mediaParser
,
PlayerId
playerId
)
{
Api31
.
setLogSessionIdOnMediaParser
(
mediaParser
,
playerId
);
}
@RequiresApi
(
31
)
private
static
final
class
Api31
{
private
Api31
()
{}
public
static
void
setLogSessionIdOnMediaParser
(
MediaParser
mediaParser
,
PlayerId
playerId
)
{
LogSessionId
logSessionId
=
playerId
.
getLogSessionId
();
if
(!
logSessionId
.
equals
(
LogSessionId
.
LOG_SESSION_ID_NONE
))
{
mediaParser
.
setLogSessionId
(
logSessionId
);
}
}
}
}
}
library/core/src/test/java/com/google/android/exoplayer2/source/ProgressiveMediaPeriodTest.java
View file @
f946ade1
...
@@ -22,6 +22,7 @@ import android.net.Uri;
...
@@ -22,6 +22,7 @@ import android.net.Uri;
import
androidx.test.core.app.ApplicationProvider
;
import
androidx.test.core.app.ApplicationProvider
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.analytics.PlayerId
;
import
com.google.android.exoplayer2.drm.DrmSessionEventListener
;
import
com.google.android.exoplayer2.drm.DrmSessionEventListener
;
import
com.google.android.exoplayer2.drm.DrmSessionManager
;
import
com.google.android.exoplayer2.drm.DrmSessionManager
;
import
com.google.android.exoplayer2.extractor.mp4.Mp4Extractor
;
import
com.google.android.exoplayer2.extractor.mp4.Mp4Extractor
;
...
@@ -48,7 +49,8 @@ public final class ProgressiveMediaPeriodTest {
...
@@ -48,7 +49,8 @@ public final class ProgressiveMediaPeriodTest {
@Test
@Test
public
void
prepareUsingMediaParser_updatesSourceInfoBeforeOnPreparedCallback
()
public
void
prepareUsingMediaParser_updatesSourceInfoBeforeOnPreparedCallback
()
throws
TimeoutException
{
throws
TimeoutException
{
testExtractorsUpdatesSourceInfoBeforeOnPreparedCallback
(
new
MediaParserExtractorAdapter
());
testExtractorsUpdatesSourceInfoBeforeOnPreparedCallback
(
new
MediaParserExtractorAdapter
(
PlayerId
.
UNSET
));
}
}
private
static
void
testExtractorsUpdatesSourceInfoBeforeOnPreparedCallback
(
private
static
void
testExtractorsUpdatesSourceInfoBeforeOnPreparedCallback
(
...
...
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