/// <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); }
/// <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 => { var new_collection = new List <Channel>(orig); new_collection.Add(channel); return(new_collection); }); if (ChannelAdded != null) { ChannelAdded(this, new ChannelChangedEventArgs(channel)); } if (yp != null) { yp.Announce(channel); } return(channel); }
/// <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); }
/// <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; }