Update common test util
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / toolkit-video-player.cpp
1 /*
2  * Copyright (c) 2016 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   {
38     mMuted = false;
39     mLooping = false;
40   }
41
42   void SetMuted( bool muted )
43   {
44     mMuted = muted;
45   }
46
47   bool IsMuted()
48   {
49     return mMuted;
50   }
51
52   void SetLooping( bool looping )
53   {
54     mLooping = looping;
55   }
56
57   bool IsLooping()
58   {
59     return mLooping;
60   }
61
62   void Stop()
63   {
64     if( !mFinishedSignal.Empty() )
65     {
66       mFinishedSignal.Emit();
67     }
68   }
69
70 public:
71
72   std::string mUrl;
73   float mVolumeLeft;
74   float mVolumeRight;
75   Dali::VideoPlayerPlugin::VideoPlayerSignalType mFinishedSignal;
76
77 private:
78
79   bool mMuted;
80   bool mLooping;
81 };
82
83 inline VideoPlayer& GetImplementation( Dali::VideoPlayer& player )
84 {
85   DALI_ASSERT_ALWAYS(player && "VideoPlayer handle is empty");
86   BaseObject& handle = player.GetBaseObject();
87   return static_cast< Internal::Adaptor::VideoPlayer& >( handle );
88 }
89
90 inline const VideoPlayer& GetImplementation( const Dali::VideoPlayer& player )
91 {
92   DALI_ASSERT_ALWAYS(player && "VideoPlayer handle is empty");
93   const BaseObject& handle = player.GetBaseObject();
94   return static_cast< const Internal::Adaptor::VideoPlayer& >( handle );
95 }
96
97 } // namespace Adaptor
98
99 } // namespace Internal
100
101
102 /********************************************************************************/
103 /*********************************  PUBLIC CLASS  *******************************/
104 /********************************************************************************/
105
106 VideoPlayer::VideoPlayer()
107 {
108 }
109
110 VideoPlayer::VideoPlayer( Internal::Adaptor::VideoPlayer* internal )
111 : BaseHandle( internal )
112 {
113 }
114
115 VideoPlayer::~VideoPlayer()
116 {
117 }
118
119 VideoPlayer VideoPlayer::New()
120 {
121   Internal::Adaptor::VideoPlayer* player = new Internal::Adaptor::VideoPlayer();
122
123   return VideoPlayer( player );
124 }
125
126 VideoPlayer::VideoPlayer( const VideoPlayer& player )
127 : BaseHandle( player )
128 {
129 }
130
131 VideoPlayer& VideoPlayer::operator=( const VideoPlayer& player )
132 {
133   BaseHandle::operator=( player );
134   return *this;
135 }
136
137 VideoPlayer VideoPlayer::DownCast( BaseHandle handle )
138 {
139   VideoPlayer videoPlayer;
140   return videoPlayer;
141 }
142
143 void VideoPlayer::SetUrl( const std::string& url )
144 {
145   Internal::Adaptor::GetImplementation( *this ).mUrl = url;
146 }
147
148 std::string VideoPlayer::GetUrl()
149 {
150   return Internal::Adaptor::GetImplementation( *this ).mUrl;
151 }
152
153 void VideoPlayer::SetLooping(bool looping)
154 {
155   Internal::Adaptor::GetImplementation( *this ).SetLooping( looping );
156 }
157
158 bool VideoPlayer::IsLooping()
159 {
160   return Internal::Adaptor::GetImplementation( *this ).IsLooping();
161 }
162
163 void VideoPlayer::Play()
164 {
165 }
166
167 void VideoPlayer::Pause()
168 {
169 }
170
171 void VideoPlayer::Stop()
172 {
173   Internal::Adaptor::GetImplementation( *this ).Stop();
174 }
175
176 void VideoPlayer::SetMute( bool mute )
177 {
178   Internal::Adaptor::GetImplementation( *this ).SetMuted( mute );
179 }
180
181 bool VideoPlayer::IsMuted()
182 {
183   return Internal::Adaptor::GetImplementation( *this ).IsMuted();
184 }
185
186 void VideoPlayer::SetVolume( float left, float right )
187 {
188   Internal::Adaptor::GetImplementation( *this ).mVolumeLeft = left;
189   Internal::Adaptor::GetImplementation( *this ).mVolumeRight = right;
190 }
191
192 void VideoPlayer::GetVolume( float& left, float& right )
193 {
194   left = Internal::Adaptor::GetImplementation( *this ).mVolumeLeft;
195   right = Internal::Adaptor::GetImplementation( *this ).mVolumeRight;
196 }
197
198 void VideoPlayer::SetRenderingTarget( Any target )
199 {
200 }
201
202 void VideoPlayer::SetPlayPosition( int millisecond )
203 {
204 }
205
206 int VideoPlayer::GetPlayPosition()
207 {
208   return 0;
209 }
210
211 void VideoPlayer::SetDisplayArea( DisplayArea area )
212 {
213 }
214
215 void VideoPlayer::SetDisplayRotation( Dali::VideoPlayerPlugin::DisplayRotation rotation )
216 {
217 }
218
219 Dali::VideoPlayerPlugin::DisplayRotation VideoPlayer::GetDisplayRotation()
220 {
221   return Dali::VideoPlayerPlugin::ROTATION_NONE;
222 }
223
224 Dali::VideoPlayerPlugin::VideoPlayerSignalType& VideoPlayer::FinishedSignal()
225 {
226   return Internal::Adaptor::GetImplementation( *this ).mFinishedSignal;
227 }
228
229 void VideoPlayer::Forward( int millisecond )
230 {
231 }
232
233 void VideoPlayer::Backward( int millisecond )
234 {
235 }
236
237 bool VideoPlayer::IsVideoTextureSupported() const
238 {
239   return ToolkitApplication::DECODED_IMAGES_SUPPORTED;
240 }
241
242 } // namespace Dali;
243