human: 如何处理七牛云的实时音视频QNCustomAudioTrack

gpt: [实时音视频](https://developer.qiniu.com/rtc) > API 文档 > Windows
>QNCustomAudioTrack

#  QNCustomAudioTrack

最近更新时间: 2022-03-23 22:09:47

本地音频自定义导入 Track 类

Hierarchy

  * [QNTrack](https://developer.qiniu.com/rtc/9409/qncustomaudiotrack/9452/QNTrack)
    * [QNLocalTrack](https://developer.qiniu.com/rtc/9409/qncustomaudiotrack/9422/QNLocalTrack)
      * [QNLocalVideoTrack](https://developer.qiniu.com/rtc/9409/qncustomaudiotrack/9424/QNLocalVideoTrack)
        * [QNCameraVideoTrack](https://developer.qiniu.com/rtc/9409/qncustomaudiotrack/9404/QNCameraVideoTrack)
        * [QNScreenVideoTrack](https://developer.qiniu.com/rtc/9409/qncustomaudiotrack/9448/QNScreenVideoTrack)
        * [QNCustomVideoTrack](https://developer.qiniu.com/rtc/9409/qncustomaudiotrack/9412/QNCustomVideoTrack)
      * [QNLocalAudioTrack](https://developer.qiniu.com/rtc/9409/qncustomaudiotrack/9420/QNLocalAudioTrack)
        * [QNMicrophoneAudioTrack](https://developer.qiniu.com/rtc/9409/qncustomaudiotrack/9433/QNMicrophoneAudioTrack)
        * QNCustomAudioTrack 
    * [QNRemoteTrack](https://developer.qiniu.com/rtc/9409/qncustomaudiotrack/9440/QNRemoteTrack)
      * [QNRemoteVideoTrack](https://developer.qiniu.com/rtc/9409/qncustomaudiotrack/9443/QNRemoteVideoTrack)
      * [QNRemoteAudioTrack](https://developer.qiniu.com/rtc/9409/qncustomaudiotrack/9438/QNRemoteAudioTrack)

Index

Core Methods

  * GetTrackID
  * GetUserID
  * GetTag
  * IsAudio
  * IsVideo
  * IsMuted
  * SetMuted
  * SetAudioFrameListener
  * SetVolume
  * GetVolumeLevel
  * MixAudioWithSoundCard
  * PushAudioFrame

Core Methods

GetTrackID

  * virtual const std::string& GetTrackID() = 0
  * 获取 TrackID

Returns string

GetUserID

  * virtual const std::string& GetUserID() = 0
  * 获取 UserID

Returns string

GetTag

  * virtual const std::string& GetTag() = 0
  * 获取 Tag

Returns string

IsAudio

  * virtual bool IsAudio() = 0
  * 是否为音频 track

Returns bool

IsVideo

  * virtual bool IsVideo() = 0
  * 是否为视频 track

Returns bool

IsMuted

  * virtual bool IsMuted() = 0
  * 是否 muted

Returns bool

SetMuted

  * virtual void SetMuted(bool muted) = 0
  * 设置是否静默该 track，静默后，SDK 将会发送静默帧数据

Parameters

    * muted: bool 

是否静默

SetAudioFrameListener

  * virtual void SetAudioFrameListener([QNAudioFrameListener](https://developer.qiniu.com/rtc/9409/qncustomaudiotrack/11322/QNAudioFrameListener)* listener) = 0
  * 设置是音频数据监听

Parameters

    * listener: [QNAudioFrameListener](https://developer.qiniu.com/rtc/9409/qncustomaudiotrack/11322/QNAudioFrameListener)

音频数据监听接口

SetVolume

  * virtual void SetVolume(double volume) = 0
  * 设置采集音频音量（不改变系统设备的音量）

Parameters

    * volume: double 

音量大小，[1.0-10.0], 默认为 1.0

GetVolumeLevel

  * virtual float GetVolumeLevel() = 0
  * 获取音频采集的音量

Returns float

MixAudioWithSoundCard

  * virtual void MixAudioWithSoundCard(bool enable, float volume_scale_ratio = 1.0f) = 0
  * 激活监听功能：混合本地麦克风和系统声卡的声音(仅适用于 Windows 和 iOS)

Parameters

    * enable: bool 

是否开启监听

    * volume_scale_ratio: float 

系统声音缩放倍数，以方便控制系统音量大小

PushAudioFrame

  * virtual int32_t PushAudioFrame(const uint8_t* data,uint32_t data_size,uint32_t bits_per_sample,uint32_t sample_rate,uint32_t channels) = 0
  * 推送自定义音频帧

Parameters

    * data: uint8_t* 

音频数据

    * data_size: uint32_t 

数据长度

    * bits_per_sample: uint32_t 

位宽，即每个采样点占用位数

    * sample_rate: uint32_t 

采样率

    * channels: uint32_t 

声道数

以上内容是否对您有帮助？