Merge lp:~jhodapp/qtubuntu-media/orientation into lp:qtubuntu-media

Proposed by Jim Hodapp
Status: Merged
Approved by: Ricardo Mendoza
Approved revision: 53
Merged at revision: 49
Proposed branch: lp:~jhodapp/qtubuntu-media/orientation
Merge into: lp:qtubuntu-media
Diff against target: 241 lines (+87/-13)
6 files modified
src/aal/aalmediaplayerservice.cpp (+2/-0)
src/aal/aalmediaplayerservice.h (+2/-0)
src/aal/aalvideorenderercontrol.cpp (+58/-9)
src/aal/aalvideorenderercontrol.h (+11/-4)
unittests/player.cpp (+12/-0)
unittests/player.h (+2/-0)
To merge this branch: bzr merge lp:~jhodapp/qtubuntu-media/orientation
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Ricardo Salveti (community) Approve
Review via email: mp+238357@code.launchpad.net

Commit message

* Add simple support for Orientation Property changed signal that comes from media-hub
* Pass the video frame dimension in from media-hub through to qtvideo-node

Description of the change

* Add simple support for Orientation Property changed signal that comes from media-hub
* Pass the video frame dimension in from media-hub through to qtvideo-node

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
48. By Jim Hodapp

Don't try to access the AalMediaPlayerService instance too early in the setup of AalVideoRendererControl.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
49. By Jim Hodapp

Make sure we listen to the orientation signal in the right place.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
50. By Jim Hodapp

If video playback needs 90 degree rotation, flip the height and width values.

51. By Jim Hodapp

Merged with upstream

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
52. By Jim Hodapp

Merged with trunk.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ricardo Salveti (rsalveti) wrote :

LGTM

review: Approve
53. By Jim Hodapp

