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();
246 void FrameCallback(int32_t frameId);
249 * @brief Updates video frame image by timer if rendering targe is native image source
254 * @brief Gets current player state
256 void GetPlayerState(player_state_e* state) const;
259 * @brief Destroy all packests, which this plugin stores
261 void DestroyPackets();
264 * @brief Initializes player for video rendering using native image source
266 void InitializeTextureStreamMode(Dali::NativeImageSourcePtr nativeImageSourcePtr);
269 * @brief Initializes player for video rendering using wayland window surface
271 void InitializeUnderlayMode(Ecore_Wl2_Window* ecoreWlWindow);
274 * @brief Initializes player for video rendering with synchronization mode.
276 * @param[in] ecoreWlWindow The window for synchronization mode.
278 void InitializeEnableSyncMode(Ecore_Wl2_Window* ecoreWlWindow);
281 * @brief Destroys player handle
283 void DestroyPlayer();
286 * @brief Create Constraint for synchronization
288 void CreateConstraint();
291 * @brief Destroy Constraint for synchronization
293 void DestroyConstraint();
296 std::string mUrl; ///< The video file path
297 player_h mPlayer; ///< Tizen player handle
298 player_state_e mPlayerState; ///< Tizen player state
299 tbm_surface_h mTbmSurface; ///< tbm surface handle
300 media_packet_h mPacket; ///< Media packet handle with tbm surface of current video frame image
301 Dali::NativeImageSourcePtr mNativeImageSourcePtr; ///< native image source for video rendering
302 Dali::Timer mTimer; ///< Timer for texture streaming rendering
303 Dali::Vector4 mBackgroundColor; ///< Current background color, which texturestream mode needs.
304 RenderingTargetType mTargetType; ///< Current rendering target type
306 Dali::Mutex mPacketMutex;
307 std::list<media_packet_h> mPacketList; ///< Container for media packet handle from Tizen player callback
308 std::list<media_packet_h> mDeletePacketList; ///< Container for media packet handle from Tizen player callback
310 sound_stream_info_h mStreamInfo;
311 sound_stream_type_e mStreamType;
313 player_video_codec_type_ex_e mCodecType;
315 Ecore_Wl2_Window* mEcoreWlWindow; ///< ecore native window handle
316 Ecore_Wl2_Subsurface* mEcoreSubVideoWindow; ///< ecore native subsurface for synchronization with video player
318 Constraint mVideoSizePropertyConstraint;
319 Property::Index mVideoSizePropertyIndex;
320 Dali::VideoSyncMode mSyncMode;
322 bool mIsInitForSyncMode; ///< the flag for synchronization with video player
326 Dali::VideoPlayerPlugin::VideoPlayerSignalType mFinishedSignal;
329 } // namespace Plugin