46 { |
41 { |
47 return true; |
42 return true; |
48 } |
43 } |
49 |
44 |
50 |
45 |
51 #ifdef Q_OS_WINCE |
|
52 VideoRendererVMR9::VideoRendererVMR9(QWidget *target) : m_target(target) |
|
53 { |
|
54 m_target->setAttribute(Qt::WA_PaintOnScreen, true); |
|
55 m_filter = Filter(CLSID_VideoRenderer, IID_IBaseFilter); |
|
56 } |
|
57 |
|
58 QSize VideoRendererVMR9::videoSize() const |
|
59 { |
|
60 LONG w = 0, |
|
61 h = 0; |
|
62 ComPointer<IBasicVideo> basic(m_filter, IID_IBasicVideo); |
|
63 if (basic) { |
|
64 basic->GetVideoSize( &w, &h); |
|
65 } |
|
66 return QSize(w, h); |
|
67 } |
|
68 |
|
69 void VideoRendererVMR9::repaintCurrentFrame(QWidget * /*target*/, const QRect & /*rect*/) |
|
70 { |
|
71 //nothing to do here: the renderer paints everything |
|
72 } |
|
73 |
|
74 void VideoRendererVMR9::notifyResize(const QSize &size, Phonon::VideoWidget::AspectRatio aspectRatio, |
|
75 Phonon::VideoWidget::ScaleMode scaleMode) |
|
76 { |
|
77 if (!isActive()) { |
|
78 ComPointer<IBasicVideo> basic(m_filter, IID_IBasicVideo); |
|
79 if (basic) { |
|
80 basic->SetDestinationPosition(0, 0, 0, 0); |
|
81 } |
|
82 return; |
|
83 } |
|
84 |
|
85 ComPointer<IVideoWindow> video(m_filter, IID_IVideoWindow); |
|
86 |
|
87 OAHWND owner; |
|
88 HRESULT hr = video->get_Owner(&owner); |
|
89 if (FAILED(hr)) { |
|
90 return; |
|
91 } |
|
92 |
|
93 const OAHWND newOwner = reinterpret_cast<OAHWND>(m_target->winId()); |
|
94 if (owner != newOwner) { |
|
95 video->put_Owner(newOwner); |
|
96 video->put_MessageDrain(newOwner); |
|
97 video->put_WindowStyle(WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); |
|
98 } |
|
99 |
|
100 //make sure the widget takes the whole size of the parent |
|
101 video->SetWindowPosition(0, 0, size.width(), size.height()); |
|
102 |
|
103 const QSize vsize = videoSize(); |
|
104 internalNotifyResize(size, vsize, aspectRatio, scaleMode); |
|
105 |
|
106 ComPointer<IBasicVideo> basic(m_filter, IID_IBasicVideo); |
|
107 if (basic) { |
|
108 basic->SetDestinationPosition(m_dstX, m_dstY, m_dstWidth, m_dstHeight); |
|
109 } |
|
110 } |
|
111 |
|
112 void VideoRendererVMR9::applyMixerSettings(qreal /*brightness*/, qreal /*contrast*/, qreal /*m_hue*/, qreal /*saturation*/) |
|
113 { |
|
114 //this can't be supported for WinCE |
|
115 } |
|
116 |
|
117 QImage VideoRendererVMR9::snapshot() const |
|
118 { |
|
119 ComPointer<IBasicVideo> basic(m_filter, IID_IBasicVideo); |
|
120 if (basic) { |
|
121 LONG bufferSize = 0; |
|
122 //1st we get the buffer size |
|
123 basic->GetCurrentImage(&bufferSize, 0); |
|
124 |
|
125 QByteArray buffer; |
|
126 buffer.resize(bufferSize); |
|
127 HRESULT hr = basic->GetCurrentImage(&bufferSize, reinterpret_cast<long*>(buffer.data())); |
|
128 |
|
129 if (SUCCEEDED(hr)) { |
|
130 |
|
131 const BITMAPINFOHEADER *bmi = reinterpret_cast<const BITMAPINFOHEADER*>(buffer.constData()); |
|
132 |
|
133 const int w = qAbs(bmi->biWidth), |
|
134 h = qAbs(bmi->biHeight); |
|
135 |
|
136 // Create image and copy data into image. |
|
137 QImage ret(w, h, QImage::Format_RGB32); |
|
138 |
|
139 if (!ret.isNull()) { |
|
140 const char *data = buffer.constData() + bmi->biSize; |
|
141 const int bytes_per_line = w * sizeof(QRgb); |
|
142 for (int y = h - 1; y >= 0; --y) { |
|
143 qMemCopy(ret.scanLine(y), //destination |
|
144 data, //source |
|
145 bytes_per_line); |
|
146 data += bytes_per_line; |
|
147 } |
|
148 } |
|
149 return ret; |
|
150 } |
|
151 } |
|
152 return QImage(); |
|
153 } |
|
154 |
|
155 #else |
|
156 VideoRendererVMR9::VideoRendererVMR9(QWidget *target) : m_target(target) |
46 VideoRendererVMR9::VideoRendererVMR9(QWidget *target) : m_target(target) |
157 { |
47 { |
158 m_filter = Filter(CLSID_VideoMixingRenderer9, IID_IBaseFilter); |
48 m_filter = Filter(CLSID_VideoMixingRenderer9, IID_IBaseFilter); |
159 if (!m_filter) { |
49 if (!m_filter) { |
160 qWarning("the video widget could not be initialized correctly"); |
|
161 return; |
50 return; |
162 } |
51 } |
163 |
52 |
164 ComPointer<IVMRFilterConfig9> config(m_filter, IID_IVMRFilterConfig9); |
53 ComPointer<IVMRFilterConfig9> config(m_filter, IID_IVMRFilterConfig9); |
165 Q_ASSERT(config); |
54 Q_ASSERT(config); |