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
f329adbc
authored
Aug 02, 2021
by
olly
Committed by
Oliver Woodman
Aug 02, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Opt ExoPlayer out of transcoding when reading content URIs
PiperOrigin-RevId: 388260014
parent
40136121
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
4 deletions
RELEASENOTES.md
constants.gradle
library/core/src/main/java/com/google/android/exoplayer2/upstream/ContentDataSource.java
RELEASENOTES.md
View file @
f329adbc
...
...
@@ -50,6 +50,7 @@
*
Change interface of
`LoadErrorHandlingPolicy`
to support configuring the
behavior of track and location fallback. Location fallback is currently
only supported for DASH manifests with multiple base URLs.
*
Disable platform transcoding when playing content URIs on Android 12.
*
Remove deprecated symbols:
*
Remove
`Player.getPlaybackError`
. Use
`Player.getPlayerError`
instead.
*
Remove
`Player.getCurrentTag`
. Use
`Player.getCurrentMediaItem`
and
...
...
constants.gradle
View file @
f329adbc
...
...
@@ -17,8 +17,8 @@ project.ext {
releaseVersionCode
=
2014002
minSdkVersion
=
16
appTargetSdkVersion
=
29
targetSdkVersion
=
3
0
compileSdkVersion
=
3
0
targetSdkVersion
=
3
1
compileSdkVersion
=
3
1
dexmakerVersion
=
'2.28.1'
junitVersion
=
'4.13.2'
// Use the same Guava version as the Android repo:
...
...
library/core/src/main/java/com/google/android/exoplayer2/upstream/ContentDataSource.java
View file @
f329adbc
...
...
@@ -21,10 +21,18 @@ import static java.lang.Math.min;
import
android.content.ContentResolver
;
import
android.content.Context
;
import
android.content.res.AssetFileDescriptor
;
import
android.media.ApplicationMediaCapabilities
;
import
android.media.MediaFeature
;
import
android.media.MediaFormat
;
import
android.net.Uri
;
import
android.os.Bundle
;
import
android.provider.MediaStore
;
import
androidx.annotation.DoNotInline
;
import
androidx.annotation.Nullable
;
import
androidx.annotation.RequiresApi
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.PlaybackException
;
import
com.google.android.exoplayer2.util.Util
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
import
java.io.IOException
;
...
...
@@ -70,10 +78,17 @@ public final class ContentDataSource extends BaseDataSource {
this
.
uri
=
uri
;
transferInitializing
(
dataSpec
);
AssetFileDescriptor
assetFileDescriptor
=
resolver
.
openAssetFileDescriptor
(
uri
,
"r"
);
Bundle
providerOptions
=
new
Bundle
();
if
(
Util
.
SDK_INT
>=
31
)
{
Api31
.
disableTranscoding
(
providerOptions
);
}
AssetFileDescriptor
assetFileDescriptor
=
resolver
.
openTypedAssetFileDescriptor
(
uri
,
/* mimeType= */
"*/*"
,
providerOptions
);
this
.
assetFileDescriptor
=
assetFileDescriptor
;
if
(
assetFileDescriptor
==
null
)
{
// openAssetFileDescriptor returns null if the provider recently crashed.
// open
Typed
AssetFileDescriptor returns null if the provider recently crashed.
throw
new
ContentDataSourceException
(
new
IOException
(
"Could not open file descriptor for: "
+
uri
),
PlaybackException
.
ERROR_CODE_IO_UNSPECIFIED
);
...
...
@@ -205,4 +220,21 @@ public final class ContentDataSource extends BaseDataSource {
}
}
}
@RequiresApi
(
31
)
private
static
final
class
Api31
{
@DoNotInline
public
static
void
disableTranscoding
(
Bundle
providerOptions
)
{
ApplicationMediaCapabilities
mediaCapabilities
=
new
ApplicationMediaCapabilities
.
Builder
()
.
addSupportedVideoMimeType
(
MediaFormat
.
MIMETYPE_VIDEO_HEVC
)
.
addSupportedHdrType
(
MediaFeature
.
HdrType
.
DOLBY_VISION
)
.
addSupportedHdrType
(
MediaFeature
.
HdrType
.
HDR10
)
.
addSupportedHdrType
(
MediaFeature
.
HdrType
.
HDR10_PLUS
)
.
addSupportedHdrType
(
MediaFeature
.
HdrType
.
HLG
)
.
build
();
providerOptions
.
putParcelable
(
MediaStore
.
EXTRA_MEDIA_CAPABILITIES
,
mediaCapabilities
);
}
}
}
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