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
be88143f
authored
Aug 03, 2020
by
olly
Committed by
kim-vde
Aug 07, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Remove deprecated parts of demo app IntentUtil
PiperOrigin-RevId: 324604419
parent
33fe3a47
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
46 additions
and
50 deletions
demos/main/src/main/java/com/google/android/exoplayer2/demo/IntentUtil.java
demos/main/src/main/java/com/google/android/exoplayer2/demo/SampleChooserActivity.java
library/common/src/main/java/com/google/android/exoplayer2/util/Util.java
library/core/src/main/java/com/google/android/exoplayer2/offline/DefaultDownloaderFactory.java
library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadHelper.java
library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadRequest.java
library/core/src/main/java/com/google/android/exoplayer2/source/DefaultMediaSourceFactory.java
demos/main/src/main/java/com/google/android/exoplayer2/demo/IntentUtil.java
View file @
be88143f
...
...
@@ -24,7 +24,6 @@ import androidx.annotation.Nullable;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.MediaItem
;
import
com.google.android.exoplayer2.util.Assertions
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.android.exoplayer2.util.Util
;
import
java.util.ArrayList
;
import
java.util.Collections
;
...
...
@@ -63,8 +62,6 @@ public class IntentUtil {
public
static
final
String
MIME_TYPE_EXTRA
=
"mime_type"
;
public
static
final
String
CLIP_START_POSITION_MS_EXTRA
=
"clip_start_position_ms"
;
public
static
final
String
CLIP_END_POSITION_MS_EXTRA
=
"clip_end_position_ms"
;
// For backwards compatibility only.
public
static
final
String
EXTENSION_EXTRA
=
"extension"
;
public
static
final
String
DRM_SCHEME_EXTRA
=
"drm_scheme"
;
public
static
final
String
DRM_LICENSE_URL_EXTRA
=
"drm_license_url"
;
...
...
@@ -72,12 +69,11 @@ public class IntentUtil {
public
static
final
String
DRM_SESSION_FOR_CLEAR_TYPES_EXTRA
=
"drm_session_for_clear_types"
;
public
static
final
String
DRM_MULTI_SESSION_EXTRA
=
"drm_multi_session"
;
public
static
final
String
DRM_FORCE_DEFAULT_LICENSE_URI_EXTRA
=
"drm_force_default_license_uri"
;
public
static
final
String
AD_TAG_URI_EXTRA
=
"ad_tag_uri"
;
public
static
final
String
SUBTITLE_URI_EXTRA
=
"subtitle_uri"
;
public
static
final
String
SUBTITLE_MIME_TYPE_EXTRA
=
"subtitle_mime_type"
;
public
static
final
String
SUBTITLE_LANGUAGE_EXTRA
=
"subtitle_language"
;
// For backwards compatibility only.
public
static
final
String
DRM_SCHEME_UUID_EXTRA
=
"drm_scheme_uuid"
;
public
static
final
String
PREFER_EXTENSION_DECODERS_EXTRA
=
"prefer_extension_decoders"
;
...
...
@@ -122,31 +118,9 @@ public class IntentUtil {
}
}
/** Makes a best guess to infer the MIME type from a {@link Uri} and an optional extension. */
@Nullable
public
static
String
inferAdaptiveStreamMimeType
(
Uri
uri
,
@Nullable
String
extension
)
{
@C
.
ContentType
int
contentType
=
Util
.
inferContentType
(
uri
,
extension
);
switch
(
contentType
)
{
case
C
.
TYPE_DASH
:
return
MimeTypes
.
APPLICATION_MPD
;
case
C
.
TYPE_HLS
:
return
MimeTypes
.
APPLICATION_M3U8
;
case
C
.
TYPE_SS
:
return
MimeTypes
.
APPLICATION_SS
;
case
C
.
TYPE_OTHER
:
default
:
return
null
;
}
}
private
static
MediaItem
createMediaItemFromIntent
(
Uri
uri
,
Intent
intent
,
String
extrasKeySuffix
)
{
String
mimeType
=
intent
.
getStringExtra
(
MIME_TYPE_EXTRA
+
extrasKeySuffix
);
if
(
mimeType
==
null
)
{
// Try to use extension for backwards compatibility.
String
extension
=
intent
.
getStringExtra
(
EXTENSION_EXTRA
+
extrasKeySuffix
);
mimeType
=
inferAdaptiveStreamMimeType
(
uri
,
extension
);
}
@Nullable
String
mimeType
=
intent
.
getStringExtra
(
MIME_TYPE_EXTRA
+
extrasKeySuffix
);
MediaItem
.
Builder
builder
=
new
MediaItem
.
Builder
()
.
setUri
(
uri
)
...
...
@@ -178,17 +152,15 @@ public class IntentUtil {
private
static
MediaItem
.
Builder
populateDrmPropertiesFromIntent
(
MediaItem
.
Builder
builder
,
Intent
intent
,
String
extrasKeySuffix
)
{
String
schemeKey
=
DRM_SCHEME_EXTRA
+
extrasKeySuffix
;
String
schemeUuidKey
=
DRM_SCHEME_UUID_EXTRA
+
extrasKeySuffix
;
if
(
!
intent
.
hasExtra
(
schemeKey
)
&&
!
intent
.
hasExtra
(
schemeUuidKey
)
)
{
@Nullable
String
drmSchemeExtra
=
intent
.
getStringExtra
(
schemeKey
)
;
if
(
drmSchemeExtra
==
null
)
{
return
builder
;
}
String
drmSchemeExtra
=
intent
.
hasExtra
(
schemeKey
)
?
intent
.
getStringExtra
(
schemeKey
)
:
intent
.
getStringExtra
(
schemeUuidKey
);
@Nullable
String
[]
drmSessionForClearTypesExtra
=
intent
.
getStringArrayExtra
(
DRM_SESSION_FOR_CLEAR_TYPES_EXTRA
+
extrasKeySuffix
);
Map
<
String
,
String
>
headers
=
new
HashMap
<>();
@Nullable
String
[]
keyRequestPropertiesArray
=
intent
.
getStringArrayExtra
(
DRM_KEY_REQUEST_PROPERTIES_EXTRA
+
extrasKeySuffix
);
if
(
keyRequestPropertiesArray
!=
null
)
{
...
...
demos/main/src/main/java/com/google/android/exoplayer2/demo/SampleChooserActivity.java
View file @
be88143f
...
...
@@ -443,10 +443,13 @@ public class SampleChooserActivity extends AppCompatActivity
}
return
new
PlaylistHolder
(
title
,
mediaItems
);
}
else
{
@Nullable
String
adaptiveMimeType
=
Util
.
getAdaptiveMimeTypeForContentType
(
Util
.
inferContentType
(
uri
,
extension
));
mediaItem
.
setUri
(
uri
)
.
setMediaMetadata
(
new
MediaMetadata
.
Builder
().
setTitle
(
title
).
build
())
.
setMimeType
(
IntentUtil
.
inferAdaptiveStreamMimeType
(
uri
,
extension
)
)
.
setMimeType
(
adaptiveMimeType
)
.
setTag
(
new
IntentUtil
.
Tag
(
isLive
));
if
(
subtitleUri
!=
null
)
{
MediaItem
.
Subtitle
subtitle
=
...
...
library/common/src/main/java/com/google/android/exoplayer2/util/Util.java
View file @
be88143f
...
...
@@ -53,6 +53,7 @@ import android.view.WindowManager;
import
androidx.annotation.Nullable
;
import
androidx.annotation.RequiresApi
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.C.ContentType
;
import
com.google.android.exoplayer2.ExoPlayerLibraryInfo
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.MediaItem
;
...
...
@@ -1675,13 +1676,13 @@ public final class Util {
}
/**
* Makes a best guess to infer the
type
from a {@link Uri}.
* Makes a best guess to infer the
{@link ContentType}
from a {@link Uri}.
*
* @param uri The {@link Uri}.
* @param overrideExtension If not null, used to infer the type.
* @return The content type.
*/
@C
.
C
ontentType
@ContentType
public
static
int
inferContentType
(
Uri
uri
,
@Nullable
String
overrideExtension
)
{
return
TextUtils
.
isEmpty
(
overrideExtension
)
?
inferContentType
(
uri
)
...
...
@@ -1689,24 +1690,24 @@ public final class Util {
}
/**
* Makes a best guess to infer the
type
from a {@link Uri}.
* Makes a best guess to infer the
{@link ContentType}
from a {@link Uri}.
*
* @param uri The {@link Uri}.
* @return The content type.
*/
@C
.
C
ontentType
@ContentType
public
static
int
inferContentType
(
Uri
uri
)
{
String
path
=
uri
.
getPath
();
@Nullable
String
path
=
uri
.
getPath
();
return
path
==
null
?
C
.
TYPE_OTHER
:
inferContentType
(
path
);
}
/**
* Makes a best guess to infer the
type
from a file name.
* Makes a best guess to infer the
{@link ContentType}
from a file name.
*
* @param fileName Name of the file. It can include the path of the file.
* @return The content type.
*/
@C
.
C
ontentType
@ContentType
public
static
int
inferContentType
(
String
fileName
)
{
fileName
=
toLowerInvariant
(
fileName
);
if
(
fileName
.
endsWith
(
".mpd"
))
{
...
...
@@ -1721,14 +1722,14 @@ public final class Util {
}
/**
* Makes a best guess to infer the
type from a {@link Uri} and
MIME type.
* Makes a best guess to infer the
{@link ContentType} from a {@link Uri} and optional
MIME type.
*
* @param uri The {@link Uri}.
* @param mimeType If
not null, used to infer the type
.
* @param mimeType If
MIME type, or {@code null}
.
* @return The content type.
*/
@C
.
C
ontentType
public
static
int
inferContentType
With
MimeType
(
Uri
uri
,
@Nullable
String
mimeType
)
{
@ContentType
public
static
int
inferContentType
ForUriAnd
MimeType
(
Uri
uri
,
@Nullable
String
mimeType
)
{
if
(
mimeType
==
null
)
{
return
Util
.
inferContentType
(
uri
);
}
...
...
@@ -1745,6 +1746,25 @@ public final class Util {
}
/**
* Returns the MIME type corresponding to the given adaptive {@link ContentType}, or {@code null}
* if the content type is {@link C#TYPE_OTHER}.
*/
@Nullable
public
static
String
getAdaptiveMimeTypeForContentType
(
int
contentType
)
{
switch
(
contentType
)
{
case
C
.
TYPE_DASH
:
return
MimeTypes
.
APPLICATION_MPD
;
case
C
.
TYPE_HLS
:
return
MimeTypes
.
APPLICATION_M3U8
;
case
C
.
TYPE_SS
:
return
MimeTypes
.
APPLICATION_SS
;
case
C
.
TYPE_OTHER
:
default
:
return
null
;
}
}
/**
* Returns the specified millisecond time formatted as a string.
*
* @param builder The builder that {@code formatter} will write to.
...
...
library/core/src/main/java/com/google/android/exoplayer2/offline/DefaultDownloaderFactory.java
View file @
be88143f
...
...
@@ -69,7 +69,7 @@ public class DefaultDownloaderFactory implements DownloaderFactory {
@Override
public
Downloader
createDownloader
(
DownloadRequest
request
)
{
@C
.
ContentType
int
contentType
=
Util
.
inferContentType
With
MimeType
(
request
.
uri
,
request
.
mimeType
);
int
contentType
=
Util
.
inferContentType
ForUriAnd
MimeType
(
request
.
uri
,
request
.
mimeType
);
switch
(
contentType
)
{
case
C
.
TYPE_DASH
:
case
C
.
TYPE_HLS
:
...
...
library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadHelper.java
View file @
be88143f
...
...
@@ -909,7 +909,8 @@ public final class DownloadHelper {
}
private
static
boolean
isProgressive
(
MediaItem
.
PlaybackProperties
playbackProperties
)
{
return
Util
.
inferContentTypeWithMimeType
(
playbackProperties
.
uri
,
playbackProperties
.
mimeType
)
return
Util
.
inferContentTypeForUriAndMimeType
(
playbackProperties
.
uri
,
playbackProperties
.
mimeType
)
==
C
.
TYPE_OTHER
;
}
...
...
library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadRequest.java
View file @
be88143f
...
...
@@ -74,7 +74,7 @@ public final class DownloadRequest implements Parcelable {
@Nullable
byte
[]
keySetId
,
@Nullable
String
customCacheKey
,
@Nullable
byte
[]
data
)
{
@C
.
ContentType
int
contentType
=
Util
.
inferContentType
With
MimeType
(
uri
,
mimeType
);
@C
.
ContentType
int
contentType
=
Util
.
inferContentType
ForUriAnd
MimeType
(
uri
,
mimeType
);
if
(
contentType
==
C
.
TYPE_DASH
||
contentType
==
C
.
TYPE_HLS
||
contentType
==
C
.
TYPE_SS
)
{
Assertions
.
checkArgument
(
customCacheKey
==
null
,
"customCacheKey must be null for type: "
+
contentType
);
...
...
library/core/src/main/java/com/google/android/exoplayer2/source/DefaultMediaSourceFactory.java
View file @
be88143f
...
...
@@ -279,7 +279,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
Assertions
.
checkNotNull
(
mediaItem
.
playbackProperties
);
@C
.
ContentType
int
type
=
Util
.
inferContentType
With
MimeType
(
Util
.
inferContentType
ForUriAnd
MimeType
(
mediaItem
.
playbackProperties
.
uri
,
mediaItem
.
playbackProperties
.
mimeType
);
@Nullable
MediaSourceFactory
mediaSourceFactory
=
mediaSourceFactories
.
get
(
type
);
Assertions
.
checkNotNull
(
...
...
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