Skip to content

AudioStreamingLib APIs

antonypro edited this page Jun 27, 2019 · 9 revisions

Summary

Members Descriptions
class AudioStreamingLibCore The AudioStreamingLibCore class is the bridge between your app and the internals of the AudioStreamingLib.
class AudioStreamingLibInfo The AudioStreamingLibInfo class contains most settings of the library. This class replaces StreamingInfo.

class AudioStreamingLibCore

class AudioStreamingLibCore
  : public QObject

The AudioStreamingLibCore class is the bridge between your app and the internals of the AudioStreamingLib.

Summary

Members Descriptions
public explicit AudioStreamingLibCore(QObject * parent) Creates the instance.
public ~AudioStreamingLibCore() Destroys the instance.
{signal} public void connected(QHostAddress,QString) Tells that a new connection is done and inform the address and the ID.
{signal} public void connectedToServer(QByteArray) Tells that a connection with the WebServer is done and return the SHA-256 hash code of the server certificate.
{signal} public void disconnected(QHostAddress) Tells that are a client asking for permission to connect.
{signal} public void pending(QHostAddress,QString) Tells some peer was disconnected and the address.
{signal} public void webClientLoggedIn() Client successfully logged to server.
{signal} public void webClientWarning(QString) Warning gave by server.
{signal} public void inputData(QByteArray) Receive the input data if callback mode is enabled.
{signal} public void veryInputData(QByteArray) Receive the input data if setGetAudioEnabled() mode is enabled. No need to feedback.
{signal} public void outputData(QByteArray) Receive the output data if callback mode is enabled.
{signal} public void veryOutputData(QByteArray) Receive the output data if setGetAudioEnabled() mode is enabled. No need to feedback.
{signal} public void extraData(QByteArray) Receive the extra data.
{signal} public void inputLevel(float) Input level as float in range 0 to 1.0.
{signal} public void outputLevel(float) Output level as float in range 0 to 1.0.
{signal} public void adjustSettings() The audio settings is ready to being used.
{signal} public void extraDataWritten() SIGNAL used to tell that the all peers have called writeExtraDataResult().
{signal} public void finished() The library has stopped.
{signal} public void commandXML(QByteArray) Got an XML command from WebServer.
{signal} public void warning(QString) The library has generated a warning, but not stopped.
{signal} public void error(QString) The library has stopped due to an error.
{slot} public bool start(const AudioStreamingLibInfo & streaming_info) Initialize the library with the given AudioStreamingLibInfo settings.
{slot} public void stop() Stops the library, note that is called by destructor.
{slot} public bool isRunning() Verify if library is currently running.
{slot} public void changeInputDevice(const QAudioDeviceInfo & dev_info) If some input device is already running, change the input device to dev_info.
{slot} public void changeOutputDevice(const QAudioDeviceInfo & dev_info) If some output device is already running, change the output device to dev_info.
{slot} public DiscoverClient * discoverInstance(int time_to_destroy) Create an instance of a class for searching peers on local network and returns a pointer to this instance.
{slot} public void listen(quint16 port,bool auto_accept,const QByteArray & password,int max_connections) Start listening state
{slot} public void connectToHost(const QString & host,quint16 port,const QByteArray & password) Starts the connection with the given host, port, and password if in Encrypted mode.
{slot} public void writeCommandXML(const QByteArray & XML) Write command to WebServer in XML format.
{slot} public void connectToPeer(const QString & ID) Asks the WebServer to start a conversation with the specified ID.
{slot} public void disconnectFromPeer() Disconnect from conversation with peer.
{slot} public void acceptConnection() Accept new pending connection in response to pending() SIGNAL.
{slot} public void rejectConnection() Reject new pending connection in response to pending() SIGNAL.
{slot} public void acceptSslCertificate() Accepts the certificate gave by WebServer.
{slot} public void writeExtraData(const QByteArray & data) Writes extra data from server to all connections or from client to server.
{slot} public void writeExtraDataResult() Tells to another side of connection that the extra data was received and the client or server is ready to receive more.
{slot} public void inputDataBack(const QByteArray & data) If callback mode is enabled this function is used to feed back the input with data.
{slot} public void outputDataBack(const QByteArray & data) If callback mode is enabled this function is used to feed back the output with data.
{slot} public bool isInputMuted() Tells if input audio is currently muted.
{slot} public void setInputMuted(bool mute) Mute the audio input.
{slot} public int volume() Returns the current output volume.
{slot} public void setVolume(int volume) Set the output volume with 0 as mute and 100 the loudest volume with attenuation and 150 with attenuation ignored.
{slot} public AudioStreamingLibInfo audioStreamingLibInfo() Returns a copy of current state of the AudioStreamingLibInfo class.
{slot} public QList< QHostAddress > connectionsList() Returns a list of connected clients only useful in server mode.
{slot} public bool isReadyToWriteExtraData() Tell if writeExtraDataResult was called by all clients or by server and it's ready for subsequent extra data.
{slot} public QAudioFormat audioFormat() Function to query the audio format used after the re sampler and used with Opus codec, if not using Opus, this will be always the same as inputAudioFormat().
{slot} public QAudioFormat inputAudioFormat() Function to query the audio format used to feed the input data, may be different than audioFormat() if using Opus codec.

