Ocean
Ocean::Media::Android::AMicrophone Class Referencefinal

This class implements a microphone class for Android. More...

Inheritance diagram for Ocean::Media::Android::AMicrophone:

Public Member Functions

bool start () override
 Starts the medium. More...
 
bool pause () override
 Pauses the medium. More...
 
bool stop () override
 Stops the medium. More...
 
bool isStarted () const override
 Returns whether the medium is started currently. More...
 
Timestamp startTimestamp () const override
 Returns the start timestamp. More...
 
Timestamp pauseTimestamp () const override
 Returns the pause timestamp. More...
 
Timestamp stopTimestamp () const override
 Returns the stop timestamp. More...
 
- Public Member Functions inherited from Ocean::Media::Medium
const std::string & url () const
 Returns the url of the medium. More...
 
bool isValid () const
 Returns whether the medium is valid. More...
 
const std::string & library () const
 Returns the name of the owner library. More...
 
Type type () const
 Returns the type of the medium. More...
 
bool isType (const Type type) const
 Returns whether a medium has a given type. More...
 
bool isExclusive () const
 Returns whether this medium can be use exclusively. More...
 
virtual MediumRef clone () const
 Clones this medium and returns a new independent instance of this medium. More...
 
- Public Member Functions inherited from Ocean::Media::Microphone
virtual MicrophoneTypes microphoneTypes () const
 Returns the type of this microphone. More...
 
virtual MicrophoneConfigurations microphoneConfigurations () const
 Returns the configuration of this microphone. More...
 
virtual SamplesScopedSubscription addSamplesCallback (SamplesCallbackFunction samplesCallbackFunction)
 Adds a new callback function for samples events. More...
 
- Public Member Functions inherited from Ocean::Media::ConfigMedium
virtual bool configuration (const std::string &name, long long data)
 Starts a configuration possibility. More...
 
virtual ConfigNames configs () const
 Returns the names of the configuration possibilities. More...
 

Static Public Member Functions

static constexpr size_t monoChunkElements ()
 Returns the size of one mono chunk in elements. More...
 
- Static Public Member Functions inherited from Ocean::Media::Android::AMedium
static bool areInterfaceIdsIdentical (const SLInterfaceID &interfaceId0, const SLInterfaceID &interfaceId1)
 Returns whether two interface ids are identical. More...
 
static std::string toAString (const SLInterfaceID &interfaceId)
 Returns the hex string of an interface id,. More...
 
- Static Public Member Functions inherited from Ocean::Media::Medium
static std::string convertType (const Type type)
 Converts a medium type to a unique string. More...
 
static Type convertType (const std::string &type)
 Converts a medium type string to a medium type. More...
 

Protected Types

typedef std::vector< int16_t > Buffer
 Definition of a vector holding sample elements. More...
 
- Protected Types inherited from Ocean::Media::Microphone
using SamplesCallbackHandler = ScopedSubscriptionCallbackHandlerT< SamplesCallbackFunction, Microphone, true >
 Definition of a subscription handler for voip samples events. More...
 

Protected Member Functions

 AMicrophone (const SLEngineItf &slEngineInterface, const std::string &url)
 Creates a new medium by a given url. More...
 
 ~AMicrophone () override
 Destructs the live video object. More...
 
bool initialize (const SLEngineItf &slEngineInterface, const MicrophoneTypes microphoneTypes, const MicrophoneConfigurations microphoneConfigurations)
 Initializes the audio and all corresponding resources. More...
 
bool release ()
 Releases the audio and all corresponding resources. More...
 
void onFillBufferQueueCallback (SLAndroidSimpleBufferQueueItf bufferQueue)
 Event callback function to fill the OpenSL buffer queue. More...
 
- Protected Member Functions inherited from Ocean::Media::Android::AMedium
 AMedium (const std::string &url)
 Creates a new medium by a given url. More...
 
- Protected Member Functions inherited from Ocean::Media::Medium
 Medium (const Medium &medium)=delete
 Disabled copy constructor. More...
 
 Medium (const std::string &url)
 Creates a new medium by a given url. More...
 
