Add Text Preedit Style
[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/public-api/object/any.h>
20 #include <dali/public-api/object/base-object.h>
21 #include <toolkit-application.h>
22
23 namespace Dali
24 {
25
26 namespace Internal
27 {
28
29 namespace Adaptor
30 {
31
32 class VideoPlayer: public Dali::BaseObject
33 {
34 public:
35
36   VideoPlayer()
37   : mUrl(),
38     mVolumeLeft( 0.0f ),
39     mVolumeRight( 0.0f ),
40     mFinishedSignal(),
41     mMuted( false ),
42     mLooping( false),
43     mPlayPosition( 0 ),
44     mDisplyMode( Dali::VideoPlayerPlugin::DisplayMode::DST_ROI )
45   {
46   }
47
48   void SetMuted( bool muted )
49   {
50     mMuted = muted;
51   }
52
53   bool IsMuted()
54   {
55     return mMuted;
56   }
57
58   void SetLooping( bool looping )
59   {
60     mLooping = looping;
61   }
62
63   bool IsLooping()
64   {
65     return mLooping;
66   }
67
68   void Stop()
69   {
70     if( !mFinishedSignal.Empty() )
71     {
72       mFinishedSignal.Emit();
73     }
74   }
75
76   int GetPlayPosition()
77   {
78     return mPlayPosition;
79   }
80
81   void SetPlayPosition( int pos )
82   {
83     mPlayPosition = pos;
84   }
85
86   Dali::VideoPlayerPlugin::DisplayMode::Type GetDisplayMode() const
87   {
88     return mDisplyMode;
89   }
90
91   void SetDisplayMode( Dali::VideoPlayerPlugin::DisplayMode::Type mode )
92   {
93     mDisplyMode = mode;
94   }
95
96
97 public:
98
99   std::string mUrl;
100   float mVolumeLeft;
101   float mVolumeRight;
102   Dali::VideoPlayerPlugin::VideoPlayerSignalType mFinishedSignal;
103
104 private:
105
106   bool mMuted;
107   bool mLooping;
108   int mPlayPosition;
109   Dali::VideoPlayerPlugin::DisplayMode::Type mDisplyMode;
110 };
111
112 inline VideoPlayer& GetImplementation( Dali::VideoPlayer& player )
113 {
114   DALI_ASSERT_ALWAYS(player && "VideoPlayer handle is empty");
115   BaseObject& handle = player.GetBaseObject();
116   return static_cast< Internal::Adaptor::VideoPlayer& >( handle );
117 }
118
119 inline const VideoPlayer& GetImplementation( const Dali::VideoPlayer& player )
120 {
121   DALI_ASSERT_ALWAYS(player && "VideoPlayer handle is empty");
122   const BaseObject& handle = player.GetBaseObject();
123   return static_cast< const Internal::Adaptor::VideoPlayer& >( handle );
124 }
125
126 } // namespace Adaptor
127
128 } // namespace Internal
129
130
131 /********************************************************************************/
132 /*********************************  PUBLIC CLASS  *******************************/
133 /********************************************************************************/
134
135 VideoPlayer::VideoPlayer()
136 {
137 }
138
139 VideoPlayer::VideoPlayer( Internal::Adaptor::VideoPlayer* internal )
140 : BaseHandle( internal )
141 {
142 }
143
144 VideoPlayer::~VideoPlayer()
145 {
146 }
147
148 VideoPlayer VideoPlayer::New()
149 {
150   Internal::Adaptor::VideoPlayer* player = new Internal::Adaptor::VideoPlayer();
151
152   return VideoPlayer( player );
153 }
154
155 VideoPlayer::VideoPlayer( const VideoPlayer& player )
156 : BaseHandle( player )
157 {
158 }
159
160 VideoPlayer& VideoPlayer::operator=( const VideoPlayer& player )
161 {
162   BaseHandle::operator=( player );
163   return *this;
164 }
165
166 VideoPlayer VideoPlayer::DownCast( BaseHandle handle )
167 {
168   VideoPlayer videoPlayer;
169   return videoPlayer;
170 }
171
172 void VideoPlayer::SetUrl( const std::string& url )
173 {
174   Internal::Adaptor::GetImplementation( *this ).mUrl = url;
175 }
176
177 std::string VideoPlayer::GetUrl()
178 {
179   return Internal::Adaptor::GetImplementation( *this ).mUrl;
180 }
181
182 void VideoPlayer::SetLooping(bool looping)
183 {
184   Internal::Adaptor::GetImplementation( *this ).SetLooping( looping );
185 }
186
187 bool VideoPlayer::IsLooping()
188 {
189   return Internal::Adaptor::GetImplementation( *this ).IsLooping();
190 }
191
192 void VideoPlayer::Play()
193 {
194 }
195
196 void VideoPlayer::Pause()
197 {
198 }
199
200 void VideoPlayer::Stop()
201 {
202   Internal::Adaptor::GetImplementation( *this ).Stop();
203 }
204
205 void VideoPlayer::SetMute( bool mute )
206 {
207   Internal::Adaptor::GetImplementation( *this ).SetMuted( mute );
208 }
209
210 bool VideoPlayer::IsMuted()
211 {
212   return Internal::Adaptor::GetImplementation( *this ).IsMuted();
213 }
214
215 void VideoPlayer::SetVolume( float left, float right )
216 {
217   Internal::Adaptor::GetImplementation( *this ).mVolumeLeft = left;
218   Internal::Adaptor::GetImplementation( *this ).mVolumeRight = right;
219 }
220
221 void VideoPlayer::GetVolume( float& left, float& right )
222 {
223   left = Internal::Adaptor::GetImplementation( *this ).mVolumeLeft;
224   right = Internal::Adaptor::GetImplementation( *this ).mVolumeRight;
225 }
226
227 void VideoPlayer::SetRenderingTarget( Any target )
228 {
229 }
230
231 void VideoPlayer::SetPlayPosition( int millisecond )
232 {
233   Internal::Adaptor::GetImplementation( *this ).SetPlayPosition( millisecond );
234 }
235
236 int VideoPlayer::GetPlayPosition()
237 {
238   return Internal::Adaptor::GetImplementation( *this ).GetPlayPosition();
239 }
240
241 void VideoPlayer::SetDisplayArea( DisplayArea area )
242 {
243 }
244
245 void VideoPlayer::SetDisplayRotation( Dali::VideoPlayerPlugin::DisplayRotation rotation )
246 {
247 }
248
249 Dali::VideoPlayerPlugin::DisplayRotation VideoPlayer::GetDisplayRotation()
250 {
251   return Dali::VideoPlayerPlugin::ROTATION_NONE;
252 }
253
254 Dali::VideoPlayerPlugin::VideoPlayerSignalType& VideoPlayer::FinishedSignal()
255 {
256   return Internal::Adaptor::GetImplementation( *this ).mFinishedSignal;
257 }
258
259 void VideoPlayer::Forward( int millisecond )
260 {
261 }
262
263 void VideoPlayer::Backward( int millisecond )
264 {
265 }
266
267 bool VideoPlayer::IsVideoTextureSupported()
268 {
269   return ToolkitApplication::DECODED_IMAGES_SUPPORTED;
270 }
271
272 void VideoPlayer::SetCodecType( Dali::VideoPlayerPlugin::CodecType type )
273 {
274 }
275
276 Dali::VideoPlayerPlugin::CodecType VideoPlayer::GetCodecType() const
277 {
278   return Dali::VideoPlayerPlugin::CodecType::DEFAULT;
279 }
280
281 void VideoPlayer::SetDisplayMode( Dali::VideoPlayerPlugin::DisplayMode::Type mode )
282 {
283   Internal::Adaptor::GetImplementation( *this ).SetDisplayMode( mode );
284 }
285
286 Dali::VideoPlayerPlugin::DisplayMode::Type VideoPlayer::GetDisplayMode() const
287 {
288   return Internal::Adaptor::GetImplementation( *this ).GetDisplayMode();
289 }
290
291 } // namespace Dali;
292