Skip to content

Commit

Permalink
Video: Add QtMultimedia Receiver
Browse files Browse the repository at this point in the history
  • Loading branch information
HTRamsey committed May 16, 2024
1 parent 3f5d83e commit 56d6c06
Show file tree
Hide file tree
Showing 32 changed files with 731 additions and 194 deletions.
10 changes: 5 additions & 5 deletions qgroundcontrol.pro
Original file line number Diff line number Diff line change
Expand Up @@ -1222,19 +1222,19 @@ contains (CONFIG, DISABLE_VIDEOSTREAMING) {
QT += \
opengl \
gui-private
include(src/VideoReceiver/VideoReceiver.pri)
include(src/VideoManager/VideoReceiver/VideoReceiver.pri)
}

!VideoEnabled {
INCLUDEPATH += \
src/VideoReceiver
src/VideoManager/VideoReceiver

HEADERS += \
src/VideoManager/GLVideoItemStub.h \
src/VideoReceiver/VideoReceiver.h
src/VideoManager/VideoReceiver/GStreamer/GLVideoItemStub.h \
src/VideoManager/VideoReceiver/VideoReceiver.h

SOURCES += \
src/VideoManager/GLVideoItemStub.cc
src/VideoManager/VideoReceiver/GStreamer/GLVideoItemStub.cc
}

#-------------------------------------------------------------------------------------
Expand Down
11 changes: 4 additions & 7 deletions src/API/QGCCorePlugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#include "JoystickManager.h"
#if defined(QGC_GST_STREAMING)
#include "GStreamer.h"
#include "VideoReceiver.h"
#endif
#include "VideoReceiver.h"
#include "HorizontalFactValueGrid.h"
#include "InstrumentValueData.h"
#include "QGCLoggingCategory.h"
Expand Down Expand Up @@ -333,8 +333,7 @@ VideoReceiver* QGCCorePlugin::createVideoReceiver(QObject* parent)
#if defined(QGC_GST_STREAMING)
return GStreamer::createVideoReceiver(parent);
#else
Q_UNUSED(parent)
return nullptr;
return QtMultimediaReceiver::createVideoReceiver(parent);
#endif
}

Expand All @@ -343,9 +342,7 @@ void* QGCCorePlugin::createVideoSink(QObject* parent, QQuickItem* widget)
#if defined(QGC_GST_STREAMING)
return GStreamer::createVideoSink(parent, widget);
#else
Q_UNUSED(parent)
Q_UNUSED(widget)
return nullptr;
return QtMultimediaReceiver::createVideoSink(parent, widget);
#endif
}

Expand All @@ -354,7 +351,7 @@ void QGCCorePlugin::releaseVideoSink(void* sink)
#if defined(QGC_GST_STREAMING)
GStreamer::releaseVideoSink(sink);
#else
Q_UNUSED(sink)
QtMultimediaReceiver::releaseVideoSink(sink);
#endif
}

Expand Down
1 change: 0 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ add_subdirectory(UTMSP)
add_subdirectory(Vehicle)
add_subdirectory(VehicleSetup)
add_subdirectory(VideoManager)
add_subdirectory(VideoReceiver)
add_subdirectory(Viewer3D)

#######################################################
Expand Down
14 changes: 0 additions & 14 deletions src/QGCApplication.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@
#include <QtQml/QQmlContext>
#include <QtQml/QQmlApplicationEngine>

#if defined(QGC_GST_STREAMING)
#include "GStreamer.h"
#endif

#include "QGCConfig.h"
#include "QGCApplication.h"
#include "CmdLineOptParser.h"
Expand Down Expand Up @@ -242,16 +238,6 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
// Set up our logging filters
QGCLoggingCategoryRegister::instance()->setFilterRulesFromSettings(loggingOptions);

#if defined(QGC_GST_STREAMING)
// Gstreamer debug settings
int gstDebugLevel = 0;
if (settings.contains(AppSettings::gstDebugLevelName)) {
gstDebugLevel = settings.value(AppSettings::gstDebugLevelName).toInt();
}
// Initialize Video Receiver
GStreamer::initialize(argc, argv, gstDebugLevel);
#endif

// We need to set language as early as possible prior to loading on JSON files.
setLanguage();

