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>
28 #include <dali/public-api/object/weak-handle.h>
36 #include <Ecore_Wl2.h>
37 #include <player_internal.h>
44 * @brief Implementation of the Tizen video player class which has Tizen platform dependency.
47 class TizenVideoPlayer : public Dali::VideoPlayerPlugin, public Dali::ConnectionTracker
51 * @brief Video rendering target type
54 enum RenderingTargetType
56 WINDOW_SURFACE, ///< HW underlay @SINCE_1_9.28
57 NATIVE_IMAGE ///< texture stream @SINCE_1_9.28
63 TizenVideoPlayer(Dali::Actor actor, Dali::VideoSyncMode syncMode);
69 virtual ~TizenVideoPlayer();
72 * @copydoc Dali::VideoPlayerPlugin::SetUrl()
74 virtual void SetUrl(const std::string& url);
77 * @copydoc Dali::VideoPlayerPlugin::GetUrl()
79 virtual std::string GetUrl();
82 * @copydoc Dali::VideoPlayerPlugin::SetLooping()
84 virtual void SetLooping(bool looping);
87 * @copydoc Dali::VideoPlayerPlugin::IsLooping()
89 virtual bool IsLooping();
92 * @copydoc Dali::VideoPlayerPlugin::Play()
97 * @copydoc Dali::VideoPlayerPlugin::Pause()
102 * @copydoc Dali::VideoPlayerPlugin::Stop()
107 * @copydoc Dali::VideoPlayerPlugin::SetMute()
109 virtual void SetMute(bool mute);
112 * @copydoc Dali::VideoPlayerPlugin::IsMute()
114 virtual bool IsMuted();
117 * @copydoc Dali::VideoPlayerPlugin::SetVolume()
119 virtual void SetVolume(float left, float right);
122 * @copydoc Dali::VideoPlayerPlugin::GetVolume()
124 virtual void GetVolume(float& left, float& right);
127 * @copydoc Dali::VideoPlayerPlugin::SetRenderingTarget()
129 void SetRenderingTarget(Any target);
132 * @copydoc Dali::VideoPlayerPlugin::SetPlayPosition()
134 virtual void SetPlayPosition(int millisecond);
137 * @copydoc Dali::VideoPlayerPlugin::GetPlayPosition()
139 virtual int GetPlayPosition();
142 * @copydoc Dali::VideoPlayerPlugin::SetDisplayArea()
144 virtual void SetDisplayArea(DisplayArea area);
147 * @copydoc Dali::VideoPlayerPlugin::SetDisplayRotation()
149 virtual void SetDisplayRotation(Dali::VideoPlayerPlugin::DisplayRotation rotation);
152 * @copydoc Dali::VideoPlayerPlugin::GetDisplayRotation()
154 virtual Dali::VideoPlayerPlugin::DisplayRotation GetDisplayRotation();
157 * @copydoc Dali::VideoPlayerPlugin::FinishedSignal()
159 virtual Dali::VideoPlayerPlugin::VideoPlayerSignalType& FinishedSignal();
162 * @brief Push media packet with video frame image
164 void PushPacket(media_packet_h packet);
167 * @brief Dali::VideoPlayer::Forward()
169 void Forward(int millisecond);
172 * @brief Dali::VideoPlayer::Backward()
174 void Backward(int millisecond);
177 * @brief Dali::VideoPlayer::IsVideoTextureSupported()
179 bool IsVideoTextureSupported();
182 * @brief Dali::VideoPlayer::SetCodecType()
184 void SetCodecType(Dali::VideoPlayerPlugin::CodecType type);
187 * @brief Dali::VideoPlayer::GetCodecType()
189 Dali::VideoPlayerPlugin::CodecType GetCodecType() const;
192 * @copydoc Dali::VideoPlayerPlugin::SetDisplayMode()
194 void SetDisplayMode(Dali::VideoPlayerPlugin::DisplayMode::Type mode);
197 * @copydoc Dali::VideoPlayerPlugin::GetDisplayMode()
199 Dali::VideoPlayerPlugin::DisplayMode::Type GetDisplayMode() const;
202 * @copydoc Dali::VideoPlayerPlugin::GetMediaPlayer()
204 Any GetMediaPlayer();
207 * @copydoc Dali::VideoPlayerPlugin::StartSynchronization()
209 void StartSynchronization();
212 * @copydoc Dali::VideoPlayerPlugin::FinishSynchronization()
214 void FinishSynchronization();
217 * @copydoc Dali::VideoPlayerPlugin::RaiseAbove()
219 void RaiseAbove(Any videoSurface);
222 * @copydoc Dali::VideoPlayerPlugin::LowerBelow()
224 void LowerBelow(Any videoSurface);
227 * @copydoc Dali::VideoPlayerPlugin::RaiseToTop()
232 * @copydoc Dali::VideoPlayerPlugin::LowerToBottom()
234 void LowerToBottom();
237 * @copydoc Dali::VideoPlayerPlugin::GetVideoPlayerSurface()
239 Any GetVideoPlayerSurface();
243 * @brief Updates video frame image by timer if rendering targe is native image source
248 * @brief Gets current player state
250 void GetPlayerState(player_state_e* state) const;
253 * @brief Destroy all packests, which this plugin stores
255 void DestroyPackets();
258 * @brief Initializes player for video rendering using native image source
260 void InitializeTextureStreamMode(Dali::NativeImageSourcePtr nativeImageSourcePtr);
263 * @brief Initializes player for video rendering using wayland window surface
265 void InitializeUnderlayMode(Ecore_Wl2_Window* ecoreWlWindow);
268 * @brief Initializes player for video rendering with synchronization mode.
270 * @param[in] ecoreWlWindow The window for synchronization mode.
272 void InitializeEnableSyncMode(Ecore_Wl2_Window* ecoreWlWindow);
275 * @brief Destroys player handle
277 void DestroyPlayer();
280 * @brief Create Constraint for synchronization
282 void CreateConstraint();
285 * @brief Destroy Constraint for synchronization
287 void DestroyConstraint();
290 std::string mUrl; ///< The video file path
291 player_h mPlayer; ///< Tizen player handle
292 player_state_e mPlayerState; ///< Tizen player state
293 tbm_surface_h mTbmSurface; ///< tbm surface handle
294 media_packet_h mPacket; ///< Media packet handle with tbm surface of current video frame image
295 Dali::NativeImageSourcePtr mNativeImageSourcePtr; ///< native image source for video rendering
296 Dali::Timer mTimer; ///< Timer for texture streaming rendering
297 Dali::Vector4 mBackgroundColor; ///< Current background color, which texturestream mode needs.
298 RenderingTargetType mTargetType; ///< Current rendering target type
300 Dali::Mutex mPacketMutex;
301 std::list<media_packet_h> mPacketList; ///< Container for media packet handle from Tizen player callback
303 sound_stream_info_h mStreamInfo;
304 sound_stream_type_e mStreamType;
306 player_video_codec_type_ex_e mCodecType;
308 Ecore_Wl2_Window* mEcoreWlWindow; ///< ecore native window handle
309 Ecore_Wl2_Subsurface* mEcoreSubVideoWindow; ///< ecore native subsurface for synchronization with video player
310 Dali::WeakHandle<Dali::Actor> mSyncActor;
311 Constraint mVideoSizePropertyConstraint;
312 Property::Index mVideoSizePropertyIndex;
313 Dali::VideoSyncMode mSyncMode;
315 bool mIsInitForSyncMode; ///< the flag for synchronization with video player
316 bool mIsMovedHandle; ///< the flag for moved the handle
319 Dali::VideoPlayerPlugin::VideoPlayerSignalType mFinishedSignal;
322 } // namespace Plugin