Ocean
AVFMicrophone.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) Meta Platforms, Inc. and affiliates.
3
*
4
* This source code is licensed under the MIT license found in the
5
* LICENSE file in the root directory of this source tree.
6
*/
7
8
#ifndef META_OCEAN_MEDIA_AVF_MICROPHONE_H
9
#define META_OCEAN_MEDIA_AVF_MICROPHONE_H
10
11
#include "
ocean/media/avfoundation/AVFoundation.h
"
12
#include "
ocean/media/avfoundation/AVFMedium.h
"
13
14
#include "
ocean/media/Microphone.h
"
15
16
17
namespace
Ocean
18
{
19
20
namespace
Media
21
{
22
23
namespace
AVFoundation
24
{
25
26
/**
27
* This class implements an AVFoundation microphone object.
28
* @ingroup mediaavf
29
*/
30
class
AVFMicrophone
:
31
virtual
public
AVFMedium
,
32
virtual
public
Microphone
33
{
34
friend
class
AVFLibrary
;
35
36
protected
:
37
38
/**
39
* Definition of a vector holding sample elements.
40
*/
41
typedef
std::vector<int16_t>
Buffer
;
42
43
protected
:
44
45
/**
46
* Creates a new medium by a given url.
47
* @param url Url of the medium
48
*/
49
explicit
AVFMicrophone
(
const
std::string&
url
);
50
51
/**
52
* Destructs the media object.
53
*/
54
~AVFMicrophone
()
override
;
55
56
/**
57
* Internally starts the medium.
58
* @see AVFMedium::internalStart()
59
*/
60
bool
internalStart
()
override
;
61
62
/**
63
* Internally pauses the medium.
64
* @see AVFMedium::internalPause()
65
*/
66
bool
internalPause
()
override
;
67
68
/**
69
* Internally stops the medium.
70
* @see AVFMedium::internalStop()
71
*/
72
bool
internalStop
()
override
;
73
74
/**
75
* Extracts and sends mono samles form a PCM buffer.
76
* @param avAudioPCMBuffer The PCM buffer from which the samples will be extracted, must be valid
77
* @return True, if succeeded
78
*/
79
bool
sendSamplesMono
(AVAudioPCMBuffer* avAudioPCMBuffer);
80
81
protected
:
82
83
/// The audio engine.
84
AVAudioEngine*
avAudioEngine_
=
nullptr
;
85
86
/// Optional convert from external audio format to internal audio format.
87
AVAudioConverter*
avAudioConverter_
=
nullptr
;
88
89
/// Optional audio format for int16 samples.
90
AVAudioFormat*
avAudioFormatInternalInt16_
=
nullptr
;
91
92
/// Optional audio buffer for int16 samples.
93
AVAudioPCMBuffer*
avAudioPCMBufferInternalInt16_
=
nullptr
;
94
95
/// True, if the audio session was started.
96
bool
audioSessionStarted_
=
false
;
97
};
98
99
}
100
101
}
102
103
}
104
105
#endif
// META_OCEAN_MEDIA_AVF_MICROPHONE_H
AVFMedium.h
AVFoundation.h
Ocean::Media::AVFoundation::AVFLibrary
This class implements the AVFoundation library.
Definition:
AVFLibrary.h:32
Ocean::Media::AVFoundation::AVFMedium
This is the base class for all AVFoundation mediums.
Definition:
AVFMedium.h:36
Ocean::Media::AVFoundation::AVFMicrophone
This class implements an AVFoundation microphone object.
Definition:
AVFMicrophone.h:33
Ocean::Media::AVFoundation::AVFMicrophone::internalStart
bool internalStart() override
Internally starts the medium.
Ocean::Media::AVFoundation::AVFMicrophone::internalStop
bool internalStop() override
Internally stops the medium.
Ocean::Media::AVFoundation::AVFMicrophone::internalPause
bool internalPause() override
Internally pauses the medium.
Ocean::Media::AVFoundation::AVFMicrophone::avAudioEngine_
AVAudioEngine * avAudioEngine_
The audio engine.
Definition:
AVFMicrophone.h:84
Ocean::Media::AVFoundation::AVFMicrophone::Buffer
std::vector< int16_t > Buffer
Definition of a vector holding sample elements.
Definition:
AVFMicrophone.h:41
Ocean::Media::AVFoundation::AVFMicrophone::AVFMicrophone
AVFMicrophone(const std::string &url)
Creates a new medium by a given url.
Ocean::Media::AVFoundation::AVFMicrophone::~AVFMicrophone
~AVFMicrophone() override
Destructs the media object.
Ocean::Media::AVFoundation::AVFMicrophone::sendSamplesMono
bool sendSamplesMono(AVAudioPCMBuffer *avAudioPCMBuffer)
Extracts and sends mono samles form a PCM buffer.
Ocean::Media::AVFoundation::AVFMicrophone::audioSessionStarted_
bool audioSessionStarted_
True, if the audio session was started.
Definition:
AVFMicrophone.h:96
Ocean::Media::AVFoundation::AVFMicrophone::avAudioPCMBufferInternalInt16_
AVAudioPCMBuffer * avAudioPCMBufferInternalInt16_
Optional audio buffer for int16 samples.
Definition:
AVFMicrophone.h:93
Ocean::Media::AVFoundation::AVFMicrophone::avAudioFormatInternalInt16_
AVAudioFormat * avAudioFormatInternalInt16_
Optional audio format for int16 samples.
Definition:
AVFMicrophone.h:90
Ocean::Media::AVFoundation::AVFMicrophone::avAudioConverter_
AVAudioConverter * avAudioConverter_
Optional convert from external audio format to internal audio format.
Definition:
AVFMicrophone.h:87
Ocean::Media::Medium::url
const std::string & url() const
Returns the url of the medium.
Definition:
Medium.h:236
Ocean::Media::Microphone
This class is the base class for all microphones.
Definition:
media/Microphone.h:37
Microphone.h
Ocean
The namespace covering the entire Ocean framework.
Definition:
Accessor.h:15
impl
ocean
media
avfoundation
AVFMicrophone.h
Generated on Wed Nov 13 2024 18:48:16 for Ocean by
1.9.1