/// <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="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> /// 指定されたプロトコル、名前、URIを使って新しいYPを作成しYPリストに追加します /// </summary> /// <param name="protocol">YPクライアントのプロトコル名</param> /// <param name="name">YPの名前</param> /// <param name="uri">YPのURI</param> public IYellowPageClient AddYellowPage(string protocol, string name, Uri uri) { IYellowPageClient yp = null; foreach (var factory in YellowPageFactories) { if (factory.Protocol == protocol) { yp = factory.Create(name, uri); break; } } if (yp == null) { throw new ArgumentException(String.Format("Protocol `{0}' is not found", protocol)); } Utils.ReplaceCollection(ref yellowPages, orig => { var new_yps = new List <IYellowPageClient>(orig); new_yps.Add(yp); return(new_yps); }); logger.Debug("YP Added: {0}", yp.Name); if (YellowPagesChanged != null) { YellowPagesChanged(this, new EventArgs()); } return(yp); }
private void OnBroadcast() { var source = StreamSource; var contentReaderFactory = ContentType; if (!CanBroadcast(source, contentReaderFactory, channelName)) { return; } IYellowPageClient yellowPage = this.yellowPage; var channelInfo = CreateChannelInfo(this); var channelTrack = CreateChannelTrack(this); var channel_id = PeerCastStation.Core.BroadcastChannel.CreateChannelID( peerCast.BroadcastID, channelName, genre, source.ToString()); var source_stream = selectedSourceStream ?? peerCast.SourceStreamFactories .Where(sstream => (sstream.Type & SourceStreamType.Broadcast) != 0) .FirstOrDefault(sstream => sstream.Scheme == source.Scheme); var channel = peerCast.BroadcastChannel( yellowPage, channel_id, channelInfo, source, source_stream, contentReaderFactory); if (channel != null) { channel.ChannelTrack = channelTrack; } var info = new BroadcastInfoViewModel { StreamUrl = this.StreamUrl, StreamType = this.SelectedSourceStream != null ? this.SelectedSourceStream.Name : null, Bitrate = this.bitrate.HasValue ? this.bitrate.Value : 0, ContentType = this.ContentType.Name, YellowPage = this.YellowPage != null ? this.YellowPage.Name : null, ChannelName = this.ChannelName, Genre = this.Genre, Description = this.Description, Comment = this.Comment, ContactUrl = this.ContactUrl, TrackTitle = this.TrackTitle, TrackAlbum = this.TrackAlbum, TrackArtist = this.TrackArtist, TrackGenre = this.TrackGenre, TrackUrl = this.TrackUrl, Favorite = false, }; uiSettings.AddBroadcastHistory(info); uiSettings.Save(); }
internal YellowPageClientViewModel( SettingViewModel owner, IYellowPageClient model) { this.owner = owner; this.name = model.Name; this.uri = model.Uri; this.protocol = owner.peerCast.YellowPageFactories.FirstOrDefault(factory => factory.Protocol == model.Protocol); }
/// <summary> /// 指定したYPをYPリストから取り除きます /// </summary> /// <param name="yp">取り除くYP</param> public void RemoveYellowPage(IYellowPageClient yp) { yp.StopAnnounce(); Utils.ReplaceCollection(ref yellowPages, orig => { var new_yps = new List <IYellowPageClient>(orig); new_yps.Remove(yp); return(new_yps); }); logger.Debug("YP Removed: {0}", yp.Name); if (YellowPagesChanged != null) { YellowPagesChanged(this, new EventArgs()); } }
/// <summary> /// 指定されたプロトコル、名前、URIを使って新しいYPを作成しYPリストに追加します /// </summary> /// <param name="protocol">YPクライアントのプロトコル名</param> /// <param name="name">YPの名前</param> /// <param name="announce_uri">YPの掲載先URI</param> /// <param name="channels_uri">YPのチャンネル一覧取得先URI</param> public IYellowPageClient AddYellowPage(string protocol, string name, Uri announce_uri, Uri channels_uri) { IYellowPageClient yp = null; foreach (var factory in YellowPageFactories) { if (factory.Protocol == protocol) { yp = factory.Create(name, announce_uri, channels_uri); break; } } if (yp == null) { throw new ArgumentException(String.Format("Protocol `{0}' is not found", protocol)); } ReplaceCollection(ref yellowPages, orig => orig.Add(yp)); logger.Debug("YP Added: {0}", yp.Name); return(yp); }
/// <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); }
public PCPYellowPageChannel(IYellowPageClient source) { this.Source = source; }
internal YellowPageClientViewModel( SettingViewModel owner, IYellowPageClient model) { this.owner = owner; this.name = model.Name; this.uri = model.Uri; this.protocol = model.Protocol; }
public YellowPageItem(string name, IYellowPageClient yellowpage) { this.Name = name; this.YellowPageClient = yellowpage; }
/// <summary> /// 指定したYPをYPリストから取り除きます /// </summary> /// <param name="yp">取り除くYP</param> public void RemoveYellowPage(IYellowPageClient yp) { yp.StopAnnounce(); ReplaceCollection(ref yellowPages, orig => orig.Remove(yp)); logger.Debug("YP Removed: {0}", yp.Name); }
/// <summary> /// 指定したYPをYPリストから取り除きます /// </summary> /// <param name="yp">取り除くYP</param> public void RemoveYellowPage(IYellowPageClient yp) { yp.StopAnnounce(); Utils.ReplaceCollection(ref yellowPages, orig => { var new_yps = new List<IYellowPageClient>(orig); new_yps.Remove(yp); return new_yps; }); logger.Debug("YP Removed: {0}", yp.Name); if (YellowPagesChanged!=null) YellowPagesChanged(this, new EventArgs()); }
public YellowPageItem(IYellowPageClient yp) { YellowPage = yp; }
/// <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; }
private string BroadcastChannel(int?yellowPageId, string sourceUri, string contentReader, JObject info, JObject track) { IYellowPageClient yp = null; if (yellowPageId.HasValue) { yp = PeerCast.YellowPages.FirstOrDefault(y => y.GetHashCode() == yellowPageId.Value); if (yp == null) { throw new RPCError(RPCErrorCode.InvalidParams, "Yellow page not found"); } } if (sourceUri == null) { throw new RPCError(RPCErrorCode.InvalidParams, "source uri required"); } Uri source; try { source = new Uri(sourceUri); } catch (UriFormatException) { throw new RPCError(RPCErrorCode.InvalidParams, "Invalid Uri"); } var content_reader = PeerCast.ContentReaderFactories.FirstOrDefault(reader => reader.Name == contentReader); if (content_reader == null) { throw new RPCError(RPCErrorCode.InvalidParams, "Content reader not found"); } var new_info = new AtomCollection(); if (info != null) { if (info["name"] != null) { new_info.SetChanInfoName((string)info["name"]); } if (info["url"] != null) { new_info.SetChanInfoURL((string)info["url"]); } if (info["genre"] != null) { new_info.SetChanInfoGenre((string)info["genre"]); } if (info["desc"] != null) { new_info.SetChanInfoDesc((string)info["desc"]); } if (info["comment"] != null) { new_info.SetChanInfoComment((string)info["comment"]); } } var channel_info = new ChannelInfo(new_info); if (channel_info.Name == null || channel_info.Name == "") { throw new RPCError(RPCErrorCode.InvalidParams, "Channel name must not be empty"); } var channel_id = Utils.CreateChannelID( PeerCast.BroadcastID, channel_info.Name, channel_info.Genre ?? "", source.ToString()); var channel = PeerCast.BroadcastChannel(yp, channel_id, channel_info, source, content_reader); if (track != null) { var new_track = new AtomCollection(channel.ChannelTrack.Extra); if (track["name"] != null) { new_track.SetChanTrackTitle((string)track["name"]); } if (track["genre"] != null) { new_track.SetChanTrackGenre((string)track["genre"]); } if (track["album"] != null) { new_track.SetChanTrackAlbum((string)track["album"]); } if (track["creator"] != null) { new_track.SetChanTrackCreator((string)track["creator"]); } if (track["url"] != null) { new_track.SetChanTrackURL((string)track["url"]); } channel.ChannelTrack = new ChannelTrack(new_track); } return(channel.ChannelID.ToString("N").ToUpper()); }
internal YellowPageClientViewModel( SettingViewModel owner, IYellowPageClient model) { this.owner = owner; this.name = model.Name; this.announceUri = model.AnnounceUri; this.channelsUri = model.ChannelsUri; this.protocol = owner.peerCast.YellowPageFactories.FirstOrDefault(factory => factory.Protocol==model.Protocol); }
public YellowPageItem(IYellowPageClient yellowpage) : this(String.Format("{0} ({1})", yellowpage.Name, yellowpage.Uri), yellowpage) { }
public YellowPageItem(IYellowPageClient yellowpage) : this(String.Format("{0} ({1})", yellowpage.Name, yellowpage.AnnounceUri), yellowpage) { }
internal YellowPageItem(IYellowPageClient yellowpage) : this(String.Format("{0} ({1})", yellowpage.Name, yellowpage.Uri), yellowpage) { }
internal YellowPageItem(string name, IYellowPageClient yellowpage) { this.Name = name; this.YellowPageClient = yellowpage; }