Cgw.Channel.MonitorChannelRelationManager.SetMic C# (CSharp) Method

SetMic() public method

设置摄像头音频状态
public SetMic ( string channelLabel, string cameraNo, bool isOn ) : SmcErr
channelLabel string
cameraNo string
isOn bool
return Cgw.SmcError.SmcErr
        public SmcErr SetMic(string channelLabel, string cameraNo, bool isOn)
        {
            SmcErr err = new SmcErr();
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Info("SetMic start.");

            try
            {
                bool successed = this.monitorChannelRelationDicLocker.TryEnterWriteLock(CgwConst.ENTER_LOCK_WAIT_TIME);
                // 申请互斥
                if (successed)
                {
                    try
                    {
                        err = this.SetCameraAudio(channelLabel, cameraNo, isOn);
                        if (!err.IsSuccess())
                        {
                            logEx.Error("SetMic channelLabel={0}, cameraNo={1},isOn={2} failed.", channelLabel, cameraNo, isOn);
                            return err;
                        }
                    }
                    finally
                    {
                        // 释放互斥量
                        this.monitorChannelRelationDicLocker.ExitWriteLock();
                    }
                }
                else
                {
                    // 日志
                    logEx.Error("SetMic: Enert Write Lock Failed.WaitingReadCount:{0};WaitingWriteCount:{1}.", this.monitorChannelRelationDicLocker.WaitingReadCount, this.monitorChannelRelationDicLocker.WaitingWriteCount);
                    err.SetErrorNo(CgwError.ERR_CGW_CHANNEL_GET_LOCK_FAIL);
                }
            }
            catch (Exception ex)
            {
                // 日志
                logEx.Error(ex, "SetMic: Enert Write Lock Exception.");
                err.SetErrorNo(CgwError.ERR_CGW_CHANNEL_SERVICE_ADNORMAL);
            }

            logEx.Info("SetMic SetMic={0}, cameraNo={1},isOn={2} successfully.", channelLabel, cameraNo, isOn);
            return err;
        }