示例#1
0
        public void StartAudioInjection(string audioFilePath)
        {
            if (!ChannelSessions.Any((cs) => cs.AudioState == ConnectionState.Connected))
            {
                throw new InvalidOperationException($"{GetType().Name}: StartAudioInjection() failed for InvalidState: The channel's AudioState must be connected");
            }
            vx_req_sessiongroup_control_audio_injection_t request;

            request = new vx_req_sessiongroup_control_audio_injection_t
            {
                sessiongroup_handle          = _groupHandle,
                filename                     = audioFilePath,
                audio_injection_control_type = vx_sessiongroup_audio_injection_control_type.vx_sessiongroup_audio_injection_control_start
            };

            VxClient.Instance.BeginIssueRequest(request, result =>
            {
                try
                {
                    VxClient.Instance.EndIssueRequest(result);
                    IsInjectingAudio = true;
                }
                catch (Exception e)
                {
                    VivoxDebug.Instance.VxExceptionMessage($"{request.GetType().Name} failed: {e}");
                    if (VivoxDebug.Instance.throwInternalExcepetions)
                    {
                        throw;
                    }
                }
            });
        }
示例#2
0
        public void StopAudioInjection()
        {
            if (!ChannelSessions.Any((cs) => cs.AudioState == ConnectionState.Connected || cs.TextState == ConnectionState.Connected) ||
                IsInjectingAudio == false)
            {
                VivoxDebug.Instance.DebugMessage($"{GetType().Name}: StopAudioInjection() warning; No audio injection to stop", vx_log_level.log_warning);
                return;
            }
            vx_req_sessiongroup_control_audio_injection_t request;

            request = new vx_req_sessiongroup_control_audio_injection_t
            {
                sessiongroup_handle          = _groupHandle,
                audio_injection_control_type = vx_sessiongroup_audio_injection_control_type.vx_sessiongroup_audio_injection_control_stop
            };

            VxClient.Instance.BeginIssueRequest(request, result =>
            {
                try
                {
                    VxClient.Instance.EndIssueRequest(result);
                    IsInjectingAudio = false;
                }
                catch (Exception e)
                {
                    VivoxDebug.Instance.VxExceptionMessage($"{request.GetType().Name} failed: {e}");
                }
            });
        }
示例#3
0
        public void SetTransmissionMode(TransmissionMode mode, ChannelId singleChannel = null)
        {
            if (mode == TransmissionMode.Single && singleChannel == null)
            {
                throw new ArgumentException("Setting parameter 'mode' to TransmissionsMode.Single expects a ChannelId for the 'singleChannel' parameter");
            }

            _transmissionType    = mode;
            _transmittingChannel = mode == TransmissionMode.Single ? singleChannel : null;

            bool sessionGroupExists = false;

            foreach (var session in _channelSessions)
            {
                if (session.AudioState != ConnectionState.Disconnected || session.TextState != ConnectionState.Disconnected)
                {
                    sessionGroupExists = true;
                    break;
                }
            }
            if (sessionGroupExists && (_transmissionType != TransmissionMode.Single || ChannelSessions.ContainsKey(_transmittingChannel)))
            {
                SetTransmission();
            }
        }