Ejemplo n.º 1
0
        /// <summary>
        /// Initializes the video handlers (camera, image providers etc.).
        /// </summary>
        private void InitVideo()
        {
            // ----- CREATE -----
            WebCamera = WebCamera.GetDefaultDevice();

            LocalImageProvider  = new BitmapSourceProvider();
            RemoteImageProvider = new BitmapSourceProvider();

            phoneCallVideoReceiver = new PhoneCallVideoReceiver();
            phoneCallVideoSender   = new PhoneCallVideoSender();

            // ----- CONNECT -----
            videoConnector.Connect(phoneCallVideoReceiver, RemoteImageProvider);
            if (WebCamera != null)
            {
                videoConnector.Connect(WebCamera, LocalImageProvider);
                videoConnector.Connect(WebCamera, phoneCallVideoSender);
            }

            // add to collection
            Dictionary <string, VoIPMediaHandler> collection = new Dictionary <string, VoIPMediaHandler>();

            collection.Add("LocalImageProvider", LocalImageProvider);
            collection.Add("RemoteImageProvider", RemoteImageProvider);
            collection.Add("PhoneCallVideoReceiver", phoneCallVideoReceiver);
            collection.Add("PhoneCallVideoSender", phoneCallVideoSender);
            videoCollection = new MediaHandlerCollection(videoConnector, collection);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes the video handlers (camera, image providers etc.).
        /// </summary>
        private void InitVideo()
        {
            // ----- CREATE -----
            WebCamera = WebCamera.GetDefaultDevice();

            LocalImageProvider = new BitmapSourceProvider();
            RemoteImageProvider = new BitmapSourceProvider();

            phoneCallVideoReceiver = new PhoneCallVideoReceiver();
            phoneCallVideoSender = new PhoneCallVideoSender();

            // ----- CONNECT -----
            videoConnector.Connect(phoneCallVideoReceiver, RemoteImageProvider);
            if (WebCamera != null)
            {
                videoConnector.Connect(WebCamera, LocalImageProvider);
                videoConnector.Connect(WebCamera, phoneCallVideoSender);
            }

            // add to collection
            Dictionary<string, VoIPMediaHandler> collection = new Dictionary<string, VoIPMediaHandler>();
            collection.Add("LocalImageProvider", LocalImageProvider);
            collection.Add("RemoteImageProvider", RemoteImageProvider);
            collection.Add("PhoneCallVideoReceiver", phoneCallVideoReceiver);
            collection.Add("PhoneCallVideoSender", phoneCallVideoSender);
            videoCollection = new MediaHandlerCollection(videoConnector, collection);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes the audio handlers (microphone, speaker, DTMF player etc.).
        /// </summary>
        private void InitAudio()
        {
            // ----- CREATE -----
            // devices
            Microphone = Microphone.GetDefaultDevice();
            Speaker = Speaker.GetDefaultDevice();

            // audio processors
            AudioEnhancer = new AudioQualityEnhancer();
            AudioEnhancer.SetEchoSource(Speaker);
            dtmfPlayer = new DtmfEventWavePlayer();

            // ringtones
            var ringbackStream = LoadRingbackStream();
            var ringtoneStream = LoadRingtoneStream();
            ringtonePlayer = new WaveStreamPlayback(ringtoneStream, true, false);
            ringbackPlayer = new WaveStreamPlayback(ringbackStream, true, false);

            // mixers
            outgoingDataMixer = new AudioMixerMediaHandler();
            speakerMixer = new AudioMixerMediaHandler();
            recordDataMixer = new AudioMixerMediaHandler();

            // phone handlers
            phoneCallAudioSender = new PhoneCallAudioSender();
            phoneCallAudioReceiver = new PhoneCallAudioReceiver();

            // ----- CONNECT -----
            // connect outgoing
            audioConnector.Connect(AudioEnhancer, outgoingDataMixer);
            audioConnector.Connect(outgoingDataMixer, phoneCallAudioSender);
            audioConnector.Connect(outgoingDataMixer, recordDataMixer);
            if (Microphone != null)
            {
                Microphone.LevelChanged += (Microphone_LevelChanged);
                audioConnector.Connect(Microphone, AudioEnhancer);
            }

            // connect incoming
            audioConnector.Connect(phoneCallAudioReceiver, speakerMixer);
            audioConnector.Connect(phoneCallAudioReceiver, recordDataMixer);
            audioConnector.Connect(ringtonePlayer, speakerMixer);
            audioConnector.Connect(ringbackPlayer, speakerMixer);
            audioConnector.Connect(dtmfPlayer, speakerMixer);
            if (Speaker != null)
            {
                Speaker.LevelChanged += (Speaker_LevelChanged);
                audioConnector.Connect(speakerMixer, Speaker);
            }

            // add to collection
            Dictionary<string, VoIPMediaHandler> collection = new Dictionary<string, VoIPMediaHandler>();
            collection.Add("AudioEnhancer", AudioEnhancer);
            collection.Add("DTMFPlayer", dtmfPlayer);
            collection.Add("OutgoingDataMixer", outgoingDataMixer);
            collection.Add("SpeakerMixer", speakerMixer);
            collection.Add("PhoneCallAudioSender", phoneCallAudioSender);
            collection.Add("PhoneCallAudioReceiver", phoneCallAudioReceiver);
            audioCollection = new MediaHandlerCollection(audioConnector, collection);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes the audio handlers (microphone, speaker, DTMF player etc.).
        /// </summary>
        private void InitAudio()
        {
            // ----- CREATE -----
            // devices
            Microphone = Microphone.GetDefaultDevice();
            Speaker    = Speaker.GetDefaultDevice();

            // audio processors
            AudioEnhancer = new AudioQualityEnhancer();
            AudioEnhancer.SetEchoSource(Speaker);
            dtmfPlayer = new DtmfEventWavePlayer();

            // ringtones
            var ringbackStream = LoadRingbackStream();
            var ringtoneStream = LoadRingtoneStream();

            ringtonePlayer = new WaveStreamPlayback(ringtoneStream, true, false);
            ringbackPlayer = new WaveStreamPlayback(ringbackStream, true, false);

            // mixers
            outgoingDataMixer = new AudioMixerMediaHandler();
            speakerMixer      = new AudioMixerMediaHandler();
            recordDataMixer   = new AudioMixerMediaHandler();

            // phone handlers
            phoneCallAudioSender   = new PhoneCallAudioSender();
            phoneCallAudioReceiver = new PhoneCallAudioReceiver();


            // ----- CONNECT -----
            // connect outgoing
            audioConnector.Connect(AudioEnhancer, outgoingDataMixer);
            audioConnector.Connect(outgoingDataMixer, phoneCallAudioSender);
            audioConnector.Connect(outgoingDataMixer, recordDataMixer);
            if (Microphone != null)
            {
                Microphone.LevelChanged += (Microphone_LevelChanged);
                audioConnector.Connect(Microphone, AudioEnhancer);
            }

            // connect incoming
            audioConnector.Connect(phoneCallAudioReceiver, speakerMixer);
            audioConnector.Connect(phoneCallAudioReceiver, recordDataMixer);
            audioConnector.Connect(ringtonePlayer, speakerMixer);
            audioConnector.Connect(ringbackPlayer, speakerMixer);
            audioConnector.Connect(dtmfPlayer, speakerMixer);
            if (Speaker != null)
            {
                Speaker.LevelChanged += (Speaker_LevelChanged);
                audioConnector.Connect(speakerMixer, Speaker);
            }

            // add to collection
            Dictionary <string, VoIPMediaHandler> collection = new Dictionary <string, VoIPMediaHandler>();

            collection.Add("AudioEnhancer", AudioEnhancer);
            collection.Add("DTMFPlayer", dtmfPlayer);
            collection.Add("OutgoingDataMixer", outgoingDataMixer);
            collection.Add("SpeakerMixer", speakerMixer);
            collection.Add("PhoneCallAudioSender", phoneCallAudioSender);
            collection.Add("PhoneCallAudioReceiver", phoneCallAudioReceiver);
            audioCollection = new MediaHandlerCollection(audioConnector, collection);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates the incoming and outgoing media handlers such as microphone or speaker
        /// </summary>
        private void CreateMediaHandlers()
        {
            MediaHandlerFactory factory = new MediaHandlerFactory();
            activeAudioCallListener = factory.CreateSoftPhoneCallListener();
            activeVideoCallListener = factory.CreateSoftPhoneVideoCallListener();

            phoneCallAudioReceiver = activeAudioCallListener.GetComponent("AudiReceiver") as PhoneCallAudioReceiver;
            phoneCallAudioSender = activeAudioCallListener.GetComponent("AudioSender") as PhoneCallAudioSender;

            phonecallVideoSender = activeVideoCallListener.GetComponent("VideoSender") as PhoneCallVideoSender;
            phonecallVideoReceiver = activeVideoCallListener.GetComponent("VideoReceiver") as PhoneCallVideoReceiver;

            mediaConnector = activeAudioCallListener.MediaConnector;

            microphone = activeAudioCallListener.GetComponent("Microphone") as Microphone;
            if (microphone != null)
            {
                microphone.LevelChanged += (Microphone_LevelChanged);
            }

            speaker = activeAudioCallListener.GetComponent("Speaker") as Speaker;
            if (speaker != null)
            {
                speaker.LevelChanged += (Speaker_LevelChanged);
            }

            incomingDataMixer = activeAudioCallListener.GetComponent("SpeakerMixer") as AudioMixerMediaHandler;
            camera = activeVideoCallListener.GetComponent("WebCamera") as WebCamera;

            remoteImageHandler = activeVideoCallListener.GetComponent("RemoteImageHandler") as ImageProvider<Image>;
            localImageHandler = activeVideoCallListener.GetComponent("LocalImageHandler") as ImageProvider<Image>;

            AudioProcessor = activeAudioCallListener.GetComponent("AudioProcessor") as AudioQualityEnhancer;
            outgoingDataMixer = activeAudioCallListener.GetComponent("OutGoingDataMixer") as AudioMixerMediaHandler;
            RecordDataMixer = activeAudioCallListener.GetComponent("RecordDataMixer") as AudioMixerMediaHandler;

            dtmfEventWavePlayer = activeAudioCallListener.GetComponent("DTMF") as DtmfEventWavePlayer;
            ringtoneWavePlayer = activeAudioCallListener.GetComponent("Ringtones") as PhoneCallStateWavePlayer;

            Stream basicRing = Assembly.GetExecutingAssembly().GetManifestResourceStream(
                "OzekiDemoSoftphone.Resources.basic_ring.wav"
                );

            ringtoneWavePlayer.UpdateIncomingStateStream(CallState.Ringing, @"..\..\Resources\basic_ring.wav");
            ringtoneWavePlayer.UpdateOutgoingStateStream(CallState.Ringing, @"..\..\Resources\ringback.wav");
        }