Provides functionality for grabbing the next video frame handed by the VMR to MediaPortal.
예제 #1
0
    // MP1-4248 : End* Ambilight Capture

    public static FrameGrabber GetInstance()
    {
      if (instance == null)
      {
        instance = new FrameGrabber();
      }
      return instance;
    }
예제 #2
0
 public static FrameGrabber GetInstance()
 {
     if (instance == null)
     {
         instance = new FrameGrabber();
     }
     return(instance);
 }
예제 #3
0
파일: Plugin.cs 프로젝트: WoLpH/AtmoLight
        /// <summary>
        /// Calculates the pixel data that gets send to AtmoWin.
        /// And starts the SetPixelDataThread() threads to send the data.
        /// </summary>
        /// <param name="width">Frame width.</param>
        /// <param name="height">Frame height.</param>
        /// <param name="arWidth">Aspect ratio width.</param>
        /// <param name="arHeight">Aspect ratio height.</param>
        /// <param name="pSurface">Surface.</param>
        /// <param name="FrameSource">Source of frame, see enums FrameGrabber.FrameSource</param>/// 
        private void AtmolightPlugin_OnNewFrame(short width, short height, short arWidth, short arHeight, uint pSurface, FrameGrabber.FrameSource FrameSource)
        {
            if (coreObject.GetCurrentEffect() != ContentEffect.MediaPortalLiveMode || !coreObject.IsConnected() ||
              !coreObject.IsAtmoLightOn() || width == 0 || height == 0)
              {
            return;
              }

              //Drop any frames?
              if (Settings.trueGrabbing)
              {
              //GUI grabbing while video is minimized activated
              if (g_Player.Playing && (!GUIGraphicsContext.IsFullScreenVideo) && (FrameSource == FrameGrabber.FrameSource.Video))
              {
            //Drop Video frames when user has set TrueGrabbing & video is playing minimized -> just GUI frames will pass
            return;
              }
              }
              else
              {
              //GUI grabbing while video is minimized deactivated
              if((g_Player.Playing) && (FrameSource == FrameGrabber.FrameSource.GUI))
              {
              //Drop GUI frames when user has NOT set TrueGrabbing & video is playing -> just video frames will pass
            return;
              }
              }

              // Low CPU setting.
              // Skip frame if LowCPUTime has not yet passed since last frame.
              if (Settings.lowCPU)
              {
            if ((Win32API.GetTickCount() - lastFrame) < Settings.lowCPUTime)
            {
              return;
            }
            else
            {
              lastFrame = Win32API.GetTickCount();
            }
              }

              if (rgbSurface == null)
              {
            rgbSurface = GUIGraphicsContext.DX9Device.CreateRenderTarget(coreObject.GetCaptureWidth(),
              coreObject.GetCaptureHeight(), Format.A8R8G8B8,
              MultiSampleType.None, 0, true);
              }
              unsafe
              {
            try
            {
              if (Settings.sbs3dOn)
              {
            VideoSurfaceToRGBSurfaceExt(new IntPtr(pSurface), width/2, height, (IntPtr) rgbSurface.UnmanagedComPointer,
              coreObject.GetCaptureWidth(), coreObject.GetCaptureHeight());
              }
              else
              {
            VideoSurfaceToRGBSurfaceExt(new IntPtr(pSurface), width, height, (IntPtr) rgbSurface.UnmanagedComPointer,
              coreObject.GetCaptureWidth(), coreObject.GetCaptureHeight());
              }

              Microsoft.DirectX.GraphicsStream stream = SurfaceLoader.SaveToStream(ImageFileFormat.Bmp, rgbSurface);

              coreObject.CalculateBitmap(stream);

              stream.Close();
              stream.Dispose();
            }
            catch (Exception ex)
            {
              Log.Error("Error in AtmolightPlugin_OnNewFrame.");
              Log.Error("Exception: {0}", ex.Message);

              rgbSurface.Dispose();
              rgbSurface = null;
            }
              }
        }