Members

public explicit AudioStreamingLibCore(QObject * parent)

Creates the instance.

Destroys the instance.

{signal} public void connected(QHostAddress,QString)

Tells that a new connection is done and inform the address and the ID.

{signal} public void connectedToServer(QByteArray)

Tells that a connection with the WebServer is done and return the SHA-256 hash code of the server certificate.

{signal} public void disconnected(QHostAddress)

Tells that are a client asking for permission to connect.

Answer calling acceptConnection() to accept or rejectConnection() to reject.

{signal} public void pending(QHostAddress,QString)

Tells some peer was disconnected and the address.

{signal} public void webClientLoggedIn()

Client successfully logged to server.

{signal} public void webClientWarning(QString)

Warning gave by server.

{signal} public void inputData(QByteArray)

Receive the input data if callback mode is enabled.

Note: Remember that you need to feedback the data by calling inputDataBack().

{signal} public void veryInputData(QByteArray)

Receive the input data if setGetAudioEnabled() mode is enabled. No need to feedback.

{signal} public void outputData(QByteArray)

Receive the output data if callback mode is enabled.

Note: Remember that you need to feedback the data by calling outputDataBack() if you configured to play audio.

{signal} public void veryOutputData(QByteArray)

Receive the output data if setGetAudioEnabled() mode is enabled. No need to feedback.

This SIGNAL returns audio data immediately before volume is applied to samples and the audio being played.

{signal} public void extraData(QByteArray)

Receive the extra data.

{signal} public void inputLevel(float)

Input level as float in range 0 to 1.0.

{signal} public void outputLevel(float)

Output level as float in range 0 to 1.0.

{signal} public void adjustSettings()

The audio settings is ready to being used.

To get the settings call audioFormat() and inputAudioFormat().

{signal} public void extraDataWritten()

SIGNAL used to tell that the all peers have called writeExtraDataResult().

{signal} public void finished()

The library has stopped.

{signal} public void commandXML(QByteArray)

Got an XML command from WebServer.

{signal} public void warning(QString)

The library has generated a warning, but not stopped.

{signal} public void error(QString)

The library has stopped due to an error.

Most times a description of the error is available, otherwise the error is empty.

{slot} public bool start(const AudioStreamingLibInfo & streaming_info)

Initialize the library with the given AudioStreamingLibInfo settings.

{slot} public void stop()

Stops the library, note that is called by destructor.

{slot} public bool isRunning()

Verify if library is currently running.

{slot} public void changeInputDevice(const QAudioDeviceInfo & dev_info)

If some input device is already running, change the input device to dev_info.

{slot} public void changeOutputDevice(const QAudioDeviceInfo & dev_info)

If some output device is already running, change the output device to dev_info.

{slot} public DiscoverClient * discoverInstance(int time_to_destroy)

Create an instance of a class for searching peers on local network and returns a pointer to this instance.

It will be auto deleted before time_to_destroy time elapsed(minimum accepted value 1000 ms), also calling the function while discover client instance is running will delete the instance and return a pointer to a new instance.

