Beispiel #1
0
        /// <summary>
        /// Create and start AV session with remote Uri
        /// </summary>
        /// <param name="remoteUri"></param>
        public void StartAVSession(string avRemoteUri)
        {
            this.avRemoteUri = avRemoteUri;

            // Create AV session
            CreateSession(UCC_SESSION_TYPE.UCCST_AUDIO_VIDEO);

            // Create remote participant
            UccUriManager                    uriManager    = new UccUriManager();
            IUccSessionParticipant           participant   = this.avSession.CreateParticipant(uriManager.ParseUri(this.avRemoteUri), null);
            IUccAudioVideoSessionParticipant avParticipant = participant as IUccAudioVideoSessionParticipant;

            // Create audio channel
            IUccMediaChannel channel = avParticipant.CreateChannel(UCC_MEDIA_TYPES.UCCMT_AUDIO, null);

            channel.PreferredMedia = (int)(UCC_MEDIA_DIRECTIONS.UCCMD_RECEIVE | UCC_MEDIA_DIRECTIONS.UCCMD_SEND);

            // Add channel
            avParticipant.AddChannel(channel);

            UccOperationContext context = new UccOperationContextClass();

            context.Initialize(operationId++, null);
            // Add remote participant
            this.avSession.AddParticipant(participant, context);
        }
Beispiel #2
0
 protected virtual void OnParticipantAdded(IUccSession eventSource, IUccSessionParticipant participant)
 {
     if (participant.IsLocal == false)
     {
         ComEvents.Advise <_IUccSessionParticipantEvents>(participant, this);
     }
 }
Beispiel #3
0
        protected override void OnParticipantAdded(IUccSession eventSource, IUccSessionParticipant participant)
        {
            base.OnParticipantAdded(eventSource, participant);

            if (participant.IsLocal == false)
            {
                ComEvents.Advise <_IUccInstantMessagingSessionParticipantEvents>(participant, this);
            }
        }
Beispiel #4
0
        protected override void OnParticipantAdded(IUccSession eventSource, IUccSessionParticipant participant)
        {
            base.OnParticipantAdded(eventSource, participant);

            IUccAudioVideoSessionParticipant avParticipant = participant as IUccAudioVideoSessionParticipant;

            foreach (IUccMediaChannel channel in avParticipant.Channels)
            {
                this.OnChannelAdded(avParticipant, channel);
            }

            ComEvents.Advise <_IUccMediaChannelCollectionEvents>(avParticipant, this);
        }
Beispiel #5
0
        public ParticipantLog AddPartipant(string uri)
        {
            uri = Helpers.CorrectUri(uri);
            var log = this.GetPartipantLog(uri);

            if (this.UccSession == null)
            {
                log.State = PartipantLogState.SessionTerminated;
            }
            else
            {
                //if (Helpers.IsUriEqual(uri, this.PartipantLogs[0].Uri))
                //{
                //    log.SetState(PartipantLogState.InvalidUri, @"URI is invalid, loopback is not allowed");
                //    return log;
                //}

                foreach (IUccSessionParticipant participant in this.UccSession.Participants)
                {
                    if (Helpers.IsUriEqual(uri, participant.Uri))
                    {
                        return(log);
                    }
                }

                UccUri uccUri;
                if (Helpers.TryParseUri(uri, out uccUri))
                {
                    log.State = PartipantLogState.AddBegin;

                    IUccSessionParticipant participant = this.UccSession.CreateParticipant(uccUri, null);

                    this.AddChannel(participant);

                    UccOperationContext operationContext = new UccOperationContextClass();
                    operationContext.Initialize(0, new UccContextClass());
                    operationContext.Context.AddProperty(ContextParticipantUri, uri);

                    this.UccSession.AddParticipant(participant, operationContext);
                }
                else
                {
                    log.SetState(PartipantLogState.InvalidUri, @"URI is invalid, e.g. sip:[email protected]");
                }
            }

            return(log);
        }
Beispiel #6
0
        /// <summary>
        /// Create and start IM session with remote Uri
        /// </summary>
        /// <param name="remoteUri"></param>
        public void StartIMSession(string imRemoteUri)
        {
            this.imRemoteUri = imRemoteUri;

            // Create IM session
            CreateSession(UCC_SESSION_TYPE.UCCST_INSTANT_MESSAGING);

            // Create remote participant
            UccUriManager          uriManager  = new UccUriManager();
            IUccSessionParticipant participant = this.imSession.CreateParticipant(uriManager.ParseUri(this.imRemoteUri), null);

            UccOperationContext context = new UccOperationContextClass();

            context.Initialize(operationId++, null);
            // Add remote participant
            this.imSession.AddParticipant(participant, context);
        }
Beispiel #7
0
        protected override void AddChannel(IUccSessionParticipant participant)
        {
            IUccAudioVideoSessionParticipant avParticipant = participant as IUccAudioVideoSessionParticipant;

            IUccMediaChannel audioChannel = avParticipant.CreateChannel(UCC_MEDIA_TYPES.UCCMT_AUDIO, null);

            audioChannel.PreferredMedia = (int)(UCC_MEDIA_DIRECTIONS.UCCMD_RECEIVE | UCC_MEDIA_DIRECTIONS.UCCMD_SEND);

            avParticipant.AddChannel(audioChannel);

            if (this.isVideoEnabled)
            {
                IUccMediaChannel videoChannel = avParticipant.CreateChannel(UCC_MEDIA_TYPES.UCCMT_VIDEO, null);
                videoChannel.PreferredMedia = (int)(UCC_MEDIA_DIRECTIONS.UCCMD_RECEIVE | UCC_MEDIA_DIRECTIONS.UCCMD_SEND);

                avParticipant.AddChannel(videoChannel);
            }
        }
Beispiel #8
0
        /// <summary>
        /// Handle OnStateChanged events. Set the buttons in mainform to appropriate state
        /// when the session is connected or disconnected
        /// </summary>
        /// <param name="eventSource"></param>
        /// <param name="eventData"></param>
        void _IUccSessionParticipantEvents.OnStateChanged(
            IUccSessionParticipant eventSource,
            UccSessionParticipantStateChangedEvent eventData)
        {
            if (eventData.NewState == UCC_SESSION_ENTITY_STATE.UCCSES_CONNECTED)
            {
                switch (eventSource.Session.Type)
                {
                case UCC_SESSION_TYPE.UCCST_INSTANT_MESSAGING:
                    this.mainForm.SetIMOff();
                    this.mainForm.WriteStatusMessage("IM session is connected to " + eventSource.Uri);
                    break;

                case UCC_SESSION_TYPE.UCCST_AUDIO_VIDEO:
                    this.mainForm.SetVoIPOff();
                    this.mainForm.WriteStatusMessage("AV session is connected to " + eventSource.Uri);
                    break;

                default:
                    break;
                }
            }

            if (eventData.NewState == UCC_SESSION_ENTITY_STATE.UCCSES_DISCONNECTED)
            {
                switch (eventSource.Session.Type)
                {
                case UCC_SESSION_TYPE.UCCST_INSTANT_MESSAGING:
                    this.imSession = null;
                    this.mainForm.SetIMOn();
                    this.mainForm.WriteStatusMessage("IM session is disconnected.");
                    break;

                case UCC_SESSION_TYPE.UCCST_AUDIO_VIDEO:
                    this.avSession = null;
                    this.mainForm.SetVoipOn();
                    this.mainForm.WriteStatusMessage("AV Session is disconnected");
                    break;

                default:
                    return;
                }
            }
        }
Beispiel #9
0
 void _IUccSessionParticipantEvents.OnRemoveParticipantEndpoint(IUccSessionParticipant pEventSource, IUccOperationProgressEvent pEventData)
 {
 }
Beispiel #10
0
 void _IUccSessionParticipantEvents.OnStateChanged(IUccSessionParticipant eventSource, UccSessionParticipantStateChangedEvent eventData)
 {
     this.GetPartipantLog(eventSource).SetState(eventData.NewState);
 }
Beispiel #11
0
 protected ParticipantLog GetPartipantLog(IUccSessionParticipant participant)
 {
     return(this.GetPartipantLog(participant.Uri.Value));
 }
Beispiel #12
0
 protected virtual void AddChannel(IUccSessionParticipant participant)
 {
 }
        /// <summary>
        /// Handle OnStateChanged events. Set the buttons in mainform to appropriate state
        /// when the session is connected or disconnected
        /// </summary>
        /// <param name="eventSource"></param>
        /// <param name="eventData"></param>
        void _IUccSessionParticipantEvents.OnStateChanged(
                        IUccSessionParticipant eventSource,
                        UccSessionParticipantStateChangedEvent eventData)
        {
            if (eventData.NewState == UCC_SESSION_ENTITY_STATE.UCCSES_CONNECTED)
            {
                switch (eventSource.Session.Type)
                {
                    case UCC_SESSION_TYPE.UCCST_INSTANT_MESSAGING:
                        this.mainForm.SetIMOff();
                        this.mainForm.WriteStatusMessage("IM session is connected to " + eventSource.Uri);
                        break;

                    case UCC_SESSION_TYPE.UCCST_AUDIO_VIDEO:
                        this.mainForm.SetVoIPOff();
                        this.mainForm.WriteStatusMessage("AV session is connected to " + eventSource.Uri);
                        break;

                    default:
                        break;

                }
            }

            if (eventData.NewState == UCC_SESSION_ENTITY_STATE.UCCSES_DISCONNECTED)
            {
                switch (eventSource.Session.Type)
                {
                    case UCC_SESSION_TYPE.UCCST_INSTANT_MESSAGING:
                        this.imSession = null;
                        this.mainForm.SetIMOn();
                        this.mainForm.WriteStatusMessage("IM session is disconnected.");
                        break;

                    case UCC_SESSION_TYPE.UCCST_AUDIO_VIDEO:
                        this.avSession = null;
                        this.mainForm.SetVoipOn();
                        this.mainForm.WriteStatusMessage("AV Session is disconnected");
                        break;

                    default:
                        return;
                }
            }
        }
 void _IUccSessionParticipantEvents.OnRemoveParticipantEndpoint(IUccSessionParticipant pEventSource, IUccOperationProgressEvent pEventData)
 {
 }
Beispiel #15
0
        protected override void OnParticipantRemoved(IUccSession eventSource, IUccSessionParticipant participant)
        {
            base.OnParticipantRemoved(eventSource, participant);

            ComEvents.Unadvise <_IUccMediaChannelCollectionEvents>(participant, this);
        }