Exemple #1
0
        protected AbstractRenderer(ITimeline timeline)
        {
            if (timeline == null)
            {
                throw new ArgumentNullException(TimelineParameterName);
            }

            _timeline = timeline;

            int hr = 0;

            // create the render engine
            _renderEngine = (IRenderEngine) new RenderEngine();
            _cleanup.Add(_renderEngine);

            // tell the render engine about the timeline it should use
            hr = _renderEngine.SetTimelineObject(_timeline.DesTimeline);
            DESError.ThrowExceptionForHR(hr);

            // connect up the front end
            hr = _renderEngine.ConnectFrontEnd();
            DESError.ThrowExceptionForHR(hr);

            // Get the filtergraph - used all over the place
            hr = _renderEngine.GetFilterGraph(out _graph);
            _cleanup.Add(Graph);
            DESError.ThrowExceptionForHR(hr);

            // find the first (and usually last) audio and video group, we use these
            // when rendering to track progress
            _firstAudioGroup = _timeline.FindFirstGroupOfType(GroupType.Audio);
            _firstVideoGroup = _timeline.FindFirstGroupOfType(GroupType.Video);
        }
Exemple #2
0
        private void TestTimeLine()
        {
            int         hr;
            IAMTimeline tl2;

            m_pTimeline = (IAMTimeline) new AMTimeline();

            hr = m_ire.SetTimelineObject(m_pTimeline);
            DESError.ThrowExceptionForHR(hr);

            hr = m_ire.GetTimelineObject(out tl2);
            DESError.ThrowExceptionForHR(hr);

            Debug.Assert(m_pTimeline == tl2, "TimeLine");
        }
        private void RenderCommon()
        {
            int hr;

            // create the render engine
            IRenderEngine pRenderEngine = (IRenderEngine) new SmartRenderEngine();

            m_pRenderEngine = pRenderEngine as ISmartRenderEngine;

            // tell the render engine about the timeline it should use
            hr = pRenderEngine.SetTimelineObject(m_pTimeline);
            DESError.ThrowExceptionForHR(hr);

            // connect up the front end
            hr = pRenderEngine.ConnectFrontEnd( );
            DESError.ThrowExceptionForHR(hr);
        }
Exemple #4
0
        /// <summary>
        /// Called from RenderTo* routines to perform common initialization
        /// </summary>
        private void RenderCommon()
        {
            int hr;

            if (m_State >= ClassState.RenderSelected)
            {
                throw new Exception("Graph rendering has already been selected");
            }

            if (m_State < ClassState.FilesAdded)
            {
                throw new Exception("No files added to render.");
            }

            m_State = ClassState.RenderSelected;

            // create the render engine
            m_pRenderEngine = (IRenderEngine) new RenderEngine();

            // tell the render engine about the timeline it should use
            hr = m_pRenderEngine.SetTimelineObject(m_pTimeline);
            DESError.ThrowExceptionForHR(hr);

            // connect up the front end
            hr = m_pRenderEngine.ConnectFrontEnd();
            DESError.ThrowExceptionForHR(hr);

            // Get the filtergraph - used all over the place
            hr = m_pRenderEngine.GetFilterGraph(out m_pGraph);
            DESError.ThrowExceptionForHR(hr);

#if DEBUG
            // Allow the graph to be connected to from GraphEdit
            m_rot = new DsROTEntry(m_pGraph);
#endif
        }
        protected AbstractRenderer(ITimeline timeline)
        {
            if (timeline == null) throw new ArgumentNullException(TimelineParameterName);

            _timeline = timeline;

            int hr = 0;

            // create the render engine
            _renderEngine = (IRenderEngine) new RenderEngine();
            _cleanup.Add(_renderEngine);

            // tell the render engine about the timeline it should use
            hr = _renderEngine.SetTimelineObject(_timeline.DesTimeline);
            DESError.ThrowExceptionForHR(hr);

            // connect up the front end
            hr = _renderEngine.ConnectFrontEnd();
            DESError.ThrowExceptionForHR(hr);

            // Get the filtergraph - used all over the place
            hr = _renderEngine.GetFilterGraph(out _graph);
            _cleanup.Add(Graph);
            DESError.ThrowExceptionForHR(hr);

            // find the first (and usually last) audio and video group, we use these
            // when rendering to track progress
            _firstAudioGroup = _timeline.FindFirstGroupOfType(GroupType.Audio);
            _firstVideoGroup = _timeline.FindFirstGroupOfType(GroupType.Video);
        }