{slot} public void listen(quint16 port,bool auto_accept,const QByteArray & password,int max_connections)

Start listening state

Start listening state with the given port, auto accept connections choice, optional password and maximum connections (Walkie Talkie Server ignore this option and always accepts only one connection).

Note: this must be called after calling start() with some server work mode option.

{slot} public void connectToHost(const QString & host,quint16 port,const QByteArray & password)

Starts the connection with the given host, port, and password if in Encrypted mode.

Also used to connect to the WebServer.

Note: this must be called after calling start() with some client work mode option.

{slot} public void writeCommandXML(const QByteArray & XML)

Write command to WebServer in XML format.

{slot} public void connectToPeer(const QString & ID)

Asks the WebServer to start a conversation with the specified ID.

{slot} public void disconnectFromPeer()

Disconnect from conversation with peer.

Note: this does not disconnect you from the WebServer. And once time disconnected from some peer you can call or receive calling requests from another peer.

{slot} public void acceptConnection()

Accept new pending connection in response to pending() SIGNAL.

{slot} public void rejectConnection()

Reject new pending connection in response to pending() SIGNAL.

{slot} public void acceptSslCertificate()

Accepts the certificate gave by WebServer.

{slot} public void writeExtraData(const QByteArray & data)

Writes extra data from server to all connections or from client to server.

{slot} public void writeExtraDataResult()

Tells to another side of connection that the extra data was received and the client or server is ready to receive more.

{slot} public void inputDataBack(const QByteArray & data)

If callback mode is enabled this function is used to feed back the input with data.

{slot} public void outputDataBack(const QByteArray & data)

If callback mode is enabled this function is used to feed back the output with data.

{slot} public bool isInputMuted()

Tells if input audio is currently muted.

{slot} public void setInputMuted(bool mute)

Mute the audio input.

{slot} public int volume()

Returns the current output volume.

{slot} public void setVolume(int volume)

Set the output volume with 0 as mute and 100 the loudest volume with attenuation and 150 with attenuation ignored.

Returns a copy of current state of the AudioStreamingLibInfo class.

{slot} public QList< QHostAddress > connectionsList()

Returns a list of connected clients only useful in server mode.

{slot} public bool isReadyToWriteExtraData()

Tell if writeExtraDataResult was called by all clients or by server and it's ready for subsequent extra data.

{slot} public QAudioFormat audioFormat()

Function to query the audio format used after the re sampler and used with Opus codec, if not using Opus, this will be always the same as inputAudioFormat().

{slot} public QAudioFormat inputAudioFormat()

Function to query the audio format used to feed the input data, may be different than audioFormat() if using Opus codec.

class AudioStreamingLibInfo

The AudioStreamingLibInfo class contains most settings of the library. This class replaces StreamingInfo.

Note: You should not keep a copy of it, when needed request it by calling audioStreamingLibInfo() function of the AudioStreamingLibCore class.

Summary

Members Descriptions
public inline AudioStreamingLibInfo() Creates the instance and initialize variables.
public inline void setNegotiationString(const QByteArray & negotiation_string) Use this function to prevent conflicts of different applications accessing the library by the same port, search for servers conflicts are also avoided if set the negotiation string.
public inline void setID(const QString & id) ID is a friendly name that identifies you.
public inline void setWorkMode(const StreamingWorkMode & work_mode) Sets the work mode of the library.
public inline void setTimeToBuffer(qint32 ms_time) Sets the output audio time to buffer. To play with the lowest delay set it to 0.
public inline void setInputDeviceType(const AudioDeviceType & input_type) Define if using the internal audio input device, or ignore it and feed input with other data, most useful with callbacks enabled.
public inline void setOutputDeviceType(const AudioDeviceType & output_type) Define if using the internal audio output device, or ignore it and play output with other output device or not play it at all, also useful with callbacks enabled for recording audio without playing it.
public inline void setInputAudioFormat(const QAudioFormat & format) Sets the audio input format.
public inline void setAudioFormat(const QAudioFormat & format) Set the audio format after resampling if using Opus, otherwise equals to audio format.
public inline void setInputDeviceInfo(const QAudioDeviceInfo & dev_info) If using LibraryAudioDevice set the specific input device.
public inline void setOutputDeviceInfo(const QAudioDeviceInfo & dev_info) If using LibraryAudioDevice set the specific output device.
public inline void setOpusBitrate(int bitrate) Sets Opus bitrate, if not using Opus this value is undefined.
public inline void setCallBackEnabled(bool enable) Enable callback input and output audio data, you’ll receive the audio through the SIGNALS inputData() and outputData() and can process the audio and write the audio back with the functions inputDataBack() and outputDataBack().
public inline void setGetAudioEnabled(bool enable) Enable get audio input and output, if using Opus returns input audio after resampler in the veryInputData() SIGNAL, and output audio immediately before play audio, in the veryOutputData() SIGNAL.
public inline void setListenAudioInputEnabled(bool enable) If enabled this route the input audio data to the output device, so you can listen what you are streaming.
public inline void setEncryptionEnabled(bool enable) Sets if encryption is enabled or not, note that the OpenSsl must be available to successfully start an encrypted server or client.

