Add the synchronization between Ui and Video player
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / video-player-plugin.h
1 #ifndef DALI_VIDEO_PLAYER_PLUGIN_H
2 #define DALI_VIDEO_PLAYER_PLUGIN_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/signals/dali-signal.h>
23 #include <dali/public-api/math/rect.h>
24 #include <dali/public-api/actors/actor.h>
25
26 namespace Dali
27 {
28
29 class Any;
30 typedef Dali::Rect< int > DisplayArea;
31
32 /**
33  * @brief VideoPlayerPlugin is an abstract interface, used by dali-adaptor to access video player plugin.
34  * A concrete implementation must be created for each platform and provided as dynamic library.
35  * @SINCE_1_1.38
36  */
37 class VideoPlayerPlugin
38 {
39 public:
40
41   typedef Signal< void () > VideoPlayerSignalType;
42
43   /**
44    * @brief Video display rotation option
45    * @SINCE_1_1.38
46    * @remarks The option is needed only for window surface rendering target
47    */
48   enum DisplayRotation
49   {
50     ROTATION_NONE,   ///< Display isn't rotated. @SINCE_1_1.38
51     ROTATION_90,     ///< Display is rotated 90 degree. @SINCE_1_1.38
52     ROTATION_180,    ///< Display is rotated 180 degree. @SINCE_1_1.38
53     ROTATION_270     ///< Display is rotated 270 degree. @SINCE_1_1.38
54   };
55
56   /**
57    * @brief Enumeration for video codec type
58    */
59   enum class CodecType
60   {
61     DEFAULT,      ///< Codec which has higher priority as default. Platform selects it. Usually the H/W codec has higher priority than S/W codec if it exist.
62     HW,           ///< H/W codec
63     SW            ///< S/W codec
64   };
65
66   /**
67    * @brief The values of this enum determine how the video should be display mode to the view
68    */
69   struct DisplayMode
70   {
71     enum Type
72     {
73       LETTER_BOX = 0,     /**< Letter box */
74       ORIGIN_SIZE,        /**< Origin size */
75       FULL_SCREEN,        /**< Full-screen */
76       CROPPED_FULL,       /**< Cropped full-screen */
77       ORIGIN_OR_LETTER,   /**< Origin size (if surface size is larger than video size(width/height)) or Letter box (if video size(width/height) is larger than surface size) */
78       DST_ROI             /**< Region of Interest */
79     };
80   };
81
82   /**
83    * @brief Constructor.
84    * @SINCE_1_1.38
85    */
86   VideoPlayerPlugin(){}
87
88   /**
89    * @brief Destructor.
90    * @SINCE_1_1.38
91    */
92   virtual ~VideoPlayerPlugin(){}
93
94   /**
95    * @brief Sets a URL of the video file to play.
96    *
97    * @SINCE_1_1.38
98    * @param [in] url The url of video file
99    */
100   virtual void SetUrl( const std::string& url ) = 0;
101
102   /**
103    * @brief Returns the URL of the video file.
104    * @SINCE_1_1.38
105    * @return Url of string type
106    */
107   virtual std::string GetUrl() = 0;
108
109   /**
110    * @brief Sets the player looping status.
111    * @SINCE_1_1.38
112    *
113    * @param [in] looping The new looping status: true or false
114    */
115   virtual void SetLooping(bool looping) = 0;
116
117   /**
118    * @brief Returns the player looping status.
119    * @SINCE_1_1.38
120    *
121    * @return True if player is looping, false otherwise.
122    */
123   virtual bool IsLooping() = 0;
124
125   /**
126    * @brief Starts the video playback.
127    * @SINCE_1_1.38
128    */
129   virtual void Play() = 0;
130
131   /**
132    * @brief Pauses the video playback.
133    * @SINCE_1_1.38
134    */
135   virtual void Pause() = 0;
136
137   /**
138    * @brief Stops the video playback.
139    * @SINCE_1_1.38
140    */
141   virtual void Stop() = 0;
142
143   /**
144    * @brief Sets the player mute status.
145    * @SINCE_1_1.38
146    * @param[in] mute The new mute status, true is mute.
147    */
148   virtual void SetMute( bool mute ) = 0;
149
150   /**
151    * @brief Returns the player mute status.
152    * @SINCE_1_1.38
153    * @return True if player is mute.
154    */
155   virtual bool IsMuted() = 0;
156
157   /**
158    * @brief Sets the player volume.
159    * @SINCE_1_1.38
160    * @param[in] left The left volume scalar
161    * @param[in] right The right volume scalar
162    */
163   virtual void SetVolume( float left, float right ) = 0;
164
165   /**
166    * @brief Gets current volume factor.
167    * @SINCE_1_1.38
168    * @param[out] left The current left volume scalar
169    * @param[out] right The current right volume scalar
170    */
171   virtual void GetVolume( float& left, float& right ) = 0;
172
173   /**
174    * @brief Sets video rendering target.
175    * @SINCE_1_1.38
176    * @param[in] target The target for video rendering, window surface or native image source
177    */
178   virtual void SetRenderingTarget( Any target ) = 0;
179
180   /**
181    * @brief Sets the position for playback.
182    * @SINCE_1_1.38
183    *
184    * @param[in] millisecond The position for playback
185    */
186   virtual void SetPlayPosition( int millisecond ) = 0;
187
188   /**
189    * @brief Returns the current position in milliseconds.
190    * @SINCE_1_1.38
191    *
192    * @return The current position of playback
193    */
194   virtual int GetPlayPosition() = 0;
195
196   /**
197    * @brief Sets the area of video display.
198    * @SINCE_1_2.46
199    * param[in] area The left-top position and size of the video display area
200    */
201   virtual void SetDisplayArea( DisplayArea area ) = 0;
202
203   /**
204    * @brief Sets video display rotation
205    * @SINCE_1_1.38
206    * @param[in] rotation The rotation of display
207    */
208   virtual void SetDisplayRotation( Dali::VideoPlayerPlugin::DisplayRotation rotation ) = 0;
209
210   /**
211    * @brief Returns rotation of current video display
212    * @SINCE_1_1.38
213    * @return The rotation of current display
214    */
215   virtual Dali::VideoPlayerPlugin::DisplayRotation GetDisplayRotation() = 0;
216
217   /**
218    * @brief Connect to this signal to be notified when a video playback have finished.
219    *
220    * @SINCE_1_1.38
221    * @return A signal object to connect with.
222    */
223   virtual VideoPlayerSignalType& FinishedSignal() = 0;
224
225   /**
226    * @brief Seeks forward by the specified number of milliseconds.
227    *
228    * @SINCE_1_2.46
229    * @param[in] millisecond The position for forward playback
230    */
231   virtual void Forward( int millisecond ) = 0;
232
233   /**
234    * @brief Seeks backward by the specified number of milliseconds.
235    *
236    * @SINCE_1_2.46
237    * @param[in] millisecond The position for backward playback
238    */
239   virtual void Backward( int millisecond ) = 0;
240
241   /**
242    * @brief Checks whether the video texture is supported
243    * @return True if supported, otherwise false.
244    */
245   virtual bool IsVideoTextureSupported() = 0;
246
247   /**
248    * @brief Sets codec type
249    * @param[in] type The CodecType
250    */
251   virtual void SetCodecType( VideoPlayerPlugin::CodecType type ) = 0;
252
253   /**
254    * @brief Gets codec type
255    * @return CodecType
256    */
257   virtual VideoPlayerPlugin::CodecType GetCodecType() const = 0;
258
259   /**
260    * @brief Sets the display mode for playback.
261    * @param[in] mode of playback
262    */
263   virtual void SetDisplayMode( VideoPlayerPlugin::DisplayMode::Type mode ) = 0;
264
265   /**
266    * @brief Returns the current display mode.
267    * @return The current display mode of playback
268    */
269   virtual VideoPlayerPlugin::DisplayMode::Type GetDisplayMode() const = 0;
270
271   /**
272    * @brief Returns the current internal media player.
273    * @return The current internal media player of video player
274    */
275   virtual Any GetMediaPlayer() = 0;
276
277   /**
278    * @brief calls synchronization function in window system
279    * This function is called, the synchronization is started between UI(transparent hole) and video player.
280    */
281   virtual void StartSynchronization() = 0;
282
283   /**
284    * @brief calls desynchronization function in window system
285    * This function is called, the synchronization is finished between UI(transparent hole) and video player.
286    */
287   virtual void FinishSynchronization() = 0;
288
289 };
290
291 } // namespace Dali;
292
293 #endif // DALI_VIDEO_PLAYER_PLUGIN_H