@@ -830,8 +830,6 @@ uno::Reference< ::media::XPlayerWindow > SAL_CALL Player::createPlayerWindow( co
830
830
{
831
831
::osl::MutexGuard aGuard (m_aMutex);
832
832
833
- uno::Reference< ::media::XPlayerWindow > xRet;
834
-
835
833
if (rArguments.getLength () > 1 )
836
834
rArguments[1 ] >>= maArea;
837
835
@@ -842,93 +840,92 @@ uno::Reference< ::media::XPlayerWindow > SAL_CALL Player::createPlayerWindow( co
842
840
843
841
SAL_INFO ( " avmedia.gstreamer" , AVVERSION " Player::createPlayerWindow " << aSize.Width << " x" << aSize.Height << " length: " << rArguments.getLength () );
844
842
845
- if ( aSize.Width > 0 && aSize.Height > 0 )
843
+ if ( aSize.Width <= 0 || aSize.Height <= 0 )
844
+ return nullptr ;
845
+
846
+ if (rArguments.getLength () <= 2 )
846
847
{
847
- if (rArguments.getLength () <= 2 )
848
- {
849
- xRet = new ::avmedia::gstreamer::Window;
850
- return xRet;
851
- }
848
+ return new ::avmedia::gstreamer::Window;
849
+ }
852
850
853
- sal_IntPtr pIntPtr = 0 ;
854
- rArguments[ 2 ] >>= pIntPtr;
855
- SystemChildWindow *pParentWindow = reinterpret_cast < SystemChildWindow* >( pIntPtr );
856
- if (!pParentWindow)
857
- return nullptr ;
851
+ sal_IntPtr pIntPtr = 0 ;
852
+ rArguments[ 2 ] >>= pIntPtr;
853
+ SystemChildWindow *pParentWindow = reinterpret_cast < SystemChildWindow* >( pIntPtr );
854
+ if (!pParentWindow)
855
+ return nullptr ;
858
856
859
- const SystemEnvData* pEnvData = pParentWindow->GetSystemData ();
860
- if (!pEnvData)
861
- return nullptr ;
857
+ const SystemEnvData* pEnvData = pParentWindow->GetSystemData ();
858
+ if (!pEnvData)
859
+ return nullptr ;
862
860
863
- // tdf#124027: the position of embedded window is identical w/ the position
864
- // of media object in all other vclplugs (kf5, gen), in gtk3 w/o gtksink it
865
- // needs to be translated
866
- if (pEnvData->toolkit == SystemEnvData::Toolkit::Gtk)
867
- {
868
- Point aPoint = pParentWindow->GetPosPixel ();
869
- maArea.X = aPoint.getX ();
870
- maArea.Y = aPoint.getY ();
871
- }
861
+ // tdf#124027: the position of embedded window is identical w/ the position
862
+ // of media object in all other vclplugs (kf5, gen), in gtk3 w/o gtksink it
863
+ // needs to be translated
864
+ if (pEnvData->toolkit == SystemEnvData::Toolkit::Gtk)
865
+ {
866
+ Point aPoint = pParentWindow->GetPosPixel ();
867
+ maArea.X = aPoint.getX ();
868
+ maArea.Y = aPoint.getY ();
869
+ }
872
870
873
- mbUseGtkSink = false ;
871
+ mbUseGtkSink = false ;
874
872
875
- GstElement *pVideosink = static_cast <GstElement*>(pParentWindow->CreateGStreamerSink ());
876
- if (pVideosink)
877
- {
878
- if (pEnvData->toolkit == SystemEnvData::Toolkit::Gtk)
879
- mbUseGtkSink = true ;
880
- }
873
+ GstElement *pVideosink = static_cast <GstElement*>(pParentWindow->CreateGStreamerSink ());
874
+ if (pVideosink)
875
+ {
876
+ if (pEnvData->toolkit == SystemEnvData::Toolkit::Gtk)
877
+ mbUseGtkSink = true ;
878
+ }
879
+ else
880
+ {
881
+ if (pEnvData->platform == SystemEnvData::Platform::Wayland)
882
+ pVideosink = gst_element_factory_make (" waylandsink" , " video-output" );
881
883
else
882
- {
883
- if (pEnvData->platform == SystemEnvData::Platform::Wayland)
884
- pVideosink = gst_element_factory_make (" waylandsink" , " video-output" );
885
- else
886
- pVideosink = gst_element_factory_make (" autovideosink" , " video-output" );
887
- if (!pVideosink)
888
- return nullptr ;
889
- }
884
+ pVideosink = gst_element_factory_make (" autovideosink" , " video-output" );
885
+ if (!pVideosink)
886
+ return nullptr ;
887
+ }
890
888
891
- xRet = new ::avmedia::gstreamer::Window;
889
+ rtl::Reference< ::avmedia::gstreamer::Window > xRet = new ::avmedia::gstreamer::Window;
892
890
893
- g_object_set (G_OBJECT (mpPlaybin), " video-sink" , pVideosink, nullptr );
894
- g_object_set (G_OBJECT (mpPlaybin), " force-aspect-ratio" , FALSE , nullptr );
891
+ g_object_set (G_OBJECT (mpPlaybin), " video-sink" , pVideosink, nullptr );
892
+ g_object_set (G_OBJECT (mpPlaybin), " force-aspect-ratio" , FALSE , nullptr );
895
893
896
- if ((rArguments.getLength () >= 4 ) && (rArguments[3 ] >>= pIntPtr) && pIntPtr)
894
+ if ((rArguments.getLength () >= 4 ) && (rArguments[3 ] >>= pIntPtr) && pIntPtr)
895
+ {
896
+ auto pItem = reinterpret_cast <const avmedia::MediaItem*>(pIntPtr);
897
+ Graphic aGraphic = pItem->getGraphic ();
898
+ const text::GraphicCrop& rCrop = pItem->getCrop ();
899
+ if (!aGraphic.IsNone () && (rCrop.Bottom > 0 || rCrop.Left > 0 || rCrop.Right > 0 || rCrop.Top > 0 ))
897
900
{
898
- auto pItem = reinterpret_cast <const avmedia::MediaItem*>(pIntPtr);
899
- Graphic aGraphic = pItem->getGraphic ();
900
- const text::GraphicCrop& rCrop = pItem->getCrop ();
901
- if (!aGraphic.IsNone () && (rCrop.Bottom > 0 || rCrop.Left > 0 || rCrop.Right > 0 || rCrop.Top > 0 ))
901
+ // The media item has a non-empty cropping set. Try to crop the video accordingly.
902
+ Size aPref = aGraphic.GetPrefSize ();
903
+ Size aPixel = aGraphic.GetSizePixel ();
904
+ tools::Long nLeft = aPixel.getWidth () * rCrop.Left / aPref.getWidth ();
905
+ tools::Long nTop = aPixel.getHeight () * rCrop.Top / aPref.getHeight ();
906
+ tools::Long nRight = aPixel.getWidth () * rCrop.Right / aPref.getWidth ();
907
+ tools::Long nBottom = aPixel.getHeight () * rCrop.Bottom / aPref.getHeight ();
908
+ GstElement* pVideoFilter = gst_element_factory_make (" videocrop" , nullptr );
909
+ if (pVideoFilter)
902
910
{
903
- // The media item has a non-empty cropping set. Try to crop the video accordingly.
904
- Size aPref = aGraphic.GetPrefSize ();
905
- Size aPixel = aGraphic.GetSizePixel ();
906
- tools::Long nLeft = aPixel.getWidth () * rCrop.Left / aPref.getWidth ();
907
- tools::Long nTop = aPixel.getHeight () * rCrop.Top / aPref.getHeight ();
908
- tools::Long nRight = aPixel.getWidth () * rCrop.Right / aPref.getWidth ();
909
- tools::Long nBottom = aPixel.getHeight () * rCrop.Bottom / aPref.getHeight ();
910
- GstElement* pVideoFilter = gst_element_factory_make (" videocrop" , nullptr );
911
- if (pVideoFilter)
912
- {
913
- g_object_set (G_OBJECT (pVideoFilter), " left" , nLeft, nullptr );
914
- g_object_set (G_OBJECT (pVideoFilter), " top" , nTop, nullptr );
915
- g_object_set (G_OBJECT (pVideoFilter), " right" , nRight, nullptr );
916
- g_object_set (G_OBJECT (pVideoFilter), " bottom" , nBottom, nullptr );
917
- g_object_set (G_OBJECT (mpPlaybin), " video-filter" , pVideoFilter, nullptr );
918
- }
911
+ g_object_set (G_OBJECT (pVideoFilter), " left" , nLeft, nullptr );
912
+ g_object_set (G_OBJECT (pVideoFilter), " top" , nTop, nullptr );
913
+ g_object_set (G_OBJECT (pVideoFilter), " right" , nRight, nullptr );
914
+ g_object_set (G_OBJECT (pVideoFilter), " bottom" , nBottom, nullptr );
915
+ g_object_set (G_OBJECT (mpPlaybin), " video-filter" , pVideoFilter, nullptr );
919
916
}
920
917
}
918
+ }
921
919
922
- if (!mbUseGtkSink)
923
- {
924
- mnWindowID = pEnvData->GetWindowHandle (pParentWindow->ImplGetFrame ());
925
- mpDisplay = pEnvData->pDisplay ;
926
- SAL_INFO ( " avmedia.gstreamer" , AVVERSION " set window id to " << static_cast <int >(mnWindowID) << " XOverlay " << mpXOverlay);
927
- }
928
- gst_element_set_state ( mpPlaybin, GST_STATE_PAUSED );
929
- if (!mbUseGtkSink && mpXOverlay)
930
- gst_video_overlay_set_window_handle ( mpXOverlay, mnWindowID );
920
+ if (!mbUseGtkSink)
921
+ {
922
+ mnWindowID = pEnvData->GetWindowHandle (pParentWindow->ImplGetFrame ());
923
+ mpDisplay = pEnvData->pDisplay ;
924
+ SAL_INFO ( " avmedia.gstreamer" , AVVERSION " set window id to " << static_cast <int >(mnWindowID) << " XOverlay " << mpXOverlay);
931
925
}
926
+ gst_element_set_state ( mpPlaybin, GST_STATE_PAUSED );
927
+ if (!mbUseGtkSink && mpXOverlay)
928
+ gst_video_overlay_set_window_handle ( mpXOverlay, mnWindowID );
932
929
933
930
return xRet;
934
931
}
0 commit comments