Exemplo n.º 1
0
 public BroadcastChannel(
     PeerCast peercast,
     Guid channel_id,
     ChannelInfo channel_info,
     IContentReaderFactory content_reader_factory)
     : base(peercast, channel_id)
 {
     this.ChannelInfo = channel_info;
       this.ContentReaderFactory = content_reader_factory;
 }
        public BroadcastViewModel(PeerCast peerCast)
        {
            this.peerCast = peerCast;
              this.uiSettings = new UISettingsViewModel(PeerCastApplication.Current.Settings);
              start = new Command(OnBroadcast, () => CanBroadcast(StreamSource, ContentType, channelName));
              contentTypes = peerCast.ContentReaderFactories.ToArray();

              yellowPages = Enumerable.Repeat(new KeyValuePair<string,IYellowPageClient>("掲載なし", null),1)
            .Concat(peerCast.YellowPages.Select(yp => new KeyValuePair<string,IYellowPageClient>(yp.Name, yp)));
              if (contentTypes.Length > 0) contentType = contentTypes[0];

              this.SelectedSourceStream = SourceStreams.FirstOrDefault();
        }
Exemplo n.º 3
0
 public BroadcastChannel(
     PeerCast peercast,
     NetworkType network,
     Guid channel_id,
     ChannelInfo channel_info,
     ISourceStreamFactory source_stream_factory,
     IContentReaderFactory content_reader_factory)
     : base(peercast, network, channel_id)
 {
     this.ChannelInfo          = channel_info;
     this.SourceStreamFactory  = source_stream_factory;
     this.ContentReaderFactory = content_reader_factory;
 }
Exemplo n.º 4
0
        public BroadcastViewModel(PeerCast peerCast)
        {
            this.peerCast   = peerCast;
            this.uiSettings = new UISettingsViewModel(PeerCastApplication.Current.Settings);
            start           = new Command(OnBroadcast, () => CanBroadcast(StreamSource, ContentType, channelName));
            contentTypes    = peerCast.ContentReaderFactories.ToArray();

            yellowPages = Enumerable.Repeat(new KeyValuePair <string, IYellowPageClient>("掲載なし", null), 1)
                          .Concat(peerCast.YellowPages.Select(yp => new KeyValuePair <string, IYellowPageClient>(yp.Name, yp)));
            if (contentTypes.Length > 0)
            {
                contentType = contentTypes[0];
            }

            this.SelectedSourceStream = SourceStreams.FirstOrDefault();
        }
