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