Exemplo n.º 1
0
        private void EstablishServiceChannel(AsyncTask task, object state)
        {
            task.DoOneStep(
                delegate()
            {
                m_serviceChannelCall = new AudioVideoCall(m_serviceHub.Conversation);

                var options = new AudioVideoCallEstablishOptions();
                // Ee need to use generated user identity for the call as this is hidden participant
                // of the conference for service purpose.
                options.UseGeneratedIdentityForTrustedConference = !this.IsPrimaryServiceChannel;
                if (!this.IsPrimaryServiceChannel)
                {
                    this.RegisterServiceCallHandlers();
                    // Service call does not need to be in default mix of the conference. The purpose is to service a specific target user in the conference.
                    options.AudioVideoMcuDialInOptions.RemoveFromDefaultRouting = true;
                }

                m_serviceChannelCall.BeginEstablish(
                    options,
                    delegate(IAsyncResult ar)
                {
                    task.DoFinalStep(
                        delegate()
                    {
                        m_serviceChannelCall.EndEstablish(ar);
                    });
                },
                    null);
            });
        }
Exemplo n.º 2
0
        private void EstablishAvCallAndAudioRouteForNewAttendee(ParticipantEndpoint newAttendeeParticipantEndpoint)
        {
            AudioVideoCall newAttendeeCall = new AudioVideoCall(_trustedParticipantConversation);

            // Save the new Attendee Participant Endpoint in the Application
            // Context.
            newAttendeeCall.ApplicationContext = newAttendeeParticipantEndpoint;

            AudioVideoCallEstablishOptions avCallEstablishOptions = new AudioVideoCallEstablishOptions();

            // Remove the call from the default Mcu route because we will be
            // specifying custom routes after the call is established.
            avCallEstablishOptions.AudioVideoMcuDialInOptions.RemoveFromDefaultRouting = true;

            // When the Flow is active, add the tone handler
            newAttendeeCall.AudioVideoFlowConfigurationRequested += new EventHandler <
                AudioVideoFlowConfigurationRequestedEventArgs>(
                NewAttendeeCall_AudioVideoFlowConfigurationRequested);

            newAttendeeCall.BeginEstablish(avCallEstablishOptions, NewAttendeeCallEstablishCompleted,
                                           newAttendeeCall);

            // Add the call to the collection so it can be retrieved later.
            _trustedParticipantCalls.Add(newAttendeeParticipantEndpoint.Uri, newAttendeeCall);
        }
        private void EstablishCall()
        {
            // Create a new Conversation.
            Conversation conversation = new Conversation(_appEndpoint);

            // Create a new IM call.
            _avCall = new AudioVideoCall(conversation);

            try
            {
                // Establish the IM call.
                _avCall.BeginEstablish(_destinationSipUri,
                    new CallEstablishOptions(),
                    result =>
                    {
                        try
                        {
                            // Finish the asynchronous operation.
                            _avCall.EndEstablish(result);
                        }
                        catch (RealTimeException ex)
                        {
                            // Catch and log exceptions.
                            _logger.Log("Failed establishing A/V call", ex);
                        }
                    },
                    null
                );
            }
            catch (InvalidOperationException ioex)
            {
                _logger.Log("Failed establishing A/V call", ioex);
            }
        }
Exemplo n.º 4
0
        void AVCall_TransferReceived(object sender, AudioVideoCallTransferReceivedEventArgs e)
        {
            // Accept the transfer. The parameter is null as we do not want to
            // add any specalized signaling headers to the acceptance.
            AudioVideoCall audioVideoCall = e.Accept(null);

            audioVideoCall.BeginEstablish(CallEstablishCompleted, audioVideoCall);
        }
