private void BroadcastStart_Click(object sender, EventArgs args) { Uri source; if (Uri.TryCreate(bcStreamUrl.Text, UriKind.Absolute, out source)) { StreamSource = source; } else { StreamSource = null; } var reader = bcContentType.SelectedItem as ContentReaderItem; if (reader!=null) ContentReaderFactory = reader.ContentReaderFactory; var yp = bcYP.SelectedItem as YellowPageItem; if (yp!=null) YellowPage = yp.YellowPage; var info = new AtomCollection(); int bitrate; if (Int32.TryParse(bcBitrate.Text, out bitrate)) { info.SetChanInfoBitrate(bitrate); } info.SetChanInfoName(bcChannelName.Text); info.SetChanInfoGenre(bcGenre.Text); info.SetChanInfoDesc(bcDescription.Text); info.SetChanInfoComment(bcComment.Text); info.SetChanInfoURL(bcContactUrl.Text); ChannelInfo = new ChannelInfo(info); var track = new AtomCollection(); track.SetChanTrackTitle(bcTrackTitle.Text); track.SetChanTrackGenre(bcTrackGenre.Text); track.SetChanTrackAlbum(bcAlbum.Text); track.SetChanTrackCreator(bcCreator.Text); track.SetChanTrackURL(bcTrackURL.Text); ChannelTrack = new ChannelTrack(track); if (StreamSource!=null && ContentReaderFactory!=null && !String.IsNullOrEmpty(ChannelInfo.Name)) { DialogResult = DialogResult.OK; } }
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; }
/// <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, string sourceStream=null) { IYellowPageClient yp = null; if (yellowPageId.HasValue) { yp = PeerCast.YellowPages.FirstOrDefault(y => GetObjectId(y)==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 source_stream = PeerCast.SourceStreamFactories .Where(sstream => (sstream.Type & SourceStreamType.Broadcast)!=0) .FirstOrDefault(sstream => sstream.Name==sourceStream); if (source_stream==null) { source_stream = PeerCast.SourceStreamFactories .Where(sstream => (sstream.Type & SourceStreamType.Broadcast)!=0) .FirstOrDefault(sstream => sstream.Scheme==source.Scheme); } if (source_stream==null) throw new RPCError(RPCErrorCode.InvalidParams, "Source stream not found"); var new_info = new AtomCollection(); if (info!=null) { info.TryGetThen("name", v => new_info.SetChanInfoName(v)); info.TryGetThen("url", v => new_info.SetChanInfoURL(v)); info.TryGetThen("genre", v => new_info.SetChanInfoGenre(v)); info.TryGetThen("desc", v => new_info.SetChanInfoDesc(v)); info.TryGetThen("comment", v => new_info.SetChanInfoComment(v)); } 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 = PeerCastStation.Core.BroadcastChannel.CreateChannelID( PeerCast.BroadcastID, channel_info.Name, channel_info.Genre ?? "", source.ToString()); var channel = PeerCast.BroadcastChannel(yp, channel_id, channel_info, source, source_stream, content_reader); if (track!=null) { var new_track = new AtomCollection(channel.ChannelTrack.Extra); track.TryGetThen("name", v => new_track.SetChanTrackTitle(v)); track.TryGetThen("genre", v => new_track.SetChanTrackGenre(v)); track.TryGetThen("album", v => new_track.SetChanTrackAlbum(v)); track.TryGetThen("creator", v => new_track.SetChanTrackCreator(v)); track.TryGetThen("url", v => new_track.SetChanTrackURL(v)); channel.ChannelTrack = new ChannelTrack(new_track); } return channel.ChannelID.ToString("N").ToUpper(); }
private ChannelInfo UpdateChannelInfo(ChannelInfo a, ChannelInfo b) { var base_atoms = new AtomCollection(a.Extra); var new_atoms = new AtomCollection(b.Extra); if (!useContentBitrate) { new_atoms.RemoveByName(Atom.PCP_CHAN_INFO_BITRATE); } base_atoms.Update(new_atoms); return new ChannelInfo(base_atoms); }
protected void OnPCPChanInfo(Atom atom) { var channel_info = new ChannelInfo(atom.Children); var content_type = channel_info.ContentType; if (content_type==null || content_type=="UNKNOWN") { var header = Channel.ContentHeader; string mime_type = null; if (header!=null && PeerCast.ContentReaderFactories.Any( factory => factory.TryParseContentType(header.Data, out content_type, out mime_type))) { var new_info = new AtomCollection(atom.Children); new_info.SetChanInfoType(content_type); new_info.SetChanInfoStreamType(mime_type); channel_info = new ChannelInfo(new_info); } } Channel.ChannelInfo = channel_info; BroadcastHostInfo(); }
public ChannelInfoContainer(ChannelInfo info, ChannelTrack track) { if (info!=null) { InfoChannelName = info.Name; InfoGenre = info.Genre; InfoDesc = info.Desc; InfoContactURL = info.URL; InfoComment = info.Comment; InfoContentType = info.ContentType; InfoBitrate = String.Format("{0} kbps", info.Bitrate); } else { InfoChannelName = ""; InfoGenre = ""; InfoDesc = ""; InfoContactURL = ""; InfoComment = ""; InfoContentType = ""; InfoBitrate = ""; } if (track!=null) { TrackAlbum = track.Album; TrackArtist = track.Creator; TrackTitle = track.Name; TrackGenre = track.Genre; TrackContactURL = track.URL; } else { TrackAlbum = ""; TrackArtist = ""; TrackTitle = ""; TrackGenre = ""; TrackContactURL = ""; } }
protected void OnPCPChanInfo(Atom atom) { var channel_info = new ChannelInfo(atom.Children); Channel.ChannelInfo = ResetContentType(channel_info, Channel.ContentHeader); BroadcastHostInfo(); }
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(); }
private ChannelInfo ResetContentType(ChannelInfo channel_info, Content content_header) { if (channel_info==null) throw new ArgumentNullException("channel_info"); var content_type = channel_info.ContentType; if (content_type==null || content_type=="UNKNOWN") { string mime_type = null; if (content_header!=null && PeerCast.ContentReaderFactories.Any( factory => factory.TryParseContentType(content_header.Data, out content_type, out mime_type))) { var new_info = new AtomCollection(channel_info.Extra); new_info.SetChanInfoType(content_type); new_info.SetChanInfoStreamType(mime_type); channel_info = new ChannelInfo(new_info); } } return channel_info; }
public void OnChannelInfo(ChannelInfo channel_info) { this.BaseSink.OnChannelInfo(channel_info); }
public void OnChannelInfo(ChannelInfo channel_info) { this.Channel.ChannelInfo = MergeChannelInfo(Channel.ChannelInfo, channel_info); }