Make gstreamer player backend reserve/release video resource.
Use request/release of various video related controls as an indication for the decision. Change-Id: I3a2a288c7c46ca62459896745bbdda26961bb181 Reviewed-by: Michael Goddard <michael.goddard@nokia.com> Reviewed-by: Jonas Rabbe <jonas.rabbe@nokia.com>
This commit is contained in:
@@ -70,6 +70,7 @@
|
|||||||
|
|
||||||
#include <private/qmediaplaylistnavigator_p.h>
|
#include <private/qmediaplaylistnavigator_p.h>
|
||||||
#include <qmediaplaylist.h>
|
#include <qmediaplaylist.h>
|
||||||
|
#include <private/qmediaresourceset_p.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
@@ -81,6 +82,7 @@ QGstreamerPlayerService::QGstreamerPlayerService(QObject *parent):
|
|||||||
, m_videoWindow(0)
|
, m_videoWindow(0)
|
||||||
, m_videoWidget(0)
|
, m_videoWidget(0)
|
||||||
#endif
|
#endif
|
||||||
|
, m_videoReferenceCount(0)
|
||||||
{
|
{
|
||||||
m_session = new QGstreamerPlayerSession(this);
|
m_session = new QGstreamerPlayerSession(this);
|
||||||
m_control = new QGstreamerPlayerControl(m_session, this);
|
m_control = new QGstreamerPlayerControl(m_session, this);
|
||||||
@@ -125,6 +127,7 @@ QMediaControl *QGstreamerPlayerService::requestControl(const char *name)
|
|||||||
if (qstrcmp(name,QMediaVideoProbeControl_iid) == 0) {
|
if (qstrcmp(name,QMediaVideoProbeControl_iid) == 0) {
|
||||||
if (m_session) {
|
if (m_session) {
|
||||||
QGstreamerVideoProbeControl *probe = new QGstreamerVideoProbeControl(this);
|
QGstreamerVideoProbeControl *probe = new QGstreamerVideoProbeControl(this);
|
||||||
|
increaseVideoRef();
|
||||||
m_session->addProbe(probe);
|
m_session->addProbe(probe);
|
||||||
return probe;
|
return probe;
|
||||||
}
|
}
|
||||||
@@ -151,6 +154,7 @@ QMediaControl *QGstreamerPlayerService::requestControl(const char *name)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (m_videoOutput) {
|
if (m_videoOutput) {
|
||||||
|
increaseVideoRef();
|
||||||
m_control->setVideoOutput(m_videoOutput);
|
m_control->setVideoOutput(m_videoOutput);
|
||||||
return m_videoOutput;
|
return m_videoOutput;
|
||||||
}
|
}
|
||||||
@@ -164,12 +168,15 @@ void QGstreamerPlayerService::releaseControl(QMediaControl *control)
|
|||||||
if (control == m_videoOutput) {
|
if (control == m_videoOutput) {
|
||||||
m_videoOutput = 0;
|
m_videoOutput = 0;
|
||||||
m_control->setVideoOutput(0);
|
m_control->setVideoOutput(0);
|
||||||
|
decreaseVideoRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
QGstreamerVideoProbeControl* videoProbe = qobject_cast<QGstreamerVideoProbeControl*>(control);
|
QGstreamerVideoProbeControl* videoProbe = qobject_cast<QGstreamerVideoProbeControl*>(control);
|
||||||
if (videoProbe) {
|
if (videoProbe) {
|
||||||
if (m_session)
|
if (m_session) {
|
||||||
m_session->removeProbe(videoProbe);
|
m_session->removeProbe(videoProbe);
|
||||||
|
decreaseVideoRef();
|
||||||
|
}
|
||||||
delete videoProbe;
|
delete videoProbe;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -183,4 +190,20 @@ void QGstreamerPlayerService::releaseControl(QMediaControl *control)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QGstreamerPlayerService::increaseVideoRef()
|
||||||
|
{
|
||||||
|
m_videoReferenceCount++;
|
||||||
|
if (m_videoReferenceCount == 1) {
|
||||||
|
m_control->resources()->setVideoEnabled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QGstreamerPlayerService::decreaseVideoRef()
|
||||||
|
{
|
||||||
|
m_videoReferenceCount--;
|
||||||
|
if (m_videoReferenceCount == 0) {
|
||||||
|
m_control->resources()->setVideoEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|||||||
@@ -86,6 +86,10 @@ private:
|
|||||||
QMediaControl *m_videoWindow;
|
QMediaControl *m_videoWindow;
|
||||||
QMediaControl *m_videoWidget;
|
QMediaControl *m_videoWidget;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void increaseVideoRef();
|
||||||
|
void decreaseVideoRef();
|
||||||
|
int m_videoReferenceCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|||||||
Reference in New Issue
Block a user