Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
23f57eb9
Commit
23f57eb9
authored
Feb 23, 2017
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move video settings to new SettingsGroup system
parent
026e6057
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
209 additions
and
244 deletions
+209
-244
VideoManager.cc
src/FlightDisplay/VideoManager.cc
+37
-156
VideoManager.h
src/FlightDisplay/VideoManager.h
+9
-33
SettingsGroup.video.json
src/Settings/SettingsGroup.video.json
+0
-2
Video.SettingsGroup.json
src/Settings/Video.SettingsGroup.json
+31
-0
VideoSettings.cc
src/Settings/VideoSettings.cc
+82
-1
VideoSettings.h
src/Settings/VideoSettings.h
+23
-0
VideoReceiver.cc
src/VideoStreaming/VideoReceiver.cc
+7
-13
VideoReceiver.h
src/VideoStreaming/VideoReceiver.h
+0
-2
GeneralSettings.qml
src/ui/preferences/GeneralSettings.qml
+20
-37
No files found.
src/FlightDisplay/VideoManager.cc
View file @
23f57eb9
...
@@ -25,19 +25,7 @@
...
@@ -25,19 +25,7 @@
#include "QGCToolbox.h"
#include "QGCToolbox.h"
#include "QGCCorePlugin.h"
#include "QGCCorePlugin.h"
#include "QGCOptions.h"
#include "QGCOptions.h"
#include "Settings/SettingsManager.h"
static
const
char
*
kVideoSourceKey
=
"VideoSource"
;
static
const
char
*
kVideoUDPPortKey
=
"VideoUDPPort"
;
static
const
char
*
kVideoRTSPUrlKey
=
"VideoRTSPUrl"
;
static
const
char
*
kNoVideo
=
"No Video Available"
;
#if defined(QGC_GST_STREAMING)
#if defined(QGC_ENABLE_VIDEORECORDING)
static
const
char
*
kVideoSavePathKey
=
"VideoSavePath"
;
#endif
static
const
char
*
kUDPStream
=
"UDP Video Stream"
;
static
const
char
*
kRTSPStream
=
"RTSP Video Stream"
;
#endif
QGC_LOGGING_CATEGORY
(
VideoManagerLog
,
"VideoManagerLog"
)
QGC_LOGGING_CATEGORY
(
VideoManagerLog
,
"VideoManagerLog"
)
...
@@ -47,8 +35,8 @@ VideoManager::VideoManager(QGCApplication* app)
...
@@ -47,8 +35,8 @@ VideoManager::VideoManager(QGCApplication* app)
,
_videoSurface
(
NULL
)
,
_videoSurface
(
NULL
)
,
_videoReceiver
(
NULL
)
,
_videoReceiver
(
NULL
)
,
_videoRunning
(
false
)
,
_videoRunning
(
false
)
,
_udpPort
(
5600
)
//-- Defalut Port 5600 == Solo UDP Port
,
_init
(
false
)
,
_init
(
false
)
,
_videoSettings
(
NULL
)
{
{
}
}
...
@@ -65,31 +53,36 @@ VideoManager::setToolbox(QGCToolbox *toolbox)
...
@@ -65,31 +53,36 @@ VideoManager::setToolbox(QGCToolbox *toolbox)
QGCTool
::
setToolbox
(
toolbox
);
QGCTool
::
setToolbox
(
toolbox
);
QQmlEngine
::
setObjectOwnership
(
this
,
QQmlEngine
::
CppOwnership
);
QQmlEngine
::
setObjectOwnership
(
this
,
QQmlEngine
::
CppOwnership
);
qmlRegisterUncreatableType
<
VideoManager
>
(
"QGroundControl.VideoManager"
,
1
,
0
,
"VideoManager"
,
"Reference only"
);
qmlRegisterUncreatableType
<
VideoManager
>
(
"QGroundControl.VideoManager"
,
1
,
0
,
"VideoManager"
,
"Reference only"
);
//-- Get saved settings
_videoSettings
=
toolbox
->
settingsManager
()
->
videoSettings
();
QString
videoSource
=
_videoSettings
->
videoSource
()
->
rawValue
().
toString
();
#if defined(QGC_GST_STREAMING)
#if defined(QGC_GST_STREAMING)
QSettings
settings
;
#ifndef QGC_DISABLE_UVC
#if defined(NO_UDP_VIDEO)
// If we are using a UVC camera setup the device name
setVideoSource
(
settings
.
value
(
kVideoSourceKey
,
kRTSPStream
).
toString
());
QList
<
QCameraInfo
>
cameras
=
QCameraInfo
::
availableCameras
();
#else
foreach
(
const
QCameraInfo
&
cameraInfo
,
cameras
)
{
setVideoSource
(
settings
.
value
(
kVideoSourceKey
,
kUDPStream
).
toString
());
if
(
cameraInfo
.
description
()
==
videoSource
)
{
#endif
_videoSourceID
=
cameraInfo
.
deviceName
();
//-- Check if core plugin defines its own video requirements
emit
videoSourceIDChanged
();
if
(
qgcApp
()
->
toolbox
()
->
corePlugin
()
->
options
()
->
definesVideo
())
{
qCDebug
(
VideoManagerLog
)
<<
"Found USB source:"
<<
_videoSourceID
<<
" Name:"
<<
videoSource
;
if
(
qgcApp
()
->
toolbox
()
->
corePlugin
()
->
options
()
->
videoUDPPort
())
{
break
;
setUdpPort
(
qgcApp
()
->
toolbox
()
->
corePlugin
()
->
options
()
->
videoUDPPort
());
}
setVideoSource
(
kUDPStream
);
}
}
else
{
setVideoSource
(
kRTSPStream
);
setRtspURL
(
qgcApp
()
->
toolbox
()
->
corePlugin
()
->
options
()
->
videoRSTPUrl
());
}
}
else
{
setUdpPort
(
settings
.
value
(
kVideoUDPPortKey
,
5600
).
toUInt
());
setRtspURL
(
settings
.
value
(
kVideoRTSPUrlKey
,
"rtsp://192.168.42.1:554/live"
).
toString
());
//-- Example RTSP URL
}
#if defined(QGC_ENABLE_VIDEORECORDING)
setVideoSavePath
(
settings
.
value
(
kVideoSavePathKey
,
QDir
::
homePath
()).
toString
());
#endif
#endif
emit
isGStreamerChanged
();
qCDebug
(
VideoManagerLog
)
<<
"New Video Source:"
<<
videoSource
;
if
(
_videoReceiver
)
{
if
(
isGStreamer
())
{
_videoReceiver
->
start
();
}
else
{
_videoReceiver
->
stop
();
}
}
#endif
#endif
_init
=
true
;
_init
=
true
;
#if defined(QGC_GST_STREAMING)
#if defined(QGC_GST_STREAMING)
_updateVideo
();
_updateVideo
();
...
@@ -105,7 +98,8 @@ VideoManager::hasVideo()
...
@@ -105,7 +98,8 @@ VideoManager::hasVideo()
#if defined(QGC_GST_STREAMING)
#if defined(QGC_GST_STREAMING)
return
true
;
return
true
;
#endif
#endif
return
!
_videoSource
.
isEmpty
();
QString
videoSource
=
_videoSettings
->
videoSource
()
->
rawValue
().
toString
();
return
!
videoSource
.
isEmpty
()
&&
videoSource
!=
VideoSettings
::
videoSourceNoVideo
;
}
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
...
@@ -113,7 +107,8 @@ bool
...
@@ -113,7 +107,8 @@ bool
VideoManager
::
isGStreamer
()
VideoManager
::
isGStreamer
()
{
{
#if defined(QGC_GST_STREAMING)
#if defined(QGC_GST_STREAMING)
return
_videoSource
==
kUDPStream
||
_videoSource
==
kRTSPStream
;
QString
videoSource
=
_videoSettings
->
videoSource
()
->
rawValue
().
toString
();
return
videoSource
==
VideoSettings
::
videoSourceUDP
||
videoSource
==
VideoSettings
::
videoSourceRTSP
;
#else
#else
return
false
;
return
false
;
#endif
#endif
...
@@ -128,118 +123,6 @@ VideoManager::uvcEnabled()
...
@@ -128,118 +123,6 @@ VideoManager::uvcEnabled()
}
}
#endif
#endif
//-----------------------------------------------------------------------------
void
VideoManager
::
setVideoSource
(
QString
vSource
)
{
if
(
vSource
==
kNoVideo
)
return
;
_videoSource
=
vSource
;
QSettings
settings
;
settings
.
setValue
(
kVideoSourceKey
,
vSource
);
emit
videoSourceChanged
();
#ifndef QGC_DISABLE_UVC
QList
<
QCameraInfo
>
cameras
=
QCameraInfo
::
availableCameras
();
foreach
(
const
QCameraInfo
&
cameraInfo
,
cameras
)
{
if
(
cameraInfo
.
description
()
==
vSource
)
{
_videoSourceID
=
cameraInfo
.
deviceName
();
emit
videoSourceIDChanged
();
qCDebug
(
VideoManagerLog
)
<<
"Found USB source:"
<<
_videoSourceID
<<
" Name:"
<<
_videoSource
;
break
;
}
}
#endif
emit
isGStreamerChanged
();
qCDebug
(
VideoManagerLog
)
<<
"New Video Source:"
<<
vSource
;
/*
* Not working. Requires restart for now. (Undef KRTSP/kUDP above when enabling this)
if(isGStreamer())
_updateVideo();
*/
if
(
_videoReceiver
)
{
if
(
isGStreamer
())
{
_videoReceiver
->
start
();
}
else
{
_videoReceiver
->
stop
();
}
}
}
//-----------------------------------------------------------------------------
void
VideoManager
::
setUdpPort
(
quint16
port
)
{
_udpPort
=
port
;
QSettings
settings
;
settings
.
setValue
(
kVideoUDPPortKey
,
port
);
emit
udpPortChanged
();
/*
* Not working. Requires restart for now. (Undef KRTSP/kUDP above when enabling this)
if(_videoSource == kUDPStream)
_updateVideo();
*/
}
//-----------------------------------------------------------------------------
void
VideoManager
::
setRtspURL
(
QString
url
)
{
_rtspURL
=
url
;
QSettings
settings
;
settings
.
setValue
(
kVideoRTSPUrlKey
,
url
);
emit
rtspURLChanged
();
/*
* Not working. Requires restart for now. (Undef KRTSP/kUDP above when enabling this)
if(_videoSource == kRTSPStream)
_updateVideo();
*/
}
void
VideoManager
::
setVideoSavePathByUrl
(
QUrl
url
)
{
#if defined(QGC_ENABLE_VIDEORECORDING)
setVideoSavePath
(
url
.
toLocalFile
());
#else
Q_UNUSED
(
url
);
#endif
}
void
VideoManager
::
setVideoSavePath
(
QString
path
)
{
#if defined(QGC_ENABLE_VIDEORECORDING)
_videoSavePath
=
path
;
QSettings
settings
;
settings
.
setValue
(
kVideoSavePathKey
,
path
);
if
(
_videoReceiver
)
_videoReceiver
->
setVideoSavePath
(
_videoSavePath
);
emit
videoSavePathChanged
();
#else
Q_UNUSED
(
path
);
#endif
}
//-----------------------------------------------------------------------------
QStringList
VideoManager
::
videoSourceList
()
{
_videoSourceList
.
clear
();
#if defined(QGC_GST_STREAMING)
_videoSourceList
.
append
(
kUDPStream
);
_videoSourceList
.
append
(
kRTSPStream
);
#endif
#ifndef QGC_DISABLE_UVC
QList
<
QCameraInfo
>
cameras
=
QCameraInfo
::
availableCameras
();
foreach
(
const
QCameraInfo
&
cameraInfo
,
cameras
)
{
qCDebug
(
VideoManagerLog
)
<<
"UVC Video source ID:"
<<
cameraInfo
.
deviceName
()
<<
" Name:"
<<
cameraInfo
.
description
();
_videoSourceList
.
append
(
cameraInfo
.
description
());
}
#endif
if
(
_videoSourceList
.
count
()
==
0
)
_videoSourceList
.
append
(
kNoVideo
);
return
_videoSourceList
;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void
VideoManager
::
_updateTimer
()
void
VideoManager
::
_updateTimer
()
{
{
...
@@ -292,13 +175,11 @@ void VideoManager::_updateVideo()
...
@@ -292,13 +175,11 @@ void VideoManager::_updateVideo()
_videoReceiver
=
new
VideoReceiver
(
this
);
_videoReceiver
=
new
VideoReceiver
(
this
);
#if defined(QGC_GST_STREAMING)
#if defined(QGC_GST_STREAMING)
_videoReceiver
->
setVideoSink
(
_videoSurface
->
videoSink
());
_videoReceiver
->
setVideoSink
(
_videoSurface
->
videoSink
());
if
(
_videoSource
==
kUDPStream
)
QString
videoSource
=
_videoSettings
->
videoSource
()
->
rawValue
().
toString
();
_videoReceiver
->
setUri
(
QStringLiteral
(
"udp://0.0.0.0:%1"
).
arg
(
_udpPort
));
if
(
_videoSettings
->
videoSource
()
->
rawValue
().
toString
()
==
VideoSettings
::
videoSourceUDP
)
_videoReceiver
->
setUri
(
QStringLiteral
(
"udp://0.0.0.0:%1"
).
arg
(
_videoSettings
->
udpPort
()
->
rawValue
().
toInt
()));
else
else
_videoReceiver
->
setUri
(
_rtspURL
);
_videoReceiver
->
setUri
(
_videoSettings
->
rtspUrl
()
->
rawValue
().
toString
());
#if defined(QGC_ENABLE_VIDEORECORDING)
_videoReceiver
->
setVideoSavePath
(
_videoSavePath
);
#endif
#endif
#endif
_videoReceiver
->
start
();
_videoReceiver
->
start
();
}
}
...
...
src/FlightDisplay/VideoManager.h
View file @
23f57eb9
...
@@ -22,6 +22,8 @@
...
@@ -22,6 +22,8 @@
Q_DECLARE_LOGGING_CATEGORY
(
VideoManagerLog
)
Q_DECLARE_LOGGING_CATEGORY
(
VideoManagerLog
)
class
VideoSettings
;
class
VideoManager
:
public
QGCTool
class
VideoManager
:
public
QGCTool
{
{
Q_OBJECT
Q_OBJECT
...
@@ -33,28 +35,16 @@ public:
...
@@ -33,28 +35,16 @@ public:
Q_PROPERTY
(
bool
hasVideo
READ
hasVideo
NOTIFY
hasVideoChanged
)
Q_PROPERTY
(
bool
hasVideo
READ
hasVideo
NOTIFY
hasVideoChanged
)
Q_PROPERTY
(
bool
isGStreamer
READ
isGStreamer
NOTIFY
isGStreamerChanged
)
Q_PROPERTY
(
bool
isGStreamer
READ
isGStreamer
NOTIFY
isGStreamerChanged
)
Q_PROPERTY
(
QString
videoSourceID
READ
videoSourceID
NOTIFY
videoSourceIDChanged
)
Q_PROPERTY
(
QString
videoSourceID
READ
videoSourceID
NOTIFY
videoSourceIDChanged
)
Q_PROPERTY
(
QString
videoSource
READ
videoSource
WRITE
setVideoSource
NOTIFY
videoSourceChanged
)
Q_PROPERTY
(
QStringList
videoSourceList
READ
videoSourceList
NOTIFY
videoSourceListChanged
)
Q_PROPERTY
(
bool
videoRunning
READ
videoRunning
NOTIFY
videoRunningChanged
)
Q_PROPERTY
(
bool
videoRunning
READ
videoRunning
NOTIFY
videoRunningChanged
)
Q_PROPERTY
(
quint16
udpPort
READ
udpPort
WRITE
setUdpPort
NOTIFY
udpPortChanged
)
Q_PROPERTY
(
QString
rtspURL
READ
rtspURL
WRITE
setRtspURL
NOTIFY
rtspURLChanged
)
Q_PROPERTY
(
QString
videoSavePath
READ
videoSavePath
NOTIFY
videoSavePathChanged
)
Q_PROPERTY
(
bool
uvcEnabled
READ
uvcEnabled
CONSTANT
)
Q_PROPERTY
(
bool
uvcEnabled
READ
uvcEnabled
CONSTANT
)
Q_PROPERTY
(
VideoSurface
*
videoSurface
MEMBER
_videoSurface
CONSTANT
)
Q_PROPERTY
(
VideoSurface
*
videoSurface
MEMBER
_videoSurface
CONSTANT
)
Q_PROPERTY
(
VideoReceiver
*
videoReceiver
MEMBER
_videoReceiver
CONSTANT
)
Q_PROPERTY
(
VideoReceiver
*
videoReceiver
MEMBER
_videoReceiver
CONSTANT
)
Q_PROPERTY
(
bool
recordingEnabled
READ
recordingEnabled
CONSTANT
)
Q_PROPERTY
(
bool
recordingEnabled
READ
recordingEnabled
CONSTANT
)
Q_INVOKABLE
void
setVideoSavePathByUrl
(
QUrl
url
);
bool
hasVideo
();
bool
hasVideo
();
bool
isGStreamer
();
bool
isGStreamer
();
bool
videoRunning
()
{
return
_videoRunning
;
}
bool
videoRunning
()
{
return
_videoRunning
;
}
QString
videoSourceID
()
{
return
_videoSourceID
;
}
QString
videoSourceID
()
{
return
_videoSourceID
;
}
QString
videoSource
()
{
return
_videoSource
;
}
QStringList
videoSourceList
();
quint16
udpPort
()
{
return
_udpPort
;
}
QString
rtspURL
()
{
return
_rtspURL
;
}
QString
videoSavePath
()
{
return
_videoSavePath
;
}
#if defined(QGC_DISABLE_UVC)
#if defined(QGC_DISABLE_UVC)
bool
uvcEnabled
()
{
return
false
;
}
bool
uvcEnabled
()
{
return
false
;
}
...
@@ -68,43 +58,29 @@ public:
...
@@ -68,43 +58,29 @@ public:
bool
recordingEnabled
()
{
return
false
;
}
bool
recordingEnabled
()
{
return
false
;
}
#endif
#endif
void
setVideoSource
(
QString
vSource
);
void
setUdpPort
(
quint16
port
);
void
setRtspURL
(
QString
url
);
void
setVideoSavePath
(
QString
path
);
// Override from QGCTool
// Override from QGCTool
void
setToolbox
(
QGCToolbox
*
toolbox
);
void
setToolbox
(
QGCToolbox
*
toolbox
);
signals:
signals:
void
hasVideoChanged
();
void
hasVideoChanged
();
void
videoRunningChanged
();
void
videoRunningChanged
();
void
videoSourceChanged
();
void
videoSourceListChanged
();
void
isGStreamerChanged
();
void
isGStreamerChanged
();
void
videoSourceIDChanged
();
void
videoSourceIDChanged
();
void
udpPortChanged
();
void
rtspURLChanged
();
void
videoSavePathChanged
();
private:
private:
void
_updateTimer
();
void
_updateTimer
();
void
_updateVideo
();
void
_updateVideo
();
private:
private:
VideoSurface
*
_videoSurface
;
VideoSurface
*
_videoSurface
;
VideoReceiver
*
_videoReceiver
;
VideoReceiver
*
_videoReceiver
;
bool
_videoRunning
;
bool
_videoRunning
;
#if defined(QGC_GST_STREAMING)
#if defined(QGC_GST_STREAMING)
QTimer
_frameTimer
;
QTimer
_frameTimer
;
#endif
#endif
QString
_videoSource
;
QString
_videoSourceID
;
QString
_videoSourceID
;
bool
_init
;
QStringList
_videoSourceList
;
VideoSettings
*
_videoSettings
;
quint16
_udpPort
;
QString
_rtspURL
;
QString
_videoSavePath
;
bool
_init
;
};
};
#endif
#endif
src/Settings/SettingsGroup.video.json
deleted
100644 → 0
View file @
026e6057
[
]
src/Settings/Video.SettingsGroup.json
0 → 100644
View file @
23f57eb9
[
{
"name"
:
"VideoSource"
,
"shortDescription"
:
"Video source"
,
"longDescription"
:
"Source for video. UDP, RTSP and UVC Cameras may be supported supported depending on Vehicle and QGroundControl version."
,
"type"
:
"string"
,
"defaultValue"
:
""
},
{
"name"
:
"VideoUDPPort"
,
"shortDescription"
:
"Video UDP Port"
,
"longDescription"
:
"UDP port to bind to for video stream."
,
"type"
:
"uint16"
,
"min"
:
1025
,
"defaultValue"
:
5600
},
{
"name"
:
"VideoRTSPUrl"
,
"shortDescription"
:
"Video RTSP Url"
,
"longDescription"
:
"RTSP url address and port to bind to for video stream. Example: rtsp://192.168.42.1:554/live"
,
"type"
:
"string"
,
"defaultValue"
:
""
},
{
"name"
:
"VideoSavePath"
,
"shortDescription"
:
"Video save directory"
,
"longDescription"
:
"Directory to save videos to."
,
"type"
:
"string"
,
"defaultValue"
:
""
}
]
src/Settings/VideoSettings.cc
View file @
23f57eb9
...
@@ -11,12 +11,93 @@
...
@@ -11,12 +11,93 @@
#include <QQmlEngine>
#include <QQmlEngine>
#include <QtQml>
#include <QtQml>
#include <QVariantList>
#include <QCameraInfo>
const
char
*
VideoSettings
::
videoSettingsGroupName
=
"video"
;
const
char
*
VideoSettings
::
videoSettingsGroupName
=
"Video"
;
const
char
*
VideoSettings
::
videoSourceName
=
"VideoSource"
;
const
char
*
VideoSettings
::
udpPortName
=
"VideoUDPPort"
;
const
char
*
VideoSettings
::
rtspUrlName
=
"VideoRTSPUrl"
;
const
char
*
VideoSettings
::
videoSavePathName
=
"VideoSavePath"
;
const
char
*
VideoSettings
::
videoSourceNoVideo
=
"No Video Available"
;
const
char
*
VideoSettings
::
videoSourceUDP
=
"UDP Video Stream"
;
const
char
*
VideoSettings
::
videoSourceRTSP
=
"RTSP Video Stream"
;
VideoSettings
::
VideoSettings
(
QObject
*
parent
)
VideoSettings
::
VideoSettings
(
QObject
*
parent
)
:
SettingsGroup
(
videoSettingsGroupName
,
QString
()
/* root settings group */
,
parent
)
:
SettingsGroup
(
videoSettingsGroupName
,
QString
()
/* root settings group */
,
parent
)
,
_videoSourceFact
(
NULL
)
,
_udpPortFact
(
NULL
)
,
_rtspUrlFact
(
NULL
)
,
_videoSavePathFact
(
NULL
)
{
{
QQmlEngine
::
setObjectOwnership
(
this
,
QQmlEngine
::
CppOwnership
);
QQmlEngine
::
setObjectOwnership
(
this
,
QQmlEngine
::
CppOwnership
);
qmlRegisterUncreatableType
<
VideoSettings
>
(
"QGroundControl.SettingsManager"
,
1
,
0
,
"VideoSettings"
,
"Reference only"
);
qmlRegisterUncreatableType
<
VideoSettings
>
(
"QGroundControl.SettingsManager"
,
1
,
0
,
"VideoSettings"
,
"Reference only"
);
// Setup enum values for videoSource settings into meta data
QStringList
videoSourceList
;
#ifdef QGC_GST_STREAMING
#ifndef NO_UDP_VIDEO
videoSourceList
.
append
(
videoSourceUDP
);
#endif
videoSourceList
.
append
(
videoSourceRTSP
);
#endif
#ifndef QGC_DISABLE_UVC
QList
<
QCameraInfo
>
cameras
=
QCameraInfo
::
availableCameras
();
foreach
(
const
QCameraInfo
&
cameraInfo
,
cameras
)
{
videoSourceList
.
append
(
cameraInfo
.
description
());
}
#endif
if
(
videoSourceList
.
count
()
==
0
)
{
videoSourceList
.
append
(
videoSourceNoVideo
);
}
QVariantList
videoSourceVarList
;
foreach
(
const
QString
&
videoSource
,
videoSourceList
)
{
videoSourceVarList
.
append
(
QVariant
::
fromValue
(
videoSource
));
}
_nameToMetaDataMap
[
videoSourceName
]
->
setEnumInfo
(
videoSourceList
,
videoSourceVarList
);
// Set default value for videoSource
#if defined(NO_UDP_VIDEO)
_nameToMetaDataMap
[
videoSourceName
]
->
setRawDefaultValue
(
videoSourceRTSP
);
#else
_nameToMetaDataMap
[
videoSourceName
]
->
setRawDefaultValue
(
videoSourceUDP
);
#endif
}
Fact
*
VideoSettings
::
videoSource
(
void
)
{
if
(
!
_videoSourceFact
)
{
_videoSourceFact
=
_createSettingsFact
(
videoSourceName
);
}
return
_videoSourceFact
;
}
Fact
*
VideoSettings
::
udpPort
(
void
)
{
if
(
!
_udpPortFact
)
{
_udpPortFact
=
_createSettingsFact
(
udpPortName
);
}
return
_udpPortFact
;
}
Fact
*
VideoSettings
::
rtspUrl
(
void
)
{
if
(
!
_rtspUrlFact
)
{
_rtspUrlFact
=
_createSettingsFact
(
rtspUrlName
);
}
return
_rtspUrlFact
;
}
Fact
*
VideoSettings
::
videoSavePath
(
void
)
{
if
(
!
_videoSavePathFact
)
{
_videoSavePathFact
=
_createSettingsFact
(
videoSavePathName
);
}
return
_videoSavePathFact
;
}
}
src/Settings/VideoSettings.h
View file @
23f57eb9
...
@@ -19,9 +19,32 @@ class VideoSettings : public SettingsGroup
...
@@ -19,9 +19,32 @@ class VideoSettings : public SettingsGroup
public:
public:
VideoSettings
(
QObject
*
parent
=
NULL
);
VideoSettings
(
QObject
*
parent
=
NULL
);
Q_PROPERTY
(
Fact
*
videoSource
READ
videoSource
CONSTANT
)
Q_PROPERTY
(
Fact
*
udpPort
READ
udpPort
CONSTANT
)
Q_PROPERTY
(
Fact
*
rtspUrl
READ
rtspUrl
CONSTANT
)
Q_PROPERTY
(
Fact
*
videoSavePath
READ
videoSavePath
CONSTANT
)
Fact
*
videoSource
(
void
);
Fact
*
udpPort
(
void
);
Fact
*
rtspUrl
(
void
);
Fact
*
videoSavePath
(
void
);
static
const
char
*
videoSettingsGroupName
;
static
const
char
*
videoSettingsGroupName
;
static
const
char
*
videoSourceName
;
static
const
char
*
udpPortName
;
static
const
char
*
rtspUrlName
;
static
const
char
*
videoSavePathName
;
static
const
char
*
videoSourceNoVideo
;
static
const
char
*
videoSourceUDP
;
static
const
char
*
videoSourceRTSP
;
private:
private:
SettingsFact
*
_videoSourceFact
;
SettingsFact
*
_udpPortFact
;
SettingsFact
*
_rtspUrlFact
;
SettingsFact
*
_videoSavePathFact
;
};
};
#endif
#endif
src/VideoStreaming/VideoReceiver.cc
View file @
23f57eb9
...
@@ -15,6 +15,9 @@
...
@@ -15,6 +15,9 @@
*/
*/
#include "VideoReceiver.h"
#include "VideoReceiver.h"
#include "SettingsManager.h"
#include "QGCApplication.h"
#include <QDebug>
#include <QDebug>
#include <QUrl>
#include <QUrl>
#include <QDir>
#include <QDir>
...
@@ -348,16 +351,6 @@ void VideoReceiver::setUri(const QString & uri)
...
@@ -348,16 +351,6 @@ void VideoReceiver::setUri(const QString & uri)
_uri
=
uri
;
_uri
=
uri
;
}
}
void
VideoReceiver
::
setVideoSavePath
(
const
QString
&
path
)
{
#if defined(QGC_ENABLE_VIDEORECORDING)
_path
=
path
;
qCDebug
(
VideoReceiverLog
)
<<
"New Path:"
<<
_path
;
#else
Q_UNUSED
(
path
);
#endif
}
#if defined(QGC_GST_STREAMING)
#if defined(QGC_GST_STREAMING)
void
VideoReceiver
::
_shutdownPipeline
()
{
void
VideoReceiver
::
_shutdownPipeline
()
{
if
(
!
_pipeline
)
{
if
(
!
_pipeline
)
{
...
@@ -467,8 +460,9 @@ void VideoReceiver::startRecording(void)
...
@@ -467,8 +460,9 @@ void VideoReceiver::startRecording(void)
return
;
return
;
}
}
if
(
_path
.
isEmpty
())
{
QString
savePath
=
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
videoSettings
()
->
videoSavePath
()
->
rawValue
().
toString
();
qWarning
()
<<
"VideoReceiver::startRecording Empty Path!"
;
if
(
savePath
.
isEmpty
())
{
qgcApp
()
->
showMessage
(
"Unabled to record video. Video save path must be specified in Settings."
);
return
;
return
;
}
}
...
@@ -485,7 +479,7 @@ void VideoReceiver::startRecording(void)
...
@@ -485,7 +479,7 @@ void VideoReceiver::startRecording(void)
}
}
QString
videoFile
;
QString
videoFile
;
videoFile
=
_p
ath
+
"/QGC-"
+
QDateTime
::
currentDateTime
().
toString
(
"yyyy-MM-dd_hh.mm.ss"
)
+
".mkv"
;
videoFile
=
saveP
ath
+
"/QGC-"
+
QDateTime
::
currentDateTime
().
toString
(
"yyyy-MM-dd_hh.mm.ss"
)
+
".mkv"
;
g_object_set
(
G_OBJECT
(
_sink
->
filesink
),
"location"
,
qPrintable
(
videoFile
),
NULL
);
g_object_set
(
G_OBJECT
(
_sink
->
filesink
),
"location"
,
qPrintable
(
videoFile
),
NULL
);
qCDebug
(
VideoReceiverLog
)
<<
"New video file:"
<<
videoFile
;
qCDebug
(
VideoReceiverLog
)
<<
"New video file:"
<<
videoFile
;
...
...
src/VideoStreaming/VideoReceiver.h
View file @
23f57eb9
...
@@ -62,7 +62,6 @@ public slots:
...
@@ -62,7 +62,6 @@ public slots:
void
start
();
void
start
();
void
stop
();
void
stop
();
void
setUri
(
const
QString
&
uri
);
void
setUri
(
const
QString
&
uri
);
void
setVideoSavePath
(
const
QString
&
path
);
void
stopRecording
();
void
stopRecording
();
void
startRecording
();
void
startRecording
();
...
@@ -105,7 +104,6 @@ private:
...
@@ -105,7 +104,6 @@ private:
#endif
#endif
QString
_uri
;
QString
_uri
;
QString
_path
;
#if defined(QGC_GST_STREAMING)
#if defined(QGC_GST_STREAMING)
GstElement
*
_pipeline
;
GstElement
*
_pipeline
;
...
...
src/ui/preferences/GeneralSettings.qml
View file @
23f57eb9
...
@@ -453,84 +453,68 @@ QGCView {
...
@@ -453,84 +453,68 @@ QGCView {
anchors.margins
:
ScreenTools
.
defaultFontPixelWidth
anchors.margins
:
ScreenTools
.
defaultFontPixelWidth
anchors.horizontalCenter
:
parent
.
horizontalCenter
anchors.horizontalCenter
:
parent
.
horizontalCenter
visible
:
QGroundControl
.
settingsManager
.
videoSettings
.
visible
visible
:
QGroundControl
.
settingsManager
.
videoSettings
.
visible
Column
{
Column
{
id
:
videoCol
id
:
videoCol
spacing
:
ScreenTools
.
defaultFontPixelWidth
spacing
:
ScreenTools
.
defaultFontPixelWidth
anchors.centerIn
:
parent
anchors.centerIn
:
parent
Row
{
Row
{
spacing
:
ScreenTools
.
defaultFontPixelWidth
spacing
:
ScreenTools
.
defaultFontPixelWidth
visible
:
QGroundControl
.
settingsManager
.
videoSettings
.
videoSource
.
visible
QGCLabel
{
QGCLabel
{
anchors.baseline
:
videoSource
.
baseline
anchors.baseline
:
videoSource
.
baseline
text
:
qsTr
(
"
Video Source:
"
)
text
:
qsTr
(
"
Video Source:
"
)
width
:
_labelWidth
width
:
_labelWidth
}
}
QGCComboBox
{
FactComboBox
{
id
:
videoSource
id
:
videoSource
width
:
_editFieldWidth
width
:
_editFieldWidth
model
:
QGroundControl
.
videoManager
.
videoSourceList
indexModel
:
false
Component.onCompleted
:
{
fact
:
QGroundControl
.
settingsManager
.
videoSettings
.
videoSource
var
index
=
videoSource
.
find
(
QGroundControl
.
videoManager
.
videoSource
)
if
(
index
>=
0
)
{
videoSource
.
currentIndex
=
index
}
}
onActivated
:
{
if
(
index
!=
-
1
)
{
currentIndex
=
index
QGroundControl
.
videoManager
.
videoSource
=
model
[
index
]
}
}
}
}
}
}
Row
{
Row
{
spacing
:
ScreenTools
.
defaultFontPixelWidth
spacing
:
ScreenTools
.
defaultFontPixelWidth
visible
:
QGroundControl
.
videoManager
.
isGStreamer
&&
videoSource
.
currentIndex
===
0
visible
:
QGroundControl
.
settingsManager
.
videoSettings
.
udpPort
.
visible
&&
QGroundControl
.
videoManager
.
isGStreamer
&&
videoSource
.
currentIndex
===
0
QGCLabel
{
QGCLabel
{
anchors.baseline
:
udpField
.
baseline
anchors.baseline
:
udpField
.
baseline
text
:
qsTr
(
"
UDP Port:
"
)
text
:
qsTr
(
"
UDP Port:
"
)
width
:
_labelWidth
width
:
_labelWidth
}
}
QGC
TextField
{
Fact
TextField
{
id
:
udpField
id
:
udpField
width
:
_editFieldWidth
width
:
_editFieldWidth
text
:
QGroundControl
.
videoManager
.
udpPort
fact
:
QGroundControl
.
settingsManager
.
videoSettings
.
udpPort
validator
:
IntValidator
{
bottom
:
1024
;
top
:
65535
;}
inputMethodHints
:
Qt
.
ImhDigitsOnly
onEditingFinished
:
{
QGroundControl
.
videoManager
.
udpPort
=
parseInt
(
text
)
}
}
}
}
}
Row
{
Row
{
spacing
:
ScreenTools
.
defaultFontPixelWidth
spacing
:
ScreenTools
.
defaultFontPixelWidth
visible
:
QGroundControl
.
videoManager
.
isGStreamer
&&
videoSource
.
currentIndex
===
1
visible
:
QGroundControl
.
settingsManager
.
videoSettings
.
rtspUrl
.
visible
&&
QGroundControl
.
videoManager
.
isGStreamer
&&
videoSource
.
currentIndex
===
1
QGCLabel
{
QGCLabel
{
anchors.baseline
:
rtspField
.
baseline
anchors.baseline
:
rtspField
.
baseline
text
:
qsTr
(
"
RTSP URL:
"
)
text
:
qsTr
(
"
RTSP URL:
"
)
width
:
_labelWidth
width
:
_labelWidth
}
}
QGC
TextField
{
Fact
TextField
{
id
:
rtspField
id
:
rtspField
width
:
_editFieldWidth
width
:
_editFieldWidth
text
:
QGroundControl
.
videoManager
.
rtspURL
fact
:
QGroundControl
.
settingsManager
.
videoSettings
.
rtspUrl
onEditingFinished
:
{
QGroundControl
.
videoManager
.
rtspURL
=
text
}
}
}
}
}
Row
{
Row
{
spacing
:
ScreenTools
.
defaultFontPixelWidth
spacing
:
ScreenTools
.
defaultFontPixelWidth
visible
:
QGroundControl
.
videoManager
.
isGStreamer
&&
QGroundControl
.
videoManager
.
recordingEnabled
visible
:
QGroundControl
.
settingsManager
.
videoSettings
.
videoSavePath
.
visible
&&
QGroundControl
.
videoManager
.
isGStreamer
&&
QGroundControl
.
videoManager
.
recordingEnabled
QGCLabel
{
QGCLabel
{
anchors.baseline
:
pathField
.
baseline
anchors.baseline
:
pathField
.
baseline
text
:
qsTr
(
"
Save Path:
"
)
text
:
qsTr
(
"
Save Path:
"
)
width
:
_labelWidth
width
:
_labelWidth
}
}
QGC
TextField
{
Fact
TextField
{
id
:
pathField
id
:
pathField
width
:
_editFieldWidth
width
:
_editFieldWidth
readOnly
:
true
fact
:
QGroundControl
.
settingsManager
.
videoSettings
.
videoSavePath
text
:
QGroundControl
.
videoManager
.
videoSavePath
}
}
QGCButton
{
QGCButton
{
text
:
"
Browse
"
text
:
"
Browse
"
...
@@ -541,13 +525,12 @@ QGCView {
...
@@ -541,13 +525,12 @@ QGCView {
title
:
"
Choose a location to save video files.
"
title
:
"
Choose a location to save video files.
"
folder
:
shortcuts
.
home
folder
:
shortcuts
.
home
selectFolder
:
true
selectFolder
:
true
onAccepted
:
QGroundControl
.
videoManager
.
setVideoSavePathByUrl
(
f
ileDialog
.
fileUrl
)
onAccepted
:
QGroundControl
.
settingsManager
.
videoSettings
.
videoSavePath
.
value
=
QGroundControl
.
urlToLocalFile
(
videoLocationF
ileDialog
.
fileUrl
)
}
}
}
}
}
}
}
}
}
}
// Video Source - Rectangle
QGCLabel
{
QGCLabel
{
anchors.horizontalCenter
:
parent
.
horizontalCenter
anchors.horizontalCenter
:
parent
.
horizontalCenter
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment