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 <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 <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" ) );
98 if( mCreateVideoPlayerPtr == NULL )
100 DALI_LOG_ERROR( "Can't load symbol CreateVideoPlayerPlugin(), error: %s\n", error );
104 mPlugin = mCreateVideoPlayerPtr();
106 if( mPlugin == NULL )
108 DALI_LOG_ERROR( "Can't create the VideoPlayerPlugin object\n" );
112 mDestroyVideoPlayerPtr = reinterpret_cast< DestroyVideoPlayerFunction >( dlsym( mHandle, "DestroyVideoPlayerPlugin" ) );
113 if( mDestroyVideoPlayerPtr == NULL )
115 DALI_LOG_ERROR( "Can't load symbol DestroyVideoPlayerPlugin(), error: %s\n", error );
121 void VideoPlayer::SetUrl( const std::string& url )
123 if( mPlugin != NULL )
125 mPlugin->SetUrl( url );
129 std::string VideoPlayer::GetUrl()
131 if( mPlugin != NULL )
133 return mPlugin->GetUrl();
136 return std::string( NULL );
139 void VideoPlayer::SetLooping(bool looping)
141 if( mPlugin != NULL )
143 mPlugin->SetLooping( looping );
147 bool VideoPlayer::IsLooping()
149 if( mPlugin != NULL )
151 return mPlugin->IsLooping();
157 void VideoPlayer::Play()
159 if( mPlugin != NULL )
165 void VideoPlayer::Pause()
167 if( mPlugin != NULL )
173 void VideoPlayer::Stop()
175 if( mPlugin != NULL )
181 void VideoPlayer::SetMute( bool mute )
183 if( mPlugin != NULL )
185 mPlugin->SetMute( mute );
189 bool VideoPlayer::IsMuted()
191 if( mPlugin != NULL )
193 return mPlugin->IsMuted();
199 void VideoPlayer::SetVolume( float left, float right )
201 if( mPlugin != NULL )
203 mPlugin->SetVolume( left, right );
207 void VideoPlayer::GetVolume( float& left, float& right )
209 if( mPlugin != NULL )
211 mPlugin->GetVolume( left, right );
215 void VideoPlayer::SetRenderingTarget( Dali::Any target )
217 if( mPlugin != NULL )
219 mPlugin->SetRenderingTarget( target );
223 void VideoPlayer::SetPlayPosition( int millisecond )
225 if( mPlugin != NULL )
227 mPlugin->SetPlayPosition( millisecond );
231 int VideoPlayer::GetPlayPosition()
233 if( mPlugin != NULL )
235 return mPlugin->GetPlayPosition();
240 void VideoPlayer::SetDisplayArea( DisplayArea area )
242 if( mPlugin != NULL )
244 mPlugin->SetDisplayArea( area );
248 void VideoPlayer::SetDisplayRotation( Dali::VideoPlayerPlugin::DisplayRotation rotation )
250 if( mPlugin != NULL )
252 mPlugin->SetDisplayRotation( rotation );
256 Dali::VideoPlayerPlugin::DisplayRotation VideoPlayer::GetDisplayRotation()
258 if( mPlugin != NULL )
260 return mPlugin->GetDisplayRotation();
263 return Dali::VideoPlayerPlugin::ROTATION_NONE;
266 Dali::VideoPlayerPlugin::VideoPlayerSignalType& VideoPlayer::FinishedSignal()
268 if( mPlugin != NULL )
270 return mPlugin->FinishedSignal();
273 return mFinishedSignal;
276 void VideoPlayer::Forward( int millisecond )
278 if( mPlugin != NULL )
280 mPlugin->Forward( millisecond );
284 void VideoPlayer::Backward( int millisecond )
286 if( mPlugin != NULL )
288 mPlugin->Backward( millisecond );
292 } // namespace Adaptor;
293 } // namespace Internal;