void StreamingControlWidget::StartVoiceStreaming()
{
    AudioDevices tList = mAudioWorker->GetPossibleDevices();
    AudioDevices::iterator tIt;
    QString tSelectedDevice = "";

    for (tIt = tList.begin(); tIt != tList.end(); tIt++)
    {
        if (tIt->Type == Microphone)
        {
            tSelectedDevice = QString(tIt->Name.c_str());
            break;
        }
    }

    // found something?
    if (tSelectedDevice == "")
    {
        ShowWarning("Missing microphone", "No microphone available. Please, select another source!");
        return;
    }

    LOG(LOG_VERBOSE, "Selecting %s", tSelectedDevice.toStdString().c_str());

    mAudioWorker->SetCurrentDevice(tSelectedDevice);
}
Beispiel #2
0
void DevSetup::loadAudioDevices (AudioDevices const& d, QComboBox * cb, QAudioDeviceInfo const& device, QAudioDeviceInfo const& defaultDevice)
{
  using std::copy;
  using std::back_inserter;

  int currentIndex = -1;
  int defaultIndex = 0;
  for (AudioDevices::const_iterator p = d.cbegin (); p != d.cend (); ++p)
    {
      // convert supported channel counts into something we can store in the item model
      QList<QVariant> channelCounts;
      QList<int> scc (p->supportedChannelCounts ());
      copy (scc.cbegin (), scc.cend (), back_inserter (channelCounts));

      cb->addItem (p->deviceName (), channelCounts);
      if (*p == device)
	{
	  currentIndex = p - d.cbegin ();
	}
      else if (*p == defaultDevice)
	{
	  defaultIndex = p - d.cbegin ();
	}
    }
  cb->setCurrentIndex (currentIndex != -1 ? currentIndex : defaultIndex);
}
void WaveOutPulseAudio::getAudioDevices(AudioDevices &pAList)
{
    // This is where we'll store the input device list
    PulseAudioDeviceDescriptor tInputDevicesList[MAX_PULSEAUDIO_DEVICES_IN_LIST];

    // This is where we'll store the output device list
    PulseAudioDeviceDescriptor tOutputDevicesList[MAX_PULSEAUDIO_DEVICES_IN_LIST];

    if (MediaSourcePulseAudio::GetPulseAudioDevices(tInputDevicesList, tOutputDevicesList) < 0)
        LOG(LOG_ERROR, "Couldn't determine the available PulseAudio devices");

    static bool tFirstCall = true;
    AudioDeviceDescriptor tDevice;

    #ifdef WOPUA_DEBUG_PACKETS
        tFirstCall = true;
    #endif

    if (tFirstCall)
    {
        LOG(LOG_VERBOSE, "Enumerating hardware..");
        LOG(LOG_VERBOSE, "PulseAudio version \"%s\"(%d.%d.%d)", pa_get_library_version(), PA_MAJOR, PA_MINOR, PA_MICRO);
    }

    tDevice.Name = "auto";
    tDevice.Card = "";
    tDevice.Desc = "automatic device selection";
    tDevice.IoType = "Output";

    pAList.push_back(tDevice);

    for (int i = 0; i < MAX_PULSEAUDIO_DEVICES_IN_LIST; i++)
    {
        if (!tOutputDevicesList[i].Initialized)
            break;

        tDevice.Name = string(tOutputDevicesList[i].Description);
        tDevice.Card = string(tOutputDevicesList[i].Name);
        tDevice.Desc = "PulseAudio based audio device";
        tDevice.IoType = "Output";
        pAList.push_back(tDevice);

        if (tFirstCall)
        {
            LOG(LOG_VERBOSE, "Output device %d..", i);
            LOG(LOG_VERBOSE, "..name: \"%s\"", tDevice.Name.c_str());
            LOG(LOG_VERBOSE, "..card: \"%s\"", tDevice.Card.c_str());
            LOG(LOG_VERBOSE, "..description: \"%s\"", tDevice.Desc.c_str());
        }
    }

    tFirstCall = false;
}
Beispiel #4
0
int	main(int ac, char **av)
{
  const Glib::ustring lib_path = "libozaxeplugin_audiodevices.so";
  CLibrary libaudiodevices;
  if (!libaudiodevices.Load(lib_path))
    {
      std::cout << "Impossible to load library !!!" << std::endl;
      return (1);
    }
  audiodevices_t pAudioDevices_New = reinterpret_cast<audiodevices_t>(libaudiodevices.GetAddr("AudioDevices_New"));
  audiodevices_destroy_t pAudioDevices_Destroy = reinterpret_cast<audiodevices_destroy_t>(libaudiodevices.GetAddr("AudioDevices_Destroy"));
  AudioDevices* ap = pAudioDevices_New();
  std::cout << "Nombre total de peripherique audio: " << ap->GetTotalDeviceCount() << std::endl;
  device_list_t::iterator iter;

  std::cout << "[INPUT DEVICES]" << std::endl;
  for ( iter = ap->GetAllInputDevices()->begin(); iter != ap->GetAllInputDevices()->end(); ++iter )
    {
      std::cout << "Device #" << iter->first << " : " << iter->second << std::endl;
    }

  std::cout << "[OUTPUT DEVICES]" << std::endl;
  for ( iter = ap->GetAllOutputDevices()->begin(); iter != ap->GetAllOutputDevices()->end(); ++iter )
    {
      std::cout << "Device #" << iter->first << " : " << iter->second << std::endl;
    }

  std::cout << "----- START FILE RECORDING -----" << std::endl;
  if (ac == 2)
    {
      const Glib::ustring file(av[1]);
      std::cout << "Path: " << file << std::endl;
      ap->SetInputDevice((PaDeviceIndex)2);
      ap->SetOutputDevice((PaDeviceIndex)2);
      ap->m_recVolume = 1.0f;
      ap->Rec(file, 10);
      ap->Stop();
    }
  std::cout << "----- END FILE RECORDING -----" << std::endl;
  pAudioDevices_Destroy(ap);
  libaudiodevices.UnLoad();
  return (0);
}
void MediaSourceFile::getAudioDevices(AudioDevices &pAList)
{
    AudioDeviceDescriptor tDevice;

    tDevice.Name = mDesiredDevice;
    tDevice.Card = mDesiredDevice;
    tDevice.Desc = "file source: \"" + mDesiredDevice + "\"";
    tDevice.IoType = "Input/Output";

    pAList.push_back(tDevice);
}
QString MediaSourceGrabberThread::GetDeviceDescription(QString pName)
{
    if (mMediaSource->GetMediaType() == MEDIA_VIDEO)
    {
        VideoDevices::iterator tIt;
        VideoDevices tVList;

        mMediaSource->getVideoDevices(tVList);
        for (tIt = tVList.begin(); tIt != tVList.end(); tIt++)
            if (pName.toStdString() == tIt->Name)
                return QString(tIt->Desc.c_str());
    }else if (mMediaSource->GetMediaType() == MEDIA_AUDIO)
    {
        AudioDevices::iterator tIt;
        AudioDevices tVList;

        mMediaSource->getAudioDevices(tVList);
        for (tIt = tVList.begin(); tIt != tVList.end(); tIt++)
            if (pName.toStdString() == tIt->Name)
                return QString(tIt->Desc.c_str());
    }
    return "";
}
void MediaSourceOss::getAudioDevices(AudioDevices &pAList)
{
    static bool tFirstCall = true;
    AudioDeviceDescriptor tDevice;
    string tDeviceFile;
    FILE *tFile;

    #ifdef MSO_DEBUG_PACKETS
        tFirstCall = true;
    #endif

    if (tFirstCall)
        LOG(LOG_VERBOSE, "Enumerating hardware..");

    for (int tDeviceId = -1; tDeviceId < 10; tDeviceId++)
    {
        tDeviceFile = "/dev/dsp";
        if (tDeviceId != -1)
            tDeviceFile += char(tDeviceId + 48);

        if (((tFile = fopen(tDeviceFile.c_str(), "r")) != NULL) && (fclose(tFile) != EOF))
        {
            tDevice.Name = "OSS device ";
            if (tDeviceId != -1)
                tDevice.Name += char(tDeviceId + 48);
            tDevice.Card = tDeviceFile;
            tDevice.Desc = "oss based audio device";
            tDevice.IoType = "Input/Output";

            if (tFirstCall)
                LOG(LOG_VERBOSE, "Found OSS audio device: %s", tDevice.Name.c_str());

            // add this device to the result list
            pAList.push_back(tDevice);
        }
    }
    tFirstCall = false;
}
void MediaSourcePortAudio::getAudioDevices(AudioDevices &pAList)
{
    static bool tFirstCall = true;
    AudioDeviceDescriptor tDevice;
    PaStreamParameters  inputParameters, outputParameters;

    #ifdef MSCA_DEBUG_PACKETS
        tFirstCall = true;
    #endif

    int tDevCount = Pa_GetDeviceCount();
    if (tFirstCall)
    {
        LOG(LOG_VERBOSE, "Enumerating hardware..");
        LOG(LOG_VERBOSE, "PortAudio version \"%s\"(%d)", Pa_GetVersionText(), Pa_GetVersion());
        LOG(LOG_VERBOSE, "Detected %d audio devices", tDevCount);
    }

    for (int i = 0; i < tDevCount; i++)
    {
        const PaDeviceInfo *tDeviceInfo = Pa_GetDeviceInfo(i);
        tDevice.Name = string(tDeviceInfo->name);
        tDevice.Card = char(i + 48);
        if(tDeviceInfo->maxInputChannels)
            tDevice.IoType = "Input";
        if(tDeviceInfo->maxOutputChannels)
            tDevice.IoType = "Output";
        if((tDeviceInfo->maxInputChannels) && (tDeviceInfo->maxOutputChannels))
            tDevice.IoType = "Input/Outputs";
        tDevice.Desc = string(Pa_GetHostApiInfo( tDeviceInfo->hostApi)->name) + " based audio device";

        // if device is able to capture samples with 44.1 kHz add this device to the result list
        if ((tDevice.IoType.find("Input") != string::npos)  && (tDeviceInfo->defaultSampleRate == 44100.0))
        {
            tDevice.Type = Microphone;
            pAList.push_back(tDevice);
        }

        if (tFirstCall)
        {
            LOG(LOG_VERBOSE, "Device %d.. %s", i, (tDeviceInfo->defaultSampleRate == 44100.0) ? " " : "[unsupported, sample rate must be 44.1 kHz]");

            // mark global and API specific default devices
            if (i == Pa_GetDefaultInputDevice())
            {
                LOG(LOG_VERBOSE, "..is DEFAULT INPUT device");
            } else
            {
                if (i == Pa_GetHostApiInfo(tDeviceInfo->hostApi)->defaultInputDevice)
                {
                    const PaHostApiInfo *tHostApiInfo = Pa_GetHostApiInfo(tDeviceInfo->hostApi);
                    LOG(LOG_VERBOSE, "..default %s input", tHostApiInfo->name );
                }
            }

            if (i == Pa_GetDefaultOutputDevice())
            {
                LOG(LOG_VERBOSE, "..is DEFAULT OUTPUT device");
            } else
            {
                if (i == Pa_GetHostApiInfo(tDeviceInfo->hostApi)->defaultOutputDevice)
                {
                    const PaHostApiInfo *tHostApiInfo = Pa_GetHostApiInfo(tDeviceInfo->hostApi);
                    LOG(LOG_VERBOSE, "..default %s output", tHostApiInfo->name );
                }
            }

            // print device info fields
            LOG(LOG_VERBOSE, "..name: \"%s\"", tDeviceInfo->name);
            LOG(LOG_VERBOSE, "..host API: \"%s\"", Pa_GetHostApiInfo( tDeviceInfo->hostApi)->name);
            LOG(LOG_VERBOSE, "..max. inputs channels: %d", tDeviceInfo->maxInputChannels);
            LOG(LOG_VERBOSE, "..max. outputs channels: %d", tDeviceInfo->maxOutputChannels);
            LOG(LOG_VERBOSE, "..default low input latency  : %8.4f seconds", tDeviceInfo->defaultLowInputLatency);
            LOG(LOG_VERBOSE, "..default low output latency : %8.4f seconds", tDeviceInfo->defaultLowOutputLatency);
            LOG(LOG_VERBOSE, "..default high input latency : %8.4f seconds", tDeviceInfo->defaultHighInputLatency);
            LOG(LOG_VERBOSE, "..default high output latency: %8.4f seconds", tDeviceInfo->defaultHighOutputLatency);
            LOG(LOG_VERBOSE, "..default sample rate: %8.0f Hz", tDeviceInfo->defaultSampleRate);
        }
    }

    tFirstCall = false;
}
void MediaSourceMMSys::getAudioDevices(AudioDevices &pAList)
{
    static bool tFirstCall = true;
    AudioDeviceDescriptor tDevice;
    WAVEINCAPS tCaps;
    UINT tCapsSize = sizeof(tCaps);

    #ifdef MMSYS_DEBUG_PACKETS
        tFirstCall = true;
    #endif

    if (tFirstCall)
        LOG(LOG_VERBOSE, "Enumerating hardware..");

    MMRESULT tRes;
    for (UINT i = 0; i < 20; i++)
    {
    	if (waveInGetDevCaps(i, (LPWAVEINCAPS)&tCaps, tCapsSize) == MMSYSERR_NOERROR)
    	{
            tDevice.Name = string(tCaps.szPname);
            tDevice.Card = (char)i + 48;
            tDevice.Desc = "Windows multimedia system (MMSYS) audio device " + tDevice.Card + " \"" + string(tCaps.szPname) + "\"";

            if (tFirstCall)
            {
                LOG(LOG_INFO, "Found active MMSystem device %d", i);
                LOG(LOG_INFO, "  ..manufacturer identifier: %d", (int)tCaps.wMid);
                LOG(LOG_INFO, "  ..product identifier: %d", (int)tCaps.wPid);
                LOG(LOG_INFO, "  ..driver version: 0x%04X", (int)tCaps.vDriverVersion);
                LOG(LOG_INFO, "  ..product name: %s", (int)tCaps.szPname);
                LOG(LOG_INFO, "  ..channels: %d", (int)tCaps.wChannels);

                if (tCaps.dwFormats & WAVE_FORMAT_1M08)
                    LOG(LOG_INFO, "  ..supporting 11.025 kHz, mono, 8-bit");
                if (tCaps.dwFormats & WAVE_FORMAT_1M16)
                    LOG(LOG_INFO, "  ..supporting 11.025 kHz, mono, 16-bit");
                if (tCaps.dwFormats & WAVE_FORMAT_1S08)
                    LOG(LOG_INFO, "  ..supporting 11.025 kHz, stereo, 8-bit");
                if (tCaps.dwFormats & WAVE_FORMAT_1S16)
                    LOG(LOG_INFO, "  ..supporting 11.025 kHz, stereo, 16-bit");

                if (tCaps.dwFormats & WAVE_FORMAT_2M08)
                    LOG(LOG_INFO, "  ..supporting 22.05 kHz, mono, 8-bit");
                if (tCaps.dwFormats & WAVE_FORMAT_2M16)
                    LOG(LOG_INFO, "  ..supporting 22.05 kHz, mono, 16-bit");
                if (tCaps.dwFormats & WAVE_FORMAT_2S08)
                    LOG(LOG_INFO, "  ..supporting 22.05 kHz, stereo, 8-bit");
                if (tCaps.dwFormats & WAVE_FORMAT_2S16)
                    LOG(LOG_INFO, "  ..supporting 22.05 kHz, stereo, 16-bit");

                if (tCaps.dwFormats & WAVE_FORMAT_4M08)
                    LOG(LOG_INFO, "  ..supporting 44.1 kHz, mono, 8-bit");
                if (tCaps.dwFormats & WAVE_FORMAT_4M16)
                    LOG(LOG_INFO, "  ..supporting 44.1 kHz, mono, 16-bit");
                if (tCaps.dwFormats & WAVE_FORMAT_4S08)
                    LOG(LOG_INFO, "  ..supporting 44.1 kHz, stereo, 8-bit");
                if (tCaps.dwFormats & WAVE_FORMAT_4S16)
                    LOG(LOG_INFO, "  ..supporting 44.1 kHz, stereo, 16-bit");
                /*
                if (tCaps.dwFormats & WAVE_FORMAT_48M08)
                    LOG(LOG_INFO, "  ..supporting 48 kHz, mono, 8-bit");
                if (tCaps.dwFormats & WAVE_FORMAT_48M16)
                    LOG(LOG_INFO, "  ..supporting 48 kHz, mono, 16-bit");
                if (tCaps.dwFormats & WAVE_FORMAT_48S08)
                    LOG(LOG_INFO, "  ..supporting 48 kHz, stereo, 8-bit");
                if (tCaps.dwFormats & WAVE_FORMAT_48S16)
                    LOG(LOG_INFO, "  ..supporting 48 kHz, stereo, 16-bit");

                if (tCaps.dwFormats & WAVE_FORMAT_96M08)
                    LOG(LOG_INFO, "  ..supporting 96 kHz, mono, 8-bit");
                if (tCaps.dwFormats & WAVE_FORMAT_96M16)
                    LOG(LOG_INFO, "  ..supporting 96 kHz, mono, 16-bit");
                if (tCaps.dwFormats & WAVE_FORMAT_96S08)
                    LOG(LOG_INFO, "  ..supporting 96 kHz, stereo, 8-bit");
                if (tCaps.dwFormats & WAVE_FORMAT_96S16)
                    LOG(LOG_INFO, "  ..supporting 96 kHz, stereo, 16-bit");
                 */

                LOG(LOG_VERBOSE, "Found audio capture device: %s (card: %s)", tDevice.Name.c_str(), tDevice.Card.c_str());
            }

		    pAList.push_back(tDevice);
    	}else
    		break;
    }
    tFirstCall = false;
}