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/adaptor-framework/native-image-source.h>
25 #include <dali/devel-api/adaptor-framework/video-player-plugin.h>
32 #include <player_internal.h>
33 #include <Ecore_Wl2.h>
42 * @brief Implementation of the Tizen video player class which has Tizen platform dependency.
45 class TizenVideoPlayer : public Dali::VideoPlayerPlugin, public Dali::ConnectionTracker
50 * @brief Video rendering target type
53 enum RenderingTargetType
55 WindowSurface, ///< HW underlay
56 NativeImage ///< texture stream
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;
204 * @brief Updates video frame image by timer if rendering targe is native image source
209 * @brief Gets current player state
211 void GetPlayerState( player_state_e* state ) const;
214 * @brief Destroy all packests, which this plugin stores
216 void DestroyPackets();
219 * @brief Initializes player for video rendering using native image source
221 void InitializeTextureStreamMode( Dali::NativeImageSourcePtr nativeImageSourcePtr );
224 * @brief Initializes player for video rendering using wayland window surface
226 void InitializeUnderlayMode( Ecore_Wl2_Window* ecoreWlWindow );
229 * @brief Destroys player handle
231 void DestroyPlayer();
235 std::string mUrl; ///< The video file path
236 player_h mPlayer; ///< Tizen player handle
237 player_state_e mPlayerState; ///< Tizen player state
238 tbm_surface_h mTbmSurface; ///< tbm surface handle
239 media_packet_h mPacket; ///< Media packet handle with tbm surface of current video frame image
240 Dali::NativeImageSourcePtr mNativeImageSourcePtr; ///< native image source for video rendering
241 Dali::Timer mTimer; ///< Timer for texture streaming rendering
242 Dali::Vector4 mBackgroundColor; ///< Current background color, which texturestream mode needs.
243 RenderingTargetType mTargetType; ///< Current rendering target type
245 Dali::Mutex mPacketMutex;
246 Dali::Vector< media_packet_h > mPacketVector; ///< Container for media packet handle from Tizen player callback
248 Ecore_Wl2_Window* mEcoreWlWindow;
250 bool mAlphaBitChanged; ///< True if underlay rendering initialization changes window alpha
252 sound_stream_info_h mStreamInfo;
253 sound_stream_type_e mStreamType;
255 player_video_codec_type_ex_e mCodecType;
258 Dali::VideoPlayerPlugin::VideoPlayerSignalType mFinishedSignal;
261 } // namespace Plugin