Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Val Doroshchuk
qtgstreamerextras
Commits
02361a35
Commit
02361a35
authored
Dec 17, 2018
by
Val Doroshchuk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tmp example
parent
95d7b0e2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
16 deletions
+26
-16
examples/streamer/streamer.cpp
examples/streamer/streamer.cpp
+22
-16
examples/streamer/streamer.h
examples/streamer/streamer.h
+4
-0
No files found.
examples/streamer/streamer.cpp
View file @
02361a35
...
...
@@ -51,6 +51,25 @@
#include "streamer.h"
#include <QQuickItemGrabResult>
void
AppSrc
::
imageReady
()
{
m_frame
=
m_grabResult
->
image
();
m_grabResult
.
reset
();
}
QVideoFrame
AppSrc
::
readFrame
()
const
{
if
(
!
m_frame
.
isValid
()
&&
m_streamer
->
item
())
{
m_grabResult
=
qobject_cast
<
QQuickItem
*>
(
m_streamer
->
item
())
->
grabToImage
();
connect
(
m_grabResult
.
data
(),
&
QQuickItemGrabResult
::
ready
,
this
,
&
AppSrc
::
imageReady
);
}
auto
frame
=
m_frame
;
m_frame
=
QVideoFrame
();
return
frame
;
}
Streamer
::
Streamer
(
QObject
*
parent
)
:
QGstreamerPipeline
(
parent
)
{
...
...
@@ -65,10 +84,11 @@ QObject *Streamer::item() const
void
Streamer
::
setItem
(
QObject
*
src
)
{
if
(
src
==
m_item
)
auto
item
=
qobject_cast
<
QQuickItem
*>
(
src
);
if
(
m_item
==
item
)
return
;
m_item
=
qobject_cast
<
QQuickItem
*>
(
src
)
;
m_item
=
item
;
emit
itemChanged
();
}
...
...
@@ -85,17 +105,3 @@ void Streamer::onPipelineChanged()
m_appsrc
.
reset
(
new
AppSrc
(
this
,
appsrc
));
}
QVideoFrame
AppSrc
::
readFrame
()
const
{
if
(
!
m_frame
.
isValid
()
&&
m_streamer
->
item
())
{
auto
result
=
qobject_cast
<
QQuickItem
*>
(
m_streamer
->
item
())
->
grabToImage
();
connect
(
result
.
data
(),
&
QQuickItemGrabResult
::
ready
,
result
.
data
(),
[
this
,
result
](){
m_frame
=
result
->
image
();
});
}
auto
frame
=
m_frame
;
m_frame
=
QVideoFrame
();
return
frame
;
}
examples/streamer/streamer.h
View file @
02361a35
...
...
@@ -72,8 +72,12 @@ public:
protected:
QVideoFrame
readFrame
()
const
override
;
private
Q_SLOTS
:
void
imageReady
();
private:
Streamer
*
m_streamer
=
nullptr
;
mutable
QSharedPointer
<
QQuickItemGrabResult
>
m_grabResult
;
mutable
QVideoFrame
m_frame
;
};
...
...
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