Beispiel #1
0
        public T GetCapability <T>(RtpChannel channel) where T : RtpCapability
        {
            var capability = this.UnicastChannel.GetCapability <T>();

            if (capability != null)
            {
                return(capability);
            }
            lock (_multicastChannels)
            {
                foreach (var mychannel in _multicastChannels)
                {
                    if (mychannel == channel)
                    {
                        capability = channel.GetCapability <T>();
                    }

                    if (capability != null)
                    {
                        return(capability);
                    }
                }
            }
            throw new InvalidOperationException(string.Format(Strings.NoCapabilityAtContext, typeof(T).Name));
        }
Beispiel #2
0
 internal void Join(RtpChannel channel)
 {
     if (this.Channel != null)
     {
         throw new InvalidOperationException(string.Format(Strings.HasJoinedChannel, this.Name));
     }
     this.Channel = channel;
     HandleJoinedChannel(channel);
 }
Beispiel #3
0
 /// <summary>
 /// 安装模块
 /// </summary>
 /// <param name="context"></param>
 public void Install(RtpCommunicator communicator)
 {
     if (this.Installed)
     {
         return;
     }
     this.Installed    = true;
     this.Communicator = communicator;
     _channel          = CreateChannel(communicator);
     InstallImpl(communicator);
     _events.Raise(communicator, this, true);
 }
Beispiel #4
0
        /// <summary>
        /// 移除模块
        /// </summary>
        /// <param name="context"></param>
        public void Uninstall(RtpCommunicator communicator)
        {
            if (!this.Installed)
            {
                return;
            }
            this.Installed = false;
            UninstallImpl(communicator);

            LogoutCapabilities();
            RemoveChannel(communicator);
            _channel          = null;
            this.Communicator = null;
            _events.Raise(communicator, this, false);
        }
Beispiel #5
0
        public RtpChannel GetMulticastChannel(string multicastAddress)
        {
            RtpChannel result = null;

            lock (_multicastChannels)
            {
                foreach (var channel in _multicastChannels)
                {
                    if (channel.HostAddress == multicastAddress)
                    {
                        result = channel;
                        break;
                    }
                }
            }
            return(result);
        }
Beispiel #6
0
 /// <summary>
 /// 创建或得到一个基于多播地址的通道,如果通道已存在,那么返回当前通道,并追加引用计数
 /// </summary>
 /// <param name="multicastAddress"></param>
 /// <returns></returns>
 public RtpChannel CreateChannel(string multicastAddress, Participant participant)
 {
     ValidateConnected();
     lock (_multicastChannels)
     {
         var channel = GetMulticastChannel(multicastAddress);
         if (channel == null)
         {
             channel = new RtpChannel(this, multicastAddress, participant);
             _multicastChannels.Add(channel);
             this.Client.Join(multicastAddress, participant);
         }
         channel.ReferenceCount++;
         return(channel);
     }
     //throw new InvalidOperationException(string.Format(Strings.ChannelExistsOnAddress, multicastAddress));
 }
Beispiel #7
0
 /// <summary>
 /// 处理离开通道
 /// </summary>
 /// <param name="channel"></param>
 protected virtual void HandleLeftChannel(RtpChannel channel)
 {
 }
Beispiel #8
0
 /// <summary>
 /// 处理加入通道
 /// </summary>
 /// <param name="channel"></param>
 protected virtual void HandleJoinedChannel(RtpChannel channel)
 {
 }