Skip to content

Commit

Permalink
move get audio capture to CapturerFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
mpromonet committed Jul 18, 2021
1 parent 4922c95 commit 1c68cb6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 15 deletions.
3 changes: 2 additions & 1 deletion .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"configurations": [
{
"name": "default",
"includePath": [
"${workspaceFolder}/**",
"/${workspaceFolder}/../webrtc/src"
"${workspaceFolder}/../webrtc/src"
],
"intelliSenseMode": "linux-gcc-x64",
"compilerPath": "/usr/bin/gcc",
Expand Down
21 changes: 21 additions & 0 deletions inc/CapturerFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,27 @@ class CapturerFactory {
return videoSource;
}

static const std::list<std::string> GetAudioCaptureDeviceList(const std::regex & publishFilter, rtc::scoped_refptr<webrtc::AudioDeviceModule> audioDeviceModule) {
std::list<std::string> audioList;
if (std::regex_match("audiocap://", publishFilter))
{
int16_t num_audioDevices = audioDeviceModule->RecordingDevices();
RTC_LOG(INFO) << "nb audio devices:" << num_audioDevices;

for (int i = 0; i < num_audioDevices; ++i)
{
char name[webrtc::kAdmMaxDeviceNameSize] = {0};
char id[webrtc::kAdmMaxGuidSize] = {0};
if (audioDeviceModule->RecordingDeviceName(i, name, id) != -1)
{
RTC_LOG(INFO) << "audio device name:" << name << " id:" << id;
audioList.push_back(name);
}
}
}
return audioList;
}

static rtc::scoped_refptr<webrtc::AudioSourceInterface> CreateAudioSource(const std::string & audiourl,
const std::map<std::string,std::string> & opts,
const std::regex & publishFilter,
Expand Down
17 changes: 3 additions & 14 deletions src/PeerConnectionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,21 +410,10 @@ const Json::Value PeerConnectionManager::getAudioDeviceList()
{
Json::Value value(Json::arrayValue);

if (std::regex_match("audiocap://", m_publishFilter))
const std::list<std::string> audioCaptureDevice = CapturerFactory::GetAudioCaptureDeviceList(m_publishFilter, m_audioDeviceModule);
for (auto audioDevice : audioCaptureDevice)
{
int16_t num_audioDevices = m_audioDeviceModule->RecordingDevices();
RTC_LOG(INFO) << "nb audio devices:" << num_audioDevices;

for (int i = 0; i < num_audioDevices; ++i)
{
char name[webrtc::kAdmMaxDeviceNameSize] = {0};
char id[webrtc::kAdmMaxGuidSize] = {0};
if (m_audioDeviceModule->RecordingDeviceName(i, name, id) != -1)
{
RTC_LOG(INFO) << "audio device name:" << name << " id:" << id;
value.append(name);
}
}
value.append(audioDevice);
}

return value;
Expand Down

0 comments on commit 1c68cb6

Please sign in to comment.