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/threading/mutex.h>
23 #include <dali/public-api/adaptor-framework/timer.h>
24 #include <dali/public-api/animation/constraints.h>
25 #include <dali/public-api/adaptor-framework/native-image-source.h>
26 #include <dali/devel-api/adaptor-framework/video-player-plugin.h>
27 #include <dali/devel-api/adaptor-framework/video-sync-mode.h>
34 #include <player_internal.h>
35 #include <Ecore_Wl2.h>
44 * @brief Implementation of the Tizen video player class which has Tizen platform dependency.
47 class TizenVideoPlayer : public Dali::VideoPlayerPlugin, public Dali::ConnectionTracker
52 * @brief Video rendering target type
55 enum RenderingTargetType
57 WINDOW_SURFACE, ///< HW underlay @SINCE_1_9.28
58 NATIVE_IMAGE ///< texture stream @SINCE_1_9.28
64 TizenVideoPlayer( Dali::Actor actor, Dali::VideoSyncMode syncMode );
70 virtual ~TizenVideoPlayer();
73 * @copydoc Dali::VideoPlayerPlugin::SetUrl()
75 virtual void SetUrl( const std::string& url );
78 * @copydoc Dali::VideoPlayerPlugin::GetUrl()
80 virtual std::string GetUrl();
83 * @copydoc Dali::VideoPlayerPlugin::SetLooping()
85 virtual void SetLooping(bool looping);
88 * @copydoc Dali::VideoPlayerPlugin::IsLooping()
90 virtual bool IsLooping();
93 * @copydoc Dali::VideoPlayerPlugin::Play()
98 * @copydoc Dali::VideoPlayerPlugin::Pause()
100 virtual void Pause();
103 * @copydoc Dali::VideoPlayerPlugin::Stop()
108 * @copydoc Dali::VideoPlayerPlugin::SetMute()
110 virtual void SetMute( bool mute );
113 * @copydoc Dali::VideoPlayerPlugin::IsMute()
115 virtual bool IsMuted();
118 * @copydoc Dali::VideoPlayerPlugin::SetVolume()
120 virtual void SetVolume( float left, float right );
123 * @copydoc Dali::VideoPlayerPlugin::GetVolume()
125 virtual void GetVolume( float& left, float& right );
128 * @copydoc Dali::VideoPlayerPlugin::SetRenderingTarget()
130 void SetRenderingTarget( Any target );
133 * @copydoc Dali::VideoPlayerPlugin::SetPlayPosition()
135 virtual void SetPlayPosition( int millisecond );
138 * @copydoc Dali::VideoPlayerPlugin::GetPlayPosition()
140 virtual int GetPlayPosition();
143 * @copydoc Dali::VideoPlayerPlugin::SetDisplayArea()
145 virtual void SetDisplayArea( DisplayArea area );
148 * @copydoc Dali::VideoPlayerPlugin::SetDisplayRotation()
150 virtual void SetDisplayRotation( Dali::VideoPlayerPlugin::DisplayRotation rotation );
153 * @copydoc Dali::VideoPlayerPlugin::GetDisplayRotation()
155 virtual Dali::VideoPlayerPlugin::DisplayRotation GetDisplayRotation();
158 * @copydoc Dali::VideoPlayerPlugin::FinishedSignal()
160 virtual Dali::VideoPlayerPlugin::VideoPlayerSignalType& FinishedSignal();
163 * @brief Push media packet with video frame image
165 void PushPacket( media_packet_h packet );
168 * @brief Dali::VideoPlayer::Forward()
170 void Forward( int millisecond );
173 * @brief Dali::VideoPlayer::Backward()
175 void Backward( int millisecond );
178 * @brief Dali::VideoPlayer::IsVideoTextureSupported()
180 bool IsVideoTextureSupported();
183 * @brief Dali::VideoPlayer::SetCodecType()
185 void SetCodecType( Dali::VideoPlayerPlugin::CodecType type );
188 * @brief Dali::VideoPlayer::GetCodecType()
190 Dali::VideoPlayerPlugin::CodecType GetCodecType() const;
193 * @copydoc Dali::VideoPlayerPlugin::SetDisplayMode()
195 void SetDisplayMode( Dali::VideoPlayerPlugin::DisplayMode::Type mode );
198 * @copydoc Dali::VideoPlayerPlugin::GetDisplayMode()
200 Dali::VideoPlayerPlugin::DisplayMode::Type GetDisplayMode() const;
203 * @copydoc Dali::VideoPlayerPlugin::GetMediaPlayer()
205 Any GetMediaPlayer();
208 * @copydoc Dali::VideoPlayerPlugin::StartSynchronization()
210 void StartSynchronization();
213 * @copydoc Dali::VideoPlayerPlugin::FinishSynchronization()
215 void FinishSynchronization();
220 * @brief Updates video frame image by timer if rendering targe is native image source
225 * @brief Gets current player state
227 void GetPlayerState( player_state_e* state ) const;
230 * @brief Destroy all packests, which this plugin stores
232 void DestroyPackets();
235 * @brief Initializes player for video rendering using native image source
237 void InitializeTextureStreamMode( Dali::NativeImageSourcePtr nativeImageSourcePtr );
240 * @brief Initializes player for video rendering using wayland window surface
242 void InitializeUnderlayMode( Ecore_Wl2_Window* ecoreWlWindow );
245 * @brief Initializes player for video rendering with synchronization mode.
247 * @param[in] ecoreWlWindow The window for synchronization mode.
249 void InitializeEnableSyncMode( Ecore_Wl2_Window* ecoreWlWindow );
252 * @brief Destroys player handle
254 void DestroyPlayer();
257 * @brief Create Constraint for synchronization
259 void CreateConstraint();
262 * @brief Destroy Constraint for synchronization
264 void DestroyConstraint();
268 std::string mUrl; ///< The video file path
269 player_h mPlayer; ///< Tizen player handle
270 player_state_e mPlayerState; ///< Tizen player state
271 tbm_surface_h mTbmSurface; ///< tbm surface handle
272 media_packet_h mPacket; ///< Media packet handle with tbm surface of current video frame image
273 Dali::NativeImageSourcePtr mNativeImageSourcePtr; ///< native image source for video rendering
274 Dali::Timer mTimer; ///< Timer for texture streaming rendering
275 Dali::Vector4 mBackgroundColor; ///< Current background color, which texturestream mode needs.
276 RenderingTargetType mTargetType; ///< Current rendering target type
278 Dali::Mutex mPacketMutex;
279 Dali::Vector< media_packet_h > mPacketVector; ///< Container for media packet handle from Tizen player callback
281 sound_stream_info_h mStreamInfo;
282 sound_stream_type_e mStreamType;
284 player_video_codec_type_ex_e mCodecType;
286 Ecore_Wl2_Window* mEcoreWlWindow; ///< ecore native window handle
287 Ecore_Wl2_Subsurface* mEcoreSubVideoWindow; ///< ecore native subsurface for synchronization with video player
289 Constraint mVideoSizePropertyConstraint;
290 Property::Index mVideoSizePropertyIndex;
291 Dali::VideoSyncMode mSyncMode;
293 bool mIsInitForSyncMode; ///< the flag for synchronization with video player
297 Dali::VideoPlayerPlugin::VideoPlayerSignalType mFinishedSignal;
300 } // namespace Plugin