Beispiel #1
0
    private float get_val_from_pos(audio_settings audio_Settings)
    {
        float max_val   = audio_Settings.max_vals[option_to_adjust];
        float min_val   = audio_Settings.min_vals[option_to_adjust];
        float val_range = max_val - min_val;

        float multiplier = 0.5f;

        if (adjustment_Axis == adjustment_axis.vertical)
        {
            multiplier = (transform.position.y - meta_Settings.min_setting_height) / meta_Settings.height_range;
        }
        else if (adjustment_Axis == adjustment_axis.horizontal)
        {
            multiplier = (transform.position.x - meta_Settings.min_setting_width) / meta_Settings.width_range;
        }
        else if (adjustment_Axis == adjustment_axis.depth)
        {
            Debug.LogWarning("Depth adjustment axis range not set up in meta settings. Defaulting to width range.");
            multiplier = (transform.position.z - meta_Settings.min_setting_width) / meta_Settings.width_range;
        }

        float new_val = min_val + (multiplier * val_range);

        return(new_val);
    }
Beispiel #2
0
 // Apply the settings stored in an audio_settings object to a particular audioSource
 public static void apply_settings(audio_settings settings, AudioSource audioSource)
 {
     if (audioSource)
     {
         audioSource.volume = settings.get_setting(audio_option.volume);
         //audioSource.pitch = settings.get_setting(audio_option.playback_speed);
         //audioSource.panStereo = settings.get_setting(audio_option.stereo_pan);
     }
 }
Beispiel #3
0
    private void Update()
    {
        Frame frame = controller.Frame();

        if (frame.Hands.Count > 0)
        {
            Debug.Log("Found at least one hand");
            Hand first_hand = frame.Hands[0];
            bool hand_check = can_hand_control(first_hand);
            foreach (KeyValuePair <audio_settings, BoxCollider> KVP in audio_collider_pairs)
            {
                audio_settings audio_Settings = KVP.Key;
                //bool collider_check = collider_checks[KVP.Value];
                //Debug.Log("Collider check: " + collider_checks[KVP.Value]);
                bool collider_check = boxCollider.bounds.Intersects(KVP.Value.bounds);
                if (audio_Settings && hand_check && collider_check)
                {
                    float value = get_val_from_pos(audio_Settings);
                    audio_Settings.set_setting(option_to_adjust, value);
                }
            }
        }
    }
Beispiel #4
0
        /// <summary>
        ///It initializes a softphone object with a SIP BPX, and it is for requisiting a SIP account that is nedded for a SIP PBX service. It registers this SIP
        ///account to the SIP PBX through an ’IphoneLine’ object which represents the telephoneline. 
        ///If the telephone registration is successful we have a call ready softphone. In this example the softphone can be reached by dialing the number 891.
        /// </summary>
        private void InitializeSoftPhone()
        {
            try
            {
                if (Ozeki.VoIP.SDK.Protection.LicenseManager.Instance.LicenseType != Ozeki.VoIP.SDK.Protection.LicenseType.Activated)
                    Ozeki.VoIP.SDK.Protection.LicenseManager.Instance.SetLicense(m_OzekiLicenseId, m_OzekiLicenseKey);

                using (BrightPlatformEntities objDbModel = new BrightPlatformEntities(UserSession.EntityConnection)) {
                    int? _SipAcctId = objDbModel.users.FirstOrDefault(i => i.id == UserSession.CurrentUser.UserId).sip_id;
                    if (!_SipAcctId.HasValue) {
                        //MessageBox.Show(
                        //    string.Format("Your account is not yet configured for calling.{0}Please contact your administrator.", Environment.NewLine),
                        //    "Bright Sales",
                        //    MessageBoxButtons.OK,
                        //    MessageBoxIcon.Information
                        //);
                        BrightVision.Common.UI.NotificationDialog.Error(
                            "Bright Sales",
                            string.Format("Your account is not yet configured for calling.{0}Please contact your administrator.", Environment.NewLine)
                        );
                        return;
                    }

                    sip_accounts sip = objDbModel.sip_accounts.FirstOrDefault(i => i.id == _SipAcctId);
                    if (sip != null)
                        objDbModel.Detach(sip);

                    if (m_UserAudioSetting == null)
                        m_UserAudioSetting = AudioSettingUtility.GetUserAudioSetting();

                    m_UserMicrophone = AudioSettingUtility.GetDefaultDeviceMicrophone();
                    m_UserSpeaker = AudioSettingUtility.GetDefaultDeviceSpeaker();
                    m_UserMicrophone.Volume = (float)m_UserAudioSetting.mic_volume / 10;
                    m_UserSpeaker.Volume = (float)m_UserAudioSetting.speaker_volume / 10;

                    try {
                        softPhone = SoftPhoneFactory.CreateSoftPhone(SoftPhoneFactory.GetLocalIP(), 5700, 5750, 5780);
                    }
                    catch {
                    }

                    this.DisableUnwantedCodec();
                    softPhone.IncomingCall -= new EventHandler<VoIPEventArgs<IPhoneCall>>(softPhone_IncomingCall);
                    softPhone.IncomingCall += new EventHandler<VoIPEventArgs<IPhoneCall>>(softPhone_IncomingCall);
                    SIPAccount acc = new SIPAccount(
                       true,
                       sip.display_name.Trim(),
                       sip.username.Trim(),
                       sip.username.Trim(),
                       sip.password,
                       sip.sip_url.Trim(),
                       5060,
                       ""
                    );
                    // var acc = new SIPAccount(true, sip.display_name, sip.username, sip.username, sip.password, sip.sip_url, 5060,"");
                    //  NatConfiguration newNatConfiguration = new NatConfiguration(NatTraversalMethod.Auto, new NatRemoteServer("stun.ozekiphone.com", "", ""));
                    phoneLine = softPhone.CreatePhoneLine(acc, Ozeki.Network.TransportType.Udp, SRTPMode.None);
                    phoneLine.PhoneLineStateChanged -= new EventHandler<VoIPEventArgs<PhoneLineState>>(phoneLine_PhoneLineInformation);
                    phoneLine.PhoneLineStateChanged += new EventHandler<VoIPEventArgs<PhoneLineState>>(phoneLine_PhoneLineInformation);
                    softPhone.RegisterPhoneLine(phoneLine);
                    objDbModel.Dispose();
                }
            }
            catch (Exception ex) {
            }
        }
