Ring Daemon 16.0.0
Loading...
Searching...
No Matches
jami::PulseLayer Class Reference

#include <pulselayer.h>

Inheritance diagram for jami::PulseLayer:
Inheritance graph
Collaboration diagram for jami::PulseLayer:
Collaboration graph

Public Member Functions

int getAudioDeviceIndex (const std::string &descr, AudioDeviceType type) const
 
int getAudioDeviceIndexByName (const std::string &name, AudioDeviceType type) const
 
std::string getAudioDeviceName (int index, AudioDeviceType type) const
 
virtual std::vector< std::string > getCaptureDeviceList () const
 
virtual std::vector< std::string > getPlaybackDeviceList () const
 
bool inSinkList (const std::string &deviceName)
 
bool inSourceList (const std::string &deviceName)
 
 PulseLayer (AudioPreference &pref)
 
void readFromMic ()
 Write data from the ring buffer to the hardware and read data from the hardware.
 
void ringtoneToSpeaker ()
 
virtual void startStream (AudioDeviceType stream=AudioDeviceType::ALL)
 Start the capture stream and prepare the playback stream.
 
virtual void stopStream (AudioDeviceType stream=AudioDeviceType::ALL)
 Stop the playback and capture streams.
 
void updateServerInfo ()
 
void updateSinkList ()
 
void updateSourceList ()
 
void writeToSpeaker ()
 
 ~PulseLayer ()
 
- Public Member Functions inherited from jami::AudioLayer
 AudioLayer (const AudioPreference &)
 
void flushMain ()
 Flush main buffer.
 
void flushUrgent ()
 Flush urgent buffer.
 
double getCaptureGain () const
 Get capture stream gain (microphone)
 
AudioFormat getFormat () const
 Get the audio format of the layer (sample rate & channel number).
 
double getPlaybackGain () const
 Get playback stream gain (speaker)
 
unsigned int getSampleRate () const
 Get the sample rate of the audio layer.
 
bool isCaptureMuted () const
 
bool isPlaybackMuted () const
 
bool isRingtoneMuted () const
 