Exemplo n.º 5
0
        private void AddContentReaderFactory(Type type)
        {
            IContentReaderFactory factory = null;
            var constructor = type.GetConstructor(Type.EmptyTypes);

            if (constructor != null)
            {
                factory = constructor.Invoke(null) as IContentReaderFactory;
            }
            else if ((constructor = type.GetConstructor(new Type[] { typeof(PeerCast) })) != null)
            {
                factory = constructor.Invoke(new object[] { peerCast }) as IContentReaderFactory;
            }
            if (factory != null)
            {
                peerCast.ContentReaderFactories.Add(factory);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 配信を開始します。
        /// </summary>
        /// <param name="yp">チャンネル情報を載せるYellowPage</param>
        /// <param name="channel_id">チャンネルID</param>
        /// <param name="channel_info">チャンネル情報</param>
        /// <param name="source">配信ソース</param>
        /// <param name="source_stream_factory">配信ソースからコンテンツを取得するISourceStreamFactory</param>
        /// <param name="content_reader_factory">配信ソースのコンテンツを解析するIContentReaderFactory</param>
        /// <returns>Channelのインスタンス</returns>
        public Channel BroadcastChannel(
            NetworkType network,
            IYellowPageClient yp,
            Guid channel_id,
            ChannelInfo channel_info,
            Uri source,
            ISourceStreamFactory source_stream_factory,
            IContentReaderFactory content_reader_factory)
        {
            logger.Debug("Broadcasting channel {0} from {1}", channel_id.ToString("N"), source);
            var channel = new BroadcastChannel(this, network, channel_id, channel_info, source_stream_factory, content_reader_factory);

            channel.Start(source);
            ReplaceCollection(ref channels, orig => orig.Add(channel));
            DispatchMonitorEvent(mon => mon.OnChannelChanged(PeerCastChannelAction.Added, channel));
            if (yp != null)
            {
                yp.Announce(channel);
            }
            return(channel);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 配信を開始します。
        /// </summary>
        /// <param name="yp">チャンネル情報を載せるYellowPage</param>
        /// <param name="channel_id">チャンネルID</param>
        /// <param name="channel_info">チャンネル情報</param>
        /// <param name="source">配信ソース</param>
        /// <param name="content_reader_factory">配信ソースのコンテンツを解析するIContentReaderFactory</param>
        /// <returns>Channelのインスタンス</returns>
        public Channel BroadcastChannel(IYellowPageClient yp, Guid channel_id, ChannelInfo channel_info, Uri source, IContentReaderFactory content_reader_factory)
        {
            Channel channel = null;

            logger.Debug("Broadcasting channel {0} from {1}", channel_id.ToString("N"), source);
            ISourceStreamFactory source_factory = SourceStreamFactories.FirstOrDefault(factory => source.Scheme == factory.Scheme);

            if (source_factory == null)
            {
                logger.Error("Protocol `{0}' is not found", source.Scheme);
                throw new ArgumentException(String.Format("Protocol `{0}' is not found", source.Scheme));
            }
            channel = new Channel(this, channel_id, this.BroadcastID, source);
            Utils.ReplaceCollection(ref channels, orig => {
                var new_collection = new List <Channel>(orig);
                new_collection.Add(channel);
                return(new_collection);
            });
            channel.ChannelInfo = channel_info;
            var content_reader = content_reader_factory.Create(channel);
            var source_stream  = source_factory.Create(channel, source, content_reader);

            channel.Start(source_stream);
            if (ChannelAdded != null)
            {
                ChannelAdded(this, new ChannelChangedEventArgs(channel));
            }
            if (yp != null)
            {
                yp.Announce(channel);
            }
            return(channel);
        }
Exemplo n.º 8
0
 public ContentReaderItem(IContentReaderFactory reader)
 {
     ContentReaderFactory = reader;
 }
Exemplo n.º 9
0
 /// <summary>
 /// 配信を開始します。
 /// </summary>
 /// <param name="yp">チャンネル情報を載せるYellowPage</param>
 /// <param name="channel_id">チャンネルID</param>
 /// <param name="channel_info">チャンネル情報</param>
 /// <param name="source">配信ソース</param>
 /// <param name="content_reader_factory">配信ソースのコンテンツを解析するIContentReaderFactory</param>
 /// <returns>Channelのインスタンス</returns>
 public Channel BroadcastChannel(IYellowPageClient yp, Guid channel_id, ChannelInfo channel_info, Uri source, IContentReaderFactory content_reader_factory)
 {
     logger.Debug("Broadcasting channel {0} from {1}", channel_id.ToString("N"), source);
       var channel = new BroadcastChannel(this, channel_id, channel_info, content_reader_factory);
       Utils.ReplaceCollection(ref channels, orig => {
     var new_collection = new List<Channel>(orig);
     new_collection.Add(channel);
     return new_collection;
       });
       channel.Start(source);
       if (ChannelAdded!=null) ChannelAdded(this, new ChannelChangedEventArgs(channel));
       if (yp!=null) yp.Announce(channel);
       return channel;
 }
Exemplo n.º 10
0
 private bool CanBroadcast(Uri streamSource, IContentReaderFactory contentReaderFactory, string channelName)
 {
     return(streamSource != null &&
            contentReaderFactory != null &&
            !String.IsNullOrEmpty(channelName));
 }
Exemplo n.º 11
0
 private bool CanBroadcast(Uri streamSource, IContentReaderFactory contentReaderFactory, string channelName)
 {
     return streamSource != null
     && contentReaderFactory != null
     && !String.IsNullOrEmpty(channelName);
 }
Exemplo n.º 12
0
 public ContentReaderItem(IContentReaderFactory reader)
 {
     ContentReaderFactory = reader;
 }