virtual ~Medium ()
 Destructs a medium. More...
 
Mediumoperator= (const Medium &medium)=delete
 Disabled copy operator. More...
 
- Protected Member Functions inherited from Ocean::Media::Microphone
 Microphone (const std::string &url)
 Creates a new microphone by a given url. More...
 
void sendSamples (const SamplesType samplesType, const void *data, const size_t size)
 Sends samples to all subscribed callback functions. More...
 
- Protected Member Functions inherited from Ocean::Media::LiveMedium
 LiveMedium (const std::string &url)
 Creates a new live medium by a given url. More...
 
- Protected Member Functions inherited from Ocean::Media::ConfigMedium
 ConfigMedium (const std::string &url)
 Creates a new ConfigMedium object by a given url. More...
 

Static Protected Member Functions

static void onFillBufferQueueCallback (SLAndroidSimpleBufferQueueItf bufferQueue, void *context)
 Static event callback function to fill the OpenSL buffer queue. More...
 

Protected Attributes

Timestamp startTimestamp_ = Timestamp(false)
 Start timestamp. More...
 
Timestamp pauseTimestamp_ = Timestamp(false)
 Pause timestamp. More...
 
Timestamp stopTimestamp_ = Timestamp(false)
 Stop timestamp. More...
 
SLObjectItf slRecorder_ = nullptr
 The SL recorder object. More...
 
SLRecordItf slRecordInterface_ = nullptr
 The SL recorder interface. More...
 
SLAndroidSimpleBufferQueueItf slBufferQueueInterface_ = nullptr
 THe SL buffer queue interface. More...
 
std::queue< BufferbufferQueue_
 The buffer for the sample queue. More...
 
SLAndroidEffectItf slAcousticEchoCancelEffect_ = nullptr
 The SL effect interface for the acoustic echo cancel effect. More...
 
SLInterfaceID slAcousticEchoCancelerEffectImplementationId_ = nullptr
 The SL implementation id of the acoustic echo cancel effect. More...
 
- Protected Attributes inherited from Ocean::Media::Medium
std::string url_
 Url of the medium. More...
 
std::string libraryName_
 Name of the owner library. More...
 
bool isValid_ = false
 Determines whether the medium is valid. More...
 
Type type_ = MEDIUM
 Type of the medium. More...
 
Lock lock_
 Medium lock. More...
 
- Protected Attributes inherited from Ocean::Media::Microphone
MicrophoneTypes microphoneTypes_ = MT_UNKNOWN
 The microphone's types. More...
 
MicrophoneConfigurations microphoneConfigurations_ = MC_DEFAULT
 The microphone's configurations. More...
 
SamplesCallbackHandler samplesCallbackHandler_
 The handler for samples callback functions. More...
 

Static Protected Attributes

static constexpr SLuint32 numberBuffers_ = 4u
 The number of buffers in the queue. More...
 

Friends

class ALibrary
 

Additional Inherited Members

- Public Types inherited from Ocean::Media::Medium
enum  Type : uint32_t {
  MEDIUM = 0u , FRAME_MEDIUM = 1u << 0u , SOUND_MEDIUM = 1u << 1u , FINITE_MEDIUM = 1u << 2u ,
  LIVE_MEDIUM = 1u << 3u , CONFIG_MEDIUM = 1u << 4u , AUDIO = (1u << 5u) | FINITE_MEDIUM | SOUND_MEDIUM , IMAGE = (1u << 6u) | FRAME_MEDIUM ,
  PIXEL_IMAGE = (1u << 7u) | FRAME_MEDIUM , BUFFER_IMAGE = (1u << 8u) | FRAME_MEDIUM , IMAGE_SEQUENCE = (1u << 9u) | FRAME_MEDIUM | FINITE_MEDIUM , LIVE_AUDIO = (1u << 10u) | LIVE_MEDIUM | SOUND_MEDIUM ,
  LIVE_VIDEO = (1u << 11u) | LIVE_MEDIUM | FRAME_MEDIUM , MICROPHONE = (1u << 12u) | LIVE_MEDIUM , MOVIE = (1u << 13u) | FINITE_MEDIUM | FRAME_MEDIUM | SOUND_MEDIUM
}
 Definition of different medium types. More...
 
