2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/video/common/video-player-impl.h>
23 #include <dali/integration-api/debug.h>
24 #include <dali/public-api/object/type-registry.h>
25 #include <dali/public-api/object/any.h>
28 #include <dali/public-api/adaptor-framework/native-image-source.h>
39 namespace // unnamed namespace
42 const char* VIDEO_PLUGIN_SO( "libdali2-video-player-plugin.so" );
44 Dali::BaseHandle Create()
46 return Dali::VideoPlayer::New();
49 Dali::TypeRegistration type( typeid( Dali::VideoPlayer ), typeid( Dali::BaseHandle ), Create );
51 } // unnamed namespace
53 VideoPlayerPtr VideoPlayer::New()
55 VideoPlayerPtr player = new VideoPlayer();
59 VideoPlayer::VideoPlayer()
62 mCreateVideoPlayerPtr( NULL ),
63 mDestroyVideoPlayerPtr( NULL )
67 VideoPlayer::~VideoPlayer()
71 if( mDestroyVideoPlayerPtr != NULL )
73 mDestroyVideoPlayerPtr( mPlugin );
80 void VideoPlayer::Initialize( Dali::Actor actor, VideoSyncMode syncMode )
84 mHandle = dlopen( VIDEO_PLUGIN_SO, RTLD_LAZY );
87 if( mHandle == NULL || error != NULL )
89 DALI_LOG_ERROR( "VideoPlayer::Initialize(), dlopen error: %s\n", error );
93 mCreateVideoPlayerPtr = reinterpret_cast< CreateVideoPlayerFunction >( dlsym( mHandle, "CreateVideoPlayerPlugin" ) );
96 if( mCreateVideoPlayerPtr == NULL || error != NULL )
98 DALI_LOG_ERROR( "Can't load symbol CreateVideoPlayerPlugin(), error: %s\n", error );
102 mPlugin = mCreateVideoPlayerPtr( actor, syncMode );
104 if( mPlugin == NULL )
106 DALI_LOG_ERROR( "Can't create the VideoPlayerPlugin object\n" );
110 mDestroyVideoPlayerPtr = reinterpret_cast< DestroyVideoPlayerFunction >( dlsym( mHandle, "DestroyVideoPlayerPlugin" ) );
113 if( mDestroyVideoPlayerPtr == NULL || error != NULL )
115 DALI_LOG_ERROR( "Can't load symbol DestroyVideoPlayerPlugin(), error: %s\n", error );
120 void VideoPlayer::SetUrl( const std::string& url )
122 if( mPlugin != NULL )
124 mPlugin->SetUrl( url );
128 std::string VideoPlayer::GetUrl()
130 if( mPlugin != NULL )
132 return mPlugin->GetUrl();
135 return std::string();
138 void VideoPlayer::SetLooping(bool looping)
140 if( mPlugin != NULL )
142 mPlugin->SetLooping( looping );
146 bool VideoPlayer::IsLooping()
148 if( mPlugin != NULL )
150 return mPlugin->IsLooping();
156 void VideoPlayer::Play()
158 if( mPlugin != NULL )
164 void VideoPlayer::Pause()
166 if( mPlugin != NULL )
172 void VideoPlayer::Stop()
174 if( mPlugin != NULL )
180 void VideoPlayer::SetMute( bool mute )
182 if( mPlugin != NULL )
184 mPlugin->SetMute( mute );
188 bool VideoPlayer::IsMuted()
190 if( mPlugin != NULL )
192 return mPlugin->IsMuted();
198 void VideoPlayer::SetVolume( float left, float right )
200 if( mPlugin != NULL )
202 mPlugin->SetVolume( left, right );
206 void VideoPlayer::GetVolume( float& left, float& right )
208 if( mPlugin != NULL )
210 mPlugin->GetVolume( left, right );
214 void VideoPlayer::SetRenderingTarget( Dali::Any target )
216 if( mPlugin != NULL )
218 mPlugin->SetRenderingTarget( target );
222 void VideoPlayer::SetPlayPosition( int millisecond )
224 if( mPlugin != NULL )
226 mPlugin->SetPlayPosition( millisecond );
230 int VideoPlayer::GetPlayPosition()
232 if( mPlugin != NULL )
234 return mPlugin->GetPlayPosition();
239 void VideoPlayer::SetDisplayArea( DisplayArea area )
241 if( mPlugin != NULL )
243 mPlugin->SetDisplayArea( area );
247 void VideoPlayer::SetDisplayRotation( Dali::VideoPlayerPlugin::DisplayRotation rotation )
249 if( mPlugin != NULL )
251 mPlugin->SetDisplayRotation( rotation );
255 Dali::VideoPlayerPlugin::DisplayRotation VideoPlayer::GetDisplayRotation()
257 if( mPlugin != NULL )
259 return mPlugin->GetDisplayRotation();
262 return Dali::VideoPlayerPlugin::ROTATION_NONE;
265 Dali::VideoPlayerPlugin::VideoPlayerSignalType& VideoPlayer::FinishedSignal()
267 if( mPlugin != NULL )
269 return mPlugin->FinishedSignal();
272 return mFinishedSignal;
275 void VideoPlayer::Forward( int millisecond )
277 if( mPlugin != NULL )
279 mPlugin->Forward( millisecond );
283 void VideoPlayer::Backward( int millisecond )
285 if( mPlugin != NULL )
287 mPlugin->Backward( millisecond );
291 bool VideoPlayer::IsVideoTextureSupported()
293 if( mPlugin != NULL )
295 return mPlugin->IsVideoTextureSupported();
301 void VideoPlayer::SetCodecType( Dali::VideoPlayerPlugin::CodecType type )
303 if( mPlugin != NULL )
305 mPlugin->SetCodecType( type );
309 Dali::VideoPlayerPlugin::CodecType VideoPlayer::GetCodecType() const
311 if( mPlugin != NULL )
313 return mPlugin->GetCodecType();
316 return Dali::VideoPlayerPlugin::CodecType::DEFAULT;
319 void VideoPlayer::SetDisplayMode( Dali::VideoPlayerPlugin::DisplayMode::Type mode )
321 if( mPlugin != NULL )
323 mPlugin->SetDisplayMode( mode );
327 Dali::VideoPlayerPlugin::DisplayMode::Type VideoPlayer::GetDisplayMode() const
329 if( mPlugin != NULL )
331 return mPlugin->GetDisplayMode();
334 return Dali::VideoPlayerPlugin::DisplayMode::DST_ROI;
337 Any VideoPlayer::GetMediaPlayer()
339 if( mPlugin != NULL )
341 return mPlugin->GetMediaPlayer();
346 void VideoPlayer::StartSynchronization()
348 if( mPlugin != NULL )
350 mPlugin->StartSynchronization();
354 void VideoPlayer::FinishSynchronization()
356 if( mPlugin != NULL )
358 mPlugin->FinishSynchronization();
362 } // namespace Adaptor;
363 } // namespace Internal;