1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
/* This file is part of the KDE project.
Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
This library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 2.1 or 3 of the License.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include <videoplayer2.h>
#include <QtCore/private/qcore_symbian_p.h> // for qt_QRect2TRect
#include "utils.h"
#include "videooutput_surface.h"
#include "videoplayer_surface.h"
QT_BEGIN_NAMESPACE
using namespace Phonon;
using namespace Phonon::MMF;
// Two-phase constructor idiom is used because construct() calls virtual
// functions and therefore cannot be called from the AbstractVideoPlayer
// C++ constructor.
SurfaceVideoPlayer* SurfaceVideoPlayer::create(MediaObject *parent,
const AbstractPlayer *player)
{
QScopedPointer<SurfaceVideoPlayer> self(new SurfaceVideoPlayer(parent, player));
self->construct();
return self.take();
}
SurfaceVideoPlayer::SurfaceVideoPlayer(MediaObject *parent, const AbstractPlayer *player)
: AbstractVideoPlayer(parent, player)
, m_displayWindow(0)
{
}
SurfaceVideoPlayer::~SurfaceVideoPlayer()
{
}
//-----------------------------------------------------------------------------
// Public functions
//-----------------------------------------------------------------------------
void MMF::SurfaceVideoPlayer::videoWindowSizeChanged()
{
updateScaleFactors(m_videoOutput->videoWindowSize());
}
//-----------------------------------------------------------------------------
// Private functions
//-----------------------------------------------------------------------------
void MMF::SurfaceVideoPlayer::createPlayer()
{
const TInt priority = 0;
const TMdaPriorityPreference preference = EMdaPriorityPreferenceNone;
CVideoPlayerUtility2 *player = 0;
QT_TRAP_THROWING(player = CVideoPlayerUtility2::NewL(*this,
priority, preference));
m_player.reset(player);
}
void MMF::SurfaceVideoPlayer::initVideoOutput()
{
bool connected = connect(
m_videoOutput, SIGNAL(videoWindowSizeChanged()),
this, SLOT(videoWindowSizeChanged())
);
Q_ASSERT(connected);
// Suppress warnings in release builds
Q_UNUSED(connected);
AbstractVideoPlayer::initVideoOutput();
}
void MMF::SurfaceVideoPlayer::prepareCompleted()
{
videoWindowSizeChanged();
}
void MMF::SurfaceVideoPlayer::handleVideoWindowChanged()
{
parametersChanged(WindowHandle);
}
void MMF::SurfaceVideoPlayer::handleParametersChanged(VideoParameters parameters)
{
TRect rect;
if (m_videoOutput) {
m_videoOutput->dump();
const QSize size = m_videoOutput->videoWindowSize();
rect.SetSize(TSize(size.width(), size.height()));
}
CVideoPlayerUtility2 *player = static_cast<CVideoPlayerUtility2 *>(m_player.data());
if (player) {
int err = KErrNone;
if (parameters & WindowHandle) {
if (m_displayWindow)
player->RemoveDisplayWindow(*m_displayWindow);
RWindow *window = static_cast<RWindow *>(m_window);
if (window) {
window->SetBackgroundColor(TRgb(0, 0, 0, 255));
TRAP(err, player->AddDisplayWindowL(m_wsSession, m_screenDevice, *window, rect, rect));
if (KErrNone != err) {
setError(tr("Video display error"), err);
window = 0;
}
}
m_displayWindow = window;
}
if (KErrNone == err) {
if (parameters & ScaleFactors) {
Q_ASSERT(m_displayWindow);
TRAP(err, player->SetVideoExtentL(*m_displayWindow, rect));
if (KErrNone == err)
TRAP(err, player->SetWindowClipRectL(*m_displayWindow, rect));
if (KErrNone == err)
TRAP(err, player->SetScaleFactorL(*m_displayWindow, m_scaleWidth, m_scaleHeight));
if (KErrNone != err)
setError(tr("Video display error"), err);
}
}
}
}
QT_END_NAMESPACE
|