- Public Types inherited from Ocean::Media::Microphone
enum  MicrophoneTypes : uint32_t { MT_UNKNOWN = 0u , MT_BUILTIN = 1u << 0u , MT_EXTERNAL = 1u << 1u , MT_ANY = MT_BUILTIN | MT_EXTERNAL }
 Definition of individual microphone types. More...
 
enum  MicrophoneConfigurations : uint32_t { MC_DEFAULT = 0u , MC_VOICE_COMMUNICATION = 1u << 0u , MC_PERFORMANCE = 1u << 1u , MC_GAINED = 1u << 2u }
 Definition of individual microphone configurations. More...
 
enum  SamplesType : uint32_t { ST_INVALID = 0u , ST_INTEGER_16_MONO_48 }
 Definition of individual samples types. More...
 
using SamplesCallbackFunction = std::function< void(const SamplesType samplesType, const void *data, const size_t size)>
 Definition of a callback function for microphone samples. More...
 
using SamplesScopedSubscription = ScopedSubscriptionHandler::ScopedSubscriptionType
 Definition of a subscription object for microphone samples. More...
 
- Public Types inherited from Ocean::Media::ConfigMedium
typedef std::vector< std::string > ConfigNames
 Definition of a vector holding configuration names. More...
 
- Static Public Attributes inherited from Ocean::Media::Android::AMedium
static constexpr SLInterfaceID_ slEffectTypeNoiseSuppressorId_ = {0x58b4b260, 0x8e06, 0x11e0, 0xaa8e, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}
 Definition of the interface for Noise Suppressor (NS). More...
 
static constexpr SLInterfaceID_ slEffectTypeAcousticEchoCancelerId_ = {0x7b491460, 0x8d4d, 0x11e0, 0xbd61, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}
 Definition of the interface for Acoustic Echo Canceler (AEC). More...
 

Detailed Description

This class implements a microphone class for Android.

Member Typedef Documentation

◆ Buffer

typedef std::vector<int16_t> Ocean::Media::Android::AMicrophone::Buffer
protected

Definition of a vector holding sample elements.

Constructor & Destructor Documentation

◆ AMicrophone()

Ocean::Media::Android::AMicrophone::AMicrophone ( const SLEngineItf &  slEngineInterface,
const std::string &  url 
)
protected

Creates a new medium by a given url.

Parameters
slEngineInterfaceThe interface of the SL engine, must be valid
urlUrl of the medium

◆ ~AMicrophone()

Ocean::Media::Android::AMicrophone::~AMicrophone ( )
overrideprotected

Destructs the live video object.

Member Function Documentation

◆ initialize()

bool Ocean::Media::Android::AMicrophone::initialize ( const SLEngineItf &  slEngineInterface,
const MicrophoneTypes  microphoneTypes,
const MicrophoneConfigurations  microphoneConfigurations 
)
protected

Initializes the audio and all corresponding resources.

Parameters
slEngineInterfaceThe interface of the SL engine, must be valid
microphoneTypesThe types of the microphone to create
microphoneConfigurationsThe configurations of the microphone to create
Returns
True, if succeeded

◆ isStarted()

bool Ocean::Media::Android::AMicrophone::isStarted ( ) const
overridevirtual

Returns whether the medium is started currently.

See also
Medium::isStarted().

Implements Ocean::Media::Medium.

◆ monoChunkElements()

constexpr size_t Ocean::Media::Android::AMicrophone::monoChunkElements ( )
staticconstexpr

Returns the size of one mono chunk in elements.

Returns
The size of one mono chunk, in elements

◆ onFillBufferQueueCallback() [1/2]

void Ocean::Media::Android::AMicrophone::onFillBufferQueueCallback ( SLAndroidSimpleBufferQueueItf  bufferQueue)
protected

