Add API Level guard for allowedCapturePolicy
AudioAttributes::getAllowedCapturePolicy was added in API Level 29. Update WebRtcAudioTrack to add API Level check before using the API. Bug: webrtc:12250 Change-Id: Ica6604eb1d7fa736a0e64729a022eefcfb7b3020 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/195941 Commit-Queue: Gaurav Vaish <gvaish@chromium.org> Reviewed-by: Henrik Andreassson <henrika@webrtc.org> Cr-Commit-Position: refs/heads/master@{#32735}
This commit is contained in:
@ -411,8 +411,11 @@ class WebRtcAudioTrack {
|
||||
attributesBuilder.setContentType(overrideAttributes.getContentType());
|
||||
}
|
||||
|
||||
attributesBuilder.setAllowedCapturePolicy(overrideAttributes.getAllowedCapturePolicy())
|
||||
.setFlags(overrideAttributes.getFlags());
|
||||
attributesBuilder.setFlags(overrideAttributes.getFlags());
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
attributesBuilder = applyAttributesOnQOrHigher(attributesBuilder, overrideAttributes);
|
||||
}
|
||||
}
|
||||
|
||||
// Create an audio track where the audio usage is for VoIP and the content type is speech.
|
||||
@ -425,6 +428,12 @@ class WebRtcAudioTrack {
|
||||
bufferSizeInBytes, AudioTrack.MODE_STREAM, AudioManager.AUDIO_SESSION_ID_GENERATE);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.Q)
|
||||
private static AudioAttributes.Builder applyAttributesOnQOrHigher(
|
||||
AudioAttributes.Builder builder, AudioAttributes overrideAttributes) {
|
||||
return builder.setAllowedCapturePolicy(overrideAttributes.getAllowedCapturePolicy());
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation") // Deprecated in API level 25.
|
||||
private static AudioTrack createAudioTrackOnLowerThanLollipop(
|
||||
int sampleRateInHz, int channelConfig, int bufferSizeInBytes) {
|
||||
|
Reference in New Issue
Block a user