private void InitEs() { try { ioContext = ffmpegGlue.AllocIOContext(BufferSize, ReadPacket); ioContext.Seekable = false; ioContext.WriteFlag = false; formatContext = ffmpegGlue.AllocFormatContext(); formatContext.ProbeSize = ProbeSize; formatContext.MaxAnalyzeDuration = MaxAnalyzeDuration; formatContext.AVIOContext = ioContext; formatContext.Open(); } catch (FFmpegException ex) { DeallocFFmpeg(); // Report init errors resulting from reset as cancellation if (cancellationTokenSource.IsCancellationRequested) { throw new TaskCanceledException(); } Logger.Error(ex); throw new DemuxerException("Cannot open formatContext", ex); } }
public void Initialize() { try { Interop.FFmpeg.av_register_all(); Interop.FFmpeg.avformat_network_init(); unsafe { Interop.FFmpeg.av_log_set_level(FFmpegMacros.AV_LOG_INFO); Interop.av_log_set_callback_callback logCallback = (p0, level, format, vl) => { if (level > Interop.FFmpeg.av_log_get_level()) { return; } const int lineSize = 1024; var lineBuffer = stackalloc byte[lineSize]; var printPrefix = 1; Interop.FFmpeg.av_log_format_line(p0, level, format, vl, lineBuffer, lineSize, &printPrefix); var line = Marshal.PtrToStringAnsi((IntPtr)lineBuffer); Logger.Warn(line); }; Interop.FFmpeg.av_log_set_callback(logCallback); } } catch (Exception e) { Logger.Error(e, "Could not load and register FFmpeg library"); throw new DemuxerException("Could not load and register FFmpeg library", e); } }
public void Dispose() { Logger.Enter(); Interop.FFmpeg.avformat_network_deinit(); Logger.Exit(); }
public async Task <IHttpActionResult> Put([FromBody] Common.Log log) { var res = await DataFacade.Current.AddLog(log); if (!res.IsSucceeded) { //TODO: Log in file if is ON return(StatusCode(HttpStatusCode.InternalServerError)); } return(Ok(res)); }
private void ReadVideoConfig(ICollection <StreamConfig> configs) { if (videoIdx < 0) { return; } var config = formatContext.ReadConfig(videoIdx); Logger.Info("Setting video stream to " + videoIdx); Logger.Info(config.ToString()); configs.Add(config); }
private void FindStreamsInfo() { try { formatContext.FindStreamInfo(); SelectBestStreams(); } catch (FFmpegException ex) { Logger.Error(ex); DeallocFFmpeg(); throw new DemuxerException("Cannot find streams info", ex); } }
private void InitUrl(string url, IReadOnlyCollection <KeyValuePair <string, object> > options = null) { try { formatContext = ffmpegGlue.AllocFormatContext(); formatContext.IoInterrupt = () => _operationMonitor.CancelOrTimeout(); formatContext.ProbeSize = ProbeSize; formatContext.MaxAnalyzeDuration = TimeSpan.FromSeconds(10); formatContext.Open(url, options == null ? null : new AvDictionary(options)); } catch (FFmpegException ex) { DeallocFFmpeg(); Logger.Error(ex); throw new DemuxerException("Cannot open formatContext", ex); } }
private ArraySegment <byte> ReadPacket(int size) { try { var token = cancellationTokenSource.Token; var data = buffer.Take(size, token); return(data); } catch (TaskCanceledException) { Logger.Info("Take cancelled"); } catch (InvalidOperationException ex) { Logger.Warn(ex); } catch (Exception ex) { Logger.Error(ex, $"Unexpected exception: {ex.GetType()}"); } return(new ArraySegment <byte>()); }
public static DataAccess.Log ToLog(this Common.Log log) { if (log == null) { return(null); } return(new DataAccess.Log { Id = log.Id, Descriptions = log.Descriptions, Device = log.Device, Latitude = log.Latitude, Longitude = log.Longitude, LocalTime = log.LocalTime, UtcTime = log.UtcTime, LogType = log.LogType, Section = log.Section, Title = log.Title, Username = log.Username, }); }
public async Task <ActionResult> AddLog(Common.Log newLog) { if (newLog == null) { return new ActionResult { IsSucceeded = false, Message = "Null object received." } } ; var res = new ActionResult(); using (var db = new DBEntities()) { try { #region Check and Add device if (newLog.Device.HasValue) { //if device did not exist } #endregion db.Logs.Add(newLog.ToLog()); await db.SaveChangesAsync(); res.IsSucceeded = true; } catch (Exception ex) { res.IsSucceeded = false; res.Message = ex.Message; res.ErrorMetadata = ex.StackTrace; } } return(res); }
public void Prepend(byte[] prependData) { var prependLen = prependData.Length; var orgLen = Packet.size; var pkt = Packet; Span <byte> packetSpan; unsafe { if (Interop.FFmpeg.av_grow_packet(&pkt, prependLen) < 0) { Logger.Error("GrowPacket failed"); return; } packetSpan = new Span <byte>(pkt.data, pkt.size); } // Regions overlap. Copy of source data will be made. packetSpan.Slice(0, orgLen).CopyTo(packetSpan.Slice(prependLen)); prependData.AsSpan().CopyTo(packetSpan); Packet = pkt; }
public bool Update(Common.Log entity) { throw new NotImplementedException(); }
private void RecordLog(string logMessage) { Common.Log L = new Common.Log("", Properties.Settings.Default.EnableDebugLogging); L.WriteFilelog("HL7ReportsService", "HL7 Reports windows service", logMessage); }
public static bool InsertLog(Common.Log log) { Business.Log logController = new Business.Log(); return(logController.InsertLog(log)); }
private static void RecordLog(string logMessage) { Common.Log performanceLog = new Common.Log("Sender", Properties.Settings.Default.EnablePerformanceLogging); performanceLog.WriteFilelog("ReportWCF", "GetReports", logMessage); }
private void WriteToHL7LogFile(string v) { Common.Log L = new Common.Log("", Properties.Settings.Default.EnableDebugLogging); L.WriteFilelog(ReportsDataAndBusiness.Constant.APP_NAME, "ClNo " + clNo + "-" + ReportsDataAndBusiness.Constant.HL7_Listener_ModuleName, v); }
private void RecordLog(String log) { Common.Log L = new Common.Log("", Properties.Settings.Default.EnableDebugLogging); L.WriteFilelog("PCCI Reports", "Reports pull", log); }