25#include <gst/gstbuffer.h>
26#include <gst/video/video.h>
27#include <gst/video/gstvideosink.h>
45 gst_element_set_state(
mpPipeline, GST_STATE_NULL );
54 pPipelineStr = g_strdup_printf(
55 "uridecodebin uri=%s ! videoconvert ! videoscale ! appsink "
56 "name=sink caps=\"video/x-raw,format=RGB,pixel-aspect-ratio=1/1\"",
59 GError *pError =
nullptr;
60 mpPipeline = gst_parse_launch( pPipelineStr, &pError );
61 if( pError !=
nullptr) {
62 g_warning(
"Failed to construct frame-grabber pipeline '%s'\n", pError->message );
63 g_error_free( pError );
69 switch( gst_element_set_state(
mpPipeline, GST_STATE_PAUSED ) ) {
70 case GST_STATE_CHANGE_FAILURE:
71 case GST_STATE_CHANGE_NO_PREROLL:
72 g_warning(
"failure pre-rolling media" );
80 gst_element_get_state(
mpPipeline,
nullptr,
nullptr, 5 * GST_SECOND ) == GST_STATE_CHANGE_FAILURE )
96 uno::Reference< graphic::XGraphic > xRet;
101 gint64 gst_position = llround( fMediaTime * GST_SECOND );
102 gst_element_seek_simple(
104 GstSeekFlags(GST_SEEK_FLAG_KEY_UNIT | GST_SEEK_FLAG_FLUSH),
107 GstElement *pSink = gst_bin_get_by_name( GST_BIN(
mpPipeline ),
"sink" );
111 GstBuffer *pBuf =
nullptr;
112 GstCaps *pCaps =
nullptr;
115 GstSample *pSample =
nullptr;
116 g_signal_emit_by_name( pSink,
"pull-preroll", &pSample,
nullptr );
120 pBuf = gst_sample_get_buffer( pSample );
121 pCaps = gst_sample_get_caps( pSample );
125 int nWidth = 0, nHeight = 0;
127 g_warning(
"could not get snapshot format\n" );
130 GstStructure *pStruct = gst_caps_get_structure( pCaps, 0 );
133 if( !gst_structure_get_int( pStruct,
"width", &nWidth ) ||
134 !gst_structure_get_int( pStruct,
"height", &nHeight ) )
135 nWidth = nHeight = 0;
138 if( pBuf && nWidth > 0 && nHeight > 0 &&
145 gst_buffer_map( pBuf, &aMapInfo, GST_MAP_READ );
146 pData = aMapInfo.data;
148 int nStride = GST_ROUND_UP_4( nWidth * 3 );
151 gst_buffer_unmap( pBuf, &aMapInfo );
css::uno::Reference< css::graphic::XGraphic > GetXGraphic() const
constexpr OUStringLiteral AVMEDIA_GST_FRAMEGRABBER_SERVICENAME
constexpr OUStringLiteral AVMEDIA_GST_FRAMEGRABBER_IMPLEMENTATIONNAME
std::unique_ptr< sal_Int32[]> pData
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
BitmapEx CreateFromData(sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int32 nStride, sal_Int8 nBitCount, bool bReversColors, bool bReverseAlpha)