Ejemplo n.º 1
0
        /// <summary>
        /// Get all audio devices installed in the system.
        /// </summary>
        /// <returns>The array of audio devices installed in the system.</returns>
        public AudioDeviceInfo[] GetAllAudioDevices()
        {
            List <AudioDeviceInfo> audioDeviceInfo = new List <AudioDeviceInfo>();

            pjsua2.AudioDevInfoVector audioDevices = _pjAudDevManager.enumDev();

            // If devices exist.
            if (audioDevices != null && audioDevices.Count > 0)
            {
                // For each device.
                for (int i = 0; i < audioDevices.Count; i++)
                {
                    AudioDeviceInfo audoDevice = new AudioDeviceInfo();
                    audoDevice.Caps = audioDevices[i].caps;
                    audoDevice.DefaultSamplesPerSec = audioDevices[i].defaultSamplesPerSec;
                    audoDevice.Driver      = audioDevices[i].driver;
                    audoDevice.InputCount  = audioDevices[i].inputCount;
                    audoDevice.Name        = audioDevices[i].name;
                    audoDevice.OutputCount = audioDevices[i].outputCount;
                    audoDevice.Routes      = audioDevices[i].routes;

                    // Get the media format list.
                    pjsua2.MediaFormatVector mediaFormats = audioDevices[i].extFmt;

                    // if media format exists.
                    if (mediaFormats != null && mediaFormats.Count > 0)
                    {
                        List <MediaFormat> formats = new List <MediaFormat>();

                        // For each format.
                        for (int j = 0; j < mediaFormats.Count; j++)
                        {
                            MediaFormat mediaFormat = new MediaFormat();
                            mediaFormat.Id   = mediaFormats[j].id;
                            mediaFormat.Type = MediaFormat.GetMediaTypeEx(mediaFormats[j].type);

                            // Add the media formats.
                            formats.Add(mediaFormat);
                        }

                        // Add the list of media formats.
                        audoDevice.MediaFormats = formats.ToArray();
                    }

                    // Add the audio device.
                    audioDeviceInfo.Add(audoDevice);
                }
            }

            // Return the list of devices.
            return(audioDeviceInfo.ToArray());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get information about the specified conference port.
        /// </summary>
        /// <returns>The conference port.</returns>
        public ConfPortInfo GetPortInfo()
        {
            // Get the config
            pjsua2.ConfPortInfo info = _pjAudioMedia.getPortInfo();

            ConfPortInfo confPortInfo = new ConfPortInfo();

            confPortInfo.Format               = new MediaFormatAudio();
            confPortInfo.Format.AvgBps        = info.format.avgBps;
            confPortInfo.Format.BitsPerSample = info.format.bitsPerSample;
            confPortInfo.Format.ChannelCount  = info.format.channelCount;
            confPortInfo.Format.ClockRate     = info.format.clockRate;
            confPortInfo.Format.FrameTimeUsec = info.format.frameTimeUsec;
            confPortInfo.Format.Id            = info.format.id;
            confPortInfo.Format.MaxBps        = info.format.maxBps;
            confPortInfo.Format.Type          = MediaFormat.GetMediaTypeEx(info.format.type);

            confPortInfo.Name       = info.name;
            confPortInfo.PortId     = info.portId;
            confPortInfo.RxLevelAdj = info.rxLevelAdj;
            confPortInfo.TxLevelAdj = info.txLevelAdj;

            List <int> listeners = new List <int>();

            // For each code found.
            for (int i = 0; i < info.listeners.Count; i++)
            {
                // Get the port number.
                listeners.Add(info.listeners[i]);
            }

            confPortInfo.Listeners = listeners.ToArray();

            // Return the config port info.
            return(confPortInfo);
        }