Members

public inline AudioStreamingLibInfo()

Creates the instance and initialize variables.

public inline void setNegotiationString(const QByteArray & negotiation_string)

Use this function to prevent conflicts of different applications accessing the library by the same port, search for servers conflicts are also avoided if set the negotiation string.

Note that the maximum value is 128 bytes.

public inline void setID(const QString & id)

ID is a friendly name that identifies you.

Note that the maximum length is 20.

public inline void setWorkMode(const StreamingWorkMode & work_mode)

Sets the work mode of the library.

The possible values are:

Undefined
BroadcastClient
BroadcastServer
WalkieTalkieClient
WalkieTalkieServer
WebClient

The default value is Undefined.

public inline void setTimeToBuffer(qint32 ms_time)

Sets the output audio time to buffer. To play with the lowest delay set it to 0.

Note: If you set a value lower than 10 ms it will be reduced to 0 internally.

public inline void setInputDeviceType(const AudioDeviceType & input_type)

Define if using the internal audio input device, or ignore it and feed input with other data, most useful with callbacks enabled.

The possible values are:

LibraryAudioDevice
CustomAudioDevice

The default is LibraryAudioDevice.

public inline void setOutputDeviceType(const AudioDeviceType & output_type)

Define if using the internal audio output device, or ignore it and play output with other output device or not play it at all, also useful with callbacks enabled for recording audio without playing it.

The possible values are:

LibraryAudioDevice
CustomAudioDevice

The default is LibraryAudioDevice.

public inline void setInputAudioFormat(const QAudioFormat & format)

Sets the audio input format.

Only use if in server mode, in client mode it will be got by the server.

public inline void setAudioFormat(const QAudioFormat & format)

Set the audio format after resampling if using Opus, otherwise equals to audio format.

DO NOT change this setting, it will be automatically filled in client/server modes based on input audio format.

public inline void setInputDeviceInfo(const QAudioDeviceInfo & dev_info)

If using LibraryAudioDevice set the specific input device.

public inline void setOutputDeviceInfo(const QAudioDeviceInfo & dev_info)

If using LibraryAudioDevice set the specific output device.

public inline void setOpusBitrate(int bitrate)

Sets Opus bitrate, if not using Opus this value is undefined.

public inline void setCallBackEnabled(bool enable)

Enable callback input and output audio data, you’ll receive the audio through the SIGNALS inputData() and outputData() and can process the audio and write the audio back with the functions inputDataBack() and outputDataBack().

public inline void setGetAudioEnabled(bool enable)

Enable get audio input and output, if using Opus returns input audio after resampler in the veryInputData() SIGNAL, and output audio immediately before play audio, in the veryOutputData() SIGNAL.

public inline void setListenAudioInputEnabled(bool enable)

If enabled this route the input audio data to the output device, so you can listen what you are streaming.

Note: this function have effect only in BroadcastServer mode!

public inline void setEncryptionEnabled(bool enable)

Sets if encryption is enabled or not, note that the OpenSsl must be available to successfully start an encrypted server or client.

Generated by Moxygen

Clone this wiki locally