Exemplo n.º 5
0
        public void Run()
        {
            //Initialize and register the endpoint, using the credentials of the user the application will be acting as.
            _helper       = new UCMASampleHelper();
            _userEndpoint = _helper.CreateEstablishedUserEndpoint("AVCall Sample User" /*endpointFriendlyName*/);

            //Set up the conversation and place the call.
            ConversationSettings convSettings = new ConversationSettings();

            convSettings.Priority = _conversationPriority;
            convSettings.Subject  = _conversationSubject;

            //Conversation represents a collection of modalities in the context of a dialog with one or multiple callees.
            Conversation conversation = new Conversation(_userEndpoint, convSettings);

            _audioVideoCall = new AudioVideoCall(conversation);

            //Call: StateChanged: Only hooked up for logging.
            _audioVideoCall.StateChanged += new EventHandler <CallStateChangedEventArgs>(audioVideoCall_StateChanged);

            //Subscribe for the flow configuration requested event; the flow will be used to send the media.
            //Ultimately, as a part of the callback, the media will be sent/received.
            _audioVideoCall.AudioVideoFlowConfigurationRequested += this.audioVideoCall_FlowConfigurationRequested;

            // Prompt for called party
            _calledParty = UCMASampleHelper.PromptUser("Enter the URI for the user logged onto Microsoft Lync, in the sip:User@Host format or tel:+1XXXYYYZZZZ format => ", "RemoteUserURI");

            //Place the call to the remote party.
            _audioVideoCall.BeginEstablish(_calledParty, null, EndCallEstablish, _audioVideoCall);

            //Sync; wait for the call to complete.
            Console.WriteLine("Calling the remote user...");
            _waitForCallToEstablish.WaitOne();

            // Terminate the call, and then the conversation.
            // Terminating these additional objects individually is made redundant by shutting down the platform right after, but in the multiple call case,
            // this is needed for object hygene. Terminating a Conversation terminates all it's associated calls, and terminating an endpoint will terminate
            // all conversations on that endpoint.
            _audioVideoCall.BeginTerminate(EndTerminateCall, _audioVideoCall);
            Console.WriteLine("Waiting for the call to get terminated...");
            _waitForCallToTerminate.WaitOne();
            _audioVideoCall.Conversation.BeginTerminate(EndTerminateConversation, _audioVideoCall.Conversation);
            Console.WriteLine("Waiting for the conversation to get terminated...");
            _waitForConversationToTerminate.WaitOne();

            //Now, cleanup by shutting down the platform.
            Console.WriteLine("Shutting down the platform...");
            _helper.ShutdownPlatform();

            // Pause the console to allow for easier viewing of logs.
            Console.WriteLine("Please hit any key to end the sample.");
            Console.ReadKey();
        }
Exemplo n.º 6
0
        void EstablishControlCall()
        {
            AudioVideoCallEstablishOptions ceo = new AudioVideoCallEstablishOptions()
            {
                UseGeneratedIdentityForTrustedConference = true
            };

            _controlAVCall = new AudioVideoCall(_location.Conversation);

            _controlAVCall.AudioVideoFlowConfigurationRequested += new EventHandler <AudioVideoFlowConfigurationRequestedEventArgs>(_controlAVCall_AudioVideoFlowConfigurationRequested);
            _controlAVCall.BeginEstablish(ceo,
                                          ar =>
            {
                try
                {
                    _controlAVCall.EndEstablish(ar);

                    List <IncomingAudioRoute> routesin  = new List <IncomingAudioRoute>();
                    List <OutgoingAudioRoute> routesout = new List <OutgoingAudioRoute>();

                    ParticipantEndpoint localEndpoint  = GetLocalParticipant().GetEndpoints()[0];
                    ParticipantEndpoint remoteEndpoint = _controlAVCall.RemoteEndpoint;

                    routesin.Add(new IncomingAudioRoute(localEndpoint));
                    routesin.Add(new IncomingAudioRoute(remoteEndpoint));

                    routesout.Add(new OutgoingAudioRoute(localEndpoint));
                    routesout.Add(new OutgoingAudioRoute(remoteEndpoint));

                    _controlAVCall.AudioVideoMcuRouting.BeginUpdateAudioRoutes(routesout, routesin,
                                                                               ar2 =>
                    {
                        try
                        {
                            _controlAVCall.AudioVideoMcuRouting.EndUpdateAudioRoutes(ar2);
                        }
                        catch (Exception ex)
                        {
                            Log(ex.ToString());
                        }
                    },
                                                                               null);
                }
                catch (Exception ex)
                {
                    Log(ex.ToString());
                }
            },
                                          null);
        }
