Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        public void Dispose()
        {
            Logger.Enter();

            Interop.FFmpeg.avformat_network_deinit();

            Logger.Exit();
        }
Ejemplo n.º 4
0
        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));
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
 private void FindStreamsInfo()
 {
     try
     {
         formatContext.FindStreamInfo();
         SelectBestStreams();
     }
     catch (FFmpegException ex)
     {
         Logger.Error(ex);
         DeallocFFmpeg();
         throw new DemuxerException("Cannot find streams info", ex);
     }
 }
Ejemplo n.º 7
0
        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);
            }
        }
Ejemplo n.º 8
0
 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>());
 }
Ejemplo n.º 9
0
        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,
            });
        }
Ejemplo n.º 10
0
        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);
        }
Ejemplo n.º 11
0
        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;
        }
Ejemplo n.º 12
0
 public bool Update(Common.Log entity)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 13
0
 private void RecordLog(string logMessage)
 {
     Common.Log L = new Common.Log("", Properties.Settings.Default.EnableDebugLogging);
     L.WriteFilelog("HL7ReportsService", "HL7 Reports windows service", logMessage);
 }
Ejemplo n.º 14
0
 public static bool InsertLog(Common.Log log)
 {
     Business.Log logController = new Business.Log();
     return(logController.InsertLog(log));
 }
Ejemplo n.º 15
0
 private static void RecordLog(string logMessage)
 {
     Common.Log performanceLog = new Common.Log("Sender", Properties.Settings.Default.EnablePerformanceLogging);
     performanceLog.WriteFilelog("ReportWCF", "GetReports", logMessage);
 }
Ejemplo n.º 16
0
 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);
 }
Ejemplo n.º 17
0
 private void RecordLog(String log)
 {
     Common.Log L = new Common.Log("", Properties.Settings.Default.EnableDebugLogging);
     L.WriteFilelog("PCCI Reports", "Reports pull", log);
 }