private void SignalVLC(IVLCCommand command) { string log = helper.ExecuteCommand(command); VLCResponse response = new VLCResponse(log); Log sicLog = new Log(LogType.Info, log); hub.Publish <ILog>(sicLog); hub.Publish <VLCResponse>(response); }
public async Task <ChannelMediaInfo> GetChannelStream(string channelOid, CancellationToken cancellationToken) { _logger.Info("[NextPvr] Start ChannelStream"); var config = Plugin.Instance.Configuration; var baseUrl = Plugin.Instance.Configuration.WebServiceUrl; _liveStreams++; if (config.TimeShift) { var options = new HttpRequestOptions { CancellationToken = cancellationToken, Url = string.Format("{0}/public/VLCService/Dump/StreamByChannel/OID/{1}", baseUrl, channelOid) }; using (var stream = await _httpClient.Get(options).ConfigureAwait(false)) { var vlcObj = new VLCResponse().GetVLCResponse(stream, _jsonSerializer, _logger); _logger.Debug(vlcObj.StreamLocation); while (!File.Exists(vlcObj.StreamLocation)) { await Task.Delay(200).ConfigureAwait(false); } await Task.Delay(20000).ConfigureAwait(false); _logger.Info("[NextPvr] Finishing wait"); _heartBeat.Add(_liveStreams, vlcObj.ProcessId); return(new ChannelMediaInfo { Id = _liveStreams.ToString(CultureInfo.InvariantCulture), Path = vlcObj.StreamLocation, Protocol = MediaProtocol.File }); } } else { string streamUrl = string.Format("{0}/live?channeloid={1}&client=MB3.{2}", baseUrl, channelOid, _liveStreams.ToString()); _logger.Info("[NextPvr] Streaming " + streamUrl); return(new ChannelMediaInfo { Id = _liveStreams.ToString(CultureInfo.InvariantCulture), Path = streamUrl, Protocol = MediaProtocol.Http }); } throw new ResourceNotFoundException(string.Format("Could not stream channel {0}", channelOid)); }
public async Task CloseLiveStream(string id, CancellationToken cancellationToken) { _logger.Info("[NextPvr] Closing " + id); var config = Plugin.Instance.Configuration; if (config.TimeShift) { var baseUrl = Plugin.Instance.Configuration.WebServiceUrl; var options = new HttpRequestOptions() { CancellationToken = cancellationToken, Url = string.Format("{0}/public/VLCService/KillVLC/{1}", baseUrl, _heartBeat[int.Parse(id)]) }; using (var stream = await _httpClient.Get(options).ConfigureAwait(false)) { var ret = new VLCResponse().GetVLCReturn(stream, _jsonSerializer, _logger); _heartBeat.Remove(int.Parse(id)); } } }
public async Task <MediaSourceInfo> GetChannelStream(string channelOid, string mediaSourceId, CancellationToken cancellationToken) { _logger.Info("[NextPvr] Start ChannelStream"); var config = Plugin.Instance.Configuration; var baseUrl = Plugin.Instance.Configuration.WebServiceUrl; _liveStreams++; if (config.TimeShift) { var options = new HttpRequestOptions { CancellationToken = cancellationToken, Url = string.Format("{0}/public/VLCService/Dump/StreamByChannel/OID/{1}", baseUrl, channelOid) }; using (var stream = await _httpClient.Get(options).ConfigureAwait(false)) { var vlcObj = new VLCResponse().GetVLCResponse(stream, _jsonSerializer, _logger); _logger.Debug(vlcObj.StreamLocation); while (!File.Exists(vlcObj.StreamLocation)) { await Task.Delay(200).ConfigureAwait(false); } await Task.Delay(20000).ConfigureAwait(false); _logger.Info("[NextPvr] Finishing wait"); _heartBeat.Add(_liveStreams, vlcObj.ProcessId); return(new MediaSourceInfo { Id = _liveStreams.ToString(CultureInfo.InvariantCulture), Path = vlcObj.StreamLocation, Protocol = MediaProtocol.File, MediaStreams = new List <MediaStream> { new MediaStream { Type = MediaStreamType.Video, IsInterlaced = true, // Set the index to -1 because we don't know the exact index of the video stream within the container Index = -1 }, new MediaStream { Type = MediaStreamType.Audio, IsInterlaced = true, // Set the index to -1 because we don't know the exact index of the audio stream within the container Index = -1 } }, // This takes too long SupportsProbing = false }); } } string streamUrl = string.Format("{0}/live?channeloid={1}&client=MB3.{2}", baseUrl, channelOid, _liveStreams.ToString()); _logger.Info("[NextPvr] Streaming " + streamUrl); return(new MediaSourceInfo { Id = _liveStreams.ToString(CultureInfo.InvariantCulture), Path = streamUrl, Protocol = MediaProtocol.Http, MediaStreams = new List <MediaStream> { new MediaStream { Type = MediaStreamType.Video, IsInterlaced = true, // Set the index to -1 because we don't know the exact index of the video stream within the container Index = -1, }, new MediaStream { Type = MediaStreamType.Audio, IsInterlaced = true, // Set the index to -1 because we don't know the exact index of the audio stream within the container Index = -1 } }, // This takes too long SupportsProbing = false }); }