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
73b922ee
authored
Sep 09, 2019
by
kimvde
Committed by
Oliver Woodman
Sep 10, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add capture policy option to AudioAttributes
PiperOrigin-RevId: 268035329
parent
e21467f6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
16 deletions
RELEASENOTES.md
library/core/src/main/java/com/google/android/exoplayer2/C.java
library/core/src/main/java/com/google/android/exoplayer2/audio/AudioAttributes.java
RELEASENOTES.md
View file @
73b922ee
...
...
@@ -2,6 +2,8 @@
### dev-v2 (not yet released) ###
*
Add
`allowedCapturePolicy`
field to
`AudioAttributes`
wrapper to allow to
opt-out of audio recording.
*
Add
`DataSpec.httpRequestHeaders`
to set HTTP request headers when connecting
to an HTTP source.
`DefaultHttpDataSource`
,
`CronetDataSource`
and
`OkHttpDataSource`
include headers set in the DataSpec when connecting to the
...
...
library/core/src/main/java/com/google/android/exoplayer2/C.java
View file @
73b922ee
...
...
@@ -17,6 +17,7 @@ package com.google.android.exoplayer2;
import
android.annotation.TargetApi
;
import
android.content.Context
;
import
android.media.AudioAttributes
;
import
android.media.AudioFormat
;
import
android.media.AudioManager
;
import
android.media.MediaCodec
;
...
...
@@ -441,6 +442,21 @@ public final class C {
android
.
media
.
AudioAttributes
.
USAGE_VOICE_COMMUNICATION_SIGNALLING
;
/**
* Capture policies for {@link com.google.android.exoplayer2.audio.AudioAttributes}. One of {@link
* #ALLOW_CAPTURE_BY_ALL}, {@link #ALLOW_CAPTURE_BY_NONE} or {@link #ALLOW_CAPTURE_BY_SYSTEM}.
*/
@Documented
@Retention
(
RetentionPolicy
.
SOURCE
)
@IntDef
({
ALLOW_CAPTURE_BY_ALL
,
ALLOW_CAPTURE_BY_NONE
,
ALLOW_CAPTURE_BY_SYSTEM
})
public
@interface
AudioAllowedCapturePolicy
{}
/** See {@link android.media.AudioAttributes#ALLOW_CAPTURE_BY_ALL}. */
public
static
final
int
ALLOW_CAPTURE_BY_ALL
=
AudioAttributes
.
ALLOW_CAPTURE_BY_ALL
;
/** See {@link android.media.AudioAttributes#ALLOW_CAPTURE_BY_NONE}. */
public
static
final
int
ALLOW_CAPTURE_BY_NONE
=
AudioAttributes
.
ALLOW_CAPTURE_BY_NONE
;
/** See {@link android.media.AudioAttributes#ALLOW_CAPTURE_BY_SYSTEM}. */
public
static
final
int
ALLOW_CAPTURE_BY_SYSTEM
=
AudioAttributes
.
ALLOW_CAPTURE_BY_SYSTEM
;
/**
* Audio focus types. One of {@link #AUDIOFOCUS_NONE}, {@link #AUDIOFOCUS_GAIN}, {@link
* #AUDIOFOCUS_GAIN_TRANSIENT}, {@link #AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK} or {@link
* #AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE}.
...
...
library/core/src/main/java/com/google/android/exoplayer2/audio/AudioAttributes.java
View file @
73b922ee
...
...
@@ -18,6 +18,7 @@ package com.google.android.exoplayer2.audio;
import
android.annotation.TargetApi
;
import
androidx.annotation.Nullable
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.util.Util
;
/**
* Attributes for audio playback, which configure the underlying platform
...
...
@@ -42,17 +43,19 @@ public final class AudioAttributes {
private
@C
.
AudioContentType
int
contentType
;
private
@C
.
AudioFlags
int
flags
;
private
@C
.
AudioUsage
int
usage
;
private
@C
.
AudioAllowedCapturePolicy
int
allowedCapturePolicy
;
/**
* Creates a new builder for {@link AudioAttributes}.
*
<p>
*
By default the content type is {@link C#CONTENT_TYPE_UNKNOWN}, usage is
*
{@link C#USAGE_MEDIA},
and no flags are set.
*
*
<p>By default the content type is {@link C#CONTENT_TYPE_UNKNOWN}, usage is {@link
*
C#USAGE_MEDIA}, capture policy is {@link C#ALLOW_CAPTURE_BY_ALL}
and no flags are set.
*/
public
Builder
()
{
contentType
=
C
.
CONTENT_TYPE_UNKNOWN
;
flags
=
0
;
usage
=
C
.
USAGE_MEDIA
;
allowedCapturePolicy
=
C
.
ALLOW_CAPTURE_BY_ALL
;
}
/**
...
...
@@ -79,11 +82,15 @@ public final class AudioAttributes {
return
this
;
}
/**
* Creates an {@link AudioAttributes} instance from this builder.
*/
/** See {@link android.media.AudioAttributes.Builder#setAllowedCapturePolicy(int)}. */
public
Builder
setAllowedCapturePolicy
(
@C
.
AudioAllowedCapturePolicy
int
allowedCapturePolicy
)
{
this
.
allowedCapturePolicy
=
allowedCapturePolicy
;
return
this
;
}
/** Creates an {@link AudioAttributes} instance from this builder. */
public
AudioAttributes
build
()
{
return
new
AudioAttributes
(
contentType
,
flags
,
usage
);
return
new
AudioAttributes
(
contentType
,
flags
,
usage
,
allowedCapturePolicy
);
}
}
...
...
@@ -91,24 +98,38 @@ public final class AudioAttributes {
public
final
@C
.
AudioContentType
int
contentType
;
public
final
@C
.
AudioFlags
int
flags
;
public
final
@C
.
AudioUsage
int
usage
;
public
final
@C
.
AudioAllowedCapturePolicy
int
allowedCapturePolicy
;
@Nullable
private
android
.
media
.
AudioAttributes
audioAttributesV21
;
private
AudioAttributes
(
@C
.
AudioContentType
int
contentType
,
@C
.
AudioFlags
int
flags
,
@C
.
AudioUsage
int
usage
)
{
private
AudioAttributes
(
@C
.
AudioContentType
int
contentType
,
@C
.
AudioFlags
int
flags
,
@C
.
AudioUsage
int
usage
,
@C
.
AudioAllowedCapturePolicy
int
allowedCapturePolicy
)
{
this
.
contentType
=
contentType
;
this
.
flags
=
flags
;
this
.
usage
=
usage
;
this
.
allowedCapturePolicy
=
allowedCapturePolicy
;
}
/**
* Returns a {@link android.media.AudioAttributes} from this instance.
*
* <p>Field {@link AudioAttributes#allowedCapturePolicy} is ignored for API levels prior to 29.
*/
@TargetApi
(
21
)
public
android
.
media
.
AudioAttributes
getAudioAttributesV21
()
{
if
(
audioAttributesV21
==
null
)
{
audioAttributesV21
=
new
android
.
media
.
AudioAttributes
.
Builder
()
.
setContentType
(
contentType
)
.
setFlags
(
flags
)
.
setUsage
(
usage
)
.
build
();
android
.
media
.
AudioAttributes
.
Builder
builder
=
new
android
.
media
.
AudioAttributes
.
Builder
()
.
setContentType
(
contentType
)
.
setFlags
(
flags
)
.
setUsage
(
usage
);
if
(
Util
.
SDK_INT
>=
29
)
{
builder
.
setAllowedCapturePolicy
(
allowedCapturePolicy
);
}
audioAttributesV21
=
builder
.
build
();
}
return
audioAttributesV21
;
}
...
...
@@ -122,8 +143,10 @@ public final class AudioAttributes {
return
false
;
}
AudioAttributes
other
=
(
AudioAttributes
)
obj
;
return
this
.
contentType
==
other
.
contentType
&&
this
.
flags
==
other
.
flags
&&
this
.
usage
==
other
.
usage
;
return
this
.
contentType
==
other
.
contentType
&&
this
.
flags
==
other
.
flags
&&
this
.
usage
==
other
.
usage
&&
this
.
allowedCapturePolicy
==
other
.
allowedCapturePolicy
;
}
@Override
...
...
@@ -132,6 +155,7 @@ public final class AudioAttributes {
result
=
31
*
result
+
contentType
;
result
=
31
*
result
+
flags
;
result
=
31
*
result
+
usage
;
result
=
31
*
result
+
allowedCapturePolicy
;
return
result
;
}
...
...
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