//public static void ClearMadVrBitmap(string name, MeediOS.Media.MadVR madvr) //{ // try // { // if (madvr == null) // { // Madvr_VideoPlayer.Plugin.WriteLog("[Madvr Interface] Showbitmap Interface error: madvr is null"); // return; // } // IntPtr leftEye = IntPtr.Zero; // IntPtr rightEye = IntPtr.Zero; // uint colorkey = 0; // int Posx = 0; // int Posy = 0; // uint Duration = 1; // int ImagePriority = 100; // reserved = IntPtr.Zero; // IMadVROsdServices osdServices = (IMadVROsdServices)madvr; // //osdServices.OsdSetBitmap(name, leftEye, rightEye, colorkey, Posx, Posy, false, ImagePriority, Duration, 0, mouseCallback, callbackContext, reserved); // int ScreenBottom = Madvr_VideoPlayer.Plugin.Madvr_VideoPlayer.VideoPlayer.ScreenHeight; // if (CurrentPosY > (ScreenBottom / 2)) // { // if (name != "transportTime") // { // if (startTransition == true // && name == CurrentName // && (Madvr_VideoPlayer.Plugin.ArrowDirection == "up" || Madvr_VideoPlayer.Plugin.ArrowDirection == "down")) // { // while (CurrentPosY < ScreenBottom) // { // osdServices.OsdSetBitmap(CurrentName, CurrentLeftEye, rightEye, colorkey, CurrentPosX, CurrentPosY, false, CurrentImagePriority, CurrentDuration, 0, mouseCallback, callbackContext, reserved); // if (CurrentPosY < ScreenBottom) // { // CurrentPosY++; // } // if (CurrentPosY < ScreenBottom) // { // CurrentPosY++; // } // if (CurrentPosY < ScreenBottom) // { // CurrentPosY++; // } // if (CurrentPosY < ScreenBottom) // { // CurrentPosY++; // } // if (name == "iMovieInfoImage") // { // if (CurrentPosY < ScreenBottom) // { // CurrentPosY++; // } // if (CurrentPosY < ScreenBottom) // { // CurrentPosY++; // } // if (CurrentPosY < ScreenBottom) // { // CurrentPosY++; // } // if (CurrentPosY < ScreenBottom) // { // CurrentPosY++; // } // } // Thread.Sleep(1); // } // osdServices.OsdSetBitmap(name, leftEye, rightEye, colorkey, Posx, Posy, false, ImagePriority, Duration, 0, mouseCallback, callbackContext, reserved); // startTransition = false; // } // else // { // osdServices.OsdSetBitmap(name, leftEye, rightEye, colorkey, Posx, Posy, false, ImagePriority, Duration, 0, mouseCallback, callbackContext, reserved); // } // } // else // { // osdServices.OsdSetBitmap(name, leftEye, rightEye, colorkey, Posx, Posy, false, ImagePriority, Duration, 0, mouseCallback, callbackContext, reserved); // } // } // else // { // osdServices.OsdSetBitmap(name, leftEye, rightEye, colorkey, Posx, Posy, false, ImagePriority, Duration, 0, mouseCallback, callbackContext, reserved); // } // } // catch (Exception e) // { // Madvr_VideoPlayer.Plugin.WriteLog("[Madvr Interface] MadVr Clear Bitmap Error: " + e); // } //} public static void EnableExclusiveMode(bool enable, MadVR madvr) { var eModeControl = madvr as IMadVRExclusiveModeControl; if (enable) { var size = Marshal.SizeOf(typeof(Int32)); var pBool = Marshal.AllocHGlobal(size); Marshal.WriteInt32(pBool, 0, 1); // last parameter 0 (FALSE), 1 (TRUE) eModeControl.DisableExclusiveMode(pBool); Marshal.FreeHGlobal(pBool); pBool = IntPtr.Zero; } else //Works - Set to Windowed Mode { var size = Marshal.SizeOf(typeof(Int32)); var pBool = Marshal.AllocHGlobal(size); Marshal.WriteInt32(pBool, 0, 0); // last parameter 0 (FALSE), 1 (TRUE) eModeControl.DisableExclusiveMode(pBool); Marshal.FreeHGlobal(pBool); pBool = IntPtr.Zero; } }
public static void RedrawFrame(MadVR madvr) { var osdServices = (IMadVROsdServices)madvr; osdServices.OsdRedrawFrame(); }
public static void ShowMadVrBitmap(string name, IntPtr leftEye, int Posx, int Posy, uint Duration, int ImagePriority, MadVR madvr) { IntPtr rightEye = IntPtr.Zero; uint colorkey = 0; reserved = IntPtr.Zero; //mouseCallback = new OSDMOUSECALLBACK(OnMouseEvent); IMadVROsdServices osdServices = (IMadVROsdServices)madvr; int ScreenBottom = 0; // Madvr_VideoPlayer.Plugin.Madvr_VideoPlayer.VideoPlayer.ScreenHeight; if (Posy > (ScreenBottom / 2)) { if (name != "transportTime") { CurrentName = name; CurrentLeftEye = leftEye; CurrentPosX = Posx; CurrentPosY = Posy; CurrentDuration = Duration; CurrentImagePriority = ImagePriority; if (startTransition == false) { while (Posy < ScreenBottom) { osdServices.OsdSetBitmap(name, leftEye, rightEye, colorkey, Posx, ScreenBottom, false, ImagePriority, Duration, 0, mouseCallback, callbackContext, reserved); if (Posy < ScreenBottom) { ScreenBottom--; } if (Posy < ScreenBottom) { ScreenBottom--; } if (Posy < ScreenBottom) { ScreenBottom--; } if (Posy < ScreenBottom) { ScreenBottom--; } if (name == "iMovieInfoImage") { if (Posy < ScreenBottom) { ScreenBottom--; } if (Posy < ScreenBottom) { ScreenBottom--; } if (Posy < ScreenBottom) { ScreenBottom--; } if (Posy < ScreenBottom) { ScreenBottom--; } } Thread.Sleep(1); } osdServices.OsdSetBitmap(name, leftEye, rightEye, colorkey, Posx, ScreenBottom, false, ImagePriority, Duration, 0, mouseCallback, callbackContext, reserved); startTransition = true; } else { osdServices.OsdSetBitmap(name, leftEye, rightEye, colorkey, Posx, Posy, false, ImagePriority, Duration, 0, mouseCallback, callbackContext, reserved); } } else { osdServices.OsdSetBitmap(name, leftEye, rightEye, colorkey, Posx, Posy, false, ImagePriority, Duration, 0, mouseCallback, callbackContext, reserved); } } else { osdServices.OsdSetBitmap(name, leftEye, rightEye, colorkey, Posx, Posy, false, ImagePriority, Duration, 0, mouseCallback, callbackContext, reserved); } if (name.ToLower().Contains("pause") || name.ToLower().StartsWith("pause")) { osdServices.OsdRedrawFrame(); } //else if (Madvr_VideoPlayer.Plugin.Madvr_VideoPlayer.VideoPlayer.m_state == "Paused") //{ // osdServices.OsdRedrawFrame(); //} }
public static int IMAGE_UPSCALING_NGU_SHARP_GRAIN = 7; // use NGU Sharp image upscaling, with a bit of added grain public static void ShowMadVrMessage(string Message, uint DisplayTime, MadVR madvr) { var osd = (IMadVRTextOsd)madvr; osd.OsdDisplayMessage(Message, DisplayTime); }
public static bool InExclusiveMode(MadVR madvr) { var exclusiveInfo = madvr as IMadVRExclusiveModeInfo; return exclusiveInfo.IsExclusiveModeActive() == 1; }
public static void ShowMadVrBitmap(string name, IntPtr leftEye, int Posx, int Posy, uint Duration, int ImagePriority, MadVR madvr) { IntPtr rightEye = IntPtr.Zero; uint colorkey = 0; reserved = IntPtr.Zero; //mouseCallback = new OSDMOUSECALLBACK(OnMouseEvent); IMadVROsdServices osdServices = (IMadVROsdServices)madvr; int ScreenBottom = 0;// Madvr_VideoPlayer.Plugin.Madvr_VideoPlayer.VideoPlayer.ScreenHeight; if (Posy > (ScreenBottom / 2)) { if (name != "transportTime") { CurrentName = name; CurrentLeftEye = leftEye; CurrentPosX = Posx; CurrentPosY = Posy; CurrentDuration = Duration; CurrentImagePriority = ImagePriority; if (startTransition == false) { while (Posy < ScreenBottom) { osdServices.OsdSetBitmap(name, leftEye, rightEye, colorkey, Posx, ScreenBottom, false, ImagePriority, Duration, 0, mouseCallback, callbackContext, reserved); if (Posy < ScreenBottom) { ScreenBottom--; } if (Posy < ScreenBottom) { ScreenBottom--; } if (Posy < ScreenBottom) { ScreenBottom--; } if (Posy < ScreenBottom) { ScreenBottom--; } if (name == "iMovieInfoImage") { if (Posy < ScreenBottom) { ScreenBottom--; } if (Posy < ScreenBottom) { ScreenBottom--; } if (Posy < ScreenBottom) { ScreenBottom--; } if (Posy < ScreenBottom) { ScreenBottom--; } } Thread.Sleep(1); } osdServices.OsdSetBitmap(name, leftEye, rightEye, colorkey, Posx, ScreenBottom, false, ImagePriority, Duration, 0, mouseCallback, callbackContext, reserved); startTransition = true; } else { osdServices.OsdSetBitmap(name, leftEye, rightEye, colorkey, Posx, Posy, false, ImagePriority, Duration, 0, mouseCallback, callbackContext, reserved); } } else { osdServices.OsdSetBitmap(name, leftEye, rightEye, colorkey, Posx, Posy, false, ImagePriority, Duration, 0, mouseCallback, callbackContext, reserved); } } else { osdServices.OsdSetBitmap(name, leftEye, rightEye, colorkey, Posx, Posy, false, ImagePriority, Duration, 0, mouseCallback, callbackContext, reserved); } if (name.ToLower().Contains("pause") || name.ToLower().StartsWith("pause")) { osdServices.OsdRedrawFrame(); } //else if (Madvr_VideoPlayer.Plugin.Madvr_VideoPlayer.VideoPlayer.m_state == "Paused") //{ // osdServices.OsdRedrawFrame(); //} }
public static void ShowMadVrMessage(string Message, uint DisplayTime, MadVR madvr) { var osd = (IMadVRTextOsd)madvr; osd.OsdDisplayMessage(Message, DisplayTime); }
public static bool InExclusiveMode(MadVR madvr) { var exclusiveInfo = madvr as IMadVRExclusiveModeInfo; return(exclusiveInfo.IsExclusiveModeActive() == 1); }
private void CloseInterfaces() { _hiddenWindow.SizeChanged -= _hiddenWindow_SizeChanged; int hr; if (_defaultAudioRenderer != null) { m_graph.RemoveFilter(_defaultAudioRenderer as DirectShowLib.IBaseFilter); Marshal.ReleaseComObject(_defaultAudioRenderer); _defaultAudioRenderer = null; } if (_reclockAudioRenderer != null) { m_graph.RemoveFilter(_reclockAudioRenderer as DirectShowLib.IBaseFilter); Marshal.ReleaseComObject(_reclockAudioRenderer); _reclockAudioRenderer = null; } if (_lavaudio != null) { m_graph.RemoveFilter(_lavaudio as DirectShowLib.IBaseFilter); Marshal.ReleaseComObject(_lavaudio); _lavaudio = null; } if (_xyVsFilter != null) { m_graph.RemoveFilter(_xyVsFilter as DirectShowLib.IBaseFilter); Marshal.ReleaseComObject(_xyVsFilter); _xyVsFilter = null; } if (_xySubFilter != null) { m_graph.RemoveFilter(_xySubFilter as DirectShowLib.IBaseFilter); Marshal.ReleaseComObject(_xySubFilter); _xySubFilter = null; } if (_lavvideo != null) { m_graph.RemoveFilter(_lavvideo as DirectShowLib.IBaseFilter); Marshal.ReleaseComObject(_lavvideo); _lavvideo = null; } if (_madvr != null) { m_graph.RemoveFilter(_madvr as DirectShowLib.IBaseFilter); Marshal.ReleaseComObject(_madvr); _madvr = null; } if (_videoWindow != null) { // Relinquish ownership (IMPORTANT!) after hiding video window hr = _videoWindow.put_Visible(OABool.False); hr = _videoWindow.put_Owner(IntPtr.Zero); } if (_mediaEventEx != null) { hr = _mediaEventEx.SetNotifyWindow(IntPtr.Zero, 0, IntPtr.Zero); Marshal.ReleaseComObject(_mediaEventEx); _mediaEventEx = null; } if (_dvdNav != null) { Marshal.ReleaseComObject(_dvdNav); _dvdNav = null; } if (_mDvdInfo != null) { Marshal.ReleaseComObject(_mDvdInfo); _mDvdInfo = null; } if (_mDvdControl != null) { Marshal.ReleaseComObject(_mDvdControl); _mDvdControl = null; } if (_mPDisplay != null) { Marshal.ReleaseComObject(_mPDisplay); _mPDisplay = null; } if (_filterGraph != null) { Marshal.ReleaseComObject(_filterGraph); _filterGraph = null; } if (_mPEvr != null) { Marshal.ReleaseComObject(_mPEvr); _mPEvr = null; } if (_mediaEventEx != null) { Marshal.ReleaseComObject(_mediaEventEx); _mediaEventEx = null; } if (_mediaSeeking != null) { Marshal.ReleaseComObject(_mediaSeeking); _mediaSeeking = null; } if (_mediaPosition != null) { Marshal.ReleaseComObject(_mediaPosition); _mediaPosition = null; } if (_mediaControl != null) { Marshal.ReleaseComObject(_mediaControl); _mediaControl = null; } if (_basicAudio != null) { Marshal.ReleaseComObject(_basicAudio); _basicAudio = null; } if (_basicVideo != null) { Marshal.ReleaseComObject(_basicVideo); _basicVideo = null; } if (_sourceFilter != null) { Marshal.ReleaseComObject(_sourceFilter); _sourceFilter = null; } if (m_graph != null) { Marshal.ReleaseComObject(m_graph); m_graph = null; } if (_videoWindow != null) { Marshal.ReleaseComObject(_videoWindow); _videoWindow = null; } _mSeekCaps = 0; _streams = null; GC.Collect(); }
private void RenderStreams(DirectShowLib.IBaseFilter pSource, bool enableReclock, bool enableMadvr, bool enableXySubFilter) { int hr; _filterGraph = m_graph as DirectShowLib.IFilterGraph2; if (_filterGraph == null) { throw new Exception("Could not QueryInterface for the IFilterGraph2"); } // Add video renderer if (_item.IsVideo) { _mPEvr = (DirectShowLib.IBaseFilter)new EnhancedVideoRenderer(); hr = m_graph.AddFilter(_mPEvr, "Enhanced Video Renderer"); DsError.ThrowExceptionForHR(hr); InitializeEvr(_mPEvr, 1); } // Add audio renderer var useDefaultRenderer = true; if (enableReclock) { try { _reclockAudioRenderer = new ReclockAudioRenderer(); var aRenderer = _reclockAudioRenderer as DirectShowLib.IBaseFilter; if (aRenderer != null) { hr = m_graph.AddFilter(aRenderer, "Reclock Audio Renderer"); DsError.ThrowExceptionForHR(hr); useDefaultRenderer = false; } } catch (Exception ex) { _logger.ErrorException("Error adding reclock filter", ex); } } if (useDefaultRenderer) { _defaultAudioRenderer = new DefaultAudioRenderer(); var aRenderer = _defaultAudioRenderer as DirectShowLib.IBaseFilter; if (aRenderer != null) { m_graph.AddFilter(aRenderer, "Default Audio Renderer"); } } if (_item.IsVideo) { try { _lavvideo = new LAVVideo(); var vlavvideo = _lavvideo as DirectShowLib.IBaseFilter; if (vlavvideo != null) { hr = m_graph.AddFilter(vlavvideo, "LAV Video Decoder"); DsError.ThrowExceptionForHR(hr); } } catch (Exception ex) { _logger.ErrorException("Error adding LAV Video filter", ex); } try { _lavaudio = new LAVAudio(); var vlavaudio = _lavaudio as DirectShowLib.IBaseFilter; if (vlavaudio != null) { hr = m_graph.AddFilter(vlavaudio, "LAV Audio Decoder"); DsError.ThrowExceptionForHR(hr); } } catch (Exception ex) { _logger.ErrorException("Error adding LAV Audio filter", ex); } if (_item.IsVideo) { var xySubFilterSucceeded = false; if (enableMadvr) { var madVrSucceded = false; try { _madvr = new MadVR(); var vmadvr = _madvr as DirectShowLib.IBaseFilter; if (vmadvr != null) { hr = m_graph.AddFilter(vmadvr, "MadVR Video Renderer"); DsError.ThrowExceptionForHR(hr); } madVrSucceded = true; } catch (Exception ex) { _logger.ErrorException("Error adding MadVR filter", ex); } // Load xySubFilter if configured and if madvr succeeded if (enableXySubFilter && madVrSucceded) { try { _xySubFilter = new XySubFilter(); var vxySubFilter = _xySubFilter as DirectShowLib.IBaseFilter; if (vxySubFilter != null) { hr = m_graph.AddFilter(vxySubFilter, "xy-SubFilter"); DsError.ThrowExceptionForHR(hr); } xySubFilterSucceeded = true; } catch (Exception ex) { _logger.ErrorException("Error adding xy-SubFilter filter", ex); } } } // Fallback to xyVsFilter if (!xySubFilterSucceeded) { try { _xyVsFilter = new XYVSFilter(); var vxyVsFilter = _xyVsFilter as DirectShowLib.IBaseFilter; if (vxyVsFilter != null) { hr = m_graph.AddFilter(vxyVsFilter, "xy-VSFilter"); DsError.ThrowExceptionForHR(hr); } } catch (Exception ex) { _logger.ErrorException("Error adding xy-VSFilter filter", ex); } } } } DirectShowLib.IEnumPins pEnum; hr = pSource.EnumPins(out pEnum); DsError.ThrowExceptionForHR(hr); DirectShowLib.IPin[] pins = { null }; /* Counter for how many pins successfully rendered */ var pinsRendered = 0; /* Loop over each pin of the source filter */ while (pEnum.Next(1, pins, IntPtr.Zero) == 0) { if (_filterGraph.RenderEx(pins[0], AMRenderExFlags.RenderToExistingRenderers, IntPtr.Zero) >= 0) pinsRendered++; Marshal.ReleaseComObject(pins[0]); } Marshal.ReleaseComObject(pEnum); if (pinsRendered == 0) { throw new Exception("Could not render any streams from the source Uri"); } _logger.Info("Completed RenderStreams with {0} pins.", pinsRendered); if (_item.IsVideo) { SetVideoWindow(); } }
private void RenderStreams(DirectShowLib.IBaseFilter pSource, bool enableReclock, bool enableMadvr, bool enableXySubFilter) { int hr; _filterGraph = m_graph as DirectShowLib.IFilterGraph2; if (_filterGraph == null) { throw new Exception("Could not QueryInterface for the IFilterGraph2"); } // Add video renderer if (_item.IsVideo) { _mPEvr = (DirectShowLib.IBaseFilter) new EnhancedVideoRenderer(); hr = m_graph.AddFilter(_mPEvr, "Enhanced Video Renderer"); DsError.ThrowExceptionForHR(hr); InitializeEvr(_mPEvr, 1); } // Add audio renderer var useDefaultRenderer = true; if (enableReclock) { try { _reclockAudioRenderer = new ReclockAudioRenderer(); var aRenderer = _reclockAudioRenderer as DirectShowLib.IBaseFilter; if (aRenderer != null) { hr = m_graph.AddFilter(aRenderer, "Reclock Audio Renderer"); DsError.ThrowExceptionForHR(hr); useDefaultRenderer = false; } } catch (Exception ex) { _logger.ErrorException("Error adding reclock filter", ex); } } if (useDefaultRenderer) { _defaultAudioRenderer = new DefaultAudioRenderer(); var aRenderer = _defaultAudioRenderer as DirectShowLib.IBaseFilter; if (aRenderer != null) { m_graph.AddFilter(aRenderer, "Default Audio Renderer"); } } if (_item.IsVideo) { try { _lavvideo = new LAVVideo(); var vlavvideo = _lavvideo as DirectShowLib.IBaseFilter; if (vlavvideo != null) { hr = m_graph.AddFilter(vlavvideo, "LAV Video Decoder"); DsError.ThrowExceptionForHR(hr); } } catch (Exception ex) { _logger.ErrorException("Error adding LAV Video filter", ex); } try { _lavaudio = new LAVAudio(); var vlavaudio = _lavaudio as DirectShowLib.IBaseFilter; if (vlavaudio != null) { hr = m_graph.AddFilter(vlavaudio, "LAV Audio Decoder"); DsError.ThrowExceptionForHR(hr); } } catch (Exception ex) { _logger.ErrorException("Error adding LAV Audio filter", ex); } if (_item.IsVideo) { var xySubFilterSucceeded = false; if (enableMadvr) { var madVrSucceded = false; try { _madvr = new MadVR(); var vmadvr = _madvr as DirectShowLib.IBaseFilter; if (vmadvr != null) { hr = m_graph.AddFilter(vmadvr, "MadVR Video Renderer"); DsError.ThrowExceptionForHR(hr); } madVrSucceded = true; } catch (Exception ex) { _logger.ErrorException("Error adding MadVR filter", ex); } // Load xySubFilter if configured and if madvr succeeded if (enableXySubFilter && madVrSucceded) { try { _xySubFilter = new XySubFilter(); var vxySubFilter = _xySubFilter as DirectShowLib.IBaseFilter; if (vxySubFilter != null) { hr = m_graph.AddFilter(vxySubFilter, "xy-SubFilter"); DsError.ThrowExceptionForHR(hr); } xySubFilterSucceeded = true; } catch (Exception ex) { _logger.ErrorException("Error adding xy-SubFilter filter", ex); } } } // Fallback to xyVsFilter if (!xySubFilterSucceeded) { try { _xyVsFilter = new XYVSFilter(); var vxyVsFilter = _xyVsFilter as DirectShowLib.IBaseFilter; if (vxyVsFilter != null) { hr = m_graph.AddFilter(vxyVsFilter, "xy-VSFilter"); DsError.ThrowExceptionForHR(hr); } } catch (Exception ex) { _logger.ErrorException("Error adding xy-VSFilter filter", ex); } } } } DirectShowLib.IEnumPins pEnum; hr = pSource.EnumPins(out pEnum); DsError.ThrowExceptionForHR(hr); DirectShowLib.IPin[] pins = { null }; /* Counter for how many pins successfully rendered */ var pinsRendered = 0; /* Loop over each pin of the source filter */ while (pEnum.Next(1, pins, IntPtr.Zero) == 0) { if (_filterGraph.RenderEx(pins[0], AMRenderExFlags.RenderToExistingRenderers, IntPtr.Zero) >= 0) { pinsRendered++; } Marshal.ReleaseComObject(pins[0]); } Marshal.ReleaseComObject(pEnum); if (pinsRendered == 0) { throw new Exception("Could not render any streams from the source Uri"); } _logger.Info("Completed RenderStreams with {0} pins.", pinsRendered); if (_item.IsVideo) { SetVideoWindow(); } }