Media Foundation - Sequencer Source Loop

时间:2017-04-20 21:06:38

标签: c# ms-media-foundation

我试图制作一个视频播放器,按顺序无缝播放视频并循环播放。 "序列"和"无缝"部分通过使用Sequencer Source解决。但是"循环"部分让我头疼!

我想要做的是捕获 MEEndOfPresentation 事件,当它被捕获时我会执行以下步骤:

  1. 暂停媒体会话;
  2. 抓住第一个细分ID;
  3. 使用第2步结果调用MFCreateSequencerSegmentOffset;
  4. 调用媒体会话开始使用第3步结果。
  5. 这很有效。如果我将输出节点上的 MF_TOPONODE_NOSHUTDOWN_ON_REMOVE 设置为 TRUE ,则可以正常工作。但是,这会在几分钟内产生大量内存泄漏!

    如果我将 MF_TOPONODE_NOSHUTDOWN_ON_REMOVE 设置为 FALSE ,则显示的步骤无法正常工作。我使用的策略是否正确?

    我记录了这些事件,看看我在比赛后接到了什么。在这里他们分别是:

    MF_TOPONODE_NOSHUTDOWN_ON_REMOVE = FALSE

    MENewPresentation, Event Status: S_OK
    # then I queue the next segment
    MESessionTopologyStatus, Event Status: S_OK, Topology Status: StartedSource
    MESessionTopologyStatus, Event Status: S_OK, Topology Status: Ended
    MESessionTopologyStatus, Event Status: S_OK, Topology Status: SinkSwitched
    MESessionTopologyStatus, Event Status: S_OK, Topology Status: Ready
    MESessionTopologyStatus, Event Status: S_OK, Topology Status: StartedSource
    MEEndOfPresentation, Event Status: S_OK, Canceled: 0
    # then I do the steps mentioned
    MENewPresentation, Event Status: S_OK
    # then I queue the next segment
    MESessionTopologyStatus, Event Status: S_OK, Topology Status: Ended
    

    MF_TOPONODE_NOSHUTDOWN_ON_REMOVE = TRUE

    MENewPresentation, Event Status: S_OK
    # then I queue the next segment
    MESessionTopologyStatus, Event Status: S_OK, Topology Status: StartedSource
    MESessionTopologyStatus, Event Status: S_OK, Topology Status: Ended
    MESessionTopologyStatus, Event Status: S_OK, Topology Status: SinkSwitched
    MESessionTopologyStatus, Event Status: S_OK, Topology Status: Ready
    MESessionTopologyStatus, Event Status: S_OK, Topology Status: StartedSource
    MEEndOfPresentation, Event Status: S_OK, Canceled: 0
    # then I do the steps mentioned
    MENewPresentation, Event Status: S_OK
    # then I queue the next segment
    MESessionTopologyStatus, Event Status: S_OK, Topology Status: Ended
    MESessionTopologyStatus, Event Status: S_OK, Topology Status: SinkSwitched
    MESessionTopologyStatus, Event Status: S_OK, Topology Status: Ready
    MESessionTopologyStatus, Event Status: S_OK, Topology Status: StartedSource
    MESessionTopologyStatus, Event Status: S_OK, Topology Status: Ended
    MESessionTopologyStatus, Event Status: S_OK, Topology Status: SinkSwitched
    ...
    

    P.S。我没有添加代码,因为它非常大。但如果你需要,我可以编辑我的问题。

0 个答案:

没有答案