Beispiel #5
0
        private bool UserCanDoCall()
        {
            //if (!ObjectUser.CanDoCall()) {
            //    MessageBox.Show(
            //        string.Format("Your account is not yet configured for calling.{0}Please contact your administrator.", Environment.NewLine),
            //        "Bright Sales",
            //        MessageBoxButtons.OK,
            //        MessageBoxIcon.Information
            //    );
            //    return false;
            //}

            if (m_BrightSalesProperty.CommonProperty.CurrentTab != SelectionProperty.CurrentTab.CampaignBooking)
                return false;

            if (!m_BrightSalesProperty.CommonProperty.CallLogSaved)
            {
                NotificationDialog.Error("Bright Sales", "Please kindly save your call log first.");
                return false;
            }

            m_UserAudioSetting = AudioSettingUtility.GetUserAudioSetting();
            /*
             * https://brightvision.jira.com/browse/PLATFORM-2375
             * Will only going to check if Phone setting is set to internal.
            */
            if (m_UserAudioSetting == null)
            {
                audio_settings _item = (new BrightPlatformEntities(UserSession.EntityConnection)).audio_settings.FirstOrDefault(i => i.user_id == UserSession.CurrentUser.UserId);

                if ((_item != null && _item.mode == 0) || _item == null)
                {
                    NotificationDialog.Information("Bright Sales", "Your audio settings is not yet configured for calling.");
                    return false;
                }
            }

            return true;
        }