Add 180 and 270 degree rotation/flipping of video playback.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/aal/aalmediaplayerservice.cpp'
2--- src/aal/aalmediaplayerservice.cpp 2014-10-15 10:24:08 +0000
3+++ src/aal/aalmediaplayerservice.cpp 2014-10-20 21:25:32 +0000
4@@ -27,6 +27,8 @@
5
6 #include <QThread>
7
8+#include <qtubuntu_media_signals.h>
9+
10 // Defined in aalvideorenderercontrol.h
11 #ifdef MEASURE_PERFORMANCE
12 #include <QDateTime>
13
14=== modified file 'src/aal/aalmediaplayerservice.h'
15--- src/aal/aalmediaplayerservice.h 2014-10-15 09:26:40 +0000
16+++ src/aal/aalmediaplayerservice.h 2014-10-20 21:25:32 +0000
17@@ -83,6 +83,8 @@
18
19 void pushPlaylist();
20
21+ const std::shared_ptr<core::ubuntu::media::Player>& getPlayer() const { return m_hubPlayerSession; }
22+
23 /* This is for unittest purposes to be able to set a mock-object version of a
24 * player object */
25 void setPlayer(const std::shared_ptr<core::ubuntu::media::Player> &player);
26
27=== modified file 'src/aal/aalvideorenderercontrol.cpp'
28--- src/aal/aalvideorenderercontrol.cpp 2014-09-19 13:45:31 +0000
29+++ src/aal/aalvideorenderercontrol.cpp 2014-10-20 21:25:32 +0000
30@@ -38,6 +38,9 @@
31
32 #include <qgl.h>
33
34+namespace media = core::ubuntu::media;
35+using namespace std::placeholders;
36+
37 class AalGLTextureBuffer : public QAbstractVideoBuffer
38 {
39 public:
40@@ -80,8 +83,11 @@
41 m_service(service),
42 m_textureBuffer(0),
43 m_textureId(0),
44- m_height(720),
45- m_width(1280),
46+ m_orientation(media::Player::Orientation::rotate0),
47+ m_height(0),
48+ m_width(0),
49+ m_surfaceStarted(false),
50+ m_flipped(false),
51 m_firstFrame(true),
52 m_secondFrame(false)
53 #ifdef MEASURE_PERFORMANCE
54@@ -125,20 +131,55 @@
55 return m_textureId;
56 }
57
58+uint32_t AalVideoRendererControl::height() const
59+{
60+ return m_height;
61+}
62+
63+uint32_t AalVideoRendererControl::width() const
64+{
65+ return m_width;
66+}
67+
68 void AalVideoRendererControl::setupSurface()
69 {
70 qDebug() << Q_FUNC_INFO;
71
72+ m_service->getPlayer()->video_dimension_changed().connect(
73+ std::bind(&AalVideoRendererControl::onVideoDimensionChanged, this, _1));
74+
75+ // When orientation changes during playback, cache a copy here
76+ m_service->getPlayer()->orientation().changed().connect([this](const media::Player::Orientation &orientation)
77+ {
78+ m_orientation = orientation;
79+ });
80+
81 if (!m_textureBuffer)
82 m_textureBuffer = new AalGLTextureBuffer(m_textureId);
83
84 updateVideoTexture();
85 }
86
87-void AalVideoRendererControl::setVideoSize(int height, int width)
88+void AalVideoRendererControl::onVideoDimensionChanged(uint64_t mask)
89 {
90- m_height = height;
91- m_width = width;
92+ qDebug() << Q_FUNC_INFO;
93+ const uint32_t width = static_cast<uint32_t>(mask & 0xFFFF);
94+ const uint32_t height = static_cast<uint32_t>(mask >> 32);
95+
96+ // Make sure that X & Y remain flipped between multiple playbacks in the
97+ // same session
98+ if ((m_orientation == media::Player::Orientation::rotate90 ||
99+ m_orientation == media::Player::Orientation::rotate270) && !m_flipped) {
100+ m_height = width;
101+ m_width = height;
102+ m_flipped = true;
103+ } else {
104+ m_height = height;
105+ m_width = width;
106+ }
107+
108+ QSize frameSize(m_width, m_height);
109+ Q_EMIT SharedSignal::instance()->setOrientation(static_cast<SharedSignal::Orientation>(m_orientation), frameSize);
110 }
111
112 void AalVideoRendererControl::updateVideoTexture()
113@@ -211,11 +252,19 @@
114 Q_UNUSED(empty);
115 Q_ASSERT(m_surface != NULL);
116
117- if (!m_surface->isActive()) {
118- QVideoSurfaceFormat format(frame.size(), frame.pixelFormat(), frame.handleType());
119+ // Wait until we have a height and width to start m_surface
120+ if (!m_surface->isActive() || (m_height != 0 && m_width != 0)) {
121+ if (!m_surfaceStarted) {
122+ qDebug() << "Setting up surface with height: " << m_height << " width: " << m_width;
123+ QVideoSurfaceFormat format(frame.size(), frame.pixelFormat(), frame.handleType());
124
125- if (!m_surface->start(format)) {
126- qWarning() << "Failed to start video surface with format:" << format;
127+ if (!m_surface->start(format)) {
128+ qWarning() << "Failed to start video surface with format:" << format;
129+ }
130+ // Make sure we don't create any more new QVideoSurfaceFormat instances
131+ // after we have a proper height and width set
132+ if (m_height != 0 && m_width != 0)
133+ m_surfaceStarted = true;
134 }
135 }
136
137
138=== modified file 'src/aal/aalvideorenderercontrol.h'
139--- src/aal/aalvideorenderercontrol.h 2014-09-22 16:11:46 +0000
140+++ src/aal/aalvideorenderercontrol.h 2014-10-20 21:25:32 +0000
141@@ -17,6 +17,8 @@
142 #ifndef AALVIDEORENDERERCONTROL_H
143 #define AALVIDEORENDERERCONTROL_H
144
145+#include <core/media/player.h>
146+
147 #include <QImage>
148 #include <QVideoFrame>
149 #include <QVideoRendererControl>
150@@ -47,9 +49,11 @@
151
152 GLuint textureId() const;
153
154+ uint32_t height() const;
155+ uint32_t width() const;
156+
157 // Callbacks
158 static void updateVideoTextureCb(void *context);
159- static void setVideoSizeCb(int height, int width, void *data);
160
161 public Q_SLOTS:
162 void setupSurface();
163@@ -58,13 +62,13 @@
164 void surfaceChanged(QAbstractVideoSurface *surface);
165
166 private Q_SLOTS:
167- void setVideoSize(int height, int width);
168 void updateVideoTexture();
169 void onTextureCreated(unsigned int textureID);
170 void onServiceReady();
171 void onGLConsumerSet();
172
173 private:
174+ void onVideoDimensionChanged(uint64_t mask);
175 void presentVideoFrame(const QVideoFrame &frame, bool empty = false);
176
177 QAbstractVideoSurface *m_surface;
178@@ -72,8 +76,11 @@
179 AalGLTextureBuffer *m_textureBuffer;
180 GLuint m_textureId;
181
182- int m_height;
183- int m_width;
184+ core::ubuntu::media::Player::Orientation m_orientation;
185+ uint32_t m_height;
186+ uint32_t m_width;
187+ bool m_surfaceStarted;
188+ bool m_flipped;
189
190 bool m_firstFrame;
191 bool m_secondFrame;
192
193=== modified file 'unittests/player.cpp'
194--- unittests/player.cpp 2014-09-26 18:06:11 +0000
195+++ unittests/player.cpp 2014-10-20 21:25:32 +0000
196@@ -153,6 +153,12 @@
197 return ret;
198 }
199
200+const core::Property<TestPlayer::Orientation>& TestPlayer::orientation() const
201+{
202+ static core::Property<Player::Orientation> ret(Player::Orientation::rotate0);
203+ return ret;
204+}
205+
206 const core::Property<Player::LoopStatus>& TestPlayer::loop_status() const
207 {
208 static core::Property<Player::LoopStatus> ret(Player::LoopStatus::none);
209@@ -266,6 +272,12 @@
210 return ret;
211 }
212
213+const core::Signal<uint64_t>& TestPlayer::video_dimension_changed() const
214+{
215+ static core::Signal<uint64_t> ret;
216+ return ret;
217+}
218+
219 const std::shared_ptr<Service> Service::Client::instance()
220 {
221 return NULL;
222
223=== modified file 'unittests/player.h'
224--- unittests/player.h 2014-09-26 18:06:11 +0000
225+++ unittests/player.h 2014-10-20 21:25:32 +0000
226@@ -60,6 +60,7 @@
227 virtual const core::Property<bool>& is_video_source() const;
228 virtual const core::Property<bool>& is_audio_source() const;
229 virtual const core::Property<PlaybackStatus>& playback_status() const;
230+ virtual const core::Property<Orientation>& orientation() const;
231 virtual const core::Property<LoopStatus>& loop_status() const;
232 virtual const core::Property<PlaybackRate>& playback_rate() const;
233 virtual const core::Property<bool>& is_shuffle() const;
234@@ -81,6 +82,7 @@
235 virtual const core::Signal<void>& end_of_stream() const;
236 virtual const core::Signal<PlaybackStatus>& playback_status_changed() const;
237 virtual core::Signal<PlaybackStatus>& playback_status_changed();
238+ virtual const core::Signal<uint64_t>& video_dimension_changed() const;
239
240 private:
241 core::Property<int64_t> m_position;

Subscribers

People subscribed via source and target branches