Support the synchronization of changing the video player's z-order
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / toolkit-video-player.cpp
1 /*
2  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <dali/devel-api/adaptor-framework/video-player.h>
19 #include <dali/devel-api/adaptor-framework/video-sync-mode.h>
20 #include <dali/public-api/object/any.h>
21 #include <dali/public-api/object/base-object.h>
22 #include <toolkit-application.h>
23
24 namespace Dali
25 {
26
27 namespace Internal
28 {
29
30 namespace Adaptor
31 {
32
33 class VideoPlayer: public Dali::BaseObject
34 {
35 public:
36
37   VideoPlayer()
38   : mUrl(),
39     mVolumeLeft( 0.0f ),
40     mVolumeRight( 0.0f ),
41     mFinishedSignal(),
42     mMuted( false ),
43     mLooping( false),
44     mPlayPosition( 0 ),
45     mDisplyMode( Dali::VideoPlayerPlugin::DisplayMode::DST_ROI )
46   {
47   }
48
49   void SetMuted( bool muted )
50   {
51     mMuted = muted;
52   }
53
54   bool IsMuted()
55   {
56     return mMuted;
57   }
58
59   void SetLooping( bool looping )
60   {
61     mLooping = looping;
62   }
63
64   bool IsLooping()
65   {
66     return mLooping;
67   }
68
69   void Stop()
70   {
71     if( !mFinishedSignal.Empty() )
72     {
73       mFinishedSignal.Emit();
74     }
75   }
76
77   int GetPlayPosition()
78   {
79     return mPlayPosition;
80   }
81
82   void SetPlayPosition( int pos )
83   {
84     mPlayPosition = pos;
85   }
86
87   Dali::VideoPlayerPlugin::DisplayMode::Type GetDisplayMode() const
88   {
89     return mDisplyMode;
90   }
91
92   void SetDisplayMode( Dali::VideoPlayerPlugin::DisplayMode::Type mode )
93   {
94     mDisplyMode = mode;
95   }
96
97   Any GetMediaPlayer()
98   {
99     return NULL;
100   }
101
102   void StartSynchronization()
103   {
104
105   }
106
107   void FinishSynchronization()
108   {
109
110   }
111
112   void RaiseAbove(Dali::VideoPlayer target)
113   {
114
115   }
116
117   void LowerBelow(Dali::VideoPlayer target)
118   {
119
120   }
121
122   void RaiseToTop()
123   {
124
125   }
126
127   void LowerToBottom()
128   {
129
130   }
131
132 public:
133
134   std::string mUrl;
135   float mVolumeLeft;
136   float mVolumeRight;
137   Dali::VideoPlayerPlugin::VideoPlayerSignalType mFinishedSignal;
138
139 private:
140
141   bool mMuted;
142   bool mLooping;
143   int mPlayPosition;
144   Dali::VideoPlayerPlugin::DisplayMode::Type mDisplyMode;
145 };
146
147 inline VideoPlayer& GetImplementation( Dali::VideoPlayer& player )
148 {
149   DALI_ASSERT_ALWAYS(player && "VideoPlayer handle is empty");
150   BaseObject& handle = player.GetBaseObject();
151   return static_cast< Internal::Adaptor::VideoPlayer& >( handle );
152 }
153
154 inline const VideoPlayer& GetImplementation( const Dali::VideoPlayer& player )
155 {
156   DALI_ASSERT_ALWAYS(player && "VideoPlayer handle is empty");
157   const BaseObject& handle = player.GetBaseObject();
158   return static_cast< const Internal::Adaptor::VideoPlayer& >( handle );
159 }
160
161 } // namespace Adaptor
162
163 } // namespace Internal
164
165
166 /********************************************************************************/
167 /*********************************  PUBLIC CLASS  *******************************/
168 /********************************************************************************/
169
170 VideoPlayer::VideoPlayer()
171 {
172 }
173
174 VideoPlayer::VideoPlayer( Internal::Adaptor::VideoPlayer* internal )
175 : BaseHandle( internal )
176 {
177 }
178
179 VideoPlayer::~VideoPlayer()
180 {
181 }
182
183 VideoPlayer VideoPlayer::New()
184 {
185   Internal::Adaptor::VideoPlayer* player = new Internal::Adaptor::VideoPlayer();
186
187   return VideoPlayer( player );
188 }
189
190 VideoPlayer VideoPlayer::New( Dali::Actor actor, Dali::VideoSyncMode syncMode )
191 {
192   Internal::Adaptor::VideoPlayer* player = new Internal::Adaptor::VideoPlayer();
193
194   return VideoPlayer( player );
195 }
196
197 VideoPlayer::VideoPlayer( const VideoPlayer& player )
198 : BaseHandle( player )
199 {
200 }
201
202 VideoPlayer& VideoPlayer::operator=( const VideoPlayer& player )
203 {
204   BaseHandle::operator=( player );
205   return *this;
206 }
207
208 VideoPlayer VideoPlayer::DownCast( BaseHandle handle )
209 {
210   VideoPlayer videoPlayer;
211   return videoPlayer;
212 }
213
214 void VideoPlayer::SetUrl( const std::string& url )
215 {
216   Internal::Adaptor::GetImplementation( *this ).mUrl = url;
217 }
218
219 std::string VideoPlayer::GetUrl()
220 {
221   return Internal::Adaptor::GetImplementation( *this ).mUrl;
222 }
223
224 void VideoPlayer::SetLooping(bool looping)
225 {
226   Internal::Adaptor::GetImplementation( *this ).SetLooping( looping );
227 }
228
229 bool VideoPlayer::IsLooping()
230 {
231   return Internal::Adaptor::GetImplementation( *this ).IsLooping();
232 }
233
234 void VideoPlayer::Play()
235 {
236 }
237
238 void VideoPlayer::Pause()
239 {
240 }
241
242 void VideoPlayer::Stop()
243 {
244   Internal::Adaptor::GetImplementation( *this ).Stop();
245 }
246
247 void VideoPlayer::SetMute( bool mute )
248 {
249   Internal::Adaptor::GetImplementation( *this ).SetMuted( mute );
250 }
251
252 bool VideoPlayer::IsMuted()
253 {
254   return Internal::Adaptor::GetImplementation( *this ).IsMuted();
255 }
256
257 void VideoPlayer::SetVolume( float left, float right )
258 {
259   Internal::Adaptor::GetImplementation( *this ).mVolumeLeft = left;
260   Internal::Adaptor::GetImplementation( *this ).mVolumeRight = right;
261 }
262
263 void VideoPlayer::GetVolume( float& left, float& right )
264 {
265   left = Internal::Adaptor::GetImplementation( *this ).mVolumeLeft;
266   right = Internal::Adaptor::GetImplementation( *this ).mVolumeRight;
267 }
268
269 void VideoPlayer::SetRenderingTarget( Any target )
270 {
271 }
272
273 void VideoPlayer::SetPlayPosition( int millisecond )
274 {
275   Internal::Adaptor::GetImplementation( *this ).SetPlayPosition( millisecond );
276 }
277
278 int VideoPlayer::GetPlayPosition()
279 {
280   return Internal::Adaptor::GetImplementation( *this ).GetPlayPosition();
281 }
282
283 void VideoPlayer::SetDisplayArea( DisplayArea area )
284 {
285 }
286
287 void VideoPlayer::SetDisplayRotation( Dali::VideoPlayerPlugin::DisplayRotation rotation )
288 {
289 }
290
291 Dali::VideoPlayerPlugin::DisplayRotation VideoPlayer::GetDisplayRotation()
292 {
293   return Dali::VideoPlayerPlugin::ROTATION_NONE;
294 }
295
296 Dali::VideoPlayerPlugin::VideoPlayerSignalType& VideoPlayer::FinishedSignal()
297 {
298   return Internal::Adaptor::GetImplementation( *this ).mFinishedSignal;
299 }
300
301 void VideoPlayer::Forward( int millisecond )
302 {
303 }
304
305 void VideoPlayer::Backward( int millisecond )
306 {
307 }
308
309 bool VideoPlayer::IsVideoTextureSupported()
310 {
311   return ToolkitApplication::DECODED_IMAGES_SUPPORTED;
312 }
313
314 void VideoPlayer::SetCodecType( Dali::VideoPlayerPlugin::CodecType type )
315 {
316 }
317
318 Dali::VideoPlayerPlugin::CodecType VideoPlayer::GetCodecType() const
319 {
320   return Dali::VideoPlayerPlugin::CodecType::DEFAULT;
321 }
322
323 void VideoPlayer::SetDisplayMode( Dali::VideoPlayerPlugin::DisplayMode::Type mode )
324 {
325   Internal::Adaptor::GetImplementation( *this ).SetDisplayMode( mode );
326 }
327
328 Dali::VideoPlayerPlugin::DisplayMode::Type VideoPlayer::GetDisplayMode() const
329 {
330   return Internal::Adaptor::GetImplementation( *this ).GetDisplayMode();
331 }
332
333 Any VideoPlayer::GetMediaPlayer()
334 {
335   return Internal::Adaptor::GetImplementation( *this ).GetMediaPlayer();
336 }
337
338 void VideoPlayer::StartSynchronization()
339 {
340   Internal::Adaptor::GetImplementation( *this ).StartSynchronization();
341 }
342
343 void VideoPlayer::FinishSynchronization()
344 {
345   Internal::Adaptor::GetImplementation( *this ).FinishSynchronization();
346 }
347
348 void VideoPlayer::RaiseAbove(Dali::VideoPlayer target)
349 {
350   Internal::Adaptor::GetImplementation( *this ).RaiseAbove(target);
351 }
352
353 void VideoPlayer::LowerBelow(Dali::VideoPlayer target)
354 {
355   Internal::Adaptor::GetImplementation( *this ).LowerBelow(target);
356 }
357
358 void VideoPlayer::RaiseToTop()
359 {
360   Internal::Adaptor::GetImplementation( *this ).RaiseToTop();
361 }
362
363 void VideoPlayer::LowerToBottom()
364 {
365   Internal::Adaptor::GetImplementation( *this ).LowerToBottom();
366 }
367
368 } // namespace Dali;
369