[Tizen] If you take the handle, you must be responsible for its destruction.
[platform/core/uifw/dali-extension.git] / dali-extension / video-player / ecore-wl2 / tizen-video-player.h
index 4478b1c..03a70b8 100755 (executable)
  */
 
 // EXTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/video-player-plugin.h>
+#include <dali/devel-api/adaptor-framework/video-sync-mode.h>
 #include <dali/devel-api/threading/mutex.h>
+#include <dali/public-api/adaptor-framework/native-image-source.h>
 #include <dali/public-api/adaptor-framework/timer.h>
 #include <dali/public-api/animation/constraints.h>
-#include <dali/public-api/adaptor-framework/native-image-source.h>
-#include <dali/devel-api/adaptor-framework/video-player-plugin.h>
-#include <dali/devel-api/adaptor-framework/video-sync-mode.h>
+#include <dali/public-api/object/weak-handle.h>
 #include <player.h>
 #include <string>
+#include <list>
 
 #ifndef HAVE_WAYLAND
 #define HAVE_WAYLAND
 #endif
-#include <player_internal.h>
 #include <Ecore_Wl2.h>
+#include <player_internal.h>
 
 namespace Dali
 {
-
 namespace Plugin
 {
-
 /**
  * @brief Implementation of the Tizen video player class which has Tizen platform dependency.
  * @SINCE_1_1.38
@@ -47,7 +47,6 @@ namespace Plugin
 class TizenVideoPlayer : public Dali::VideoPlayerPlugin, public Dali::ConnectionTracker
 {
 public:
-
   /**
    * @brief Video rendering target type
    * @SINCE_1_1.38
@@ -55,13 +54,13 @@ public:
   enum RenderingTargetType
   {
     WINDOW_SURFACE, ///< HW underlay @SINCE_1_9.28
-    NATIVE_IMAGE ///< texture stream @SINCE_1_9.28
+    NATIVE_IMAGE    ///< texture stream @SINCE_1_9.28
   };
 
   /**
    * @brief Constructor.
    */
-  TizenVideoPlayer( Dali::Actor actor, Dali::VideoSyncMode syncMode );
+  TizenVideoPlayer(Dali::Actor actor, Dali::VideoSyncMode syncMode);
 
   /**
    * @brief Destructor.
@@ -72,7 +71,7 @@ public:
   /**
    * @copydoc Dali::VideoPlayerPlugin::SetUrl()
    */
-  virtual void SetUrl( const std::string& url );
+  virtual void SetUrl(const std::string& url);
 
   /**
    * @copydoc Dali::VideoPlayerPlugin::GetUrl()
@@ -107,7 +106,7 @@ public:
   /**
    * @copydoc Dali::VideoPlayerPlugin::SetMute()
    */
-  virtual void SetMute( bool mute );
+  virtual void SetMute(bool mute);
 
   /**
    * @copydoc Dali::VideoPlayerPlugin::IsMute()
@@ -117,22 +116,22 @@ public:
   /**
    * @copydoc Dali::VideoPlayerPlugin::SetVolume()
    */
-  virtual void SetVolume( float left, float right );
+  virtual void SetVolume(float left, float right);
 
   /**
    * @copydoc Dali::VideoPlayerPlugin::GetVolume()
    */
-  virtual void GetVolume( float& left, float& right );
+  virtual void GetVolume(float& left, float& right);
 
   /**
    * @copydoc Dali::VideoPlayerPlugin::SetRenderingTarget()
    */
-  void SetRenderingTarget( Any target );
+  void SetRenderingTarget(Any target);
 
   /**
    * @copydoc Dali::VideoPlayerPlugin::SetPlayPosition()
    */
-  virtual void SetPlayPosition( int millisecond );
+  virtual void SetPlayPosition(int millisecond);
 
   /**
    * @copydoc Dali::VideoPlayerPlugin::GetPlayPosition()
@@ -142,12 +141,12 @@ public:
   /**
    * @copydoc Dali::VideoPlayerPlugin::SetDisplayArea()
    */
-  virtual void SetDisplayArea( DisplayArea area );
+  virtual void SetDisplayArea(DisplayArea area);
 
   /**
    * @copydoc Dali::VideoPlayerPlugin::SetDisplayRotation()
    */
-  virtual void SetDisplayRotation( Dali::VideoPlayerPlugin::DisplayRotation rotation );
+  virtual void SetDisplayRotation(Dali::VideoPlayerPlugin::DisplayRotation rotation);
 
   /**
    * @copydoc Dali::VideoPlayerPlugin::GetDisplayRotation()
@@ -162,17 +161,17 @@ public:
   /**
    * @brief Push media packet with video frame image
    */
-  void PushPacket( media_packet_h packet );
+  void PushPacket(media_packet_h packet);
 
   /**
    * @brief Dali::VideoPlayer::Forward()
    */
-  void Forward( int millisecond );
+  void Forward(int millisecond);
 
   /**
    * @brief Dali::VideoPlayer::Backward()
    */
-  void Backward( int millisecond );
+  void Backward(int millisecond);
 
   /**
    * @brief Dali::VideoPlayer::IsVideoTextureSupported()
@@ -182,7 +181,7 @@ public:
   /**
    * @brief Dali::VideoPlayer::SetCodecType()
    */
-  void SetCodecType( Dali::VideoPlayerPlugin::CodecType type );
+  void SetCodecType(Dali::VideoPlayerPlugin::CodecType type);
 
   /**
    * @brief Dali::VideoPlayer::GetCodecType()
@@ -192,7 +191,7 @@ public:
   /**
    * @copydoc Dali::VideoPlayerPlugin::SetDisplayMode()
    */
-  void SetDisplayMode(  Dali::VideoPlayerPlugin::DisplayMode::Type mode );
+  void SetDisplayMode(Dali::VideoPlayerPlugin::DisplayMode::Type mode);
 
   /**
    * @copydoc Dali::VideoPlayerPlugin::GetDisplayMode()
@@ -214,9 +213,33 @@ public:
    */
   void FinishSynchronization();
 
-private:
+  /**
+   * @copydoc Dali::VideoPlayerPlugin::RaiseAbove()
+   */
+  void RaiseAbove(Any videoSurface);
+
+  /**
+   * @copydoc Dali::VideoPlayerPlugin::LowerBelow()
+   */
+  void LowerBelow(Any videoSurface);
 
   /**
+   * @copydoc Dali::VideoPlayerPlugin::RaiseToTop()
+   */
+  void RaiseToTop();
+
+  /**
+   * @copydoc Dali::VideoPlayerPlugin::LowerToBottom()
+   */
+  void LowerToBottom();
+
+  /**
+   * @copydoc Dali::VideoPlayerPlugin::GetVideoPlayerSurface()
+   */
+  Any GetVideoPlayerSurface();
+
+private:
+  /**
    * @brief Updates video frame image by timer if rendering targe is native image source
    */
   bool Update();
@@ -224,7 +247,7 @@ private:
   /**
    * @brief Gets current player state
    */
-  void GetPlayerState( player_state_e* state ) const;
+  void GetPlayerState(player_state_e* state) const;
 
   /**
    * @brief Destroy all packests, which this plugin stores
@@ -234,12 +257,19 @@ private:
   /**
    * @brief Initializes player for video rendering using native image source
    */
-  void InitializeTextureStreamMode( Dali::NativeImageSourcePtr nativeImageSourcePtr );
+  void InitializeTextureStreamMode(Dali::NativeImageSourcePtr nativeImageSourcePtr);
 
   /**
    * @brief Initializes player for video rendering using wayland window surface
    */
-  void InitializeUnderlayMode( Ecore_Wl2_Window* ecoreWlWindow );
+  void InitializeUnderlayMode(Ecore_Wl2_Window* ecoreWlWindow);
+
+  /**
+   * @brief Initializes player for video rendering with synchronization mode.
+   *
+   * @param[in] ecoreWlWindow The window for synchronization mode.
+   */
+  void InitializeEnableSyncMode(Ecore_Wl2_Window* ecoreWlWindow);
 
   /**
    * @brief Destroys player handle
@@ -257,37 +287,39 @@ private:
   void DestroyConstraint();
 
 private:
-
-  std::string mUrl; ///< The video file path
-  player_h mPlayer; ///< Tizen player handle
-  player_state_e mPlayerState; ///< Tizen player state
-  tbm_surface_h mTbmSurface; ///< tbm surface handle
-  media_packet_h mPacket; ///< Media packet handle with tbm surface of current video frame image
+  std::string                mUrl;                  ///< The video file path
+  player_h                   mPlayer;               ///< Tizen player handle
+  player_state_e             mPlayerState;          ///< Tizen player state
+  tbm_surface_h              mTbmSurface;           ///< tbm surface handle
+  media_packet_h             mPacket;               ///< Media packet handle with tbm surface of current video frame image
   Dali::NativeImageSourcePtr mNativeImageSourcePtr; ///< native image source for video rendering
-  Dali::Timer mTimer; ///< Timer for texture streaming rendering
-  Dali::Vector4 mBackgroundColor; ///< Current background color, which texturestream mode needs.
-  RenderingTargetType mTargetType; ///< Current rendering target type
+  Dali::Timer                mTimer;                ///< Timer for texture streaming rendering
+  Dali::Vector4              mBackgroundColor;      ///< Current background color, which texturestream mode needs.
+  RenderingTargetType        mTargetType;           ///< Current rendering target type
 
-  Dali::Mutex mPacketMutex;
-  Dali::Vector< media_packet_h > mPacketVector; ///< Container for media packet handle from Tizen player callback
+  Dali::Mutex                mPacketMutex;
+  std::list<media_packet_h>  mPacketList;           ///< Container for media packet handle from Tizen player callback
 
   sound_stream_info_h mStreamInfo;
   sound_stream_type_e mStreamType;
 
   player_video_codec_type_ex_e mCodecType;
 
-  Ecore_Wl2_Window*                              mEcoreWlWindow;
-  Actor                                          mSyncActor;
-  Constraint                                     mVideoSizePropertyConstraint;
-  Property::Index                                mVideoSizePropertyIndex;
-  Dali::VideoSyncMode                            mSyncMode;
+  Ecore_Wl2_Window*             mEcoreWlWindow;       ///< ecore native window handle
+  Ecore_Wl2_Subsurface*         mEcoreSubVideoWindow; ///< ecore native subsurface for synchronization with video player
+  Dali::WeakHandle<Dali::Actor> mSyncActor;
+  Constraint                    mVideoSizePropertyConstraint;
+  Property::Index               mVideoSizePropertyIndex;
+  Dali::VideoSyncMode           mSyncMode;
 
-public:
+  bool mIsInitForSyncMode; ///< the flag for synchronization with video player
+  bool mIsMovedHandle;     ///< the flag for moved the handle
 
+public:
   Dali::VideoPlayerPlugin::VideoPlayerSignalType mFinishedSignal;
 };
 
 } // namespace Plugin
-} // namespace Dali;
+} // namespace Dali
 
 #endif