Exemple #6
0
    /// <summary>
    /// Called from RenderTo* routines to perform common initialization
    /// </summary>
    private void RenderCommon()
    {
      int hr;

      if (m_State >= ClassState.RenderSelected)
      {
        throw new Exception("Graph rendering has already been selected");
      }

      if (m_State < ClassState.FilesAdded)
      {
        throw new Exception("No files added to render.");
      }

      m_State = ClassState.RenderSelected;

      // create the render engine
      m_pRenderEngine = (IRenderEngine)new RenderEngine();

      // tell the render engine about the timeline it should use
      hr = m_pRenderEngine.SetTimelineObject(m_pTimeline);
      DESError.ThrowExceptionForHR(hr);

      // connect up the front end
      hr = m_pRenderEngine.ConnectFrontEnd();
      DESError.ThrowExceptionForHR(hr);

      // Get the filtergraph - used all over the place
      hr = m_pRenderEngine.GetFilterGraph(out m_pGraph);
      DESError.ThrowExceptionForHR(hr);

#if DEBUG
      // Allow the graph to be connected to from GraphEdit
      m_rot = new DsROTEntry(m_pGraph);
#endif
    }
Exemple #7
0
        private void Transcode(string strSource, string strTarget, string strFormat)
        {
            // store the settings we want to use
            m_strSourceFile = strSource;
            m_strTargetFile = strTarget;
            m_systemsFormat = DirectEncodeNET.SystemsOutputFormat.SYSTEMSFORMAT_MPEG1;
            m_constraint = DirectEncodeNET.Constraint.CONSTRAINT_NONE;

            // Create the capture graph builder.
            m_pBuilder = (ICaptureGraphBuilder2)new CaptureGraphBuilder2();

            // Create the timline.
            m_pTimeline = (IAMTimeline)new AMTimeline();

            // get the length, dimensions, fps of the file
            double dLength = 0;
            int nWidth = 0, nHeight = 0;
            double framerate = 0;
            GetFileInfo(strSource, ref framerate, ref dLength, ref nWidth, ref nHeight);

            int hr = 0;

            // Load MPEG Codec
            hr = LoadMPEGCodec();
            DESError.ThrowExceptionForHR(hr);

            // Add the video group and files
            hr = AddVideo(dLength, framerate, nWidth, nHeight);
            DESError.ThrowExceptionForHR(hr);

            hr = AddAudio(dLength);
            DESError.ThrowExceptionForHR(hr);

            // create the render engine
            m_pRenderEngine = (IRenderEngine)new RenderEngine();

            // tell the render engine about the timeline it should use
            hr = m_pRenderEngine.SetTimelineObject( m_pTimeline );
            DESError.ThrowExceptionForHR(hr);

            // connect up the front end
            hr = m_pRenderEngine.ConnectFrontEnd( );
            DESError.ThrowExceptionForHR(hr);

            // Get the filtergraph
            hr = m_pRenderEngine.GetFilterGraph( out m_pGraph );
            DESError.ThrowExceptionForHR(hr);

            // set the filtergraph to the graph builder
            hr = m_pBuilder.SetFiltergraph(m_pGraph);
            DESError.ThrowExceptionForHR(hr);

            IPin pVideoOutPin, pAudioOutPin;
            hr = m_pRenderEngine.GetGroupOutputPin(0, out pVideoOutPin);
            hr = m_pRenderEngine.GetGroupOutputPin(1, out pAudioOutPin);
            DESError.ThrowExceptionForHR(hr);

            hr = RenderOutput(m_pBuilder, m_pGraph, m_pRenderEngine, null, pVideoOutPin, pAudioOutPin, null);
            DESError.ThrowExceptionForHR(hr);

            // get the control interfaces
            m_pEvent = (IMediaEventEx)m_pGraph;
            m_pMediaControl = (IMediaControl)m_pGraph;

            #if DEBUG
            // Allow the graph to be connected to from GraphEdit
            m_rot = null;
            m_rot = new DsROTEntry(m_pGraph);
            #endif

            // Start the conversion
            hr = m_pMediaControl.Run();

            // Alternative method of getting info
            // EventLoop();
        }