Event callback function to fill the OpenSL buffer queue.

Parameters
bufferQueueThe buffer queue to fill with the next samples, must be valid

◆ onFillBufferQueueCallback() [2/2]

static void Ocean::Media::Android::AMicrophone::onFillBufferQueueCallback ( SLAndroidSimpleBufferQueueItf  bufferQueue,
void *  context 
)
staticprotected

Static event callback function to fill the OpenSL buffer queue.

Parameters
bufferQueueThe buffer queue to fill with the next samples, must be valid
contextThe context of the event (the ALiveAudio object), must be valid

◆ pause()

bool Ocean::Media::Android::AMicrophone::pause ( )
overridevirtual

Pauses the medium.

See also
Medium::pause():

Implements Ocean::Media::Medium.

◆ pauseTimestamp()

Timestamp Ocean::Media::Android::AMicrophone::pauseTimestamp ( ) const
overridevirtual

Returns the pause timestamp.

See also
FiniteMedium::pauseTimestamp().

Implements Ocean::Media::Medium.

◆ release()

bool Ocean::Media::Android::AMicrophone::release ( )
protected

Releases the audio and all corresponding resources.

Returns
True, if succeeded

◆ start()

bool Ocean::Media::Android::AMicrophone::start ( )
overridevirtual

Starts the medium.

See also
Medium::start().

Implements Ocean::Media::Medium.

◆ startTimestamp()

Timestamp Ocean::Media::Android::AMicrophone::startTimestamp ( ) const
overridevirtual

Returns the start timestamp.

See also
FiniteMedium::startTimestamp().

Implements Ocean::Media::Medium.

◆ stop()

bool Ocean::Media::Android::AMicrophone::stop ( )
overridevirtual

Stops the medium.

See also
Medium::stop().

Implements Ocean::Media::Medium.

◆ stopTimestamp()

Timestamp Ocean::Media::Android::AMicrophone::stopTimestamp ( ) const
overridevirtual

Returns the stop timestamp.

See also
FiniteMedium::stopTimestamp().

Implements Ocean::Media::Medium.

Friends And Related Function Documentation

◆ ALibrary

friend class ALibrary
friend

Field Documentation

◆ bufferQueue_

std::queue<Buffer> Ocean::Media::Android::AMicrophone::bufferQueue_
protected

The buffer for the sample queue.

◆ numberBuffers_

constexpr SLuint32 Ocean::Media::Android::AMicrophone::numberBuffers_ = 4u
staticconstexprprotected

The number of buffers in the queue.

◆ pauseTimestamp_

Timestamp Ocean::Media::Android::AMicrophone::pauseTimestamp_ = Timestamp(false)
protected

Pause timestamp.

◆ slAcousticEchoCancelEffect_

SLAndroidEffectItf Ocean::Media::Android::AMicrophone::slAcousticEchoCancelEffect_ = nullptr
protected

The SL effect interface for the acoustic echo cancel effect.

◆ slAcousticEchoCancelerEffectImplementationId_

SLInterfaceID Ocean::Media::Android::AMicrophone::slAcousticEchoCancelerEffectImplementationId_ = nullptr
protected

The SL implementation id of the acoustic echo cancel effect.

◆ slBufferQueueInterface_

SLAndroidSimpleBufferQueueItf Ocean::Media::Android::AMicrophone::slBufferQueueInterface_ = nullptr
protected

THe SL buffer queue interface.

◆ slRecorder_

SLObjectItf Ocean::Media::Android::AMicrophone::slRecorder_ = nullptr
protected

The SL recorder object.

◆ slRecordInterface_

SLRecordItf Ocean::Media::Android::AMicrophone::slRecordInterface_ = nullptr
protected

The SL recorder interface.

◆ startTimestamp_

Timestamp Ocean::Media::Android::AMicrophone::startTimestamp_ = Timestamp(false)
protected

Start timestamp.

◆ stopTimestamp_

Timestamp Ocean::Media::Android::AMicrophone::stopTimestamp_ = Timestamp(false)
protected

Stop timestamp.


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