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

TryStopSendAudio() private method

关闭音频码流
private TryStopSendAudio ( string channelLabel, string cameraNo ) : SmcErr
channelLabel string
cameraNo string
return Cgw.SmcError.SmcErr
        private SmcErr TryStopSendAudio(string channelLabel, string cameraNo)
        {
            SmcErr err = new CgwError();
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("TryStopSendAudio start.");

            try
            {
                bool successed = this.cameraAudioRelationDicLocker.TryEnterWriteLock(CgwConst.ENTER_LOCK_WAIT_TIME);
                // 申请互斥
                if (successed)
                {
                    try
                    {
                        if (!this.cameraAudioRelationDic.ContainsKey(cameraNo))
                        {
                            logEx.Trace("TryStopSendAudio cameraNo={0} can't find cameraNo.", cameraNo);
                            return err;
                        }

                        //foreach (string channelLabel in channelLabelList)
                        //{
                        //    this.cameraAudioRelationDic[cameraNo].RemoveAll(a => { return a == channelLabel; });
                        //}
                        this.cameraAudioRelationDic[cameraNo].RemoveAll(a => { return a == channelLabel; });

                        // 判断通道是否已经存在
                        if (null == this.cameraAudioRelationDic[cameraNo] || 0 == this.cameraAudioRelationDic[cameraNo].Count)
                        {
                            // 停止音频码流
                            CgwMonitorManageAdapter.Instance().SetMic(cameraNo, false);

                            this.cameraAudioRelationDic.Remove(cameraNo);
                        }
                    }
                    finally
                    {
                        // 释放互斥量
                        this.cameraAudioRelationDicLocker.ExitWriteLock();
                    }
                }
                else
                {
                    // 日志
                    err.SetErrorNo(CgwError.ERR_CGW_CHANNEL_GET_LOCK_FAIL);
                    logEx.Error("TryStopSendAudio: Enert Write Lock Failed.WaitingReadCount:{0};WaitingWriteCount:{1}.", this.cameraAudioRelationDicLocker.WaitingReadCount, this.cameraAudioRelationDicLocker.WaitingWriteCount);
                }
            }
            catch (Exception ex)
            {
                // 日志
                err.SetErrorNo(CgwError.ERR_CGW_CHANNEL_SERVICE_ADNORMAL);
                logEx.Error(ex, "TryStopSendAudio: Enert Write Lock Exception.");
            }

            logEx.Trace("TryStopSendAudio cameraNo={0} successfully.", cameraNo);
            return err;
        }