Exemplo n.º 1
0
        /// <summary>
        /// Setup mode of interaction for the customer endpoint. This can be done only after the customer endpoint is seen.
        /// </summary>
        /// <param name="task">The task instance for this operation.</param>
        /// <remarks>To add announce but remove listening (or vice versa), two operations would be needed.</remarks>
        public void UpdateInteractiveMode(AsyncTask task, object state)
        {
            ArgumentTuple args = (ArgumentTuple)state;

            task.DoOneStep(
                delegate()
            {
                InteractionMode interactiveMode = InteractionMode.None;
                bool isAdd      = false;
                isAdd           = (bool)args.One;
                interactiveMode = (InteractionMode)args.Two;     // Integer

                var outgoingRoutes = new List <OutgoingAudioRoute>();
                var incomingRoutes = new List <IncomingAudioRoute>();

                InteractionMode announce = InteractionMode.AnnounceSpeech | InteractionMode.AnnounceSpeechAndDtmf;
                InteractionMode listen   = InteractionMode.ListenSpeech | InteractionMode.ListenSpeechAndDtmf;

                if ((interactiveMode & announce) != 0)
                {
                    OutgoingAudioRoute outRoute = new OutgoingAudioRoute(this.TargetUriEndpoint);
                    outRoute.IsDtmfEnabled      = (interactiveMode & InteractionMode.AnnounceSpeechAndDtmf) != 0;
                    outRoute.Operation          = isAdd ? RouteUpdateOperation.Add : RouteUpdateOperation.Remove;
                    outgoingRoutes.Add(outRoute);
                }
                if ((interactiveMode & listen) != 0)
                {
                    IncomingAudioRoute inRoute = new IncomingAudioRoute(this.TargetUriEndpoint);
                    inRoute.IsDtmfEnabled      = (interactiveMode & InteractionMode.ListenSpeechAndDtmf) != 0;
                    inRoute.Operation          = isAdd ? RouteUpdateOperation.Add : RouteUpdateOperation.Remove;
                    incomingRoutes.Add(inRoute);
                }

                m_serviceChannelCall.AudioVideoMcuRouting.BeginUpdateAudioRoutes(
                    outgoingRoutes,
                    incomingRoutes,
                    delegate(IAsyncResult ar)
                {
                    task.DoFinalStep(
                        delegate()
                    {
                        m_serviceChannelCall.AudioVideoMcuRouting.EndUpdateAudioRoutes(ar);
                    });
                },
                    null);
            });
        }
Exemplo n.º 2
0
        private void NewAttendeeCallEstablishCompleted(IAsyncResult result)
        {
            var newParticipantCall = (AudioVideoCall)result.AsyncState;

            try
            {
                newParticipantCall.EndEstablish(result);
            }
            catch (FailureResponseException failureResEx)
            {
                // TODO (Left to the reader): Write actual handling code for the
                // occurrence.
                Console.WriteLine("A FailureResponseException occured when ending the establishment of an Av "
                                  + "call for a new participant: {0}", failureResEx.ToString());
            }
            catch (OperationFailureException opFailEx)
            {
                // TODO (Left to the reader): Write actual handling code for the
                // occurrence.
                Console.WriteLine("An OperationFailureException occured when ending the establishment of an "
                                  + "Av call for a new participant: {0}", opFailEx.ToString());
            }
            catch (OperationTimeoutException opTimeoutEx)
            {
                // TODO (Left to the reader): Write actual handling code for the
                // occurrence.
                Console.WriteLine("An OperationTimeoutException occured when ending the establishment of an "
                                  + "Av call for a new participant: {0}",
                                  opTimeoutEx.ToString());
            }
            catch (RealTimeException realTimeEx)
            {
                // TODO (Left to the reader): Write actual handling code for the
                // occurrence.
                Console.WriteLine("A RealTimeException occured when ending the establishment of an Av call "
                                  + "for a new participant: {0}",
                                  realTimeEx.ToString());
            }

            // Retrieve the Participant endpoint from the call's Application
            // context
            var newAttendeeParticipantEndpoint = (ParticipantEndpoint)newParticipantCall.ApplicationContext;

            Console.WriteLine("ID of the new call = {0}", newParticipantCall.CallId);
            _trustedParticipantCallIDToParticipantUriStore.Add(newParticipantCall.CallId,
                                                               newAttendeeParticipantEndpoint.Participant.Uri);
            Console.WriteLine("Av Call Established to communicate with the new conference participant.");

            //Create a new outgoing route which dictates who the app is speaking
            // to via this call.
            OutgoingAudioRoute newOutgoingRoute = new OutgoingAudioRoute(newAttendeeParticipantEndpoint);

            // We're not going to send DTMF to the participant so disable DTMF
            newOutgoingRoute.IsDtmfEnabled = false;

            //Add this outbound route.
            newOutgoingRoute.Operation = RouteUpdateOperation.Add;

            //Create a new incoming route which dictates who the app is
            // listening to via this call.
            IncomingAudioRoute newIncomingRoute = new IncomingAudioRoute(newAttendeeParticipantEndpoint);

            // The app is listening for DTMF input from the user so enable it on
            // the incoming route.
            newIncomingRoute.IsDtmfEnabled = true;

            //Add this incoming route.
            newIncomingRoute.Operation = RouteUpdateOperation.Add;
            Console.WriteLine("Updating the Audio Routes to communicate with the new conference participant: "
                              + "{0}", newAttendeeParticipantEndpoint.Participant.DisplayName);

            newParticipantCall.AudioVideoMcuRouting.BeginUpdateAudioRoutes(
                new List <OutgoingAudioRoute> {
                newOutgoingRoute
            },
                new List <IncomingAudioRoute> {
                newIncomingRoute
            }, UpdateAudioRoutesCompleted,
                newParticipantCall);
        }
        private void CreateManualAudioRoutes(AudioVideoCall callToConference)
        {
            Console.WriteLine("Creating manual audio routes.");
            AudioVideoMcuSession avMcu = _backEndCallLeg.Conversation.ConferenceSession.AudioVideoMcuSession;

            // Get the participantEndpoint objects for the caller and recipient
            ParticipantEndpoint callerParticipantEndpoint = avMcu.GetRemoteParticipantEndpoints().Single(
                p => p.Participant.Uri == _backEndCallLeg.Conversation.Endpoint.OwnerUri);

            ParticipantEndpoint recipientParticipantEndpoint = avMcu.GetRemoteParticipantEndpoints().Single(
                p => p.Participant.Uri == _recipientSipUri);

            // Create incoming audio routes from the caller and recipient to the supervisor
            IncomingAudioRoute callerToSupervisorAudioRoute = new IncomingAudioRoute(callerParticipantEndpoint);
            IncomingAudioRoute recipientToSupervisorAudioRoute = new IncomingAudioRoute(recipientParticipantEndpoint);

            List<IncomingAudioRoute> routes = new List<IncomingAudioRoute>() {
                callerToSupervisorAudioRoute, recipientToSupervisorAudioRoute};

            try
            {
                // Update the MCU audio routing with the new incoming routes.
                callToConference.AudioVideoMcuRouting.BeginUpdateAudioRoutes(
                    null, routes,
                    updateRoutesAsyncResult =>
                    {
                        try
                        {
                            callToConference.AudioVideoMcuRouting.EndUpdateAudioRoutes(updateRoutesAsyncResult);
                        }
                        catch (RealTimeException ex)
                        {
                            Console.WriteLine(ex);
                        }
                    },
                    null);
            }
            catch (InvalidOperationException ex)
            {
                Console.WriteLine(ex);
            }
        }