Add the synchronization between Ui and Video player
[platform/core/uifw/dali-adaptor.git] / dali / internal / video / common / video-player-impl.h
1 #ifndef DALI_VIDEO_PLAYER_IMPL_H
2 #define DALI_VIDEO_PLAYER_IMPL_H
3
4 /*
5  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/object/base-object.h>
23 #include <dali/devel-api/adaptor-framework/video-sync-mode.h>
24
25 // INTERNAL INCLUDES
26 #include <dali/devel-api/adaptor-framework/video-player.h>
27 #include <dali/devel-api/adaptor-framework/video-player-plugin.h>
28
29 namespace Dali
30 {
31 class Any;
32
33 namespace Internal
34 {
35
36 namespace Adaptor
37 {
38
39 class VideoPlayer;
40
41 typedef IntrusivePtr< VideoPlayer > VideoPlayerPtr;
42
43 /**
44  * @brief VideoPlayer class is used for video playback.
45  * @SINCE_1_1.24
46  */
47 class VideoPlayer: public Dali::BaseObject
48 {
49 public:
50
51   /**
52    * @brief Creates a new VideoPlayer handle
53    * @SINCE_1_1.24
54    * @return VideoPlayer pointer
55    */
56   static VideoPlayerPtr New();
57
58   /**
59    * @copydoc Dali::VideoPlayer::SetUrl()
60    */
61   void SetUrl( const std::string& url );
62
63   /**
64    * @copydoc Dali::VideoPlayer::GetUrl()
65    */
66   std::string GetUrl();
67
68   /**
69    * @copydoc Dali::VideoPlayer::SetLooping()
70    */
71   void SetLooping(bool looping);
72
73   /**
74    * @copydoc Dali::VideoPlayer::IsLooping()
75    */
76   bool IsLooping();
77
78   /**
79    * @copydoc Dali::VideoPlayer::Play()
80    */
81   void Play();
82
83   /**
84    * @copydoc Dali::VideoPlayer::Pause()
85    */
86   void Pause();
87
88   /**
89    * @copydoc Dali::VideoPlayer::Stop()
90    */
91   void Stop();
92
93   /**
94    * @copydoc Dali::VideoPlayer::SetMute()
95    */
96   void SetMute( bool mute );
97
98   /**
99    * @copydoc Dali::VideoPlayer::IsMuted()
100    */
101   bool IsMuted();
102
103   /**
104    * @copydoc Dali::VideoPlayer::SetVolume()
105    */
106   void SetVolume( float left, float right );
107
108   /**
109    * @copydoc Dali::VideoPlayer::GetVolume()
110    */
111   void GetVolume( float& left, float& right );
112
113   /**
114    * @copydoc Dali::VideoPlayer::SetRenderingTarget()
115    */
116   void SetRenderingTarget( Dali::Any target );
117
118   /**
119    * @copydoc Dali::VideoPlayer::SetPlayPosition()
120    */
121   void SetPlayPosition( int millisecond );
122
123   /**
124    * @copydoc Dali::VideoPlayer::GetPlayPosition()
125    */
126   int GetPlayPosition();
127
128   /**
129    * @copydoc Dali::VideoPlayer::SetDisplayArea()
130    */
131   void SetDisplayArea( DisplayArea area );
132
133   /**
134    * @copydoc Dali::VideoPlayer::SetSetDisplayRotation()
135    */
136   void SetDisplayRotation( Dali::VideoPlayerPlugin::DisplayRotation rotation );
137
138   /**
139    * @copydoc Dali::VideoPlayer::GetDisplayRotation()
140    */
141   Dali::VideoPlayerPlugin::DisplayRotation GetDisplayRotation();
142
143   /**
144    * @copydoc Dali::VideoPlayer::FinishedSignal()
145    */
146   Dali::VideoPlayerPlugin::VideoPlayerSignalType& FinishedSignal();
147
148   /**
149    * @brief Initializes member data.
150    */
151   void Initialize( Dali::Actor actor, VideoSyncMode syncMode );
152
153   /**
154    * @brief Dali::VideoPlayer::Forward()
155    */
156   void Forward( int millisecond );
157
158   /**
159    * @brief Dali::VideoPlayer::Backward()
160    */
161   void Backward( int millisecond );
162
163   /**
164    * @brief Dali::VideoPlayer::IsVideoTextureSupported()
165    */
166   bool IsVideoTextureSupported();
167
168   /**
169    * @brief Dali::VideoPlayer::SetCodecType()
170    */
171   void SetCodecType( Dali::VideoPlayerPlugin::CodecType type );
172
173   /**
174    * @brief Dali::VideoPlayer::GetCodecType()
175    */
176   Dali::VideoPlayerPlugin::CodecType GetCodecType() const;
177
178   /**
179    * @copydoc Dali::VideoPlayer::SetDisplayMode()
180    */
181   void SetDisplayMode( Dali::VideoPlayerPlugin::DisplayMode::Type mode );
182
183   /**
184    * @brief Dali::VideoPlayer::GetDisplayMode()
185    */
186   Dali::VideoPlayerPlugin::DisplayMode::Type GetDisplayMode() const;
187
188   /**
189    * @brief Dali::VideoPlayer::GetMediaPlayer()
190    */
191   Any GetMediaPlayer();
192
193   /**
194    * @brief Dali::VideoPlayer::StartSynchronization()
195    */
196   void StartSynchronization();
197
198   /**
199    * @copydoc Dali::VideoPlayer::FinishSynchronization()
200    */
201   void FinishSynchronization();
202
203 private:
204
205   /**
206    * @brief Constructor.
207    * @SINCE_1_1.24
208    */
209   VideoPlayer();
210
211   /**
212    * @brief Destructor.
213    * @SINCE_1_1.24
214    */
215   virtual ~VideoPlayer();
216
217   // Undefined copy constructor
218   VideoPlayer( const VideoPlayer& player );
219
220   // Undefined assignment operator
221   VideoPlayer& operator=( const VideoPlayer& player );
222
223 private:
224
225   Dali::VideoPlayerPlugin* mPlugin; ///< Videoplayer plugin handle
226   void* mHandle; ///< Handle for the loaded library
227
228   typedef Dali::VideoPlayerPlugin* (*CreateVideoPlayerFunction)( Dali::Actor actor, Dali::VideoSyncMode syncMode );
229   typedef void (*DestroyVideoPlayerFunction)( Dali::VideoPlayerPlugin* plugin );
230
231   CreateVideoPlayerFunction mCreateVideoPlayerPtr;
232   DestroyVideoPlayerFunction mDestroyVideoPlayerPtr;
233
234   Dali::VideoPlayerPlugin::VideoPlayerSignalType mFinishedSignal;
235 };
236
237 } // namespace Adaptor
238 } // namespace Internal
239
240 inline static Internal::Adaptor::VideoPlayer& GetImplementation( Dali::VideoPlayer& player )
241 {
242   DALI_ASSERT_ALWAYS( player && "VideoPlayer handle is empty." );
243
244   BaseObject& handle = player.GetBaseObject();
245
246   return static_cast< Internal::Adaptor::VideoPlayer& >( handle );
247 }
248
249 inline static const Internal::Adaptor::VideoPlayer& GetImplementation( const Dali::VideoPlayer& player )
250 {
251   DALI_ASSERT_ALWAYS( player && "VideoPlayer handle is empty." );
252
253   const BaseObject& handle = player.GetBaseObject();
254
255   return static_cast< const Internal::Adaptor::VideoPlayer& >( handle );
256 }
257
258 } // namespace Dali;
259
260 #endif // DALI_VIDEO_PLAYER_IMPL_H
261