/// <summary> /// 设置属性 /// </summary> /// <param name="key">属性名</param> /// <param name="value">属性值</param> /// <param name="isPersistence">是否持久化保存</param> public void SetProperty(PropertyKey key, string value, bool isPersistence) { log.Info(string.Format(string.Format("SetProperty:{0}={1}", key, value))); properties[key] = value; if (key <= PropertyKey.PLCM_MFW_KVLIST_KEY_MAXSYS) { var errno = PlcmProxy.SetProperty(key, value); if (errno != ErrorNumber.OK) { var errMsg = string.Format("{0}设定失败,err={1}", key, errno); log.Error(errMsg); throw new Exception(errMsg); } if (isPersistence) { errno = PlcmProxy.UpdateConfig(); if (errno != ErrorNumber.OK) { var errMsg = string.Format("{0}更新配置失败,err={1}", key, errno); log.Error(errMsg); throw new Exception(errMsg); } } } else { switch (key) { case PropertyKey.LocalAddr: break; case PropertyKey.CalleeAddr: break; case PropertyKey.AUDIO_INPUT_DEVICE: { string audioOutput = null; if (properties.ContainsKey(PropertyKey.AUDIO_OUTPUT_DEVICE)) { audioOutput = properties[PropertyKey.AUDIO_OUTPUT_DEVICE]; } PlcmProxy.SetAudioDevice(value, audioOutput); } break; case PropertyKey.AUDIO_OUTPUT_DEVICE: { string audioInput = null; if (properties.ContainsKey(PropertyKey.AUDIO_INPUT_DEVICE)) { audioInput = properties[PropertyKey.AUDIO_INPUT_DEVICE]; } PlcmProxy.SetAudioDevice(audioInput, value); PlcmProxy.SetAudioDeviceForRingtone(value); } break; case PropertyKey.AUDIO_OUTPUT_DEVICE_FOR_RINGTONE: { } break; case PropertyKey.VIDEO_INPUT_DEVICE: { PlcmProxy.SetVideoDevice(value); } break; case PropertyKey.MONITOR_DEVICE: break; /*Sound Effects*/ case PropertyKey.SOUND_INCOMING: break; case PropertyKey.SOUND_CLOSED: break; case PropertyKey.SOUND_RINGING: break; case PropertyKey.SOUND_HOLD: break; //ICE token case PropertyKey.ICE_AUTH_TOKEN: break; case PropertyKey.StaticImage: { #region StaticImage if (!string.IsNullOrWhiteSpace(value)) { var filePath = Path.Combine(Application.StartupPath, value); if (File.Exists(filePath)) { var img = new Bitmap(filePath); if (null != img) { int w = img.Width; int h = img.Height; var buffer = new byte[w * h * 4]; var idx = 0; for (var row = 0; row < h; row++) { for (var col = 0; col < w; col++) { var color = img.GetPixel(col, row); //转换为RGBA模式 buffer[idx] = color.R; idx++; buffer[idx] = color.G; idx++; buffer[idx] = color.B; idx++; buffer[idx] = color.A; idx++; } } int length = buffer.Length; var intPtrBuffer = IntPtrHelper.IntPtrFromBytes(buffer); var errno = PlcmProxy.SetStaticImage(intPtrBuffer, length, w, h); if (ErrorNumber.OK != errno) { var errMsg = "setStaticImage failed,errno=" + errno; log.Error(errMsg); //throw new Exception(errMsg); } } } } #endregion } break; case PropertyKey.LayoutType: break; case PropertyKey.CryptoSuiteType: break; case PropertyKey.SRTPKey: break; case PropertyKey.AuthToken: break; } } }