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