public void Post(CloseMediaSource request) { var task = _mediaSourceManager.CloseLiveStream(request.LiveStreamId); Task.WaitAll(task); }
/// <summary> /// Kills the transcoding job. /// </summary> /// <param name="job">The job.</param> /// <param name="closeLiveStream">if set to <c>true</c> [close live stream].</param> /// <param name="delete">The delete.</param> private async Task KillTranscodingJob(TranscodingJob job, bool closeLiveStream, Func <string, bool> delete) { job.DisposeKillTimer(); Logger.LogDebug("KillTranscodingJob - JobId {0} PlaySessionId {1}. Killing transcoding", job.Id, job.PlaySessionId); lock (_activeTranscodingJobs) { _activeTranscodingJobs.Remove(job); if (!job.CancellationTokenSource.IsCancellationRequested) { job.CancellationTokenSource.Cancel(); } } lock (_transcodingLocks) { _transcodingLocks.Remove(job.Path); } lock (job.ProcessLock) { if (job.TranscodingThrottler != null) { job.TranscodingThrottler.Stop().GetAwaiter().GetResult(); } var process = job.Process; var hasExited = job.HasExited; if (!hasExited) { try { Logger.LogInformation("Stopping ffmpeg process with q command for {Path}", job.Path); process.StandardInput.WriteLine("q"); // Need to wait because killing is asynchronous if (!process.WaitForExit(5000)) { Logger.LogInformation("Killing ffmpeg process for {Path}", job.Path); process.Kill(); } } catch (InvalidOperationException) { } } } if (delete(job.Path)) { await DeletePartialStreamFiles(job.Path, job.Type, 0, 1500).ConfigureAwait(false); } if (closeLiveStream && !string.IsNullOrWhiteSpace(job.LiveStreamId)) { try { await _mediaSourceManager.CloseLiveStream(job.LiveStreamId).ConfigureAwait(false); } catch (Exception ex) { Logger.LogError(ex, "Error closing live stream for {Path}", job.Path); } } }
/// <summary> /// Kills the transcoding job. /// </summary> /// <param name="job">The job.</param> /// <param name="closeLiveStream">if set to <c>true</c> [close live stream].</param> /// <param name="delete">The delete.</param> private async void KillTranscodingJob(TranscodingJob job, bool closeLiveStream, Func <string, bool> delete) { job.DisposeKillTimer(); Logger.Debug("KillTranscodingJob - JobId {0} PlaySessionId {1}. Killing transcoding", job.Id, job.PlaySessionId); lock (_activeTranscodingJobs) { _activeTranscodingJobs.Remove(job); if (!job.CancellationTokenSource.IsCancellationRequested) { job.CancellationTokenSource.Cancel(); } } lock (job.ProcessLock) { if (job.TranscodingThrottler != null) { job.TranscodingThrottler.Stop(); } var process = job.Process; var hasExited = job.HasExited; if (!hasExited) { try { Logger.Info("Killing ffmpeg process for {0}", job.Path); //process.Kill(); process.StandardInput.WriteLine("q"); // Need to wait because killing is asynchronous process.WaitForExit(5000); } catch (Exception ex) { Logger.ErrorException("Error killing transcoding job for {0}", ex, job.Path); } } } if (delete(job.Path)) { DeletePartialStreamFiles(job.Path, job.Type, 0, 1500); } if (closeLiveStream && !string.IsNullOrWhiteSpace(job.LiveStreamId)) { try { await _mediaSourceManager.CloseLiveStream(job.LiveStreamId, CancellationToken.None).ConfigureAwait(false); } catch (Exception ex) { Logger.ErrorException("Error closing live stream for {0}", ex, job.Path); } } }
public void Post(CloseMediaSource request) { _mediaSourceManager.CloseLiveStream(request.LiveStreamId).GetAwaiter().GetResult(); }
public async Task <ActionResult> CloseLiveStream([FromQuery, Required] string liveStreamId) { await _mediaSourceManager.CloseLiveStream(liveStreamId).ConfigureAwait(false); return(NoContent()); }
public void Post(CloseMediaSource request) { var task = _mediaSourceManager.CloseLiveStream(request.LiveStreamId, CancellationToken.None); Task.WaitAll(task); }