From ee0a1565d8a52fafc20e2c5beab39db93dcd427b Mon Sep 17 00:00:00 2001 From: "taeyoon0.lee" Date: Fri, 12 Jan 2018 21:36:25 +0900 Subject: [PATCH] Added APIs for codec and seek in VideoView Change-Id: Ib8ccab9464a703444f6a5c65ab0fe3d911c777af --- .../toolkit-video-player.cpp | 26 ++++++++++- .../src/dali-toolkit/utc-Dali-VideoView.cpp | 54 ++++++++++++++++++++++ build/tizen/docs/dali.doxy.in | 2 + .../controls/video-view/video-view-impl.cpp | 39 ++++++++++++++++ .../internal/controls/video-view/video-view-impl.h | 15 ++++++ .../public-api/controls/video-view/video-view.cpp | 15 ++++++ .../public-api/controls/video-view/video-view.h | 35 +++++++++++++- 7 files changed, 182 insertions(+), 4 deletions(-) diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-video-player.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-video-player.cpp index e7fb2cf..6e539eb 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-video-player.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-video-player.cpp @@ -37,6 +37,7 @@ public: { mMuted = false; mLooping = false; + mPlayPosition = 0; } void SetMuted( bool muted ) @@ -67,6 +68,16 @@ public: } } + int GetPlayPosition() + { + return mPlayPosition; + } + + void SetPlayPosition( int pos ) + { + mPlayPosition = pos; + } + public: std::string mUrl; @@ -78,6 +89,7 @@ private: bool mMuted; bool mLooping; + int mPlayPosition; }; inline VideoPlayer& GetImplementation( Dali::VideoPlayer& player ) @@ -201,11 +213,12 @@ void VideoPlayer::SetRenderingTarget( Any target ) void VideoPlayer::SetPlayPosition( int millisecond ) { + Internal::Adaptor::GetImplementation( *this ).SetPlayPosition( millisecond ); } int VideoPlayer::GetPlayPosition() { - return 0; + return Internal::Adaptor::GetImplementation( *this ).GetPlayPosition(); } void VideoPlayer::SetDisplayArea( DisplayArea area ) @@ -234,10 +247,19 @@ void VideoPlayer::Backward( int millisecond ) { } -bool VideoPlayer::IsVideoTextureSupported() const +bool VideoPlayer::IsVideoTextureSupported() { return ToolkitApplication::DECODED_IMAGES_SUPPORTED; } +void VideoPlayer::SetCodecType( Dali::VideoPlayerPlugin::CodecType type ) +{ +} + +Dali::VideoPlayerPlugin::CodecType VideoPlayer::GetCodecType() const +{ + return Dali::VideoPlayerPlugin::CodecType::DEFAULT; +} + } // namespace Dali; diff --git a/automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp index 8baed37..4ea5bd3 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp @@ -409,6 +409,7 @@ int UtcDaliVideoViewMethodsForCoverage2(void) int UtcDaliVideoViewPropertyUnderlay(void) { ToolkitTestApplication application; + tet_infoline("UtcDaliVideoViewPropertyUnderlay"); ToolkitApplication::DECODED_IMAGES_SUPPORTED = true; VideoView view = VideoView::New(); @@ -453,3 +454,56 @@ int UtcDaliVideoViewPropertyUnderlay(void) END_TEST; } + +int UtcDaliVideoViewPropertyPlayPosition(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliVideoViewPropertyPlayPosition"); + + VideoView view = VideoView::New(); + DALI_TEST_CHECK( view ); + + Stage::GetCurrent().Add( view ); + view.Play(); + + application.SendNotification(); + application.Render(); + + int playPos = view.GetProperty( Toolkit::VideoView::Property::PLAY_POSITION ).Get< int >(); + DALI_TEST_CHECK( playPos == 0 ); + + view.SetProperty( Toolkit::VideoView::Property::PLAY_POSITION, 10 ); + playPos = view.GetProperty( Toolkit::VideoView::Property::PLAY_POSITION ).Get< int >(); + // Actually setting play position will be async + // Actual platform result may be different. + DALI_TEST_CHECK( playPos == 10 ); + + END_TEST; +} + +// For coverage. +int UtcDaliVideoViewNew2(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliVideoViewNew2"); + + VideoView view = VideoView::New( true ); + DALI_TEST_CHECK( view ); + + Stage::GetCurrent().Add( view ); + view.Play(); + + application.SendNotification(); + application.Render(); + + VideoView view2 = VideoView::New( "", false ); + DALI_TEST_CHECK( view2 ); + + Stage::GetCurrent().Add( view2 ); + view2.Play(); + + application.SendNotification(); + application.Render(); + + END_TEST; +} diff --git a/build/tizen/docs/dali.doxy.in b/build/tizen/docs/dali.doxy.in index 354478a..f95ad4a 100644 --- a/build/tizen/docs/dali.doxy.in +++ b/build/tizen/docs/dali.doxy.in @@ -357,6 +357,7 @@ ALIASES += SINCE_1_2_32="@since 1.2.32" # Extra tags for Tizen 4.0 ALIASES += SINCE_1_3_4="@since 1.3.4" ALIASES += SINCE_1_3_5="@since 1.3.5" +ALIASES += SINCE_1_3_9="@since 1.3.9" ALIASES += DEPRECATED_1_0="@deprecated Deprecated since 1.0" ALIASES += DEPRECATED_1_1="@deprecated Deprecated since 1.1" @@ -391,6 +392,7 @@ ALIASES += REMARK_RAWVIDEO="" ## Extra tags for Tizen 4.0 #ALIASES += SINCE_1_3_4="\par Since:\n 4.0, DALi version 1.3.4" #ALIASES += SINCE_1_3_5="\par Since:\n 4.0, DALi version 1.3.5" +#ALIASES += SINCE_1_3_9="\par Since:\n 4.0, DALi version 1.3.9" ## DALi has no deprecated API in Tizen 2.4 because it's DALi's first release. ## Thus deprecated APIs in DALi 1.0.xx will be deprecated in Tizen 3.0. diff --git a/dali-toolkit/internal/controls/video-view/video-view-impl.cpp b/dali-toolkit/internal/controls/video-view/video-view-impl.cpp index 25dff01..5876633 100644 --- a/dali-toolkit/internal/controls/video-view/video-view-impl.cpp +++ b/dali-toolkit/internal/controls/video-view/video-view-impl.cpp @@ -63,6 +63,7 @@ DALI_PROPERTY_REGISTRATION( Toolkit, VideoView, "looping", BOOLEAN, LOOPING ) DALI_PROPERTY_REGISTRATION( Toolkit, VideoView, "muted", BOOLEAN, MUTED ) DALI_PROPERTY_REGISTRATION( Toolkit, VideoView, "volume", MAP, VOLUME ) DALI_PROPERTY_REGISTRATION( Toolkit, VideoView, "underlay", BOOLEAN, UNDERLAY ) +DALI_PROPERTY_REGISTRATION( Toolkit, VideoView, "playPosition", INTEGER, PLAY_POSITION ) DALI_SIGNAL_REGISTRATION( Toolkit, VideoView, "finished", FINISHED_SIGNAL ) @@ -451,6 +452,15 @@ void VideoView::SetProperty( BaseObject* object, Property::Index index, const Pr } break; } + case Toolkit::VideoView::Property::PLAY_POSITION: + { + int pos; + if( value.Get( pos ) ) + { + impl.SetPlayPosition( pos ); + } + break; + } } } } @@ -504,6 +514,11 @@ Property::Value VideoView::GetProperty( BaseObject* object, Property::Index prop value = impl.IsUnderlay(); break; } + case Toolkit::VideoView::Property::PLAY_POSITION: + { + value = impl.GetPlayPosition(); + break; + } } } @@ -724,6 +739,30 @@ bool VideoView::IsUnderlay() return mIsUnderlay; } +void VideoView::SetSWCodec( bool on ) +{ + // If setting SW or HW type is failed , video-view shows video by default codec type. + // The default codec type is selected by platform. + if( on ) + { + mVideoPlayer.SetCodecType( Dali::VideoPlayerPlugin::CodecType::SW ); + } + else + { + mVideoPlayer.SetCodecType( Dali::VideoPlayerPlugin::CodecType::HW ); + } +} + +int VideoView::GetPlayPosition() +{ + return mVideoPlayer.GetPlayPosition(); +} + +void VideoView::SetPlayPosition( int pos ) +{ + mVideoPlayer.SetPlayPosition( pos ); +} + } // namespace Internal } // namespace toolkit diff --git a/dali-toolkit/internal/controls/video-view/video-view-impl.h b/dali-toolkit/internal/controls/video-view/video-view-impl.h index 5f85a3f..1f58785 100644 --- a/dali-toolkit/internal/controls/video-view/video-view-impl.h +++ b/dali-toolkit/internal/controls/video-view/video-view-impl.h @@ -224,6 +224,21 @@ public: */ bool IsUnderlay(); + /** + * @brief Sets sw codec type. + */ + void SetSWCodec( bool on ); + + /** + * @brief Gets play position. + */ + int GetPlayPosition(); + + /** + * @brief Sets play position. + */ + void SetPlayPosition( int pos ); + private: // From Control /** diff --git a/dali-toolkit/public-api/controls/video-view/video-view.cpp b/dali-toolkit/public-api/controls/video-view/video-view.cpp index 7a0aa1d..e709a58 100644 --- a/dali-toolkit/public-api/controls/video-view/video-view.cpp +++ b/dali-toolkit/public-api/controls/video-view/video-view.cpp @@ -65,6 +65,21 @@ VideoView VideoView::New( const std::string& url ) return videoView; } +VideoView VideoView::New( bool swCodec ) +{ + VideoView videoView = Internal::VideoView::New(); + Dali::Toolkit::GetImpl( videoView ).SetSWCodec( swCodec ); + return videoView; +} + +VideoView VideoView::New( const std::string& url, bool swCodec ) +{ + VideoView videoView = Internal::VideoView::New(); + Dali::Toolkit::GetImpl( videoView ).SetUrl( url ); + Dali::Toolkit::GetImpl( videoView ).SetSWCodec( swCodec ); + return videoView; +} + VideoView VideoView::DownCast( BaseHandle handle ) { return Control::DownCast< VideoView, Internal::VideoView >( handle ); diff --git a/dali-toolkit/public-api/controls/video-view/video-view.h b/dali-toolkit/public-api/controls/video-view/video-view.h index 5f25a9f..0933801 100644 --- a/dali-toolkit/public-api/controls/video-view/video-view.h +++ b/dali-toolkit/public-api/controls/video-view/video-view.h @@ -115,7 +115,14 @@ public: * @SINCE_1_2.62 * @REMARK_RAWVIDEO */ - UNDERLAY + UNDERLAY, + + /** + * @brief The play position (millisecond) of the video. + * @details Name "playPosition", type Property::INTEGER + * @SINCE_1_3_9 + */ + PLAY_POSITION }; }; @@ -126,7 +133,6 @@ public: * @SINCE_1_1.38 * @return A handle to a newly allocated Dali ImageView * - * @note VideoView will not display anything */ static VideoView New(); @@ -143,6 +149,31 @@ public: static VideoView New( const std::string& url ); /** + * @brief Creates an initialized VideoView. + * @SINCE_1_3_9 + * @param[in] swCodec Video rendering by H/W codec if false + * @return A handle to a newly allocated Dali ImageView + * + * @note If platform or target does not support sw codec, video-view shows an error message and video by default codec type + */ + static VideoView New( bool swCodec ); + + /** + * @brief Creates an initialized VideoView. + * If the string is empty, VideoView will not display anything. + * + * @SINCE_1_3_9 + * @REMARK_INTERNET + * @REMARK_STORAGE + * @param[in] url The url of the video resource to display + * @param[in] swCodec Video rendering by H/W codec if false + * @return A handle to a newly allocated Dali VideoView + * + * @note If platform or target does not support sw codec, video-view shows an error message and video by default codec type + */ + static VideoView New( const std::string& url, bool swCodec ); + + /** * @brief Creates an uninitialized VideoView. * @SINCE_1_1.38 */ -- 2.7.4