Skip to content

Commit

Permalink
Add AudioClip placeholder. Support WebEngine if available.
Browse files Browse the repository at this point in the history
  • Loading branch information
rectalogic committed Oct 21, 2023
1 parent 403337a commit 334fbe8
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 1 deletion.
8 changes: 7 additions & 1 deletion mediafx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License along with mediaFX.
# If not, see <https://www.gnu.org/licenses/>.

find_package(Qt6 REQUIRED COMPONENTS Core Gui Multimedia Qml Quick Quick3D)
find_package(Qt6 REQUIRED COMPONENTS Core Gui Multimedia Qml Quick Quick3D QUIET OPTIONAL_COMPONENTS WebEngineQuick)

qt_policy(SET QTP0001 NEW)

Expand All @@ -23,6 +23,7 @@ qt_add_executable(mediafx
mediafx.cpp
render_control.cpp
clip.cpp
audio_clip.cpp
visual_clip.cpp
video_clip.cpp
image_clip.cpp
Expand All @@ -34,4 +35,9 @@ qt_add_qml_module(mediafx

target_link_libraries(mediafx PRIVATE Qt6::Core Qt6::Gui Qt6::GuiPrivate Qt6::Multimedia Qt6::Qml Qt6::Quick Qt6::Quick3D)

if(${Qt6WebEngineQuick_FOUND})
target_link_libraries(mediafx PRIVATE Qt6::WebEngineQuick)
add_definitions(-DWEBENGINEQUICK)
endif()

install(TARGETS mediafx RUNTIME DESTINATION)
43 changes: 43 additions & 0 deletions mediafx/audio_clip.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (C) 2023 Andrew Wason
*
* This file is part of mediaFX.
*
* mediaFX is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* mediaFX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with mediaFX.
* If not, see <https://www.gnu.org/licenses/>.
*/

#include "audio_clip.h"
#include <QMediaTimeRange>

bool AudioClip::active()
{
// XXX
return false;
}

void AudioClip::setActive(bool active)
{
Clip::setActive(active);
// XXX
}

bool AudioClip::renderClip(const QMediaTimeRange::Interval& globalTime)
{
// XXX
return true;
}

void AudioClip::stop()
{
Clip::stop();
// XXX
}
40 changes: 40 additions & 0 deletions mediafx/audio_clip.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (C) 2023 Andrew Wason
*
* This file is part of mediaFX.
*
* mediaFX is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* mediaFX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with mediaFX.
* If not, see <https://www.gnu.org/licenses/>.
*/

#pragma once

#include "clip.h"
#include <QMediaTimeRange>
#include <QtQmlIntegration>

class AudioClip : public Clip {
Q_OBJECT
QML_ELEMENT

public:
using Clip::Clip;

protected:
void setActive(bool active) override;
bool active() override;

bool renderClip(const QMediaTimeRange::Interval& globalTime) override;

virtual void stop() override;

private:
};
12 changes: 12 additions & 0 deletions mediafx/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
#include <QUrl>
#include <QtTypes>
#include <stdlib.h>
#ifdef WEBENGINEQUICK
#include <QtWebEngineQuick>
#endif

int main(int argc, char* argv[])
{
Expand All @@ -33,6 +36,15 @@ int main(int argc, char* argv[])
const_cast<char*>("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM=1"));
#endif

#ifdef WEBENGINEQUICK
#if !defined(QT_NO_OPENGL)
// https://doc.qt.io/qt-6/qml-qtwebengine-webengineview.html#rendering-to-opengl-surface
// https://doc.qt.io/qt-6/qtwebengine-overview.html#embedding-web-content-into-qt-quick-applications
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
#endif
QtWebEngineQuick::initialize();
#endif

QGuiApplication app(argc, argv);

app.setOrganizationDomain("mediafx.stream");
Expand Down

0 comments on commit 334fbe8

Please sign in to comment.