public Task<Progressive.PecaStarter5.Plugins.BroadcastingParameter> BroadcastAsync( IPeercast peercast, IEnumerable<IExternalYellowPages> externalYellowPagesList, IYellowPages yellowPages, int? acceptedHash, Dictionary<string, string> yellowPagesParameter, BroadcastParameter parameter, IProgress<string> progress) { return Task.Factory.StartNew(() => { // YPの更新確認 ThrowIfYellowPagesUpdatedAwait(yellowPages, acceptedHash, progress); // 開始 var broadcastedParameter = StartBroadcastAwait(peercast, parameter, yellowPages, yellowPagesParameter, progress); // 外部YPに通知 if (yellowPages.IsExternal) { try { Find(externalYellowPagesList, yellowPages.Name) .OnBroadcastedAsync(broadcastedParameter).Wait(); } catch (Exception ex) { peercast.StopAsync(broadcastedParameter.Id).Wait(); throw ex; } } progress.Report("チャンネルを作成しました"); return broadcastedParameter; }); }
private Progressive.PecaStarter5.Plugins.BroadcastingParameter StartBroadcastAwait(IPeercast peercast, BroadcastParameter parameter, IYellowPages yellowPages, Dictionary<string, string> yellowPagesParameter, IProgress<string> progress) { progress.Report("チャンネルを作成中..."); var param = parameter.Clone(); param.Genre = yellowPages.GetPrefix(yellowPagesParameter) + param.Genre; var tuple = peercast.BroadcastAsync( new Peercast4Net.Datas.YellowPages() { Name = yellowPages.Name, Url = yellowPages.Host }, param).Result; return new Progressive.PecaStarter5.Plugins.BroadcastingParameter { Bitrate = tuple.Item2, Id = tuple.Item1, YellowPagesParameters = yellowPagesParameter, BroadcastParameter = parameter }; }
public Task<Progressive.PecaStarter5.Plugins.BroadcastingParameter> BroadcastAsync(IYellowPages yellowPages, int? acceptedHash, Dictionary<string, string> yellowPagesParameter, BroadcastParameter parameter, IProgress<string> progress) { return service.BroadcastAsync(Peercast, externalYellowPagesList, yellowPages, acceptedHash, yellowPagesParameter, parameter, progress) .ContinueWith(t => { if (t.IsFaulted) throw t.Exception; var broadcasting = t.Result; Channel = ChannelDxo.ToChannel(broadcasting); ChannelStatusChanged(this, new ChannelStatusChangedEventArgs(Channel)); timer.BeginTimer(yellowPages, broadcasting.Id); // プラグイン処理 plugins.OnBroadcastAsync(broadcasting); return broadcasting; }); }
public override Task<Tuple<string, int>> BroadcastAsync(YellowPages yellowPages, BroadcastParameter parameter) { return Task.Factory.StartNew(() => { using (var dao = new PeercastStationDao(Address)) { var ypId = GetOrCreateYellowPagesIdAwait(dao, yellowPages); var id = dao.BroadcastChannelAsync(ypId, parameter.StreamUrl, parameter.StreamUrl.Contains("rtmp://") ? "RTMP Source" : "http", parameter.Type == "WMV" ? "ASF(WMV or WMA)" : parameter.Type == "FLV" ? "Flash Video (FLV)" : "", parameter.Name, parameter.ContactUrl, -1, "", parameter.Genre, parameter.Description, parameter.Comment, parameter.TrackTitle, parameter.TrackArtist, parameter.TrackGenre, parameter.TrackAlbum, parameter.TrackContact).Result; return Tuple.Create(id, -1); } }); }
public override Task<Tuple<string, int>> BroadcastAsync(YellowPages yellowPages, BroadcastParameter parameter) { return Task.Factory.StartNew(() => { using (var dao = new PeercastDao(Address)) { SetYellowPagesAwait(dao, yellowPages.Url); var status = new XmlStatus(dao.GetViewXmlAsync().Result); if (status.Exists(parameter.Name)) { throw new PeerCastException("同名のチャンネルが既にあります。"); } dao.FetchAsync(parameter.StreamUrl, parameter.Name, parameter.Genre, parameter.Description, parameter.ContactUrl, parameter.Type).Wait(); var tuple = Repeat(() => { var afterStatus = new XmlStatus(dao.GetViewXmlAsync().Result); return GetChannelInfo(afterStatus, parameter.Name); }); if (NullId == tuple.Item1) { dao.StopAsync(tuple.Item1).Wait(); throw new PeerCastException("チャンネルの作成に失敗しました。" + Environment.NewLine + "エンコードが開始されているか、またはストリームURLが正しいか確認してください。"); } dao.SetMetaAsync(parameter.Name, parameter.Genre, parameter.Description, parameter.ContactUrl, parameter.Comment, parameter.TrackArtist, parameter.TrackTitle, parameter.TrackAlbum, parameter.TrackGenre, parameter.TrackContact).Wait(); return tuple; } }); }
private string GetMessage(BroadcastParameter parameter) { return "PeerCastで配信中!" + parameter.Name + " [" + parameter.Genre + " - " + parameter.Description + "]「" + parameter.Comment + "」"; }
public abstract Task<Tuple<string, int>> BroadcastAsync( YellowPages yellowPages, BroadcastParameter parameter);