1 #ifndef __DALI_TIZEN_VIDEO_PLAYER_PLUGIN_H__
2 #define __DALI_TIZEN_VIDEO_PLAYER_PLUGIN_H__
5 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/devel-api/adaptor-framework/video-player-plugin.h>
23 #include <dali/devel-api/adaptor-framework/video-sync-mode.h>
24 #include <dali/devel-api/threading/mutex.h>
25 #include <dali/public-api/adaptor-framework/native-image-source.h>
26 #include <dali/public-api/adaptor-framework/timer.h>
27 #include <dali/public-api/animation/constraints.h>
35 #include <Ecore_Wl2.h>
36 #include <player_internal.h>
43 * @brief Implementation of the Tizen video player class which has Tizen platform dependency.
46 class TizenVideoPlayer : public Dali::VideoPlayerPlugin, public Dali::ConnectionTracker
50 * @brief Video rendering target type
53 enum RenderingTargetType
55 WINDOW_SURFACE, ///< HW underlay @SINCE_1_9.28
56 NATIVE_IMAGE ///< texture stream @SINCE_1_9.28
62 TizenVideoPlayer(Dali::Actor actor, Dali::VideoSyncMode syncMode);
68 virtual ~TizenVideoPlayer();
71 * @copydoc Dali::VideoPlayerPlugin::SetUrl()
73 virtual void SetUrl(const std::string& url);
76 * @copydoc Dali::VideoPlayerPlugin::GetUrl()
78 virtual std::string GetUrl();
81 * @copydoc Dali::VideoPlayerPlugin::SetLooping()
83 virtual void SetLooping(bool looping);
86 * @copydoc Dali::VideoPlayerPlugin::IsLooping()
88 virtual bool IsLooping();
91 * @copydoc Dali::VideoPlayerPlugin::Play()
96 * @copydoc Dali::VideoPlayerPlugin::Pause()
101 * @copydoc Dali::VideoPlayerPlugin::Stop()
106 * @copydoc Dali::VideoPlayerPlugin::SetMute()
108 virtual void SetMute(bool mute);
111 * @copydoc Dali::VideoPlayerPlugin::IsMute()
113 virtual bool IsMuted();
116 * @copydoc Dali::VideoPlayerPlugin::SetVolume()
118 virtual void SetVolume(float left, float right);
121 * @copydoc Dali::VideoPlayerPlugin::GetVolume()
123 virtual void GetVolume(float& left, float& right);
126 * @copydoc Dali::VideoPlayerPlugin::SetRenderingTarget()
128 void SetRenderingTarget(Any target);
131 * @copydoc Dali::VideoPlayerPlugin::SetPlayPosition()
133 virtual void SetPlayPosition(int millisecond);
136 * @copydoc Dali::VideoPlayerPlugin::GetPlayPosition()
138 virtual int GetPlayPosition();
141 * @copydoc Dali::VideoPlayerPlugin::SetDisplayArea()
143 virtual void SetDisplayArea(DisplayArea area);
146 * @copydoc Dali::VideoPlayerPlugin::SetDisplayRotation()
148 virtual void SetDisplayRotation(Dali::VideoPlayerPlugin::DisplayRotation rotation);
151 * @copydoc Dali::VideoPlayerPlugin::GetDisplayRotation()
153 virtual Dali::VideoPlayerPlugin::DisplayRotation GetDisplayRotation();
156 * @copydoc Dali::VideoPlayerPlugin::FinishedSignal()
158 virtual Dali::VideoPlayerPlugin::VideoPlayerSignalType& FinishedSignal();
161 * @brief Push media packet with video frame image
163 void PushPacket(media_packet_h packet);
166 * @brief Dali::VideoPlayer::Forward()
168 void Forward(int millisecond);
171 * @brief Dali::VideoPlayer::Backward()
173 void Backward(int millisecond);
176 * @brief Dali::VideoPlayer::IsVideoTextureSupported()
178 bool IsVideoTextureSupported();
181 * @brief Dali::VideoPlayer::SetCodecType()
183 void SetCodecType(Dali::VideoPlayerPlugin::CodecType type);
186 * @brief Dali::VideoPlayer::GetCodecType()
188 Dali::VideoPlayerPlugin::CodecType GetCodecType() const;
191 * @copydoc Dali::VideoPlayerPlugin::SetDisplayMode()
193 void SetDisplayMode(Dali::VideoPlayerPlugin::DisplayMode::Type mode);
196 * @copydoc Dali::VideoPlayerPlugin::GetDisplayMode()
198 Dali::VideoPlayerPlugin::DisplayMode::Type GetDisplayMode() const;
201 * @copydoc Dali::VideoPlayerPlugin::GetMediaPlayer()
203 Any GetMediaPlayer();
206 * @copydoc Dali::VideoPlayerPlugin::StartSynchronization()
208 void StartSynchronization();
211 * @copydoc Dali::VideoPlayerPlugin::FinishSynchronization()
213 void FinishSynchronization();
216 * @copydoc Dali::VideoPlayerPlugin::RaiseAbove()
218 void RaiseAbove(Any videoSurface);
221 * @copydoc Dali::VideoPlayerPlugin::LowerBelow()
223 void LowerBelow(Any videoSurface);
226 * @copydoc Dali::VideoPlayerPlugin::RaiseToTop()
231 * @copydoc Dali::VideoPlayerPlugin::LowerToBottom()
233 void LowerToBottom();
236 * @copydoc Dali::VideoPlayerPlugin::GetVideoPlayerSurface()
238 Any GetVideoPlayerSurface();
242 * @brief Updates video frame image by timer if rendering targe is native image source
247 * @brief Gets current player state
249 void GetPlayerState(player_state_e* state) const;
252 * @brief Destroy all packests, which this plugin stores
254 void DestroyPackets();
257 * @brief Initializes player for video rendering using native image source
259 void InitializeTextureStreamMode(Dali::NativeImageSourcePtr nativeImageSourcePtr);
262 * @brief Initializes player for video rendering using wayland window surface
264 void InitializeUnderlayMode(Ecore_Wl2_Window* ecoreWlWindow);
267 * @brief Initializes player for video rendering with synchronization mode.
269 * @param[in] ecoreWlWindow The window for synchronization mode.
271 void InitializeEnableSyncMode(Ecore_Wl2_Window* ecoreWlWindow);
274 * @brief Destroys player handle
276 void DestroyPlayer();
279 * @brief Create Constraint for synchronization
281 void CreateConstraint();
284 * @brief Destroy Constraint for synchronization
286 void DestroyConstraint();
289 std::string mUrl; ///< The video file path
290 player_h mPlayer; ///< Tizen player handle
291 player_state_e mPlayerState; ///< Tizen player state
292 tbm_surface_h mTbmSurface; ///< tbm surface handle
293 media_packet_h mPacket; ///< Media packet handle with tbm surface of current video frame image
294 Dali::NativeImageSourcePtr mNativeImageSourcePtr; ///< native image source for video rendering
295 Dali::Timer mTimer; ///< Timer for texture streaming rendering
296 Dali::Vector4 mBackgroundColor; ///< Current background color, which texturestream mode needs.
297 RenderingTargetType mTargetType; ///< Current rendering target type
299 Dali::Mutex mPacketMutex;
300 std::list<media_packet_h> mPacketList; ///< Container for media packet handle from Tizen player callback
302 sound_stream_info_h mStreamInfo;
303 sound_stream_type_e mStreamType;
305 player_video_codec_type_ex_e mCodecType;
307 Ecore_Wl2_Window* mEcoreWlWindow; ///< ecore native window handle
308 Ecore_Wl2_Subsurface* mEcoreSubVideoWindow; ///< ecore native subsurface for synchronization with video player
310 Constraint mVideoSizePropertyConstraint;
311 Property::Index mVideoSizePropertyIndex;
312 Dali::VideoSyncMode mSyncMode;
314 bool mIsInitForSyncMode; ///< the flag for synchronization with video player
317 Dali::VideoPlayerPlugin::VideoPlayerSignalType mFinishedSignal;
320 } // namespace Plugin