aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRobert Wu <85952307+robertwu1@users.noreply.github.com>2023-03-24 17:09:00 +0000
committerGitHub <noreply@github.com>2023-03-24 10:09:00 -0700
commit79f9d8fc52aa59091d8ecd7e2c3146a524261fb8 (patch)
tree18ecf1850e64845bc9c9906e46a4045d096289cb /include
parente54826cfdb2c9480ca0b7bb38f4558f1e99ad152 (diff)
downloadoboe-79f9d8fc52aa59091d8ecd7e2c3146a524261fb8.tar.gz
Add privacy sensitive mode for API 30+ (#1751)
Diffstat (limited to 'include')
-rw-r--r--include/oboe/AudioStreamBase.h17
-rw-r--r--include/oboe/AudioStreamBuilder.h25
-rw-r--r--include/oboe/Definitions.h26
3 files changed, 68 insertions, 0 deletions
diff --git a/include/oboe/AudioStreamBase.h b/include/oboe/AudioStreamBase.h
index c0a582e9..b956f351 100644
--- a/include/oboe/AudioStreamBase.h
+++ b/include/oboe/AudioStreamBase.h
@@ -158,6 +158,20 @@ public:
SessionId getSessionId() const { return mSessionId; }
/**
+ * Return whether this input stream is marked as privacy sensitive.
+ *
+ * See AudioStreamBuilder_setPrivacySensitiveMode().
+ *
+ * Added in API level 30 to AAudio.
+ *
+ * @param stream reference provided by AAudioStreamBuilder_openStream()
+ * @return PrivacySensitiveMode::Enabled if privacy sensitive,
+ * PrivacySensitiveMode::Disabled if not privacy sensitive, and
+ * PrivacySensitiveMode::Unspecified if API is not supported.
+ */
+ PrivacySensitiveMode getPrivacySensitiveMode() const { return mPrivacySensitiveMode; }
+
+ /**
* @return true if Oboe can convert channel counts to achieve optimal results.
*/
bool isChannelConversionAllowed() const {
@@ -244,6 +258,9 @@ protected:
/** Stream session ID allocation strategy. Only active on Android 28+ */
SessionId mSessionId = SessionId::None;
+ /** Privacy Sensitive Mode. Only active on Android 30+ */
+ PrivacySensitiveMode mPrivacySensitiveMode = PrivacySensitiveMode::Unspecified;
+
/** Control the name of the package creating the stream. Only active on Android 31+ */
std::string mPackageName;
/** Control the attribution tag of the context creating the stream. Only active on Android 31+ */
diff --git a/include/oboe/AudioStreamBuilder.h b/include/oboe/AudioStreamBuilder.h
index 5c7ac4b6..04e50292 100644
--- a/include/oboe/AudioStreamBuilder.h
+++ b/include/oboe/AudioStreamBuilder.h
@@ -348,6 +348,31 @@ public:
return this;
}
+
+ /** Indicates whether this input stream must be marked as privacy sensitive or not.
+ *
+ * When PrivacySensitiveMode::Enabled, this input stream is privacy sensitive and any
+ * concurrent capture is not permitted.
+ *
+ * This is off (PrivacySensitiveMode::Disabled) by default except when the input preset is
+ * InputPreset::VoiceRecognition or InputPreset::Camcorder
+ *
+ * Always takes precedence over default from input preset when set explicitly.
+ *
+ * Only relevant if the stream direction is Direction::Input and AAudio is used.
+ *
+ * Added in API level 30 to AAudio.
+ *
+ * @param builder reference provided by AAudio_createStreamBuilder()
+ * @param privacySensitive PrivacySensitiveMode::Enabled if capture from this stream must be
+ * marked as privacy sensitive, PrivacySensitiveMode::Disabled if stream should be marked as
+ * not sensitive.
+ */
+ AudioStreamBuilder *setPrivacySensitiveMode(PrivacySensitiveMode privacySensitiveMode) {
+ mPrivacySensitiveMode = privacySensitiveMode;
+ return this;
+ }
+
/**
* Specifies an object to handle data related callbacks from the underlying API.
*
diff --git a/include/oboe/Definitions.h b/include/oboe/Definitions.h
index 763d1d2a..3cc4c03e 100644
--- a/include/oboe/Definitions.h
+++ b/include/oboe/Definitions.h
@@ -651,6 +651,32 @@ namespace oboe {
};
/**
+ * The PrivacySensitiveMode attribute determines whether an input stream can be shared
+ * with another privileged app, for example the Assistant.
+ *
+ * This allows to override the default behavior tied to the audio source (e.g
+ * InputPreset::VoiceCommunication is private by default but InputPreset::Unprocessed is not).
+ */
+ enum class PrivacySensitiveMode : int32_t {
+
+ /**
+ * When not explicitly requested, set privacy sensitive mode according to input preset:
+ * communication and camcorder captures are considered privacy sensitive by default.
+ */
+ Unspecified = kUnspecified,
+
+ /**
+ * Privacy sensitive mode disabled.
+ */
+ Disabled = 1,
+
+ /**
+ * Privacy sensitive mode enabled.
+ */
+ Enabled = 2,
+ };
+
+ /**
* On API 16 to 26 OpenSL ES will be used. When using OpenSL ES the optimal values for sampleRate and
* framesPerBurst are not known by the native code.
* On API 17+ these values should be obtained from the AudioManager using this code: