45 |
45 |
46 #include "qt7backend.h" |
46 #include "qt7backend.h" |
47 #include "qt7playerservice.h" |
47 #include "qt7playerservice.h" |
48 #include "qt7playercontrol.h" |
48 #include "qt7playercontrol.h" |
49 #include "qt7playersession.h" |
49 #include "qt7playersession.h" |
50 #include "qt7videooutputcontrol.h" |
50 #include "qt7videooutput.h" |
51 #include "qt7movieviewoutput.h" |
51 #include "qt7movieviewoutput.h" |
52 #include "qt7movieviewrenderer.h" |
52 #include "qt7movieviewrenderer.h" |
53 #include "qt7movierenderer.h" |
53 #include "qt7movierenderer.h" |
54 #include "qt7movievideowidget.h" |
54 #include "qt7movievideowidget.h" |
55 #include "qt7playermetadata.h" |
55 #include "qt7playermetadata.h" |
58 #include <qmediaplaylist.h> |
58 #include <qmediaplaylist.h> |
59 |
59 |
60 QT_USE_NAMESPACE |
60 QT_USE_NAMESPACE |
61 |
61 |
62 QT7PlayerService::QT7PlayerService(QObject *parent): |
62 QT7PlayerService::QT7PlayerService(QObject *parent): |
63 QMediaService(parent) |
63 QMediaService(parent), |
|
64 m_videoOutput(0) |
64 { |
65 { |
65 m_session = new QT7PlayerSession; |
66 m_session = new QT7PlayerSession(this); |
66 |
67 |
67 m_control = new QT7PlayerControl(this); |
68 m_control = new QT7PlayerControl(this); |
68 m_control->setSession(m_session); |
69 m_control->setSession(m_session); |
69 |
70 |
70 m_playerMetaDataControl = new QT7PlayerMetaDataControl(m_session, this); |
71 m_playerMetaDataControl = new QT7PlayerMetaDataControl(m_session, this); |
71 connect(m_control, SIGNAL(mediaChanged(QMediaContent)), m_playerMetaDataControl, SLOT(updateTags())); |
72 connect(m_control, SIGNAL(mediaChanged(QMediaContent)), m_playerMetaDataControl, SLOT(updateTags())); |
72 |
|
73 m_videoOutputControl = new QT7VideoOutputControl(this); |
|
74 |
|
75 m_videoWidnowControl = 0; |
|
76 m_videoWidgetControl = 0; |
|
77 m_videoRendererControl = 0; |
|
78 |
|
79 #if defined(QT_MAC_USE_COCOA) |
|
80 m_videoWidnowControl = new QT7MovieViewOutput(this); |
|
81 m_videoOutputControl->enableOutput(QVideoOutputControl::WindowOutput); |
|
82 qDebug() << "Using cocoa"; |
|
83 #endif |
|
84 |
|
85 #ifdef QUICKTIME_C_API_AVAILABLE |
|
86 m_videoRendererControl = new QT7MovieRenderer(this); |
|
87 m_videoOutputControl->enableOutput(QVideoOutputControl::RendererOutput); |
|
88 |
|
89 m_videoWidgetControl = new QT7MovieVideoWidget(this); |
|
90 m_videoOutputControl->enableOutput(QVideoOutputControl::WidgetOutput); |
|
91 qDebug() << "QuickTime C API is available"; |
|
92 #else |
|
93 m_videoRendererControl = new QT7MovieViewRenderer(this); |
|
94 m_videoOutputControl->enableOutput(QVideoOutputControl::RendererOutput); |
|
95 qDebug() << "QuickTime C API is not available"; |
|
96 #endif |
|
97 |
|
98 |
|
99 connect(m_videoOutputControl, SIGNAL(videoOutputChanged(QVideoOutputControl::Output)), |
|
100 this, SLOT(updateVideoOutput())); |
|
101 } |
73 } |
102 |
74 |
103 QT7PlayerService::~QT7PlayerService() |
75 QT7PlayerService::~QT7PlayerService() |
104 { |
76 { |
105 } |
77 } |
106 |
78 |
107 QMediaControl *QT7PlayerService::control(const char *name) const |
79 QMediaControl *QT7PlayerService::requestControl(const char *name) |
108 { |
80 { |
109 if (qstrcmp(name, QMediaPlayerControl_iid) == 0) |
81 if (qstrcmp(name, QMediaPlayerControl_iid) == 0) |
110 return m_control; |
82 return m_control; |
111 |
83 |
112 if (qstrcmp(name, QVideoOutputControl_iid) == 0) |
84 if (qstrcmp(name, QMetaDataReaderControl_iid) == 0) |
113 return m_videoOutputControl; |
85 return m_playerMetaDataControl; |
114 |
86 |
115 if (qstrcmp(name, QVideoWindowControl_iid) == 0) |
87 if (!m_videoOutput) { |
116 return m_videoWidnowControl; |
88 if (qstrcmp(name, QVideoWindowControl_iid) == 0) { |
|
89 #if defined(QT_MAC_USE_COCOA) |
|
90 m_videoOutput = new QT7MovieViewOutput(this); |
|
91 #endif |
|
92 } |
117 |
93 |
118 if (qstrcmp(name, QVideoRendererControl_iid) == 0) |
94 if (qstrcmp(name, QVideoRendererControl_iid) == 0) { |
119 return m_videoRendererControl; |
95 #ifdef QUICKTIME_C_API_AVAILABLE |
|
96 m_videoOutput = new QT7MovieRenderer(this); |
|
97 #else |
|
98 m_videoOutput = new QT7MovieViewRenderer(this); |
|
99 #endif |
|
100 } |
120 |
101 |
121 if (qstrcmp(name, QVideoWidgetControl_iid) == 0) |
102 if (qstrcmp(name, QVideoWidgetControl_iid) == 0) { |
122 return m_videoWidgetControl; |
103 #ifdef QUICKTIME_C_API_AVAILABLE |
|
104 m_videoOutput = new QT7MovieVideoWidget(this); |
|
105 #endif |
|
106 } |
123 |
107 |
124 if (qstrcmp(name, QMetaDataControl_iid) == 0) |
108 if (m_videoOutput) { |
125 return m_playerMetaDataControl; |
109 QT7VideoOutput *videoOutput = qobject_cast<QT7VideoOutput*>(m_videoOutput); |
|
110 m_session->setVideoOutput(videoOutput); |
|
111 return m_videoOutput; |
|
112 } |
|
113 } |
126 |
114 |
127 return 0; |
115 return 0; |
128 } |
116 } |
129 |
117 |
130 void QT7PlayerService::updateVideoOutput() |
118 void QT7PlayerService::releaseControl(QMediaControl *control) |
131 { |
119 { |
132 qDebug() << "QT7PlayerService::updateVideoOutput" << m_videoOutputControl->output(); |
120 if (m_videoOutput == control) { |
133 |
121 m_videoOutput = 0; |
134 switch (m_videoOutputControl->output()) { |
|
135 case QVideoOutputControl::WindowOutput: |
|
136 m_session->setVideoOutput(m_videoWidnowControl); |
|
137 break; |
|
138 case QVideoOutputControl::RendererOutput: |
|
139 m_session->setVideoOutput(m_videoRendererControl); |
|
140 break; |
|
141 case QVideoOutputControl::WidgetOutput: |
|
142 m_session->setVideoOutput(m_videoWidgetControl); |
|
143 break; |
|
144 default: |
|
145 m_session->setVideoOutput(0); |
122 m_session->setVideoOutput(0); |
|
123 delete control; |
146 } |
124 } |
147 } |
125 } |
148 |
126 |
149 #include "moc_qt7playerservice.cpp" |
127 #include "moc_qt7playerservice.cpp" |