Skip to content

Commit

Permalink
Video: GStreamer Plugin Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
HTRamsey committed Oct 6, 2024
1 parent 459fd03 commit 31aa063
Show file tree
Hide file tree
Showing 17 changed files with 534 additions and 516 deletions.
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ target_link_libraries(QGC
FollowMe
Gimbal
GPS
GStreamerReceiver
Joystick
MAVLink
MissionManager
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
PRIVATE
Qt6::Multimedia
API
GStreamerReceiver
QmlControls
Vehicle
VideoManager
Expand Down
20 changes: 0 additions & 20 deletions src/Settings/VideoDecoderOptions.h

This file was deleted.

28 changes: 17 additions & 11 deletions src/Settings/VideoSettings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
#include <QtQml/QQmlEngine>
#include <QtCore/QVariantList>

#ifdef QGC_GST_STREAMING
#include "GStreamer.h"
#endif

#ifndef QGC_DISABLE_UVC
#include <QtMultimedia/QMediaDevices>
#include <QtMultimedia/QCameraDevice>
Expand Down Expand Up @@ -56,27 +60,29 @@ DECLARE_SETTINGGROUP(Video, "Video")

_nameToMetaDataMap[videoSourceName]->setEnumInfo(videoSourceCookedList, videoSourceList);

#ifdef QGC_GST_STREAMING
const QVariantList removeForceVideoDecodeList{
#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
VideoDecoderOptions::ForceVideoDecoderDirectX3D,
VideoDecoderOptions::ForceVideoDecoderVideoToolbox,
GStreamer::VideoDecoderOptions::ForceVideoDecoderDirectX3D,
GStreamer::VideoDecoderOptions::ForceVideoDecoderVideoToolbox,
#elif defined(Q_OS_WIN)
VideoDecoderOptions::ForceVideoDecoderVAAPI,
VideoDecoderOptions::ForceVideoDecoderVideoToolbox,
GStreamer::VideoDecoderOptions::ForceVideoDecoderVAAPI,
GStreamer::VideoDecoderOptions::ForceVideoDecoderVideoToolbox,
#elif defined(Q_OS_MAC)
VideoDecoderOptions::ForceVideoDecoderDirectX3D,
VideoDecoderOptions::ForceVideoDecoderVAAPI,
GStreamer::VideoDecoderOptions::ForceVideoDecoderDirectX3D,
GStreamer::VideoDecoderOptions::ForceVideoDecoderVAAPI,
#elif defined(Q_OS_ANDROID)
VideoDecoderOptions::ForceVideoDecoderDirectX3D,
VideoDecoderOptions::ForceVideoDecoderVideoToolbox,
VideoDecoderOptions::ForceVideoDecoderVAAPI,
VideoDecoderOptions::ForceVideoDecoderNVIDIA,
GStreamer::VideoDecoderOptions::ForceVideoDecoderDirectX3D,
GStreamer::VideoDecoderOptions::ForceVideoDecoderVideoToolbox,
GStreamer::VideoDecoderOptions::ForceVideoDecoderVAAPI,
GStreamer::VideoDecoderOptions::ForceVideoDecoderNVIDIA,
#endif
};

for(const auto& value : removeForceVideoDecodeList) {
for (const auto &value : removeForceVideoDecodeList) {
_nameToMetaDataMap[forceVideoDecoderName]->removeEnumInfo(value);
}
#endif

// Set default value for videoSource
_setDefaults();
Expand Down
3 changes: 0 additions & 3 deletions src/Settings/VideoSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#pragma once

#include "SettingsGroup.h"
#include "VideoDecoderOptions.h"

class VideoSettings : public SettingsGroup
{
Expand All @@ -37,8 +36,6 @@ class VideoSettings : public SettingsGroup
DEFINE_SETTINGFACT(lowLatencyMode)
DEFINE_SETTINGFACT(forceVideoDecoder)

Q_ENUM(VideoDecoderOptions)

Q_PROPERTY(bool streamConfigured READ streamConfigured NOTIFY streamConfiguredChanged)
Q_PROPERTY(QString rtspVideoSource READ rtspVideoSource CONSTANT)
Q_PROPERTY(QString udp264VideoSource READ udp264VideoSource CONSTANT)
Expand Down
19 changes: 3 additions & 16 deletions src/VideoManager/VideoManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "SubtitleWriter.h"
#ifdef QGC_GST_STREAMING
#include "GStreamer.h"
#include "VideoDecoderOptions.h"
#else
#include "GLVideoItemStub.h"
#endif
Expand All @@ -38,6 +37,7 @@

#include <QtCore/QDir>
#include <QtQml/QQmlEngine>
#include <QtQuick/QQuickItem>

QGC_LOGGING_CATEGORY(VideoManagerLog, "qgc.videomanager.videomanager")

Expand All @@ -53,20 +53,7 @@ VideoManager::VideoManager(QGCApplication* app, QGCToolbox* toolbox)
, _subtitleWriter(new SubtitleWriter(this))
{
#ifdef QGC_GST_STREAMING
// Gstreamer debug settings
int gstDebugLevel = 0;
QSettings settings;
if (settings.contains(AppSettings::gstDebugLevelName)) {
gstDebugLevel = settings.value(AppSettings::gstDebugLevelName).toInt();
}
QStringList args = _app->arguments();
const qsizetype argc = args.size();
char** argv = new char*[argc];
for (qsizetype i = 0; i < argc; i++) {
argv[i] = args[i].toUtf8().data();
}
GStreamer::initialize(argc, argv, gstDebugLevel);
delete[] argv;
GStreamer::initialize();
#else
qmlRegisterType<GLVideoItemStub>("org.freedesktop.gstreamer.Qt6GLVideoItem", 1, 0, "GstGLQt6VideoItem");
#endif
Expand Down Expand Up @@ -118,7 +105,7 @@ VideoManager::setToolbox(QGCToolbox *toolbox)
connect(pVehicleMgr, &MultiVehicleManager::activeVehicleChanged, this, &VideoManager::_setActiveVehicle);

#ifdef QGC_GST_STREAMING
GStreamer::blacklist(static_cast<VideoDecoderOptions>(_videoSettings->forceVideoDecoder()->rawValue().toInt()));
GStreamer::blacklist(static_cast<GStreamer::VideoDecoderOptions>(_videoSettings->forceVideoDecoder()->rawValue().toInt()));
#endif

int index = 0;
Expand Down
12 changes: 8 additions & 4 deletions src/VideoManager/VideoReceiver/GStreamer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ endif()

target_sources(GStreamerReceiver
PRIVATE
gstqgc.c
gstqgcvideosinkbin.c
gstqgc.cc
gstqgcelement.cc
gstqgcelements.h
gstqgcvideosinkbin.cc
gstqgcvideosinkbin.h
GStreamer.cc
GStreamer.h
GstVideoReceiver.cc
Expand All @@ -31,13 +34,14 @@ target_sources(GStreamerReceiver
if(IOS)
target_sources(GStreamerReceiver
PRIVATE
gst_ios_init.h
gst_ios_init.m
gst_ios_init.h
)
endif()

target_link_libraries(GStreamerReceiver
PRIVATE
QGC
Utilities
PUBLIC
Qt6::Core
Expand All @@ -46,4 +50,4 @@ target_link_libraries(GStreamerReceiver
VideoReceiver
)

target_compile_definitions(QGC PUBLIC QGC_GST_STREAMING)
target_compile_definitions(GStreamerReceiver PUBLIC QGC_GST_STREAMING)
4 changes: 1 addition & 3 deletions src/VideoManager/VideoReceiver/GStreamer/GLVideoItemStub.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,5 @@ class GLVideoItemStub : public QQuickItem

public:
GLVideoItemStub(QQuickItem *parent = nullptr) :
QQuickItem(parent)
{}
~GLVideoItemStub() = default;
QQuickItem(parent) {}
};
Loading

0 comments on commit 31aa063

Please sign in to comment.