Updates for const->constexpr
[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 public:
113
114   std::string mUrl;
115   float mVolumeLeft;
116   float mVolumeRight;
117   Dali::VideoPlayerPlugin::VideoPlayerSignalType mFinishedSignal;
118
119 private:
120
121   bool mMuted;
122   bool mLooping;
123   int mPlayPosition;
124   Dali::VideoPlayerPlugin::DisplayMode::Type mDisplyMode;
125 };
126
127 inline VideoPlayer& GetImplementation( Dali::VideoPlayer& player )
128 {
129   DALI_ASSERT_ALWAYS(player && "VideoPlayer handle is empty");
130   BaseObject& handle = player.GetBaseObject();
131   return static_cast< Internal::Adaptor::VideoPlayer& >( handle );
132 }
133
134 inline const VideoPlayer& GetImplementation( const Dali::VideoPlayer& player )
135 {
136   DALI_ASSERT_ALWAYS(player && "VideoPlayer handle is empty");
137   const BaseObject& handle = player.GetBaseObject();
138   return static_cast< const Internal::Adaptor::VideoPlayer& >( handle );
139 }
140
141 } // namespace Adaptor
142
143 } // namespace Internal
144
145
146 /********************************************************************************/
147 /*********************************  PUBLIC CLASS  *******************************/
148 /********************************************************************************/
149
150 VideoPlayer::VideoPlayer()
151 {
152 }
153
154 VideoPlayer::VideoPlayer( Internal::Adaptor::VideoPlayer* internal )
155 : BaseHandle( internal )
156 {
157 }
158
159 VideoPlayer::~VideoPlayer()
160 {
161 }
162
163 VideoPlayer VideoPlayer::New()
164 {
165   Internal::Adaptor::VideoPlayer* player = new Internal::Adaptor::VideoPlayer();
166
167   return VideoPlayer( player );
168 }
169
170 VideoPlayer VideoPlayer::New( Dali::Actor actor, Dali::VideoSyncMode syncMode )
171 {
172   Internal::Adaptor::VideoPlayer* player = new Internal::Adaptor::VideoPlayer();
173
174   return VideoPlayer( player );
175 }
176
177 VideoPlayer::VideoPlayer( const VideoPlayer& player )
178 : BaseHandle( player )
179 {
180 }
181
182 VideoPlayer& VideoPlayer::operator=( const VideoPlayer& player )
183 {
184   BaseHandle::operator=( player );
185   return *this;
186 }
187
188 VideoPlayer VideoPlayer::DownCast( BaseHandle handle )
189 {
190   VideoPlayer videoPlayer;
191   return videoPlayer;
192 }
193
194 void VideoPlayer::SetUrl( const std::string& url )
195 {
196   Internal::Adaptor::GetImplementation( *this ).mUrl = url;
197 }
198
199 std::string VideoPlayer::GetUrl()
200 {
201   return Internal::Adaptor::GetImplementation( *this ).mUrl;
202 }
203
204 void VideoPlayer::SetLooping(bool looping)
205 {
206   Internal::Adaptor::GetImplementation( *this ).SetLooping( looping );
207 }
208
209 bool VideoPlayer::IsLooping()
210 {
211   return Internal::Adaptor::GetImplementation( *this ).IsLooping();
212 }
213
214 void VideoPlayer::Play()
215 {
216 }
217
218 void VideoPlayer::Pause()
219 {
220 }
221
222 void VideoPlayer::Stop()
223 {
224   Internal::Adaptor::GetImplementation( *this ).Stop();
225 }
226
227 void VideoPlayer::SetMute( bool mute )
228 {
229   Internal::Adaptor::GetImplementation( *this ).SetMuted( mute );
230 }
231
232 bool VideoPlayer::IsMuted()
233 {
234   return Internal::Adaptor::GetImplementation( *this ).IsMuted();
235 }
236
237 void VideoPlayer::SetVolume( float left, float right )
238 {
239   Internal::Adaptor::GetImplementation( *this ).mVolumeLeft = left;
240   Internal::Adaptor::GetImplementation( *this ).mVolumeRight = right;
241 }
242
243 void VideoPlayer::GetVolume( float& left, float& right )
244 {
245   left = Internal::Adaptor::GetImplementation( *this ).mVolumeLeft;
246   right = Internal::Adaptor::GetImplementation( *this ).mVolumeRight;
247 }
248
249 void VideoPlayer::SetRenderingTarget( Any target )
250 {
251 }
252
253 void VideoPlayer::SetPlayPosition( int millisecond )
254 {
255   Internal::Adaptor::GetImplementation( *this ).SetPlayPosition( millisecond );
256 }
257
258 int VideoPlayer::GetPlayPosition()
259 {
260   return Internal::Adaptor::GetImplementation( *this ).GetPlayPosition();
261 }
262
263 void VideoPlayer::SetDisplayArea( DisplayArea area )
264 {
265 }
266
267 void VideoPlayer::SetDisplayRotation( Dali::VideoPlayerPlugin::DisplayRotation rotation )
268 {
269 }
270
271 Dali::VideoPlayerPlugin::DisplayRotation VideoPlayer::GetDisplayRotation()
272 {
273   return Dali::VideoPlayerPlugin::ROTATION_NONE;
274 }
275
276 Dali::VideoPlayerPlugin::VideoPlayerSignalType& VideoPlayer::FinishedSignal()
277 {
278   return Internal::Adaptor::GetImplementation( *this ).mFinishedSignal;
279 }
280
281 void VideoPlayer::Forward( int millisecond )
282 {
283 }
284
285 void VideoPlayer::Backward( int millisecond )
286 {
287 }
288
289 bool VideoPlayer::IsVideoTextureSupported()
290 {
291   return ToolkitApplication::DECODED_IMAGES_SUPPORTED;
292 }
293
294 void VideoPlayer::SetCodecType( Dali::VideoPlayerPlugin::CodecType type )
295 {
296 }
297
298 Dali::VideoPlayerPlugin::CodecType VideoPlayer::GetCodecType() const
299 {
300   return Dali::VideoPlayerPlugin::CodecType::DEFAULT;
301 }
302
303 void VideoPlayer::SetDisplayMode( Dali::VideoPlayerPlugin::DisplayMode::Type mode )
304 {
305   Internal::Adaptor::GetImplementation( *this ).SetDisplayMode( mode );
306 }
307
308 Dali::VideoPlayerPlugin::DisplayMode::Type VideoPlayer::GetDisplayMode() const
309 {
310   return Internal::Adaptor::GetImplementation( *this ).GetDisplayMode();
311 }
312
313 Any VideoPlayer::GetMediaPlayer()
314 {
315   return Internal::Adaptor::GetImplementation( *this ).GetMediaPlayer();
316 }
317
318 void VideoPlayer::StartSynchronization()
319 {
320   Internal::Adaptor::GetImplementation( *this ).StartSynchronization();
321 }
322
323 void VideoPlayer::FinishSynchronization()
324 {
325   Internal::Adaptor::GetImplementation( *this ).FinishSynchronization();
326 }
327
328 } // namespace Dali;
329