Example #1
0
        /// <summary>
        /// Add VMR7 filter to graph and configure it
        /// </summary>
        /// <param name="graphBuilder"></param>
        public void AddVMR7(IGraphBuilder graphBuilder)
        {
            Log.Info("VMR7Helper:AddVMR7");
            if (vmr7intialized)
            {
                return;
            }

            VMR7Filter = (IBaseFilter) new VideoMixingRenderer();
            if (VMR7Filter == null)
            {
                Error.SetError("Unable to play movie", "VMR7 is not installed");
                Log.Error("VMR7Helper:Failed to get instance of VMR7 ");
                return;
            }

            int hr;
            IVMRFilterConfig config = VMR7Filter as IVMRFilterConfig;

            if (config != null)
            {
                hr = config.SetNumberOfStreams(1);
                if (hr != 0)
                {
                    Log.Error("VMR7Helper:Failed to set number of streams:0x{0:X}", hr);
                    DirectShowUtil.ReleaseComObject(VMR7Filter);
                    VMR7Filter = null;
                    return;
                }
            }

            hr = graphBuilder.AddFilter(VMR7Filter, "Video Mixing Renderer");
            if (hr != 0)
            {
                Error.SetError("Unable to play movie", "Unable to initialize VMR7");
                Log.Error("VMR7Helper:Failed to add VMR7 to filtergraph");
                DirectShowUtil.ReleaseComObject(VMR7Filter);
                VMR7Filter = null;
                return;
            }
            m_graphBuilder = graphBuilder;
            m_mixerBitmap  = VMR7Filter as IVMRMixerBitmap;
            quality        = VMR7Filter as IQualProp;
            g_vmr7         = this;
            vmr7intialized = true;
        }
Example #2
0
        /// <summary>
        /// removes the VMR7 filter from the graph and free up all unmanaged resources
        /// </summary>
        public void RemoveVMR7()
        {
            if (vmr7intialized)
            {
                int result;
                Log.Info("VMR7Helper:RemoveVMR7");
                //if (m_mixerBitmap != null)
                //	while ((result=DirectShowUtil.ReleaseComObject(m_mixerBitmap))>0);
                m_mixerBitmap = null;

//				if (quality != null)
//					while ((result=DirectShowUtil.ReleaseComObject(quality))>0);
                quality = null;

                if (VMR7Filter != null)
                {
                    //while ((result=DirectShowUtil.ReleaseComObject(VMR7Filter))>0);
                    try
                    {
                        result = m_graphBuilder.RemoveFilter(VMR7Filter);
                        if (result != 0)
                        {
                            Log.Info("VMR7Helper:RemoveFilter():{0}", result);
                        }
                    }
                    catch (Exception) {}
                    while ((result = DirectShowUtil.ReleaseComObject(VMR7Filter)) > 0)
                    {
                        ;
                    }
                    if (result != 0)
                    {
                        Log.Info("VMR7Helper:ReleaseComObject():{0}", result);
                    }
                    m_graphBuilder = null;
                }
                vmr7intialized = false;
                g_vmr7         = null;
            }
        }
Example #3
0
    /// <summary>
    /// Add VMR7 filter to graph and configure it
    /// </summary>
    /// <param name="graphBuilder"></param>
    public void AddVMR7(IGraphBuilder graphBuilder)
    {
      Log.Info("VMR7Helper:AddVMR7");
      if (vmr7intialized)
      {
        return;
      }

      VMR7Filter = (IBaseFilter)new VideoMixingRenderer();
      if (VMR7Filter == null)
      {
        Error.SetError("Unable to play movie", "VMR7 is not installed");
        Log.Error("VMR7Helper:Failed to get instance of VMR7 ");
        return;
      }

      int hr;
      IVMRFilterConfig config = VMR7Filter as IVMRFilterConfig;
      if (config != null)
      {
        hr = config.SetNumberOfStreams(1);
        if (hr != 0)
        {
          Log.Error("VMR7Helper:Failed to set number of streams:0x{0:X}", hr);
          DirectShowUtil.ReleaseComObject(VMR7Filter);
          VMR7Filter = null;
          return;
        }
      }

      hr = graphBuilder.AddFilter(VMR7Filter, "Video Mixing Renderer");
      if (hr != 0)
      {
        Error.SetError("Unable to play movie", "Unable to initialize VMR7");
        Log.Error("VMR7Helper:Failed to add VMR7 to filtergraph");
        DirectShowUtil.ReleaseComObject(VMR7Filter);
        VMR7Filter = null;
        return;
      }
      m_graphBuilder = graphBuilder;
      m_mixerBitmap = VMR7Filter as IVMRMixerBitmap;
      quality = VMR7Filter as IQualProp;
      g_vmr7 = this;
      vmr7intialized = true;
    }
Example #4
0
    /// <summary>
    /// removes the VMR7 filter from the graph and free up all unmanaged resources
    /// </summary>
    public void RemoveVMR7()
    {
      if (vmr7intialized)
      {
        int result;
        Log.Info("VMR7Helper:RemoveVMR7");
        //if (m_mixerBitmap != null)
        //	while ((result=DirectShowUtil.ReleaseComObject(m_mixerBitmap))>0);
        m_mixerBitmap = null;

//				if (quality != null)
//					while ((result=DirectShowUtil.ReleaseComObject(quality))>0);
        quality = null;

        if (VMR7Filter != null)
        {
          //while ((result=DirectShowUtil.ReleaseComObject(VMR7Filter))>0); 
          try
          {
            result = m_graphBuilder.RemoveFilter(VMR7Filter);
            if (result != 0)
            {
              Log.Info("VMR7Helper:RemoveFilter():{0}", result);
            }
          }
          catch (Exception) {}
          while ((result = DirectShowUtil.ReleaseComObject(VMR7Filter)) > 0)
          {
            ;
          }
          if (result != 0)
          {
            Log.Info("VMR7Helper:ReleaseComObject():{0}", result);
          }
          m_graphBuilder = null;
        }
        vmr7intialized = false;
        g_vmr7 = null;
      }
    }