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