2014-03-26 18:46:52 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "oglframegrabber.hxx"
|
|
|
|
|
|
|
|
#include <cppuhelper/supportsservice.hxx>
|
|
|
|
#include <vcl/bitmapex.hxx>
|
|
|
|
#include <vcl/graph.hxx>
|
2014-04-20 18:00:33 +02:00
|
|
|
#include <vcl/salbtype.hxx>
|
|
|
|
#include <vcl/bmpacc.hxx>
|
2014-03-26 18:46:52 +01:00
|
|
|
|
2014-04-27 14:17:05 +02:00
|
|
|
#include <vcl/opengl/OpenGLHelper.hxx>
|
|
|
|
|
2015-06-15 17:58:15 +09:00
|
|
|
#include <memory>
|
2014-04-27 14:17:05 +02:00
|
|
|
|
2014-03-26 18:46:52 +01:00
|
|
|
using namespace com::sun::star;
|
2014-08-05 09:54:05 +02:00
|
|
|
using namespace libgltf;
|
2014-03-26 18:46:52 +01:00
|
|
|
|
|
|
|
namespace avmedia { namespace ogl {
|
|
|
|
|
2014-05-29 15:00:20 +02:00
|
|
|
OGLFrameGrabber::OGLFrameGrabber( glTFHandle& rHandle )
|
2014-03-26 18:46:52 +01:00
|
|
|
: FrameGrabber_BASE()
|
2014-05-29 15:00:20 +02:00
|
|
|
, m_rHandle( rHandle )
|
2014-03-26 18:46:52 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
OGLFrameGrabber::~OGLFrameGrabber()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-05-20 22:00:19 +02:00
|
|
|
uno::Reference< css::graphic::XGraphic > SAL_CALL OGLFrameGrabber::grabFrame( double /*fMediaTime*/ )
|
2014-03-26 18:46:52 +01:00
|
|
|
throw ( uno::RuntimeException, std::exception )
|
|
|
|
{
|
2015-06-15 17:58:15 +09:00
|
|
|
std::unique_ptr<sal_uInt8[]> pBuffer(new sal_uInt8[m_rHandle.viewport.width * m_rHandle.viewport.height * 4]);
|
2014-05-29 15:00:20 +02:00
|
|
|
glTFHandle* pHandle = &m_rHandle;
|
2015-01-17 18:05:56 +01:00
|
|
|
int nRet = gltf_renderer_get_bitmap(&pHandle, 1, reinterpret_cast<char*>(pBuffer.get()), GL_BGRA);
|
2014-07-14 00:21:55 +02:00
|
|
|
if( nRet != 0 )
|
|
|
|
{
|
2014-11-10 15:05:25 +01:00
|
|
|
SAL_WARN("avmedia.opengl", "Error occurred while rendering to bitmap! Error code: " << nRet);
|
2014-07-14 00:21:55 +02:00
|
|
|
return uno::Reference< css::graphic::XGraphic >();
|
|
|
|
}
|
2014-05-29 15:00:20 +02:00
|
|
|
BitmapEx aBitmap = OpenGLHelper::ConvertBGRABufferToBitmapEx(pBuffer.get(), m_rHandle.viewport.width, m_rHandle.viewport.height);
|
2014-03-26 18:46:52 +01:00
|
|
|
return Graphic( aBitmap ).GetXGraphic();
|
|
|
|
}
|
|
|
|
|
|
|
|
OUString SAL_CALL OGLFrameGrabber::getImplementationName() throw ( uno::RuntimeException, std::exception )
|
|
|
|
{
|
|
|
|
return OUString("com.sun.star.comp.avmedia.FrameGrabber_OpenGL");
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool SAL_CALL OGLFrameGrabber::supportsService( const OUString& rServiceName )
|
|
|
|
throw ( uno::RuntimeException, std::exception )
|
|
|
|
{
|
|
|
|
return cppu::supportsService(this, rServiceName);
|
|
|
|
}
|
|
|
|
|
|
|
|
uno::Sequence< OUString > SAL_CALL OGLFrameGrabber::getSupportedServiceNames()
|
|
|
|
throw ( uno::RuntimeException, std::exception )
|
|
|
|
{
|
|
|
|
uno::Sequence< OUString > aRet(1);
|
2014-12-18 13:19:53 +01:00
|
|
|
aRet[0] = "com.sun.star.media.FrameGrabber_OpenGL";
|
2014-03-26 18:46:52 +01:00
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace ogl
|
|
|
|
} // namespace avmedia
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|