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>
34 #include <Ecore_Wl2.h>
35 #include <player_internal.h>
42 * @brief Implementation of the Tizen video player class which has Tizen platform dependency.
45 class TizenVideoPlayer : public Dali::VideoPlayerPlugin, public Dali::ConnectionTracker
49 * @brief Video rendering target type
52 enum RenderingTargetType
54 WINDOW_SURFACE, ///< HW underlay @SINCE_1_9.28
55 NATIVE_IMAGE ///< texture stream @SINCE_1_9.28
61 TizenVideoPlayer(Dali::Actor actor, Dali::VideoSyncMode syncMode);
67 virtual ~TizenVideoPlayer();
70 * @copydoc Dali::VideoPlayerPlugin::SetUrl()
72 virtual void SetUrl(const std::string& url);
75 * @copydoc Dali::VideoPlayerPlugin::GetUrl()
77 virtual std::string GetUrl();
80 * @copydoc Dali::VideoPlayerPlugin::SetLooping()
82 virtual void SetLooping(bool looping);
85 * @copydoc Dali::VideoPlayerPlugin::IsLooping()
87 virtual bool IsLooping();
90 * @copydoc Dali::VideoPlayerPlugin::Play()
95 * @copydoc Dali::VideoPlayerPlugin::Pause()
100 * @copydoc Dali::VideoPlayerPlugin::Stop()
105 * @copydoc Dali::VideoPlayerPlugin::SetMute()
107 virtual void SetMute(bool mute);
110 * @copydoc Dali::VideoPlayerPlugin::IsMute()
112 virtual bool IsMuted();
115 * @copydoc Dali::VideoPlayerPlugin::SetVolume()
117 virtual void SetVolume(float left, float right);
120 * @copydoc Dali::VideoPlayerPlugin::GetVolume()
122 virtual void GetVolume(float& left, float& right);
125 * @copydoc Dali::VideoPlayerPlugin::SetRenderingTarget()
127 void SetRenderingTarget(Any target);
130 * @copydoc Dali::VideoPlayerPlugin::SetPlayPosition()
132 virtual void SetPlayPosition(int millisecond);
135 * @copydoc Dali::VideoPlayerPlugin::GetPlayPosition()
137 virtual int GetPlayPosition();
140 * @copydoc Dali::VideoPlayerPlugin::SetDisplayArea()
142 virtual void SetDisplayArea(DisplayArea area);
145 * @copydoc Dali::VideoPlayerPlugin::SetDisplayRotation()
147 virtual void SetDisplayRotation(Dali::VideoPlayerPlugin::DisplayRotation rotation);
150 * @copydoc Dali::VideoPlayerPlugin::GetDisplayRotation()
152 virtual Dali::VideoPlayerPlugin::DisplayRotation GetDisplayRotation();
155 * @copydoc Dali::VideoPlayerPlugin::FinishedSignal()
157 virtual Dali::VideoPlayerPlugin::VideoPlayerSignalType& FinishedSignal();
160 * @brief Push media packet with video frame image
162 void PushPacket(media_packet_h packet);
165 * @brief Dali::VideoPlayer::Forward()
167 void Forward(int millisecond);
170 * @brief Dali::VideoPlayer::Backward()
172 void Backward(int millisecond);
175 * @brief Dali::VideoPlayer::IsVideoTextureSupported()
177 bool IsVideoTextureSupported();
180 * @brief Dali::VideoPlayer::SetCodecType()
182 void SetCodecType(Dali::VideoPlayerPlugin::CodecType type);
185 * @brief Dali::VideoPlayer::GetCodecType()
187 Dali::VideoPlayerPlugin::CodecType GetCodecType() const;
190 * @copydoc Dali::VideoPlayerPlugin::SetDisplayMode()
192 void SetDisplayMode(Dali::VideoPlayerPlugin::DisplayMode::Type mode);
195 * @copydoc Dali::VideoPlayerPlugin::GetDisplayMode()
197 Dali::VideoPlayerPlugin::DisplayMode::Type GetDisplayMode() const;
200 * @copydoc Dali::VideoPlayerPlugin::GetMediaPlayer()
202 Any GetMediaPlayer();
205 * @copydoc Dali::VideoPlayerPlugin::StartSynchronization()
207 void StartSynchronization();
210 * @copydoc Dali::VideoPlayerPlugin::FinishSynchronization()
212 void FinishSynchronization();
215 * @copydoc Dali::VideoPlayerPlugin::RaiseAbove()
217 void RaiseAbove(Any videoSurface);
220 * @copydoc Dali::VideoPlayerPlugin::LowerBelow()
222 void LowerBelow(Any videoSurface);
225 * @copydoc Dali::VideoPlayerPlugin::RaiseToTop()
230 * @copydoc Dali::VideoPlayerPlugin::LowerToBottom()
232 void LowerToBottom();
235 * @copydoc Dali::VideoPlayerPlugin::GetVideoPlayerSurface()
237 Any GetVideoPlayerSurface();
241 * @brief Updates video frame image by timer if rendering targe is native image source
246 * @brief Gets current player state
248 void GetPlayerState(player_state_e* state) const;
251 * @brief Destroy all packests, which this plugin stores
253 void DestroyPackets();
256 * @brief Initializes player for video rendering using native image source
258 void InitializeTextureStreamMode(Dali::NativeImageSourcePtr nativeImageSourcePtr);
261 * @brief Initializes player for video rendering using wayland window surface
263 void InitializeUnderlayMode(Ecore_Wl2_Window* ecoreWlWindow);
266 * @brief Initializes player for video rendering with synchronization mode.
268 * @param[in] ecoreWlWindow The window for synchronization mode.
270 void InitializeEnableSyncMode(Ecore_Wl2_Window* ecoreWlWindow);
273 * @brief Destroys player handle
275 void DestroyPlayer();
278 * @brief Create Constraint for synchronization
280 void CreateConstraint();
283 * @brief Destroy Constraint for synchronization
285 void DestroyConstraint();
288 std::string mUrl; ///< The video file path
289 player_h mPlayer; ///< Tizen player handle
290 player_state_e mPlayerState; ///< Tizen player state
291 tbm_surface_h mTbmSurface; ///< tbm surface handle
292 media_packet_h mPacket; ///< Media packet handle with tbm surface of current video frame image
293 Dali::NativeImageSourcePtr mNativeImageSourcePtr; ///< native image source for video rendering
294 Dali::Timer mTimer; ///< Timer for texture streaming rendering
295 Dali::Vector4 mBackgroundColor; ///< Current background color, which texturestream mode needs.
296 RenderingTargetType mTargetType; ///< Current rendering target type
298 Dali::Mutex mPacketMutex;
299 Dali::Vector<media_packet_h> mPacketVector; ///< Container for media packet handle from Tizen player callback
301 sound_stream_info_h mStreamInfo;
302 sound_stream_type_e mStreamType;
304 player_video_codec_type_ex_e mCodecType;
306 Ecore_Wl2_Window* mEcoreWlWindow; ///< ecore native window handle
307 Ecore_Wl2_Subsurface* mEcoreSubVideoWindow; ///< ecore native subsurface for synchronization with video player
309 Constraint mVideoSizePropertyConstraint;
310 Property::Index mVideoSizePropertyIndex;
311 Dali::VideoSyncMode mSyncMode;
313 bool mIsInitForSyncMode; ///< the flag for synchronization with video player
316 Dali::VideoPlayerPlugin::VideoPlayerSignalType mFinishedSignal;
319 } // namespace Plugin