bool isStarted () const
 Determine whether or not the audio layer is active (i.e.
 
void muteCapture (bool muted)
 Mute capture (microphone)
 
void mutePlayback (bool muted)
 Mute playback.
 
void muteRingtone (bool muted)
 
void notifyIncomingCall ()
 Emit an audio notification (beep) on incoming calls.
 
void playIncomingCallNotification (bool play)
 Start/Stop playing the incoming call notification sound (beep) while playing back audio (typically during an ongoing call).
 
void putUrgent (std::shared_ptr< AudioFrame > buffer)
 Send a chunk of data to the hardware buffer to start the playback Copy data in the urgent buffer.
 
void setCaptureGain (double gain)
 Set capture stream gain (microphone) Range should be [-1.0, 1.0].
 
void setPlaybackGain (double gain)
 Set playback stream gain (speaker) Range should be [-1.0, 1.0].
 
template<class Rep , class Period >
bool waitForStart (const std::chrono::duration< Rep, Period > &rel_time) const
 
virtual ~AudioLayer ()
 

Friends

class AudioLayerTest
 

Additional Inherited Members

- Protected Types inherited from jami::AudioLayer
enum class  Status { Idle , Starting , Started }
 
- Protected Member Functions inherited from jami::AudioLayer
void devicesChanged ()
 
void flush ()
 
std::shared_ptr< AudioFramegetPlayback (AudioFormat format, size_t samples)
 
std::shared_ptr< AudioFramegetToPlay (AudioFormat format, size_t writableSamples)
 
std::shared_ptr< AudioFramegetToRing (AudioFormat format, size_t writableSamples)
 
void hardwareFormatAvailable (AudioFormat playback, size_t bufSize=0)
 Callback to be called by derived classes when the audio output is opened.
 
void hardwareInputFormatAvailable (AudioFormat capture)
 Set the input format on necessary objects.
 
void playbackChanged (bool started)
 
void putRecorded (std::shared_ptr< AudioFrame > &&frame)
 
void recordChanged (bool started)
 
void setHasNativeAEC (bool hasEAC)
 
void setHasNativeNS (bool hasNS)
 
- Protected Attributes inherited from jami::AudioLayer
AudioFormat audioFormat_
 Sample Rate that should be sent to the sound card.
 
AudioFormat audioInputFormat_
 Sample Rate for input.
 
double captureGain_
 Gain applied to mic signal.
 
bool hasNativeAEC_ {true}
 
bool hasNativeNS_ {false}
 
bool isCaptureMuted_
 True if capture is not to be used.
 
bool isPlaybackMuted_
 True if playback is not to be used.
 
bool isRingtoneMuted_ {false}
 True if ringtone should be muted.
 
std::shared_ptr< RingBuffermainRingBuffer_
 Buffers for audio processing.
 
std::mutex mutex_ {}
 Lock for the entire audio layer.
 
size_t nativeFrameSize_ {0}
 
double playbackGain_
 Gain applied to playback signal.
 
std::unique_ptr< AudioFrameResizerplaybackQueue_
 
bool playbackStarted_ {false}
 
const AudioPreferencepref_
 
bool recordStarted_ {false}
 
std::unique_ptr< Resamplerresampler_
 Manage sampling rate conversion.
 
std::condition_variable startedCv_
 
std::atomic< Statusstatus_ {Status::Idle}
 Whether or not the audio layer's playback stream is started.
 
RingBuffer urgentRingBuffer_
 Urgent ring buffer used for ringtones.
 

Detailed Description

Definition at line 107 of file pulselayer.h.

Constructor & Destructor Documentation

◆ PulseLayer()

jami::PulseLayer::PulseLayer ( AudioPreference pref)

Definition at line 55 of file pulselayer.cpp.

References jami::emitSignal(), JAMI_INFO, and jami::AudioLayer::setHasNativeNS().

Here is the call graph for this function:

◆ ~PulseLayer()

jami::PulseLayer::~PulseLayer ( )

Definition at line 100 of file pulselayer.cpp.

References jami::emitSignal(), jami::AudioLayer::playbackChanged(), and jami::AudioLayer::recordChanged().

Here is the call graph for this function:

Member Function Documentation

◆ getAudioDeviceIndex()

int jami::PulseLayer::getAudioDeviceIndex ( const std::string &  descr,
AudioDeviceType  type 
) const
virtual

Implements jami::AudioLayer.

Definition at line 256 of file pulselayer.cpp.

References jami::CAPTURE, jami::emitSignal(), JAMI_ERR, jami::PLAYBACK, and jami::RINGTONE.

Here is the call graph for this function:

◆ getAudioDeviceIndexByName()

int jami::PulseLayer::getAudioDeviceIndexByName ( const std::string &  name,
AudioDeviceType  type 
) const

Definition at line 277 of file pulselayer.cpp.

References jami::CAPTURE, JAMI_ERR, jami::PLAYBACK, and jami::RINGTONE.

◆ getAudioDeviceName()

std::string jami::PulseLayer::getAudioDeviceName ( int  index,
AudioDeviceType  type 
) const
virtual

Implements jami::AudioLayer.

Definition at line 335 of file pulselayer.cpp.

References jami::CAPTURE, jami::emitSignal(), JAMI_ERR, jami::PLAYBACK, and jami::RINGTONE.

Here is the call graph for this function:

◆ getCaptureDeviceList()

std::vector< std::string > jami::PulseLayer::getCaptureDeviceList ( ) const
virtual

Implements jami::AudioLayer.

Definition at line 236 of file pulselayer.cpp.

References jami::emitSignal().

Here is the call graph for this function:

◆ getPlaybackDeviceList()

std::vector< std::string > jami::PulseLayer::getPlaybackDeviceList ( ) const
virtual

Implements jami::AudioLayer.

Definition at line 246 of file pulselayer.cpp.

References jami::emitSignal().

Here is the call graph for this function:

◆ inSinkList()

bool jami::PulseLayer::inSinkList ( const std::string &  deviceName)

Definition at line 218 of file pulselayer.cpp.

◆ inSourceList()

bool jami::PulseLayer::inSourceList ( const std::string &  deviceName)

Definition at line 227 of file pulselayer.cpp.

◆ readFromMic()

void jami::PulseLayer::readFromMic ( )

Write data from the ring buffer to the hardware and read data from the hardware.

Definition at line 514 of file pulselayer.cpp.

References jami::emitSignal(), jami::libav_utils::fillWithSilence(), jami::AudioLayer::isCaptureMuted_, JAMI_ERR, and jami::AudioLayer::putRecorded().

Referenced by startStream().

Here is the call graph for this function:

◆ ringtoneToSpeaker()

void jami::PulseLayer::ringtoneToSpeaker ( )

Definition at line 543 of file pulselayer.cpp.

References jami::emitSignal(), jami::AudioLayer::getToRing(), and jami::AudioLayer::isRingtoneMuted_.

Referenced by startStream().

Here is the call graph for this function:

◆ startStream()

void jami::PulseLayer::startStream ( AudioDeviceType  stream = AudioDeviceType::ALL)
virtual

Start the capture stream and prepare the playback stream.

The playback starts accordingly to its threshold

Implements jami::AudioLayer.

Definition at line 427 of file pulselayer.cpp.

References jami::CAPTURE, jami::emitSignal(), jami::AudioPreference::getEchoCanceller(), jami::AudioLayer::mutex_, jami::PLAYBACK, readFromMic(), jami::RINGTONE, ringtoneToSpeaker(), jami::AudioLayer::setHasNativeAEC(), jami::AudioLayer::Started, jami::AudioLayer::startedCv_, jami::AudioLayer::status_, and writeToSpeaker().

Here is the call graph for this function:

◆ stopStream()

void jami::PulseLayer::stopStream ( AudioDeviceType  stream = AudioDeviceType::ALL)
virtual

Stop the playback and capture streams.

Drops the pending frames and put the capture and playback handles to PREPARED state

Implements jami::AudioLayer.

Definition at line 466 of file pulselayer.cpp.

References jami::ALL, jami::emitSignal(), jami::AudioLayer::Idle, jami::AudioLayer::mutex_, jami::PLAYBACK, jami::AudioLayer::playbackChanged(), jami::AudioLayer::startedCv_, and jami::AudioLayer::status_.

Here is the call graph for this function:

◆ updateServerInfo()

void jami::PulseLayer::updateServerInfo ( )

Definition at line 204 of file pulselayer.cpp.

References jami::emitSignal(), and JAMI_DBG.

Here is the call graph for this function:

◆ updateSinkList()

void jami::PulseLayer::updateSinkList ( )

Definition at line 170 of file pulselayer.cpp.

References jami::emitSignal(), JAMI_DBG, and jami::AudioFormat::nb_channels.

Here is the call graph for this function:

◆ updateSourceList()

void jami::PulseLayer::updateSourceList ( )

Definition at line 187 of file pulselayer.cpp.

References jami::emitSignal(), JAMI_DBG, and jami::AudioFormat::nb_channels.

Here is the call graph for this function:

◆ writeToSpeaker()

void jami::PulseLayer::writeToSpeaker ( )

Definition at line 491 of file pulselayer.cpp.

References jami::emitSignal(), jami::AudioLayer::getToPlay(), and jami::AudioLayer::isPlaybackMuted_.

Referenced by startStream().

Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ AudioLayerTest

friend class AudioLayerTest
friend

Definition at line 248 of file pulselayer.h.


The documentation for this class was generated from the following files: