예제 #1
0
        public static bool Start(string device, IEmulationElement loggingParent)
        {
#if !PLATFORM_LINUX
            throw new RecoverableException("Video capture is supported on Linux only!");
#else
            // stop any previous capturer
            Stop();

            VideoCapturer.loggingParent = loggingParent;

            loggingParent.Log(LogLevel.Debug, "Opening device: {0}...", device);
            fd = LibCWrapper.Open(device, O_RDWR);

            if (fd == -1)
            {
                loggingParent.Log(LogLevel.Error, "Couldn't open device: {0}", device);
                return(false);
            }

            if (!CheckImageFormat())
            {
                loggingParent.Log(LogLevel.Error, "Device does not support JPEG output: {0}", device);
                LibCWrapper.Close(fd);
                return(false);
            }

            started = true;
            return(RequestBuffer());
#endif
        }
예제 #2
0
파일: Logger.cs 프로젝트: krytarowski/emul8
 public static void Trace(this IEmulationElement e, LogLevel type, string message = "",
                          [CallerLineNumber] int lineNumber = 0,
                          [CallerMemberName] string caller  = null,
                          [CallerFilePath] string fileName  = null)
 {
     e.Log(type, String.Format("{0} in {1} ({2}@{3}).", message, caller, Path.GetFileName(fileName), lineNumber));
 }
예제 #3
0
 public static bool TryCreateFrameOrLogWarning(IEmulationElement source, byte[] data, out EthernetFrame frame, bool addCrc)
 {
     if (EthernetFrame.TryCreateEthernetFrame(data, addCrc, out frame))
     {
         return(true);
     }
     source.Log(LogLevel.Warning, "Insufficient data to create an ethernet frame, expected {0} bytes but got {1} bytes.",
                EthernetFrame.MinFrameSizeWithoutCRC + (addCrc ? 0 : EthernetFrame.CRCLength), data.Length);
     return(false);
 }
예제 #4
0
파일: Utilities.cs 프로젝트: rte-se/emul8
 public static long HzToTicksSafe(long hz, IEmulationElement sender)
 {
     var result = (long)Math.Round(HzToTicks(hz));
     if(result == 0)
     {
         result = 1;
     }
     var againInHz = TicksToHz(result);
     if(Math.Abs(againInHz - hz) / hz > MaximalDifference)
     {
         sender.Log(LogLevel.Warning, "Significant difference between desired and actual frequency: {0}Hz={1}Hz vs {2}Hz={3}Hz,", 
                    Misc.NormalizeDecimal(hz), Misc.NormalizeDecimal(againInHz), hz, againInHz);
     }
     return result;
 }
예제 #5
0
        public static long HzToTicksSafe(long hz, IEmulationElement sender)
        {
            var result = (long)Math.Round(HzToTicks(hz));

            if (result == 0)
            {
                result = 1;
            }
            var againInHz = TicksToHz(result);

            if (Math.Abs(againInHz - hz) / hz > MaximalDifference)
            {
                sender.Log(LogLevel.Warning, "Significant difference between desired and actual frequency: {0}Hz={1}Hz vs {2}Hz={3}Hz,",
                           Misc.NormalizeDecimal(hz), Misc.NormalizeDecimal(againInHz), hz, againInHz);
            }
            return(result);
        }