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 #if _GLIBCXX_USE_CXX11_ABI
43 const char* VIDEO_PLUGIN_SO( "libdali-video-player-plugin.so" );
45 const char* VIDEO_PLUGIN_SO( "libdali-video-player-plugin-cxx03.so" );
48 Dali::BaseHandle Create()
50 return Dali::VideoPlayer::New();
53 Dali::TypeRegistration type( typeid( Dali::VideoPlayer ), typeid( Dali::BaseHandle ), Create );
55 } // unnamed namespace
57 VideoPlayerPtr VideoPlayer::New()
59 VideoPlayerPtr player = new VideoPlayer();
63 VideoPlayer::VideoPlayer()
66 mCreateVideoPlayerPtr( NULL ),
67 mDestroyVideoPlayerPtr( NULL )
71 VideoPlayer::~VideoPlayer()
75 if( mDestroyVideoPlayerPtr != NULL )
77 mDestroyVideoPlayerPtr( mPlugin );
84 void VideoPlayer::Initialize()
88 mHandle = dlopen( VIDEO_PLUGIN_SO, RTLD_LAZY );
91 if( mHandle == NULL || error != NULL )
93 DALI_LOG_ERROR( "VideoPlayer::Initialize(), dlopen error: %s\n", error );
97 mCreateVideoPlayerPtr = reinterpret_cast< CreateVideoPlayerFunction >( dlsym( mHandle, "CreateVideoPlayerPlugin" ) );
100 if( mCreateVideoPlayerPtr == NULL || error != NULL )
102 DALI_LOG_ERROR( "Can't load symbol CreateVideoPlayerPlugin(), error: %s\n", error );
106 mPlugin = mCreateVideoPlayerPtr();
108 if( mPlugin == NULL )
110 DALI_LOG_ERROR( "Can't create the VideoPlayerPlugin object\n" );
114 mDestroyVideoPlayerPtr = reinterpret_cast< DestroyVideoPlayerFunction >( dlsym( mHandle, "DestroyVideoPlayerPlugin" ) );
117 if( mDestroyVideoPlayerPtr == NULL || error != NULL )
119 DALI_LOG_ERROR( "Can't load symbol DestroyVideoPlayerPlugin(), error: %s\n", error );
124 void VideoPlayer::SetUrl( const std::string& url )
126 if( mPlugin != NULL )
128 mPlugin->SetUrl( url );
132 std::string VideoPlayer::GetUrl()
134 if( mPlugin != NULL )
136 return mPlugin->GetUrl();
139 return std::string();
142 void VideoPlayer::SetLooping(bool looping)
144 if( mPlugin != NULL )
146 mPlugin->SetLooping( looping );
150 bool VideoPlayer::IsLooping()
152 if( mPlugin != NULL )
154 return mPlugin->IsLooping();
160 void VideoPlayer::Play()
162 if( mPlugin != NULL )
168 void VideoPlayer::Pause()
170 if( mPlugin != NULL )
176 void VideoPlayer::Stop()
178 if( mPlugin != NULL )
184 void VideoPlayer::SetMute( bool mute )
186 if( mPlugin != NULL )
188 mPlugin->SetMute( mute );
192 bool VideoPlayer::IsMuted()
194 if( mPlugin != NULL )
196 return mPlugin->IsMuted();
202 void VideoPlayer::SetVolume( float left, float right )
204 if( mPlugin != NULL )
206 mPlugin->SetVolume( left, right );
210 void VideoPlayer::GetVolume( float& left, float& right )
212 if( mPlugin != NULL )
214 mPlugin->GetVolume( left, right );
218 void VideoPlayer::SetRenderingTarget( Dali::Any target )
220 if( mPlugin != NULL )
222 mPlugin->SetRenderingTarget( target );
226 void VideoPlayer::SetPlayPosition( int millisecond )
228 if( mPlugin != NULL )
230 mPlugin->SetPlayPosition( millisecond );
234 int VideoPlayer::GetPlayPosition()
236 if( mPlugin != NULL )
238 return mPlugin->GetPlayPosition();
243 void VideoPlayer::SetDisplayArea( DisplayArea area )
245 if( mPlugin != NULL )
247 mPlugin->SetDisplayArea( area );
251 void VideoPlayer::SetDisplayRotation( Dali::VideoPlayerPlugin::DisplayRotation rotation )
253 if( mPlugin != NULL )
255 mPlugin->SetDisplayRotation( rotation );
259 Dali::VideoPlayerPlugin::DisplayRotation VideoPlayer::GetDisplayRotation()
261 if( mPlugin != NULL )
263 return mPlugin->GetDisplayRotation();
266 return Dali::VideoPlayerPlugin::ROTATION_NONE;
269 Dali::VideoPlayerPlugin::VideoPlayerSignalType& VideoPlayer::FinishedSignal()
271 if( mPlugin != NULL )
273 return mPlugin->FinishedSignal();
276 return mFinishedSignal;
279 void VideoPlayer::Forward( int millisecond )
281 if( mPlugin != NULL )
283 mPlugin->Forward( millisecond );
287 void VideoPlayer::Backward( int millisecond )
289 if( mPlugin != NULL )
291 mPlugin->Backward( millisecond );
295 bool VideoPlayer::IsVideoTextureSupported()
297 if( mPlugin != NULL )
299 return mPlugin->IsVideoTextureSupported();
305 void VideoPlayer::SetCodecType( Dali::VideoPlayerPlugin::CodecType type )
307 if( mPlugin != NULL )
309 mPlugin->SetCodecType( type );
313 Dali::VideoPlayerPlugin::CodecType VideoPlayer::GetCodecType() const
315 if( mPlugin != NULL )
317 return mPlugin->GetCodecType();
320 return Dali::VideoPlayerPlugin::CodecType::DEFAULT;
323 void VideoPlayer::SetDisplayMode( Dali::VideoPlayerPlugin::DisplayMode::Type mode )
325 if( mPlugin != NULL )
327 mPlugin->SetDisplayMode( mode );
331 Dali::VideoPlayerPlugin::DisplayMode::Type VideoPlayer::GetDisplayMode() const
333 if( mPlugin != NULL )
335 return mPlugin->GetDisplayMode();
338 return Dali::VideoPlayerPlugin::DisplayMode::DST_ROI;
341 } // namespace Adaptor;
342 } // namespace Internal;