Beispiel #6
0
        private void simpleButtonSave_Click(object sender, EventArgs e)
        {
            if (mic == null && speaker == null) {
                NotificationDialog.Error("Bright Sales", "Some devices are missing. Please connect a speaker/microphone device first.");
                return;
            }

            WaitDialog.Show(ParentForm, "Saving Audio Settings ...");
            float speakerVolume = float.Parse(zoomTrackBarControlSpeakerVolume.EditValue.ToString());
            float micVolume = float.Parse(zoomTrackBarControlMicVolume.EditValue.ToString());
            bool speakerAutoAdjust = checkEditSpeakerAutoAdjust.Checked;
            bool micAutoAdjust = checkEditMicAutoAdjust.Checked;
            BrightPlatformEntities objDbModel = new BrightPlatformEntities(UserSession.EntityConnection);
            audio_settings audioSetting = objDbModel.audio_settings.FirstOrDefault(r => r.user_id == UserSession.CurrentUser.UserId);

            int? _mic_device_id = null;
            string _mic_device_name = string.Empty;
            if (lookUpEditMicrophone.EditValue != null) {
                _mic_device_id = Convert.ToInt32(lookUpEditMicrophone.EditValue);
                _mic_device_name = lookUpEditMicrophone.Text;
            }

            int? _speaker_device_id = null;
            string _speaker_device_name = string.Empty;
            if (lookUpEditSpeaker.EditValue != null) {
                _speaker_device_id = Convert.ToInt32(lookUpEditSpeaker.EditValue);
                _speaker_device_name = lookUpEditSpeaker.Text;
            }

            if (audioSetting == null) {
                audioSetting = new audio_settings() {
                    user_id = UserSession.CurrentUser.UserId,
                    mode = comboBoxEditMode.SelectedIndex,
                    mic_volume = micVolume,
                    mic_auto_adjust = micAutoAdjust,
                    speaker_volume = speakerVolume,
                    speaker_auto_adjust = speakerAutoAdjust,
                    mic_device_id = _mic_device_id,
                    mic_device_name = _mic_device_name,
                    speaker_device_id = _speaker_device_id,
                    speaker_device_name = _speaker_device_name
                };
                objDbModel.audio_settings.AddObject(audioSetting);
            }
            else {
                audioSetting.user_id = UserSession.CurrentUser.UserId;
                audioSetting.mode = comboBoxEditMode.SelectedIndex;
                audioSetting.mic_volume = micVolume;
                audioSetting.mic_auto_adjust = micAutoAdjust;
                audioSetting.speaker_volume = speakerVolume;
                audioSetting.speaker_auto_adjust = speakerAutoAdjust;
                audioSetting.mic_device_id = _mic_device_id;
                audioSetting.mic_device_name = _mic_device_name;
                audioSetting.speaker_device_id = _speaker_device_id;
                audioSetting.speaker_device_name = _speaker_device_name;
                objDbModel.audio_settings.ApplyCurrentValues(audioSetting);
            }
            objDbModel.SaveChanges();

            /* https://brightvision.jira.com/browse/PLATFORM-2665
             * DAN: Added to update the calllogbar m_SoftPhone to solve the scenario issue on ticket.
             * It happen because the variable m_SoftPhone.RegisterSuccess is false even thought the user has updated the audio settings.
            */
            //----------------------------------------------------
            CallLogBar clb = CallLogBar.InstanceNoParam;
            if (clb != null)
            {
                if (clb.m_SoftPhone != null)
                    clb.m_SoftPhone.RegisterPhone();
            }
            //----------------------------------------------------

            WaitDialog.Close();
            NotificationDialog.Information("Bright Sales", "Audio setting saved.");
            this.ParentForm.Close();
        }
Beispiel #7
0
        public static audio_settings GetUserAudioSetting()
        {
            var speaker = Speaker.GetDefaultDevice();
            if (speaker == null)
                return null;

            var mic = Microphone.GetDefaultDevice();
            if (mic == null)
                return null;

            if (SelectedSpeaker == null)
                SelectedSpeaker = speaker;
            if (SelectedMicrophone == null)
                SelectedMicrophone = mic;
            audio_settings audioSetting;
            using (BrightPlatformEntities objDbModel = new BrightPlatformEntities(UserSession.EntityConnection))
            {
                audioSetting = objDbModel.audio_settings.Where(r => r.user_id == UserSession.CurrentUser.UserId).FirstOrDefault();
                if (audioSetting == null)
                {
                    audioSetting = new audio_settings();
                    audioSetting.user_id = UserSession.CurrentUser.UserId;
                    audioSetting.mode = 0;
                    audioSetting.mic_volume = mic.Volume * 10;
                    audioSetting.mic_auto_adjust = true;
                    audioSetting.mic_device_id = mic.DeviceInfo.DeviceID;
                    audioSetting.mic_device_name = mic.DeviceInfo.ProductName;
                    audioSetting.speaker_volume = speaker.Volume * 10;
                    audioSetting.speaker_auto_adjust = true;
                    audioSetting.speaker_device_id = speaker.DeviceInfo.DeviceID;
                    audioSetting.speaker_device_name = speaker.DeviceInfo.ProductName;
                    objDbModel.audio_settings.AddObject(audioSetting);
                    objDbModel.SaveChanges();
                }
                objDbModel.Detach(audioSetting);
             }
             return audioSetting;
        }