public async Task <IActionResult> ListArchives(string sessionId, int max) { var session = await _context.VonageVideoAPISessions.Include(x => x.Project).Where(x => x.SessionId == sessionId).SingleAsync(); var archives = await OpenTokFs.Api.Archive.ListAllAsync( session.Project, new ListParameters( new PageBoundaries(0, Math.Min(1000, max)), ListLimit.NewStopAtItemCount(max)), SessionIdFilter.NewSingleSessionId(sessionId)); return(Ok(archives)); }
public async Task <IActionResult> StopBroadcast(string sessionId) { var session = await _context.VonageVideoAPISessions.Include(x => x.Project).Where(x => x.SessionId == sessionId).SingleAsync(); var broadcasts = await OpenTokFs.Api.Broadcast.ListAllAsync( session.Project, SingleItem, SessionIdFilter.NewSingleSessionId(sessionId)); var b = broadcasts.SingleOrDefault(); if (b != null) { await OpenTokFs.Api.Broadcast.StopAsync(session.Project, b.Id); } return(View("Player", null)); }
public async Task <IActionResult> StartBroadcast( string sessionId, string layout, string layoutCss, int maxDuration, bool hls, string rtmpServerUrl, string rtmpStreamName, string resolution ) { var session = await _context.VonageVideoAPISessions.Include(x => x.Project).Where(x => x.SessionId == sessionId).SingleAsync(); var broadcasts = await OpenTokFs.Api.Broadcast.ListAllAsync( session.Project, SingleItem, SessionIdFilter.NewSingleSessionId(sessionId)); var broadcast = broadcasts.SingleOrDefault(); if (broadcast == null) { var req = new BroadcastStartRequest( sessionId: sessionId, layout: !string.IsNullOrWhiteSpace(layoutCss) ? Layout.NewCustomCss(layoutCss) : layout == "Best Fit" ? Layout.NewStandard(StandardLayout.BestFit) : layout == "Picture-in-Picture" ? Layout.NewStandard(StandardLayout.Pip) : layout == "Vertical Presentation" ? Layout.NewStandard(StandardLayout.VerticalPresentation) : layout == "Horizontal Presentation" ? Layout.NewStandard(StandardLayout.HorizontalPresentation) : Layout.NewStandard(StandardLayout.BestFit), maxDuration: TimeSpan.FromSeconds(maxDuration), outputs: hls ? BroadcastTargets.HlsOnly : BroadcastTargets.RtmpOnly(rtmpServerUrl, rtmpStreamName), resolution: resolution == "1280x720" ? Resolution.HighDefinition : Resolution.StandardDefinition); string json = Newtonsoft.Json.JsonConvert.SerializeObject(req); broadcast = await OpenTokFs.Api.Broadcast.StartAsync( session.Project, req); } return(View("Player", broadcast)); }
public async Task <IActionResult> StopArchive(string sessionId) { var session = await _context.VonageVideoAPISessions.Include(x => x.Project).Where(x => x.SessionId == sessionId).SingleAsync(); var archives = await OpenTokFs.Api.Archive.ListAllAsync( session.Project, SingleItem, SessionIdFilter.NewSingleSessionId(sessionId)); var a = archives.SingleOrDefault(); if (a != null) { if (a.Status == "started" || a.Status == "paused") { var stopped = await OpenTokFs.Api.Archive.StopAsync(session.Project, a.Id); for (int i = 0; i < 5 && stopped.Status != "uploaded" && stopped.Status != "available"; i++) { await Task.Delay(3000); stopped = await OpenTokFs.Api.Archive.GetAsync(session.Project, a.Id); } if (stopped.Url == null) { return(Content("Archive stopped, but URL not available")); } else if (stopped.Url.Contains("archive.mp4", StringComparison.InvariantCultureIgnoreCase)) { return(Redirect(stopped.Url)); } else { return(Content(stopped.Url, "text/plain")); } } } return(NoContent()); }
public async Task <IActionResult> ChangeLayout(string sessionId, string layout, string screenSharingLayout, string layoutCss) { var l = !string.IsNullOrWhiteSpace(layoutCss) ? Layout.NewCustomCss(layoutCss) : screenSharingLayout == "Picture-in-Picture" ? Layout.NewBestFitOr(ScreenshareType.NewScreenshareType(StandardLayout.Pip)) : screenSharingLayout == "Vertical Presentation" ? Layout.NewBestFitOr(ScreenshareType.NewScreenshareType(StandardLayout.VerticalPresentation)) : screenSharingLayout == "Horizontal Presentation" ? Layout.NewBestFitOr(ScreenshareType.NewScreenshareType(StandardLayout.HorizontalPresentation)) : layout == "Best Fit" ? Layout.NewStandard(StandardLayout.BestFit) : layout == "Picture-in-Picture" ? Layout.NewStandard(StandardLayout.Pip) : layout == "Vertical Presentation" ? Layout.NewStandard(StandardLayout.VerticalPresentation) : layout == "Horizontal Presentation" ? Layout.NewStandard(StandardLayout.HorizontalPresentation) : Layout.NewStandard(StandardLayout.BestFit); var session = await _context.VonageVideoAPISessions.Include(x => x.Project).Where(x => x.SessionId == sessionId).SingleAsync(); var broadcasts = await OpenTokFs.Api.Broadcast.ListAllAsync( session.Project, SingleItem, SessionIdFilter.NewSingleSessionId(sessionId)); foreach (var b in broadcasts) { await OpenTokFs.Api.Broadcast.SetLayoutAsync(session.Project, b.Id, l); } var archives = await OpenTokFs.Api.Archive.ListAllAsync( session.Project, SingleItem, SessionIdFilter.NewSingleSessionId(sessionId)); foreach (var a in archives) { if (a.Status == "started" || a.Status == "paused") { await OpenTokFs.Api.Archive.SetLayoutAsync(session.Project, a.Id, l); } } return(NoContent()); }