[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 40b7dd8..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/timer.h>
 #include <dali/public-api/adaptor-framework/native-image-source.h>
-#include <dali/devel-api/adaptor-framework/video-player-plugin.h>
+#include <dali/public-api/adaptor-framework/timer.h>
+#include <dali/public-api/animation/constraints.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
@@ -45,22 +47,20 @@ namespace Plugin
 class TizenVideoPlayer : public Dali::VideoPlayerPlugin, public Dali::ConnectionTracker
 {
 public:
-
   /**
    * @brief Video rendering target type
    * @SINCE_1_1.38
    */
   enum RenderingTargetType
   {
-    WindowSurface, ///< HW underlay
-    NativeImage ///< texture stream
+    WINDOW_SURFACE, ///< HW underlay @SINCE_1_9.28
+    NATIVE_IMAGE    ///< texture stream @SINCE_1_9.28
   };
 
   /**
    * @brief Constructor.
-   * @SINCE_1_1.38
    */
-  TizenVideoPlayer();
+  TizenVideoPlayer(Dali::Actor actor, Dali::VideoSyncMode syncMode);
 
   /**
    * @brief Destructor.
@@ -71,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()
@@ -106,7 +106,7 @@ public:
   /**
    * @copydoc Dali::VideoPlayerPlugin::SetMute()
    */
-  virtual void SetMute( bool mute );
+  virtual void SetMute(bool mute);
 
   /**
    * @copydoc Dali::VideoPlayerPlugin::IsMute()
@@ -116,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()
@@ -141,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()
@@ -161,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()
@@ -181,7 +181,7 @@ public:
   /**
    * @brief Dali::VideoPlayer::SetCodecType()
    */
-  void SetCodecType( Dali::VideoPlayerPlugin::CodecType type );
+  void SetCodecType(Dali::VideoPlayerPlugin::CodecType type);
 
   /**
    * @brief Dali::VideoPlayer::GetCodecType()
@@ -191,16 +191,55 @@ public:
   /**
    * @copydoc Dali::VideoPlayerPlugin::SetDisplayMode()
    */
-  void SetDisplayMode(  Dali::VideoPlayerPlugin::DisplayMode::Type mode );
+  void SetDisplayMode(Dali::VideoPlayerPlugin::DisplayMode::Type mode);
 
   /**
    * @copydoc Dali::VideoPlayerPlugin::GetDisplayMode()
    */
   Dali::VideoPlayerPlugin::DisplayMode::Type GetDisplayMode() const;
 
-private:
+  /**
+   * @copydoc Dali::VideoPlayerPlugin::GetMediaPlayer()
+   */
+  Any GetMediaPlayer();
 
   /**
+   * @copydoc Dali::VideoPlayerPlugin::StartSynchronization()
+   */
+  void StartSynchronization();
+
+  /**
+   * @copydoc Dali::VideoPlayerPlugin::FinishSynchronization()
+   */
+  void FinishSynchronization();
+
+  /**
+   * @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();
@@ -208,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
@@ -218,47 +257,69 @@ 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
    */
   void DestroyPlayer();
 
-private:
+  /**
+   * @brief Create Constraint for synchronization
+   */
+  void CreateConstraint();
+
+  /**
+   * @brief Destroy Constraint for synchronization
+   */
+  void DestroyConstraint();
 
-  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
+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
   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
 
-  Ecore_Wl2_Window* mEcoreWlWindow;
+  sound_stream_info_h mStreamInfo;
+  sound_stream_type_e mStreamType;
 
-  bool mAlphaBitChanged; ///< True if underlay rendering initialization changes window alpha
+  player_video_codec_type_ex_e mCodecType;
 
-  player_codec_type_e mCodecType;
+  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;
 
-  sound_stream_info_h mStreamInfo;
-  sound_stream_type_e mStreamType;
-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