harmony 鸿蒙native_audiostreambuilder.h

  • 2025-06-12
  • 浏览 (4)

native_audiostreambuilder.h

Overview

The native_audiostreambuilder.h file declares the functions related to the audio stream builder.

You can use the functions to create and destroy an audio stream builder, set audio stream attributes, and set callbacks.

Library: libohaudio.so

File to include: <ohaudio/native_audiostreambuilder.h>

System capability: SystemCapability.Multimedia.Audio.Core

Since: 10

Related module: OHAudio

Summary

Functions

Name Description
OH_AudioStream_Result OH_AudioStreamBuilder_Create(OH_AudioStreamBuilder **builder, OH_AudioStream_Type type) Creates an audio stream builder, which can be an audio renderer or capturer.
OH_AudioStream_Result OH_AudioStreamBuilder_Destroy(OH_AudioStreamBuilder *builder) Destroys an audio stream builder.
OH_AudioStream_Result OH_AudioStreamBuilder_SetSamplingRate(OH_AudioStreamBuilder *builder, int32_t rate) Sets the sampling rate of an audio stream.
OH_AudioStream_Result OH_AudioStreamBuilder_SetChannelCount(OH_AudioStreamBuilder *builder, int32_t channelCount) Sets the number of channels for an audio stream.
OH_AudioStream_Result OH_AudioStreamBuilder_SetSampleFormat(OH_AudioStreamBuilder *builder, OH_AudioStream_SampleFormat format) Sets the sampling format of an audio stream.
OH_AudioStream_Result OH_AudioStreamBuilder_SetEncodingType(OH_AudioStreamBuilder *builder, OH_AudioStream_EncodingType encodingType) Sets the encoding type of an audio stream.
OH_AudioStream_Result OH_AudioStreamBuilder_SetLatencyMode(OH_AudioStreamBuilder *builder, OH_AudioStream_LatencyMode latencyMode) Sets the latency mode of an audio stream.
OH_AudioStream_Result OH_AudioStreamBuilder_SetChannelLayout(OH_AudioStreamBuilder *builder, OH_AudioChannelLayout channelLayout) Sets the channel layout for an audio stream.
OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererInfo(OH_AudioStreamBuilder *builder, OH_AudioStream_Usage usage) Sets the usage scenario of an audio renderer.
OH_AudioStream_Result OH_AudioStreamBuilder_SetVolumeMode (OH_AudioStreamBuilder *builder, OH_AudioStream_VolumeMode volumeMode) Sets the volume mode for an audio stream.
OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerInfo(OH_AudioStreamBuilder *builder, OH_AudioStream_SourceType sourceType) Sets the usage scenario of an audio capturer.
OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererCallback(OH_AudioStreamBuilder *builder, OH_AudioRenderer_Callbacks callbacks, void *userData) Sets callbacks for an audio renderer.
OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererOutputDeviceChangeCallback(OH_AudioStreamBuilder *builder, OH_AudioRenderer_OutputDeviceChangeCallback callback, void *userData) Sets the callback invoked when the audio stream device changes.
OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererPrivacy(OH_AudioStreamBuilder *builder, OH_AudioStream_PrivacyType privacy) Sets the privacy type for the audio stream being played. The privacy type specifies whether the audio stream can be recorded by other applications.
OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerCallback(OH_AudioStreamBuilder *builder, OH_AudioCapturer_Callbacks callbacks, void *userData) Sets callbacks for an audio capturer.
OH_AudioStream_Result OH_AudioStreamBuilder_SetWriteDataWithMetadataCallback(OH_AudioStreamBuilder *builder, OH_AudioRenderer_WriteDataWithMetadataCallback callback, void *userData) Sets the callback used to write both audio data and metadata.
OH_AudioStream_Result OH_AudioStreamBuilder_GenerateRenderer(OH_AudioStreamBuilder *builder, OH_AudioRenderer **audioRenderer) Creates an audio renderer instance.
OH_AudioStream_Result OH_AudioStreamBuilder_GenerateCapturer(OH_AudioStreamBuilder *builder, OH_AudioCapturer **audioCapturer) Creates an audio capturer instance.
OH_AudioStream_Result OH_AudioStreamBuilder_SetFrameSizeInCallback(OH_AudioStreamBuilder *builder, int32_t frameSize) Sets the frame size for each callback during playback. The frame size must be at least equal to the size of the data processed by the audio hardware at a time and less than half of the internal buffer capacity.
OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererInterruptMode(OH_AudioStreamBuilder *builder, OH_AudioInterrupt_Mode mode) Sets the interrupt mode of the stream client.
OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererWriteDataCallback(OH_AudioStreamBuilder *builder, OH_AudioRenderer_OnWriteDataCallback callback, void *userData) Sets the callback used to write audio data.
OH_AudioStream_ResultOH_AudioStreamBuilder_SetRendererInterruptCallback (OH_AudioStreamBuilder *builder, OH_AudioRenderer_OnInterruptCallback callback, void *userData) Sets the callback for interruption events of an audio renderer.
OH_AudioStream_ResultOH_AudioStreamBuilder_SetRendererErrorCallback (OH_AudioStreamBuilder *builder, OH_AudioRenderer_OnErrorCallback callback, void *userData) Sets the callback for error events of an audio renderer.
OH_AudioStream_ResultOH_AudioStreamBuilder_SetCapturerReadDataCallback (OH_AudioStreamBuilder *builder, OH_AudioCapturer_OnReadDataCallback callback, void *userData) Sets the callback used to read data for an audio capturer.
OH_AudioStream_ResultOH_AudioStreamBuilder_SetCapturerDeviceChangeCallback (OH_AudioStreamBuilder *builder, OH_AudioCapturer_OnDeviceChangeCallback callback, void *userData) Sets the callback for audio capturer device change events.
OH_AudioStream_ResultOH_AudioStreamBuilder_SetCapturerInterruptCallback (OH_AudioStreamBuilder *builder, OH_AudioCapturer_OnInterruptCallback callback, void *userData) Sets the callback for interruption events of an audio capturer.
OH_AudioStream_ResultOH_AudioStreamBuilder_SetCapturerErrorCallback (OH_AudioStreamBuilder *builder, OH_AudioCapturer_OnErrorCallback callback, void *userData) Sets the callback for error events of an audio capturer.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Audio Kit

harmony 鸿蒙OH_AudioCapturer_Callbacks_Struct

harmony 鸿蒙OH_AudioDeviceDescriptorArray

harmony 鸿蒙OH_AudioRenderer_Callbacks_Struct

harmony 鸿蒙OH_AudioSession_DeactivatedEvent

harmony 鸿蒙OH_AudioSession_Strategy

harmony 鸿蒙_o_h_audio

harmony 鸿蒙Audio Error Codes

harmony 鸿蒙Ringtone Error Codes

harmony 鸿蒙js-apis-audio-sys

0  赞