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