Exemplo n.º 7
0
        public AudioVideoFlow CreateAudioVideoFlow(EventHandler <AudioVideoFlowConfigurationRequestedEventArgs> audioVideoFlowConfigurationRequestedEventHandler, EventHandler <MediaFlowStateChangedEventArgs> audioVideoFlowStateChangedEventHandler)
        {
            _audioVideoFlowConfigurationRequestedEventHandler = audioVideoFlowConfigurationRequestedEventHandler;
            _audioVideoFlowStateChangedEventHandler           = audioVideoFlowStateChangedEventHandler;

            UCMASampleHelper UCMASampleHelper = new UCMASampleHelper();
            UserEndpoint     userEndpoint     = UCMASampleHelper.CreateEstablishedUserEndpoint("AudioVideoFlowHelper");

            // If application settings are provided via the app.config file, then use them
            if (ConfigurationManager.AppSettings.HasKeys() == true)
            {
                _calledParty = "sip:" + ConfigurationManager.AppSettings["CalledParty"];
            }
            else
            {
                // Prompt user for user URI
                string prompt = "Please enter the Called Party URI in the User@Host format => ";
                _calledParty = UCMASampleHelper.PromptUser(prompt, "Remote User URI");
                _calledParty = "sip:" + _calledParty;
            }

            // Setup the conversation and place the call.
            ConversationSettings convSettings = new ConversationSettings();

            convSettings.Priority = _conversationPriority;
            convSettings.Subject  = _conversationSubject;

            // Conversation represents a collection of modes of communication (media types)in the context of a dialog with one or multiple callees.
            Conversation   conversation   = new Conversation(userEndpoint, convSettings);
            AudioVideoCall audioVideoCall = new AudioVideoCall(conversation);

            //Call: StateChanged: Only hooked up for logging.
            audioVideoCall.StateChanged += new EventHandler <CallStateChangedEventArgs>(audioVideoCall_StateChanged);

            //Subscribe for the flow configuration requested event; the flow will be used to send the media.
            //Ultimately, as a part of the callback, the media will be sent/recieved.
            audioVideoCall.AudioVideoFlowConfigurationRequested += new EventHandler <AudioVideoFlowConfigurationRequestedEventArgs>(audioVideoCall_FlowConfigurationRequested);

            //Place the call to the remote party, with the default call options.
            audioVideoCall.BeginEstablish(_calledParty, null, EndCallEstablish, audioVideoCall);

            //Sync; wait for the call to complete.
            _waitForAudioVideoCallEstablishCompleted.WaitOne();

            //Sync; wait for the AudioVideoFlow goes Active
            _waitForAudioVideoFlowStateChangedToActiveCompleted.WaitOne();

            return(_audioVideoFlow);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Establishes an Av call to the conferencesession on the supplied
        /// conversation.
        /// </summary>
        /// <param name="conversationToEstablishImCallOn">
        /// The conversation to establish the Av call on.
        /// </param>
        private AudioVideoCall EstablishAvCallToConference(Conversation conversationToEstablishImCallOn)
        {
            Console.WriteLine("Establishing an Av call to the conference.");

            AutoResetEvent _avFlowCreated = new AutoResetEvent(false);
            var            newAvCall      = new AudioVideoCall(conversationToEstablishImCallOn);

            //Calling begin Establish with no parameters will establish an Av
            // call to the conference session on the conversation.
            var establishCallResult = newAvCall.BeginEstablish(ConferenceAvCallEstablishCompleted, newAvCall);

            Console.WriteLine("Waiting for the AvCall to be established to the conference.");
            establishCallResult.AsyncWaitHandle.WaitOne();

            return(newAvCall);
        }
        /// <summary>
        /// Establishes av call directly to the destination.
        /// </summary>
        private void EstablishAvCallDirectly()
        {
            bool      exceptionEncountered = true;
            Exception exceptionCaught      = null;

            try
            {
                CallEstablishOptions establishOptions = new CallEstablishOptions();
                //Add custom MIME parts based on conversation context.
                if (m_cutomMimePart != null)
                {
                    establishOptions.CustomMimeParts.Add(m_cutomMimePart);
                }
                //Construct the destination uri, if needed.
                m_avCall.BeginEstablish(m_destinationUri, establishOptions, this.AudioVideoCallEstablishCompleted, null /*state*/);
                exceptionEncountered = false;
            }
            catch (ArgumentException ae)
            {
                Helper.Logger.Error("Exception = {0}", EventLogger.ToString(ae));
                exceptionCaught = ae;
            }
            catch (InvalidOperationException ioe)
            {
                Helper.Logger.Info("Exception = {0}", EventLogger.ToString(ioe));
                exceptionCaught = ioe;
            }
            finally
            {
                if (exceptionEncountered)
                {
                    OperationFault operationFault = null;
                    if (exceptionCaught != null)
                    {
                        operationFault = FaultHelper.CreateClientOperationFault(exceptionCaught.Message, exceptionCaught.InnerException);
                    }
                    else
                    {
                        operationFault = FaultHelper.CreateServerOperationFault(FailureStrings.GenericFailures.UnexpectedException, null /*innerException*/);
                    }

                    this.CompleteEstablishOperationWithException(new FaultException <OperationFault>(operationFault));
                }
            }
        }
Exemplo n.º 10
0
        public void EstablishAudioVideoCall(Conversation conversation)
        {
            if (_state == TranscriptRecorderState.Terminated)
            {
                NonBlockingConsole.WriteLine("Error: AVTranscriptRecorder has already been shutdown.");
                // TODO: Error message
                return;
            }

            if (_audioVideoCall != null)
            {
                NonBlockingConsole.WriteLine("Warn: AVCall already exists for this Conversation. Shutting down previous call...");
                // TODO: info message
                TerminateCall();
            }

            _state = TranscriptRecorderState.Initialized;
            _waitForAudioVideoCallTerminated.Reset();

            try
            {
                AudioVideoCall avCall = new AudioVideoCall(conversation);

                // Register for Call events
                _audioVideoCall = avCall;

                // Call: StateChanged: Only hooked up for logging, to show the call
                // state transitions.
                _audioVideoCall.StateChanged += new EventHandler <CallStateChangedEventArgs>(AudioVideoCall_StateChanged);

                // Subscribe for the flow configuration requested event; the flow will be used to send the media.
                // Ultimately, as a part of the callback, the media will be sent/recieved.
                _audioVideoCall.AudioVideoFlowConfigurationRequested += new EventHandler <AudioVideoFlowConfigurationRequestedEventArgs>(AudioVideoCall_FlowConfigurationRequested);

                _audioVideoCall.ConversationChanged += new EventHandler <ConversationChangedEventArgs>(AudioVideoCall_ConversationChanged);

                // Establish AudioVideoCall
                avCall.BeginEstablish(AudioVideoCall_EstablishCompleted, avCall);
            }
            catch (InvalidOperationException ex)
            {
                NonBlockingConsole.WriteLine("Error: avCall.BeginEstablish failed. Exception: {0}", ex.ToString());
                // TODO: Error message
            }
        }
Exemplo n.º 11
0
        private void InitialCallEstablishCompleted(IAsyncResult ar)
        {
            Call      call = ar.AsyncState as Call;
            Exception ex   = null;

            try
            {
                call.EndEstablish(ar);
                Console.WriteLine("The call with Local Participant: " + call.Conversation.LocalParticipant +
                                  " and Remote Participant: " + call.RemoteEndpoint.Participant +
                                  " is now in the established state.");
                // Perform the second call, from the transferor user to the
                // final user, without specifying any custom options.
                Conversation   convFinalandTransferring  = new Conversation(_transferorUserEndpoint);
                AudioVideoCall avCallTransferringtoFinal = new AudioVideoCall(convFinalandTransferring);
                // Bind the event handler to display the events as the transferor
                // endpoint begins the transfer.
                avCallTransferringtoFinal.TransferStateChanged += this.AVCall_TransferStateChanged;
                avCallTransferringtoFinal.BeginEstablish(_transferTargetURI, null,
                                                         TransferringCallEstablishCompleted, avCallTransferringtoFinal);
            }
            catch (OperationFailureException opFailEx)
            {
                // OperationFailureException: Indicates failure to connect the
                // call to the remote party.
                // TODO (Left to the reader): Add error handling code here.
                ex = opFailEx;
            }
            catch (RealTimeException exception)
            {
                // RealTimeException may be thrown on media or link-layer failures.
                // TODO (Left to the reader): Add error handling code here.
                ex = exception;
            }
            finally
            {
                if (ex != null)
                {
                    Console.WriteLine(ex.ToString());
                    Console.WriteLine("Terminating the application due to failure");
                    _sampleCompleted.Set();
                }
            }
        }
Exemplo n.º 12
0
        private void CallEstablishCompleted(IAsyncResult ar)
        {
            Call call            = ar.AsyncState as Call;
            RealTimeException ex = null;

            try
            {
                call.EndEstablish(ar);
                Console.WriteLine("The call with Local Participant: " + call.Conversation.LocalParticipant +
                                  " and Remote Participant: " + call.RemoteEndpoint.Participant +
                                  " is now in the established state.");
                // Setup the call object for the second call (AV), reusing the
                // original conversation, and place the call (synchronously).
                // Reuse of the conversation allows for effortless modality
                // management. Either endpoint could add the new modality and
                // place the call below.
                AudioVideoCall audioVideoCall = new AudioVideoCall(_conversation);
                audioVideoCall.BeginEstablish(AVCallEstablishCompleted, audioVideoCall);
            }
            catch (OperationFailureException opFailEx)
            {
                // OperationFailureException: Indicates failure to connect the
                // call to the remote party.
                // TODO (Left to the reader): Add error handling code here
                ex = opFailEx;
            }
            catch (RealTimeException exception)
            {
                // RealTimeException may be thrown on media or link-layer failures.
                // TODO (Left to the reader): Add error handling code here
                ex = exception;
            }
            finally
            {
                if (ex != null)
                {
                    Console.WriteLine("Completing application with error");
                    Console.WriteLine(ex.ToString());
                    _sampleCompleted.Set();
                }
            }
        }
        /// <summary>
        /// Establish call by first calling the phone number and then doing self transfer and then back to backing with the destination.
        /// </summary>
        private void EstablishClickToCall()
        {
            bool      exceptionEncountered = true;
            Exception exceptionCaught      = null;

            try
            {
                string callbackPhoneUri = Helper.GetCallbackPhoneUri(m_establishAvCallRequest.CallbackPhoneNumber);
                m_callbackCall.BeginEstablish(callbackPhoneUri, null /*establishOptions*/, this.CallbackAudioVideoCallEstablishCompleted, null /*state*/);
                exceptionEncountered = false;
            }
            catch (ArgumentException ae)
            {
                Helper.Logger.Error("Exception = {0}", EventLogger.ToString(ae));
                exceptionCaught = ae;
            }
            catch (InvalidOperationException ioe)
            {
                Helper.Logger.Info("Exception = {0}", EventLogger.ToString(ioe));
                exceptionCaught = ioe;
            }
            finally
            {
                if (exceptionEncountered)
                {
                    OperationFault operationFault = null;
                    if (exceptionCaught != null)
                    {
                        operationFault = FaultHelper.CreateClientOperationFault(exceptionCaught.Message, exceptionCaught.InnerException);
                    }
                    else
                    {
                        operationFault = FaultHelper.CreateServerOperationFault(FailureStrings.GenericFailures.UnexpectedException, null /*innerException*/);
                    }

                    this.CompleteEstablishOperationWithException(new FaultException <OperationFault>(operationFault));
                }
            }
        }
Exemplo n.º 14
0
        private void Run()
        {
            // A helper class to take care of platform and endpoint setup and
            // cleanup. This has been abstracted from this sample to focus on Call Control.
            _helper = new UCMASampleHelper();

            // Create the user endpoints from the network credential objects
            // defined above.
            _transfereeEndpoint     = _helper.CreateEstablishedUserEndpoint("Transferee" /*endpointFriendlyName*/);
            _transferorUserEndpoint = _helper.CreateEstablishedUserEndpoint(
                "Transferor" /*endpointFriendlyName*/);
            _transferTargetEndpoint = _helper.CreateEstablishedUserEndpoint(
                "Transfer Target" /*endpointFriendlyName*/);
            _transfereeURI     = _transfereeEndpoint.OwnerUri;
            _transferTargetURI = _transferTargetEndpoint.OwnerUri;

            // Register for incoming audio calls on the initial and final endpoints.
            _transferTargetEndpoint.RegisterForIncomingCall <AudioVideoCall>(On_AudioVideoCall_Received);
            _transfereeEndpoint.RegisterForIncomingCall <AudioVideoCall>(On_AudioVideoCall_Received);

            // Setup the call objects for both the call from transferring
            // to initial and transferring to final
            Conversation convInitialandTransferring = new Conversation(_transferorUserEndpoint);

            _avCallTransferringtoInitial = new AudioVideoCall(convInitialandTransferring);

            // Perform the first call, from the transferor user to the initial
            // user, without specifying any custom options.
            _avCallTransferringtoInitial.BeginEstablish(_transfereeURI, null, InitialCallEstablishCompleted,
                                                        _avCallTransferringtoInitial);

            _sampleCompleted.WaitOne();

            UCMASampleHelper.PauseBeforeContinuing("Press ENTER to shutdown and exit.");

            // And shutdown.
            _helper.ShutdownPlatform();
        }
Exemplo n.º 15
0
        public void ExtablishOutboundAVCall(ApplicationEndpoint appEndpoint, string destinationSipUri, string message)
        {
            
            try
            {
                Conversation conversation = new Conversation(appEndpoint);
                AudioVideoCall call = new AudioVideoCall(conversation);

                call.BeginEstablish(destinationSipUri,
                    new CallEstablishOptions(),
                    result =>
                    {
                        try
                        {
                            call.EndEstablish(result);
                            SpeakMessage(call.Flow, message);
/*                                string.Format("Hello, {0}. This my UCMA app calling you. " + "Your SIP URI is {1}",
                                call.RemoteEndpoint.Participant.DisplayName,
                                call.RemoteEndpoint.Participant.Uri));
 * */
                        }
                        catch (RealTimeException ex)
                        {
                            Console.WriteLine("Failed establishing AV call {0}", ex);
                        }
                    },
                    null);
            }
            catch (InvalidOperationException ex)
            {
                Console.WriteLine("Failed establishing AV call {0}", ex);
            }
        }
Exemplo n.º 16
0
        private void PerformSupervisedTransfer()
        {
            ConversationSettings settings = new ConversationSettings()
            {
                Subject = "Supervised transfer"
            };

            Conversation newConversation = new Conversation(_appEndpoint, settings);

            AudioVideoCall newCall = new AudioVideoCall(newConversation);

            try
            {
                newCall.BeginEstablish(_destinationSipUri, null,
                    ar =>
                    {
                        try
                        {
                            newCall.EndEstablish(ar);

                            ReplaceNewCallWithIncomingCall(newCall);
                        }
                        catch (RealTimeException rtex)
                        {
                            _logger.Log("Failed establishing second call.", rtex);
                        }
                    },
                    null
                );
            }
            catch (InvalidOperationException ioex)
            {
                _logger.Log("Failed establishing second call.", ioex);
            }
        }
        private void OnTransferReceived(object sender, AudioVideoCallTransferReceivedEventArgs e)
        {
            // Unregister the event handlers.
            _avCall.TransferReceived -= OnTransferReceived;
            _avCall.Forwarded -= OnCallForwarded;

            // Accept the REFER request with no special headers.
            e.Accept(null);

            // Create a new A/V call with the transfer-to URI using the
            // pre-initialized Conversation object.
            AudioVideoCall newCall = new AudioVideoCall(e.NewConversation);

            try
            {
                // Establish the call to the transfer-to endpoint.
                newCall.BeginEstablish(e.TransferDestination, null, 
                    ar =>
                    {
                        try
                        {
                            newCall.EndEstablish(ar);
                        }
                        catch (RealTimeException rtex)
                        {
                            _logger.Log("Failed establishing new call following transfer.", rtex);
                        }
                    },
                    null
                );
            }
            catch (InvalidOperationException ioex)
            {
                _logger.Log("Failed establishing new call following transfer.", ioex);
            }
        }
Exemplo n.º 18
0
        public Location(int id, string name, string fileName, LocalEndpoint endpoint)
        {
            if (!File.Exists(fileName))
                throw new FileNotFoundException(fileName);

            _id = id;
            _Name = name;
            _FileName = fileName;
            _Endpoint = endpoint;

            ConferenceScheduleInformation csi = new ConferenceScheduleInformation()
            {
                AccessLevel = ConferenceAccessLevel.Everyone,
                Description = _Name,
                ExpiryTime = DateTime.Now.AddYears(5),
                AutomaticLeaderAssignment = AutomaticLeaderAssignment.Everyone
            };

            csi.Mcus.Add(new ConferenceMcuInformation(McuType.AudioVideo));

            _Endpoint.ConferenceServices.BeginScheduleConference(csi,
                ar =>
                {
                    try
                    {
                        _conference = _Endpoint.ConferenceServices.EndScheduleConference(ar);

                        Log("Conference " + _conference.ConferenceId + " scheduled. Starting music...");

                        Log(_conference.ConferenceUri);

                        ConversationSettings cs = new ConversationSettings()
                        {
                            Subject = _Name
                        };

                        _conversation = new Conversation(_Endpoint, cs);

                        ConferenceJoinOptions cjo = new ConferenceJoinOptions()
                        {
                            JoinMode = JoinMode.TrustedParticipant
                        };

                        _conversation.ConferenceSession.BeginJoin(_conference.ConferenceUri,
                            cjo,
                            ar1 =>
                            {
                                try
                                {
                                    _conversation.ConferenceSession.EndJoin(ar1);

                                    _avCall = new AudioVideoCall(_conversation);
                                    _avCall.AudioVideoFlowConfigurationRequested +=
                                        new EventHandler<AudioVideoFlowConfigurationRequestedEventArgs>(_avCall_AudioVideoFlowConfigurationRequested);

                                    AudioVideoCallEstablishOptions options = new AudioVideoCallEstablishOptions()
                                    {
                                        UseGeneratedIdentityForTrustedConference = true,
                                        SupportsReplaces = CapabilitySupport.Supported
                                    };

                                    _avCall.BeginEstablish(
                                        options,
                                        ar2 =>
                                        {
                                            try
                                            {
                                                _avCall.EndEstablish(ar2);
                                            }
                                            catch (Exception ex)
                                            {
                                                Log(ex.ToString());
                                            }
                                        },
                                        null);
                                }
                                catch (Exception ex)
                                {
                                    Log(ex.ToString());
                                }
                            },
                            null);
                    }
                    catch (Exception ex)
                    {
                        Log(ex.ToString());
                    }
                },
                null);
        }
        public void EstablishAudioVideoCall(Conversation conversation)
        {
            if (_state == TranscriptRecorderState.Terminated)
            {
                NonBlockingConsole.WriteLine("Error: AVTranscriptRecorder has already been shutdown.");
                // TODO: Error message
                return;
            }

            if (_audioVideoCall != null)
            {
                NonBlockingConsole.WriteLine("Warn: AVCall already exists for this Conversation. Shutting down previous call...");
                // TODO: info message
                TerminateCall();
            }
            
            _state = TranscriptRecorderState.Initialized;
            _waitForAudioVideoCallTerminated.Reset();

            try
            {
                AudioVideoCall avCall = new AudioVideoCall(conversation);

                // Register for Call events
                _audioVideoCall = avCall;

                // Call: StateChanged: Only hooked up for logging, to show the call 
                // state transitions.
                _audioVideoCall.StateChanged += new EventHandler<CallStateChangedEventArgs>(AudioVideoCall_StateChanged);

                // Subscribe for the flow configuration requested event; the flow will be used to send the media.
                // Ultimately, as a part of the callback, the media will be sent/recieved.
                _audioVideoCall.AudioVideoFlowConfigurationRequested += new EventHandler<AudioVideoFlowConfigurationRequestedEventArgs>(AudioVideoCall_FlowConfigurationRequested);

                _audioVideoCall.ConversationChanged += new EventHandler<ConversationChangedEventArgs>(AudioVideoCall_ConversationChanged);

                // Establish AudioVideoCall
                avCall.BeginEstablish(AudioVideoCall_EstablishCompleted, avCall);
            }
            catch (InvalidOperationException ex)
            {
                NonBlockingConsole.WriteLine("Error: avCall.BeginEstablish failed. Exception: {0}", ex.ToString());
                // TODO: Error message
            }
        }
Exemplo n.º 20
0
        public void Run()
        {
            //Initalize and startup the platform.
            ClientPlatformSettings clientPlatformSettings = new ClientPlatformSettings(_applicationName, _transportType);

            _collabPlatform = new CollaborationPlatform(clientPlatformSettings);
            _collabPlatform.BeginStartup(EndPlatformStartup, _collabPlatform);

            // Get port range
            NetworkPortRange portRange = CollaborationPlatform.AudioVideoSettings.GetPortRange();

            Console.WriteLine("Port range is from " + portRange.LocalNetworkPortMin + " to " + portRange.LocalNetworkPortMax);

            // Modifying port range
            portRange.SetRange(1500, 2000);
            CollaborationPlatform.AudioVideoSettings.SetPortRange(portRange);
            Console.WriteLine("Port range now is from " + portRange.LocalNetworkPortMin + " to " + portRange.LocalNetworkPortMax);

            //Sync; wait for the startup to complete.
            _autoResetEvent.WaitOne();


            //Initalize and register the endpoint, using the credentials of the user the application will be acting as.
            UserEndpointSettings userEndpointSettings = new UserEndpointSettings(_userURI, _userServer);

            userEndpointSettings.Credential = _credential;
            _userEndpoint = new UserEndpoint(_collabPlatform, userEndpointSettings);
            _userEndpoint.BeginEstablish(EndEndpointEstablish, _userEndpoint);

            //Sync; wait for the registration to complete.
            _autoResetEvent.WaitOne();


            //Setup the conversation and place the call.
            ConversationSettings convSettings = new ConversationSettings();

            convSettings.Priority = _conversationPriority;
            convSettings.Subject  = _conversationSubject;
            //Conversation represents a collection of modalities in the context of a dialog with one or multiple callees.
            Conversation conversation = new Conversation(_userEndpoint, convSettings);

            _audioVideoCall = new AudioVideoCall(conversation);

            //Call: StateChanged: Only hooked up for logging.
            _audioVideoCall.StateChanged += new EventHandler <CallStateChangedEventArgs>(audioVideoCall_StateChanged);

            //Subscribe for the flow configuration requested event; the flow will be used to send the media.
            //Ultimately, as a part of the callback, the media will be sent/recieved.
            _audioVideoCall.AudioVideoFlowConfigurationRequested += this.audioVideoCall_FlowConfigurationRequested;


            //Place the call to the remote party;
            _audioVideoCall.BeginEstablish(_calledParty, null, EndCallEstablish, _audioVideoCall);

            //Sync; wait for the call to complete.
            _autoResetEvent.WaitOne();

            // Shutdown the platform
            _collabPlatform.BeginShutdown(EndPlatformShutdown, _collabPlatform);

            //Wait for shutdown to occur.
            _autoResetShutdownEvent.WaitOne();
        }
Exemplo n.º 21
0
        public Location(int id, string name, string fileName, LocalEndpoint endpoint)
        {
            if (!File.Exists(fileName))
            {
                throw new FileNotFoundException(fileName);
            }

            _id       = id;
            _Name     = name;
            _FileName = fileName;
            _Endpoint = endpoint;

            ConferenceScheduleInformation csi = new ConferenceScheduleInformation()
            {
                AccessLevel = ConferenceAccessLevel.Everyone,
                Description = _Name,
                ExpiryTime  = DateTime.Now.AddYears(5),
                AutomaticLeaderAssignment = AutomaticLeaderAssignment.Everyone
            };

            csi.Mcus.Add(new ConferenceMcuInformation(McuType.AudioVideo));

            _Endpoint.ConferenceServices.BeginScheduleConference(csi,
                                                                 ar =>
            {
                try
                {
                    _conference = _Endpoint.ConferenceServices.EndScheduleConference(ar);

                    Log("Conference " + _conference.ConferenceId + " scheduled. Starting music...");

                    Log(_conference.ConferenceUri);

                    ConversationSettings cs = new ConversationSettings()
                    {
                        Subject = _Name
                    };

                    _conversation = new Conversation(_Endpoint, cs);

                    ConferenceJoinOptions cjo = new ConferenceJoinOptions()
                    {
                        JoinMode = JoinMode.TrustedParticipant
                    };

                    _conversation.ConferenceSession.BeginJoin(_conference.ConferenceUri,
                                                              cjo,
                                                              ar1 =>
                    {
                        try
                        {
                            _conversation.ConferenceSession.EndJoin(ar1);

                            _avCall = new AudioVideoCall(_conversation);
                            _avCall.AudioVideoFlowConfigurationRequested +=
                                new EventHandler <AudioVideoFlowConfigurationRequestedEventArgs>(_avCall_AudioVideoFlowConfigurationRequested);

                            AudioVideoCallEstablishOptions options = new AudioVideoCallEstablishOptions()
                            {
                                UseGeneratedIdentityForTrustedConference = true,
                                SupportsReplaces = CapabilitySupport.Supported
                            };

                            _avCall.BeginEstablish(
                                options,
                                ar2 =>
                            {
                                try
                                {
                                    _avCall.EndEstablish(ar2);
                                }
                                catch (Exception ex)
                                {
                                    Log(ex.ToString());
                                }
                            },
                                null);
                        }
                        catch (Exception ex)
                        {
                            Log(ex.ToString());
                        }
                    },
                                                              null);
                }
                catch (Exception ex)
                {
                    Log(ex.ToString());
                }
            },
                                                                 null);
        }
        private void InviteSupervisor()
        {
            Console.WriteLine("Inviting the supervisor (" + _supervisorSipUri + ") to incoming call.");
            LocalEndpoint localEndpoint = _backEndCallLeg.Conversation.Endpoint;

            // Create a new audio call to call the supervisor.
            Conversation supervisorConversation = new Conversation(localEndpoint);
            AudioVideoCall supervisorCall = new AudioVideoCall(supervisorConversation);

            try
            {
                // Place an outbound call to the supervisor.
                supervisorCall.BeginEstablish(_supervisorSipUri,
                    default(CallEstablishOptions),
                    establishAsyncResult =>
                    {
                        try
                        {
                            supervisorCall.EndEstablish(establishAsyncResult);

                            // Wait for a couple of seconds before transferring.
                            Thread.Sleep(2000);

                            SelfTransferSupervisorCall(supervisorCall);
                        }
                        catch (RealTimeException ex)
                        {
                            Console.WriteLine(ex);
                        }
                    },
                    null);
            }
            catch (InvalidOperationException ex)
            {
                Console.WriteLine(ex);
            }
        }
Exemplo n.º 23
0
        void EstablishControlCall()
        {
            AudioVideoCallEstablishOptions ceo = new AudioVideoCallEstablishOptions()
            {
                UseGeneratedIdentityForTrustedConference = true
            };

            _controlAVCall = new AudioVideoCall(_location.Conversation);

            _controlAVCall.AudioVideoFlowConfigurationRequested += new EventHandler<AudioVideoFlowConfigurationRequestedEventArgs>(_controlAVCall_AudioVideoFlowConfigurationRequested);
            _controlAVCall.BeginEstablish(ceo,
                ar =>
                {
                    try
                    {
                        _controlAVCall.EndEstablish(ar);

                        List<IncomingAudioRoute> routesin = new List<IncomingAudioRoute>();
                        List<OutgoingAudioRoute> routesout = new List<OutgoingAudioRoute>();

                        ParticipantEndpoint localEndpoint = GetLocalParticipant().GetEndpoints()[0];
                        ParticipantEndpoint remoteEndpoint = _controlAVCall.RemoteEndpoint;

                        routesin.Add(new IncomingAudioRoute(localEndpoint));
                        routesin.Add(new IncomingAudioRoute(remoteEndpoint));

                        routesout.Add(new OutgoingAudioRoute(localEndpoint));
                        routesout.Add(new OutgoingAudioRoute(remoteEndpoint));

                        _controlAVCall.AudioVideoMcuRouting.BeginUpdateAudioRoutes(routesout, routesin,
                            ar2 =>
                            {
                                try
                                {
                                    _controlAVCall.AudioVideoMcuRouting.EndUpdateAudioRoutes(ar2);
                                }
                                catch (Exception ex)
                                {
                                    Log(ex.ToString());
                                }
                            },
                            null);
                    }
                    catch (Exception ex)
                    {
                        Log(ex.ToString());
                    }
                },
                null);
        }