Expand Down
1 change: 1 addition & 0 deletions src/Settings/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ target_link_libraries(Settings
API
QmlControls
Vehicle
VideoReceiver
PUBLIC
Qt6::Core
Qt6::Qml
Expand Down
9 changes: 3 additions & 6 deletions src/Vehicle/Vehicle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
#include "VehicleBatteryFactGroup.h"
#include "VehicleObjectAvoidance.h"
#include "VideoManager.h"
#include "VideoReceiver.h"
#include "VideoSettings.h"

#ifdef CONFIG_UTM_ADAPTER
Expand Down Expand Up @@ -1474,11 +1473,9 @@ void Vehicle::_updateArmed(bool armed)
_trajectoryPoints->stop();
_flightTimerStop();
// Also handle Video Streaming
if(qgcApp()->toolbox()->videoManager()->videoReceiver()) {
if(_settingsManager->videoSettings()->disableWhenDisarmed()->rawValue().toBool()) {
_settingsManager->videoSettings()->streamEnabled()->setRawValue(false);
qgcApp()->toolbox()->videoManager()->videoReceiver()->stop();
}
if(_settingsManager->videoSettings()->disableWhenDisarmed()->rawValue().toBool()) {
_settingsManager->videoSettings()->streamEnabled()->setRawValue(false);
qgcApp()->toolbox()->videoManager()->stopVideo();
}
}
}
Expand Down
19 changes: 6 additions & 13 deletions src/VideoManager/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
find_package(Qt6 REQUIRED COMPONENTS Core Quick)
add_subdirectory(VideoReceiver)

find_package(Qt6 REQUIRED COMPONENTS Core)

qt_add_library(VideoManager STATIC
GLVideoItemStub.cc
GLVideoItemStub.h
SubtitleWriter.cc
SubtitleWriter.h
VideoManager.cc
Expand All @@ -14,23 +14,16 @@ target_link_libraries(VideoManager
API
Camera
FactSystem
GStreamerReceiver
QmlControls
QtMultimediaReceiver
Settings
Utilities
Vehicle
VideoReceiver
PUBLIC
Qt6::Core
Qt6::Quick
QGC
VideoReceiver
)

option(QGC_DISABLE_UVC "Disable UVC Devices" OFF)
if(QGC_DISABLE_UVC)
target_compile_definitions(VideoManager PUBLIC QGC_DISABLE_UVC)
else()
find_package(Qt6 REQUIRED COMPONENTS Multimedia)
target_link_libraries(VideoManager PRIVATE Qt6::Multimedia)
endif()

target_include_directories(VideoManager PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
8 changes: 5 additions & 3 deletions src/VideoManager/SubtitleWriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@
#include <QtCore/QDateTime>
#include <QtCore/QString>
#include <QtCore/QFileInfo>
#include <QtCore/QTimer>

QGC_LOGGING_CATEGORY(SubtitleWriterLog, "SubtitleWriterLog")

const int SubtitleWriter::_sampleRate = 1; // Sample rate in Hz for getting telemetry data, most players do weird stuff when > 1Hz

SubtitleWriter::SubtitleWriter(QObject* parent)
: QObject(parent)
, _timer(new QTimer(this))
{
connect(&_timer, &QTimer::timeout, this, &SubtitleWriter::_captureTelemetry);
connect(_timer, &QTimer::timeout, this, &SubtitleWriter::_captureTelemetry);
}

void SubtitleWriter::startCapturingTelemetry(const QString& videoFile)
Expand Down Expand Up @@ -93,13 +95,13 @@ void SubtitleWriter::startCapturingTelemetry(const QString& videoFile)
// TODO: Find a good way to input title
//stream << QStringLiteral("Dialogue: 0,0:00:00.00,999:00:00.00,Default,,0,0,0,,{\\pos(5,35)}%1\n");

_timer.start(1000/_sampleRate);
_timer->start(1000/_sampleRate);
}

void SubtitleWriter::stopCapturingTelemetry()
{
qCDebug(SubtitleWriterLog) << "Stopping writing";
_timer.stop();
_timer->stop();
_file.close();
}

Expand Down
4 changes: 2 additions & 2 deletions src/VideoManager/SubtitleWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
#pragma once

#include <QtCore/QObject>
#include <QtCore/QTimer>
#include <QtCore/QTime>
#include <QtCore/QFile>
#include <QtCore/QLoggingCategory>

class Fact;
class QTimer;

Q_DECLARE_LOGGING_CATEGORY(SubtitleWriterLog)

Expand All @@ -43,7 +43,7 @@ private slots:
void _captureTelemetry();

private:
QTimer _timer;
QTimer* _timer = nullptr;
QList<Fact*> _facts;
QTime _lastEndTime;
QFile _file;
Expand Down

0 comments on commit 56d6c06

Please sign in to comment.