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