コード例 #1
0
bool MediaPlayerPrivateMediaFoundation::addBranchToPartialTopology(int stream)
{
    // Get the stream descriptor for this stream.
    COMPtr<IMFStreamDescriptor> sourceSD;
    BOOL selected = FALSE;
    if (FAILED(m_sourcePD->GetStreamDescriptorByIndex(stream, &selected, &sourceSD)))
        return false;

    // Create the topology branch only if the stream is selected.
    // Otherwise, do nothing.
    if (!selected)
        return true;

    // Create a source node for this stream.
    COMPtr<IMFTopologyNode> sourceNode;
    if (!createSourceStreamNode(sourceSD, sourceNode))
        return false;

    COMPtr<IMFTopologyNode> outputNode;
    if (!createOutputNode(sourceSD, outputNode))
        return false;

    // Add both nodes to the topology.
    if (FAILED(m_topology->AddNode(sourceNode.get())))
        return false;

    if (FAILED(m_topology->AddNode(outputNode.get())))
        return false;

    // Connect the source node to the output node.
    if (FAILED(sourceNode->ConnectOutput(0, outputNode.get(), 0)))
        return false;

    return true;
}
VerticalPatchBlock::VerticalPatchBlock(MainController* controller, QString uid)
    : BlockBase(controller, uid)
{
    // prepare nodes:
    m_inputNode = createInputNode("inputNode");
    m_outputNode1 = createOutputNode("outputNode1");
    m_outputNode2 = createOutputNode("outputNode2");

    // set initial requested size:
    updateRequestedSize();

    // connect signals and slots:
    connect(m_outputNode1, SIGNAL(requestedSizeChanged()), this, SLOT(updateRequestedSize()));
    connect(m_outputNode2, SIGNAL(requestedSizeChanged()), this, SLOT(updateRequestedSize()));

    connect(m_inputNode, SIGNAL(dataChanged()), this, SLOT(updateOutput()));
}
AudioPlaybackBlock::AudioPlaybackBlock(MainController* controller, QString uid)
    : BlockBase(controller, uid)
    , m_playNode(nullptr)
    , m_pauseNode(nullptr)
    , m_toggleNode(nullptr)
    , m_activeNode(nullptr)
    , m_endNode(nullptr)
    , m_positionNode(nullptr)
    , m_filePath("")
    , m_lastPlayNodeValue(0.0)
    , m_lastPauseNodeValue(0.0)
    , m_lastToggleNodeValue(0.0)
    , m_alwaysStartAtBegin(false)
    , m_loop(false)
    , m_toggleMode(true)
    , m_player(this)
{
    m_widthIsResizable = true;

    m_playNode = createInputNode("playNode");
    m_pauseNode = createInputNode("pauseNode");
    m_toggleNode = createInputNode("toggleNode");
    connect(m_playNode, SIGNAL(dataChanged()), this, SLOT(onPlayNodeValueChanged()));
    connect(m_pauseNode, SIGNAL(dataChanged()), this, SLOT(onPauseNodeValueChanged()));
    connect(m_toggleNode, SIGNAL(dataChanged()), this, SLOT(onToggleNodeValueChanged()));

    m_activeNode = createOutputNode("activeNode");
    m_endNode = createOutputNode("endNode");
    m_positionNode = createOutputNode("positionNode");

    // setup Timer to be able to send a short pulse when end of file is reached:
    m_endPulseTimer.setSingleShot(true);
    m_endPulseTimer.setInterval(100);
    connect(&m_endPulseTimer, SIGNAL(timeout()), this, SLOT(onEndPulseTimeout()));

    connect(&m_player, SIGNAL(endOfFile()), this, SLOT(onEndOfFile()));
    connect(&m_player, SIGNAL(isPlayingChanged()), this, SIGNAL(isPlayingChanged()));
    connect(&m_player, SIGNAL(isPlayingChanged()), this, SLOT(onIsPlayingChanged()));
    connect(&m_player, SIGNAL(positionChanged()), this, SIGNAL(playbackPositionChanged()));
    connect(&m_player, SIGNAL(positionChanged()), this, SLOT(onPlaybackPositionChanged()));
    connect(&m_player, SIGNAL(lengthChanged()), this, SIGNAL(lengthChanged()));

    connect(&m_waveform, SIGNAL(pointsChanged()), this, SIGNAL(waveformChanged()));
    connect(&m_waveform, SIGNAL(availableChanged()), this, SIGNAL(waveformChanged()));
}