1e6da1319a312a1b8448cece935a41f4f4df85e8
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / video-view / video-view-impl.cpp
1 /*
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // CLASS HEADER
19 #include "video-view-impl.h"
20
21 // EXTERNAL INCLUDES
22 #include <cstring>
23 #include <dali/public-api/object/type-registry.h>
24 #include <dali/public-api/object/type-registry-helper.h>
25 #include <dali/public-api/common/stage.h>
26 #include <dali/devel-api/scripting/scripting.h>
27 #include <dali/public-api/adaptor-framework/native-image-source.h>
28 #include <dali/integration-api/adaptors/adaptor.h>
29 #include <dali/integration-api/debug.h>
30 #include <dali/public-api/animation/constraint.h>
31 #include <dali/devel-api/actors/actor-devel.h>
32
33 // INTERNAL INCLUDES
34 #include <dali-toolkit/public-api/controls/video-view/video-view.h>
35 #include <dali-toolkit/public-api/visuals/visual-properties.h>
36 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
37 #include <dali-toolkit/internal/visuals/visual-string-constants.h>
38 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
39 #include <dali-toolkit/internal/visuals/visual-factory-impl.h>
40 #include <dali-toolkit/internal/visuals/visual-factory-cache.h>
41
42 namespace Dali
43 {
44
45 namespace Toolkit
46 {
47
48 namespace Internal
49 {
50
51 namespace
52 {
53
54 BaseHandle Create()
55 {
56   return Toolkit::VideoView::New();
57 }
58
59 DALI_TYPE_REGISTRATION_BEGIN( Toolkit::VideoView, Toolkit::Control, Create );
60
61 DALI_PROPERTY_REGISTRATION( Toolkit, VideoView, "video", MAP, VIDEO )
62 DALI_PROPERTY_REGISTRATION( Toolkit, VideoView, "looping", BOOLEAN, LOOPING )
63 DALI_PROPERTY_REGISTRATION( Toolkit, VideoView, "muted", BOOLEAN, MUTED )
64 DALI_PROPERTY_REGISTRATION( Toolkit, VideoView, "volume", MAP, VOLUME )
65 DALI_PROPERTY_REGISTRATION( Toolkit, VideoView, "underlay", BOOLEAN, UNDERLAY )
66 DALI_PROPERTY_REGISTRATION( Toolkit, VideoView, "playPosition", INTEGER, PLAY_POSITION )
67 DALI_PROPERTY_REGISTRATION( Toolkit, VideoView, "displayMode", INTEGER, DISPLAY_MODE )
68
69 DALI_SIGNAL_REGISTRATION( Toolkit, VideoView, "finished", FINISHED_SIGNAL )
70
71 DALI_ACTION_REGISTRATION( Toolkit, VideoView, "play", ACTION_VIDEOVIEW_PLAY )
72 DALI_ACTION_REGISTRATION( Toolkit, VideoView, "pause", ACTION_VIDEOVIEW_PAUSE )
73 DALI_ACTION_REGISTRATION( Toolkit, VideoView, "stop", ACTION_VIDEOVIEW_STOP )
74 DALI_ACTION_REGISTRATION( Toolkit, VideoView, "forward", ACTION_VIDEOVIEW_FORWARD )
75 DALI_ACTION_REGISTRATION( Toolkit, VideoView, "backward", ACTION_VIDEOVIEW_BACKWARD )
76
77 DALI_TYPE_REGISTRATION_END()
78
79 const char* const VOLUME_LEFT( "volumeLeft" );
80 const char* const VOLUME_RIGHT( "volumeRight" );
81
82 // 3.0 TC uses RENDERING_TARGET. It should be removed in next release
83 const char* const RENDERING_TARGET( "renderingTarget" );
84 const char* const WINDOW_SURFACE_TARGET( "windowSurfaceTarget" );
85 const char* const NATIVE_IMAGE_TARGET( "nativeImageTarget" );
86
87 const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
88   attribute mediump vec2 aPosition;\n
89   uniform mediump mat4 uMvpMatrix;\n
90   uniform mediump vec3 uSize;\n
91   \n
92   void main()\n
93   {\n
94     mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n
95     vertexPosition.xyz *= uSize;\n
96     gl_Position = uMvpMatrix * vertexPosition;\n
97   }\n
98 );
99
100 const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
101   uniform lowp vec4 uColor;\n
102   uniform lowp vec3 mixColor;\n
103   \n
104   void main()\n
105   {\n
106     gl_FragColor = vec4(mixColor, 1.0)*uColor;\n
107   }\n
108 );
109
110 } // anonymous namepsace
111
112 VideoView::VideoView()
113 : Control( ControlBehaviour( ACTOR_BEHAVIOUR_DEFAULT | DISABLE_STYLE_CHANGE_SIGNALS ) ),
114   mCurrentVideoPlayPosition( 0 ),
115   mIsPlay( false ),
116   mIsUnderlay( true )
117 {
118   mVideoPlayer = Dali::VideoPlayer::New();
119 }
120
121 VideoView::~VideoView()
122 {
123 }
124
125 Toolkit::VideoView VideoView::New()
126 {
127   VideoView* impl = new VideoView();
128   Toolkit::VideoView handle = Toolkit::VideoView( *impl );
129
130   impl->Initialize();
131
132   return handle;
133 }
134
135 void VideoView::OnInitialize()
136 {
137   mVideoPlayer.FinishedSignal().Connect( this, &VideoView::EmitSignalFinish );
138   SetWindowSurfaceTarget();
139 }
140
141 void VideoView::SetUrl( const std::string& url )
142 {
143   if( mUrl != url || !mPropertyMap.Empty() )
144   {
145     mUrl = url;
146     mPropertyMap.Clear();
147   }
148
149   if( !mIsUnderlay )
150   {
151     Actor self( Self() );
152     Internal::InitializeVisual( self, mVisual, mNativeImage );
153   }
154
155   mVideoPlayer.SetUrl( mUrl );
156 }
157
158 void VideoView::SetPropertyMap( Property::Map map )
159 {
160   mPropertyMap = map;
161
162   Actor self( Self() );
163   Internal::InitializeVisual( self, mVisual, mPropertyMap );
164
165   Property::Value* widthValue = mPropertyMap.Find( "width" );
166   if( widthValue )
167   {
168     int width;
169     if( widthValue->Get( width ) )
170     {
171       mVideoSize = ImageDimensions( width, mVideoSize.GetHeight() );
172     }
173   }
174
175   Property::Value* heightValue = mPropertyMap.Find( "height" );
176   if( heightValue )
177   {
178     int height;
179     if( heightValue->Get( height ) )
180     {
181       mVideoSize = ImageDimensions( mVideoSize.GetWidth(), height );
182     }
183   }
184
185   Property::Value* target = map.Find( RENDERING_TARGET );
186   std::string targetType;
187
188   if( target && target->Get( targetType ) && targetType == WINDOW_SURFACE_TARGET )
189   {
190     mIsUnderlay = true;
191     SetWindowSurfaceTarget();
192   }
193   else if( target && target->Get( targetType ) && targetType == NATIVE_IMAGE_TARGET )
194   {
195     mIsUnderlay = false;
196     SetNativeImageTarget();
197   }
198
199   RelayoutRequest();
200 }
201
202 std::string VideoView::GetUrl()
203 {
204   return mUrl;
205 }
206
207 void VideoView::SetLooping(bool looping)
208 {
209   mVideoPlayer.SetLooping( looping );
210 }
211
212 bool VideoView::IsLooping()
213 {
214   return mVideoPlayer.IsLooping();
215 }
216
217 void VideoView::Play()
218 {
219   if( mIsUnderlay )
220   {
221     Self().AddRenderer( mRenderer );
222   }
223
224   mVideoPlayer.Play();
225   mIsPlay = true;
226 }
227
228 void VideoView::Pause()
229 {
230   mVideoPlayer.Pause();
231   mIsPlay = false;
232 }
233
234 void VideoView::Stop()
235 {
236   mVideoPlayer.Stop();
237   mIsPlay = false;
238 }
239
240 void VideoView::Forward( int millisecond )
241 {
242   int curPos = mVideoPlayer.GetPlayPosition();
243
244   int nextPos = curPos + millisecond;
245
246   mVideoPlayer.SetPlayPosition( nextPos );
247 }
248
249 void VideoView::Backward( int millisecond )
250 {
251   int curPos = mVideoPlayer.GetPlayPosition();
252
253   int nextPos = curPos - millisecond;
254   nextPos = ( nextPos < 0 )? 0: nextPos;
255
256   mVideoPlayer.SetPlayPosition( nextPos );
257 }
258
259 void VideoView::SetMute( bool mute )
260 {
261   mVideoPlayer.SetMute( mute );
262 }
263
264 bool VideoView::IsMuted()
265 {
266   return mVideoPlayer.IsMuted();
267 }
268
269 void VideoView::SetVolume( float left, float right )
270 {
271   mVideoPlayer.SetVolume( left, right );
272 }
273
274 void VideoView::GetVolume( float& left, float& right )
275 {
276   mVideoPlayer.GetVolume( left, right );
277 }
278
279 Dali::Toolkit::VideoView::VideoViewSignalType& VideoView::FinishedSignal()
280 {
281   return mFinishedSignal;
282 }
283
284 void VideoView::EmitSignalFinish()
285 {
286   if( mIsUnderlay )
287   {
288     Self().RemoveRenderer( mRenderer );
289   }
290
291   if ( !mFinishedSignal.Empty() )
292   {
293     Dali::Toolkit::VideoView handle( GetOwner() );
294     mFinishedSignal.Emit( handle );
295   }
296 }
297
298 bool VideoView::DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes )
299 {
300   bool ret = false;
301
302   Dali::BaseHandle handle( object );
303   Toolkit::VideoView videoView = Toolkit::VideoView::DownCast( handle );
304
305   if( !videoView )
306   {
307     return ret;
308   }
309
310   VideoView& impl = GetImpl( videoView );
311
312   if( strcmp( actionName.c_str(), ACTION_VIDEOVIEW_PLAY ) == 0 )
313   {
314     impl.Play();
315     ret = true;
316   }
317   else if( strcmp( actionName.c_str(), ACTION_VIDEOVIEW_PAUSE ) == 0 )
318   {
319     impl.Pause();
320     ret = true;
321   }
322   else if( strcmp( actionName.c_str(), ACTION_VIDEOVIEW_STOP ) == 0 )
323   {
324     impl.Stop();
325     ret = true;
326   }
327   else if( strcmp( actionName.c_str(), ACTION_VIDEOVIEW_FORWARD ) == 0 )
328   {
329     int millisecond = 0;
330     if( attributes["videoForward"].Get( millisecond ) )
331     {
332       impl.Forward( millisecond );
333       ret = true;
334     }
335   }
336   else if( strcmp( actionName.c_str(), ACTION_VIDEOVIEW_BACKWARD ) == 0 )
337   {
338     int millisecond = 0;
339     if( attributes["videoBackward"].Get( millisecond ) )
340     {
341       impl.Backward( millisecond );
342       ret = true;
343     }
344   }
345
346   return ret;
347 }
348
349 bool VideoView::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
350 {
351   Dali::BaseHandle handle( object );
352
353   bool connected( true );
354   Toolkit::VideoView videoView = Toolkit::VideoView::DownCast( handle );
355
356   if( 0 == strcmp( signalName.c_str(), FINISHED_SIGNAL ) )
357   {
358     videoView.FinishedSignal().Connect( tracker, functor );
359   }
360   else
361   {
362     // signalName does not match any signal
363     connected = false;
364   }
365
366   return connected;
367 }
368
369 void VideoView::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
370 {
371   Toolkit::VideoView videoView = Toolkit::VideoView::DownCast( Dali::BaseHandle( object ) );
372
373   if( videoView )
374   {
375     VideoView& impl = GetImpl( videoView );
376
377     switch( index )
378     {
379       case Toolkit::VideoView::Property::VIDEO:
380       {
381         std::string videoUrl;
382         Property::Map map;
383
384         if( value.Get( videoUrl ) )
385         {
386           impl.SetUrl( videoUrl );
387         }
388         else if( value.Get( map ) )
389         {
390           Property::Value* shaderValue = map.Find( Toolkit::Visual::Property::SHADER, CUSTOM_SHADER );
391
392           if( map.Count() > 1u || !shaderValue )
393           {
394             impl.SetPropertyMap( map );
395           }
396           else if( impl.mVisual && map.Count() == 1u && shaderValue )
397           {
398             Property::Map shaderMap;
399             if( shaderValue->Get( shaderMap ) )
400             {
401               Internal::Visual::Base& visual = Toolkit::GetImplementation( impl.mVisual );
402               visual.SetCustomShader( shaderMap );
403               if( videoView.OnStage() )
404               {
405                 visual.SetOffStage( videoView );
406                 visual.SetOnStage( videoView );
407               }
408             }
409           }
410         }
411         break;
412       }
413       case Toolkit::VideoView::Property::LOOPING:
414       {
415         bool looping;
416         if( value.Get( looping ) )
417         {
418           impl.SetLooping( looping );
419         }
420         break;
421       }
422       case Toolkit::VideoView::Property::MUTED:
423       {
424         bool mute;
425         if( value.Get( mute ) )
426         {
427           impl.SetMute( mute );
428         }
429         break;
430       }
431       case Toolkit::VideoView::Property::VOLUME:
432       {
433         Property::Map map;
434         float left, right;
435         if( value.Get( map ) )
436         {
437           Property::Value* volumeLeft = map.Find( VOLUME_LEFT );
438           Property::Value* volumeRight = map.Find( VOLUME_RIGHT );
439           if( volumeLeft && volumeLeft->Get( left ) && volumeRight && volumeRight->Get( right ) )
440           {
441             impl.SetVolume( left, right );
442           }
443         }
444         break;
445       }
446       case Toolkit::VideoView::Property::UNDERLAY:
447       {
448         bool underlay;
449         if( value.Get( underlay ) )
450         {
451           impl.SetUnderlay( underlay );
452         }
453         break;
454       }
455       case Toolkit::VideoView::Property::PLAY_POSITION:
456       {
457         int pos;
458         if( value.Get( pos ) )
459         {
460           impl.SetPlayPosition( pos );
461         }
462         break;
463       }
464       case Toolkit::VideoView::Property::DISPLAY_MODE:
465       {
466         int mode;
467         if( value.Get( mode ) )
468         {
469           impl.SetDisplayMode( mode );
470         }
471         break;
472       }
473     }
474   }
475 }
476
477 Property::Value VideoView::GetProperty( BaseObject* object, Property::Index propertyIndex )
478 {
479   Property::Value value;
480   Toolkit::VideoView videoView = Toolkit::VideoView::DownCast( Dali::BaseHandle( object ) );
481
482   if( videoView )
483   {
484     VideoView& impl = GetImpl( videoView );
485
486     switch( propertyIndex )
487     {
488       case Toolkit::VideoView::Property::VIDEO:
489       {
490         if( !impl.mUrl.empty() )
491         {
492           value = impl.mUrl;
493         }
494         else if( !impl.mPropertyMap.Empty() )
495         {
496           value = impl.mPropertyMap;
497         }
498         break;
499       }
500       case Toolkit::VideoView::Property::LOOPING:
501       {
502         value = impl.IsLooping();
503         break;
504       }
505       case Toolkit::VideoView::Property::MUTED:
506       {
507         value = impl.IsMuted();
508         break;
509       }
510       case Toolkit::VideoView::Property::VOLUME:
511       {
512         Property::Map map;
513         float left, right;
514
515         impl.GetVolume( left, right );
516         map.Insert( VOLUME_LEFT, left );
517         map.Insert( VOLUME_RIGHT, right );
518         value = map;
519         break;
520       }
521       case Toolkit::VideoView::Property::UNDERLAY:
522       {
523         value = impl.IsUnderlay();
524         break;
525       }
526       case Toolkit::VideoView::Property::PLAY_POSITION:
527       {
528         value = impl.GetPlayPosition();
529         break;
530       }
531       case Toolkit::VideoView::Property::DISPLAY_MODE:
532       {
533         value = impl.GetDisplayMode();
534         break;
535       }
536     }
537   }
538
539   return value;
540 }
541
542 void VideoView::SetDepthIndex( int depthIndex )
543 {
544   if( mVisual )
545   {
546     mVisual.SetDepthIndex( depthIndex );
547   }
548 }
549
550 void VideoView::OnStageConnection( int depth )
551 {
552   if( mVisual )
553   {
554     CustomActor self = Self();
555     Toolkit::GetImplementation(mVisual).SetOnStage( self );
556   }
557
558   Control::OnStageConnection( depth );
559 }
560
561 void VideoView::OnStageDisconnection()
562 {
563   if( mVisual )
564   {
565     CustomActor self = Self();
566     Toolkit::GetImplementation(mVisual).SetOffStage( self );
567   }
568
569   Control::OnStageDisconnection();
570 }
571
572 Vector3 VideoView::GetNaturalSize()
573 {
574   Vector3 size;
575   size.x = mVideoSize.GetWidth();
576   size.y = mVideoSize.GetHeight();
577
578   if( size.x > 0 && size.y > 0 )
579   {
580     size.z = std::min( size.x, size.y );
581     return size;
582   }
583   else
584   {
585     return Control::GetNaturalSize();
586   }
587 }
588
589 float VideoView::GetHeightForWidth( float width )
590 {
591   if( mVideoSize.GetWidth() > 0 && mVideoSize.GetHeight() > 0 )
592   {
593     return GetHeightForWidthBase( width );
594   }
595   else
596   {
597     return Control::GetHeightForWidthBase( width );
598   }
599 }
600
601 float VideoView::GetWidthForHeight( float height )
602 {
603   if( mVideoSize.GetWidth() > 0 && mVideoSize.GetHeight() > 0 )
604   {
605     return GetWidthForHeightBase( height );
606   }
607   else
608   {
609     return Control::GetWidthForHeightBase( height );
610   }
611 }
612
613 void VideoView::SetWindowSurfaceTarget()
614 {
615   Actor self = Self();
616   int curPos = mVideoPlayer.GetPlayPosition();
617
618   if( mVisual )
619   {
620     Toolkit::GetImplementation(mVisual).SetOffStage(self);
621     mVisual.Reset();
622   }
623
624   if( mIsPlay )
625   {
626     mVideoPlayer.Pause();
627   }
628
629   mPositionUpdateNotification = self.AddPropertyNotification( Actor::Property::WORLD_POSITION, StepCondition( 1.0f, 1.0f ) );
630   mSizeUpdateNotification = self.AddPropertyNotification( Actor::Property::SIZE, StepCondition( 1.0f, 1.0f ) );
631   mScaleUpdateNotification = self.AddPropertyNotification( Actor::Property::WORLD_SCALE, StepCondition( 0.1f, 1.0f ) );
632   mPositionUpdateNotification.NotifySignal().Connect( this, &VideoView::UpdateDisplayArea );
633   mSizeUpdateNotification.NotifySignal().Connect( this, &VideoView::UpdateDisplayArea );
634   mScaleUpdateNotification.NotifySignal().Connect( this, &VideoView::UpdateDisplayArea );
635
636   mVideoPlayer.SetRenderingTarget( Dali::Adaptor::Get().GetNativeWindowHandle() );
637   mVideoPlayer.SetUrl( mUrl );
638
639   if( !mRenderer )
640   {
641     // For underlay rendering mode, video display area have to be transparent.
642     Geometry geometry = VisualFactoryCache::CreateQuadGeometry();
643     Shader shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
644     mRenderer = Renderer::New( geometry, shader );
645
646     mRenderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON );
647     mRenderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::ONE );
648     mRenderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::ZERO );
649     mRenderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::ONE );
650     mRenderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::ZERO );
651   }
652
653   if( mIsPlay )
654   {
655     Play();
656   }
657
658   if( curPos > 0 )
659   {
660     mVideoPlayer.SetPlayPosition( curPos );
661   }
662 }
663
664 void VideoView::SetNativeImageTarget()
665 {
666   if( mVideoPlayer.IsVideoTextureSupported() == false )
667   {
668     DALI_LOG_ERROR( "Platform doesn't support decoded video frame images\n" );
669     mIsUnderlay = true;
670     return;
671   }
672
673   if( mIsPlay )
674   {
675     mVideoPlayer.Pause();
676   }
677
678   Actor self( Self() );
679   self.RemoveRenderer( mRenderer );
680   Dali::Stage::GetCurrent().KeepRendering( 0.0f );
681
682   self.RemovePropertyNotification( mPositionUpdateNotification );
683   self.RemovePropertyNotification( mSizeUpdateNotification );
684   self.RemovePropertyNotification( mScaleUpdateNotification );
685
686   int curPos = mVideoPlayer.GetPlayPosition();
687
688   Any source;
689   Dali::NativeImageSourcePtr nativeImageSourcePtr = Dali::NativeImageSource::New( source );
690   mNativeImage = Dali::NativeImage::New( *nativeImageSourcePtr );
691
692   mVideoPlayer.SetRenderingTarget( nativeImageSourcePtr );
693   mVideoPlayer.SetUrl( mUrl );
694
695   Internal::InitializeVisual( self, mVisual, mNativeImage );
696   Self().RemoveRenderer( mRenderer );
697
698   if( mIsPlay )
699   {
700     Play();
701   }
702
703   if( curPos > 0 )
704   {
705     mVideoPlayer.SetPlayPosition( curPos );
706   }
707 }
708
709 void VideoView::UpdateDisplayArea( Dali::PropertyNotification& source )
710 {
711   if( !mIsUnderlay )
712   {
713     return;
714   }
715
716   Actor self( Self() );
717
718   bool positionUsesAnchorPoint = self.GetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT ).Get< bool >();
719   Vector3 actorSize = self.GetCurrentSize() * self.GetCurrentScale();
720   Vector3 anchorPointOffSet = actorSize * ( positionUsesAnchorPoint ? self.GetCurrentAnchorPoint() : AnchorPoint::TOP_LEFT );
721
722   Vector2 screenPosition = self.GetProperty( DevelActor::Property::SCREEN_POSITION ).Get< Vector2 >();
723
724   mDisplayArea.x = screenPosition.x - anchorPointOffSet.x;
725   mDisplayArea.y = screenPosition.y - anchorPointOffSet.y;
726   mDisplayArea.width = actorSize.x;
727   mDisplayArea.height = actorSize.y;
728
729   mVideoPlayer.SetDisplayArea( mDisplayArea );
730 }
731
732 void VideoView::SetUnderlay( bool set )
733 {
734   if( set != mIsUnderlay )
735   {
736     mIsUnderlay = set;
737
738     if( mIsUnderlay )
739     {
740       SetWindowSurfaceTarget();
741     }
742     else
743     {
744       SetNativeImageTarget();
745     }
746
747     RelayoutRequest();
748   }
749 }
750
751 bool VideoView::IsUnderlay()
752 {
753   return mIsUnderlay;
754 }
755
756 void VideoView::SetSWCodec( bool on )
757 {
758   // If setting SW or HW type is failed , video-view shows video by default codec type.
759   // The default codec type is selected by platform.
760   if( on )
761   {
762     mVideoPlayer.SetCodecType( Dali::VideoPlayerPlugin::CodecType::SW );
763   }
764   else
765   {
766     mVideoPlayer.SetCodecType( Dali::VideoPlayerPlugin::CodecType::HW );
767   }
768 }
769
770 int VideoView::GetPlayPosition()
771 {
772   return mVideoPlayer.GetPlayPosition();
773 }
774
775 void VideoView::SetPlayPosition( int pos )
776 {
777   mVideoPlayer.SetPlayPosition( pos );
778 }
779
780 void VideoView::SetDisplayMode( int mode )
781 {
782   mVideoPlayer.SetDisplayMode( static_cast< Dali::VideoPlayerPlugin::DisplayMode::Type >( mode ) );
783 }
784
785 int VideoView::GetDisplayMode() const
786 {
787   return static_cast< int >( mVideoPlayer.GetDisplayMode() );
788 }
789
790 } // namespace Internal
791
792 } // namespace toolkit
793
794 } // namespace Dali