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>
29 #include <player_internal.h>
30 #include <Ecore_Wayland.h>
33 #include <native-image-source.h>
34 #include <video-player-plugin.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 WindowSurface, ///< HW underlay
58 NativeImage ///< texture stream
71 virtual ~TizenVideoPlayer();
74 * @copydoc Dali::VideoPlayerPlugin::SetUrl()
76 virtual void SetUrl( const std::string& url );
79 * @copydoc Dali::VideoPlayerPlugin::GetUrl()
81 virtual std::string GetUrl();
84 * @copydoc Dali::VideoPlayerPlugin::SetLooping()
86 virtual void SetLooping(bool looping);
89 * @copydoc Dali::VideoPlayerPlugin::IsLooping()
91 virtual bool IsLooping();
94 * @copydoc Dali::VideoPlayerPlugin::Play()
99 * @copydoc Dali::VideoPlayerPlugin::Pause()
101 virtual void Pause();
104 * @copydoc Dali::VideoPlayerPlugin::Stop()
109 * @copydoc Dali::VideoPlayerPlugin::SetMute()
111 virtual void SetMute( bool mute );
114 * @copydoc Dali::VideoPlayerPlugin::IsMute()
116 virtual bool IsMuted();
119 * @copydoc Dali::VideoPlayerPlugin::SetVolume()
121 virtual void SetVolume( float left, float right );
124 * @copydoc Dali::VideoPlayerPlugin::GetVolume()
126 virtual void GetVolume( float& left, float& right );
129 * @copydoc Dali::VideoPlayerPlugin::SetRenderingTarget()
131 void SetRenderingTarget( Any target );
134 * @copydoc Dali::VideoPlayerPlugin::SetPlayPosition()
136 virtual void SetPlayPosition( int millisecond );
139 * @copydoc Dali::VideoPlayerPlugin::GetPlayPosition()
141 virtual int GetPlayPosition();
144 * @copydoc Dali::VideoPlayerPlugin::SetDisplayArea()
146 virtual void SetDisplayArea( DisplayArea area );
149 * @copydoc Dali::VideoPlayerPlugin::SetDisplayRotation()
151 virtual void SetDisplayRotation( Dali::VideoPlayerPlugin::DisplayRotation rotation );
154 * @copydoc Dali::VideoPlayerPlugin::GetDisplayRotation()
156 virtual Dali::VideoPlayerPlugin::DisplayRotation GetDisplayRotation();
159 * @copydoc Dali::VideoPlayerPlugin::FinishedSignal()
161 virtual Dali::VideoPlayerPlugin::VideoPlayerSignalType& FinishedSignal();
164 * @brief Push media packet with video frame image
166 void PushPacket( media_packet_h packet );
169 * @brief Dali::VideoPlayer::Forward()
171 void Forward( int millisecond );
174 * @brief Dali::VideoPlayer::Backward()
176 void Backward( int millisecond );
181 * @brief Updates video frame image by timer if rendering targe is native image source
186 * @brief Gets current player state
188 void GetPlayerState( player_state_e* state );
191 * @brief Destroy all packests, which this plugin stores
193 void DestroyPackets();
196 * @brief Initializes player for video rendering using native image source
198 void InitializeTextureStreamMode( Dali::NativeImageSourcePtr nativeImageSourcePtr );
201 * @brief Initializes player for video rendering using wayland window surface
203 void InitializeUnderlayMode( Ecore_Wl_Window* ecoreWlWindow );
207 std::string mUrl; ///< The video file path
208 player_h mPlayer; ///< Tizen player handle
209 player_state_e mPlayerState; ///< Tizen player state
210 tbm_surface_h mTbmSurface; ///< tbm surface handle
211 media_packet_h mPacket; ///< Media packet handle with tbm surface of current video frame image
212 Dali::NativeImageSourcePtr mNativeImageSourcePtr; ///< native image source for video rendering
213 Dali::Timer mTimer; ///< Timer for texture streaming rendering
214 Dali::Vector4 mBackgroundColor; ///< Current background color, which texturestream mode needs.
215 RenderingTargetType mTargetType; ///< Current rendering target type
217 Dali::Mutex mPacketMutex;
218 Dali::Vector< media_packet_h > mPacketVector; ///< Container for media packet handle from Tizen player callback
220 Ecore_Wl_Window* mEcoreWlWindow;
222 bool mAlphaBitChanged; ///< True if underlay rendering initialization changes window alpha
226 Dali::VideoPlayerPlugin::VideoPlayerSignalType mFinishedSignal;
229 } // namespace Plugin