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 <qmediaplaylist.h>
|
||||
#include <private/qmediaresourceset_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@@ -81,6 +82,7 @@ QGstreamerPlayerService::QGstreamerPlayerService(QObject *parent):
|
||||
, m_videoWindow(0)
|
||||
, m_videoWidget(0)
|
||||
#endif
|
||||
, m_videoReferenceCount(0)
|
||||
{
|
||||
m_session = new QGstreamerPlayerSession(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 (m_session) {
|
||||
QGstreamerVideoProbeControl *probe = new QGstreamerVideoProbeControl(this);
|
||||
increaseVideoRef();
|
||||
m_session->addProbe(probe);
|
||||
return probe;
|
||||
}
|
||||
@@ -151,6 +154,7 @@ QMediaControl *QGstreamerPlayerService::requestControl(const char *name)
|
||||
#endif
|
||||
|
||||
if (m_videoOutput) {
|
||||
increaseVideoRef();
|
||||
m_control->setVideoOutput(m_videoOutput);
|
||||
return m_videoOutput;
|
||||
}
|
||||
@@ -164,12 +168,15 @@ void QGstreamerPlayerService::releaseControl(QMediaControl *control)
|
||||
if (control == m_videoOutput) {
|
||||
m_videoOutput = 0;
|
||||
m_control->setVideoOutput(0);
|
||||
decreaseVideoRef();
|
||||
}
|
||||
|
||||
QGstreamerVideoProbeControl* videoProbe = qobject_cast<QGstreamerVideoProbeControl*>(control);
|
||||
if (videoProbe) {
|
||||
if (m_session)
|
||||
if (m_session) {
|
||||
m_session->removeProbe(videoProbe);
|
||||
decreaseVideoRef();
|
||||
}
|
||||
delete videoProbe;
|
||||
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
|
||||
|
||||
@@ -86,6 +86,10 @@ private:
|
||||
QMediaControl *m_videoWindow;
|
||||
QMediaControl *m_videoWidget;
|
||||
#endif
|
||||
|
||||
void increaseVideoRef();
|
||||
void decreaseVideoRef();
|
||||
int m_videoReferenceCount;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
Reference in New Issue
Block a user