summaryrefslogtreecommitdiff
path: root/avmedia/source
diff options
context:
space:
mode:
authorZolnai Tamás <tamas.zolnai@collabora.com>2014-04-20 18:00:33 +0200
committerZolnai Tamás <tamas.zolnai@collabora.com>2014-04-20 18:00:48 +0200
commitd8920e6d1de0698f7c132d74cc34e2f1021c6fb3 (patch)
tree83a8b9101fa46c9e3a7bd3ba32b6cab5b91b4a2e /avmedia/source
parent78609b36e0d61bd5535cfdc1ab2f1e0e59505042 (diff)
Make OGLFrameGrabber work
Steps of grabFrame - Init opengl context - Call libgltf to render - Get a RGB buffer from libgltf - Create a Bitmap from this RGB buffer Additionally: - Using mimetype is neccessary to decide which player to create. - bAllowToCreateReplacementGraphic is unneeded. Change-Id: I7fef043a3341771389144a4f4cac71b0862ef8a7
Diffstat (limited to 'avmedia/source')
-rw-r--r--avmedia/source/opengl/oglframegrabber.cxx30
-rw-r--r--avmedia/source/opengl/oglframegrabber.hxx7
-rw-r--r--avmedia/source/opengl/oglplayer.cxx5
-rw-r--r--avmedia/source/opengl/oglplayer.hxx2
-rw-r--r--avmedia/source/viewer/mediawindow.cxx12
-rw-r--r--avmedia/source/viewer/mediawindow_impl.cxx2
-rw-r--r--avmedia/source/viewer/mediawindow_impl.hxx2
7 files changed, 45 insertions, 15 deletions
diff --git a/avmedia/source/opengl/oglframegrabber.cxx b/avmedia/source/opengl/oglframegrabber.cxx
index 2aeda9720b8e..81be9c138826 100644
--- a/avmedia/source/opengl/oglframegrabber.cxx
+++ b/avmedia/source/opengl/oglframegrabber.cxx
@@ -12,13 +12,16 @@
#include <cppuhelper/supportsservice.hxx>
#include <vcl/bitmapex.hxx>
#include <vcl/graph.hxx>
+#include <vcl/salbtype.hxx>
+#include <vcl/bmpacc.hxx>
using namespace com::sun::star;
namespace avmedia { namespace ogl {
-OGLFrameGrabber::OGLFrameGrabber( const OUString& /*rUrl*/ )
+OGLFrameGrabber::OGLFrameGrabber( glTFHandle* pHandle )
: FrameGrabber_BASE()
+ , m_pHandle( pHandle )
{
}
@@ -26,12 +29,29 @@ OGLFrameGrabber::~OGLFrameGrabber()
{
}
-uno::Reference< css::graphic::XGraphic > SAL_CALL OGLFrameGrabber::grabFrame( double /*fMediaTime*/ )
+uno::Reference< css::graphic::XGraphic > SAL_CALL OGLFrameGrabber::grabFrame( double fMediaTime )
throw ( uno::RuntimeException, std::exception )
{
- // TODO: Here we need a bitmap of the model at the point specified by fMediaTime
- // See com::sun::star::media::XFrameGrabber
- BitmapEx aBitmap;
+ // TODO: libgltf should provide an RGBA buffer, not just an RGB one. See: OpenGLRender::GetAsBitmap().
+ char* pBuffer = new char[m_pHandle->viewport.width * m_pHandle->viewport.height * 3];
+ gltf_renderer_get_bitmap(m_pHandle, fMediaTime, pBuffer, 800, 600);
+ Bitmap aBitmap( Size(m_pHandle->viewport.width, m_pHandle->viewport.height), 24 );
+ {
+ Bitmap::ScopedWriteAccess pWriteAccess( aBitmap );
+ size_t nCurPos = 0;
+ for( int y = 0; y < m_pHandle->viewport.height; ++y)
+ {
+ Scanline pScan = pWriteAccess->GetScanline(y);
+ for( int x = 0; x < m_pHandle->viewport.width; ++x )
+ {
+ *pScan++ = pBuffer[nCurPos];
+ *pScan++ = pBuffer[nCurPos+1];
+ *pScan++ = pBuffer[nCurPos+2];
+ nCurPos += 3;
+ }
+ }
+ }
+ delete [] pBuffer;
return Graphic( aBitmap ).GetXGraphic();
}
diff --git a/avmedia/source/opengl/oglframegrabber.hxx b/avmedia/source/opengl/oglframegrabber.hxx
index fd3d9fb76b81..b4b1daee7326 100644
--- a/avmedia/source/opengl/oglframegrabber.hxx
+++ b/avmedia/source/opengl/oglframegrabber.hxx
@@ -14,6 +14,8 @@
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/media/XFrameGrabber.hpp>
+#include <libgltf.h>
+
namespace avmedia { namespace ogl {
typedef ::cppu::WeakImplHelper2< com::sun::star::media::XFrameGrabber,
@@ -23,7 +25,7 @@ class OGLFrameGrabber : public FrameGrabber_BASE
{
public:
- OGLFrameGrabber( const OUString& rURL );
+ OGLFrameGrabber( glTFHandle* pHandle );
virtual ~OGLFrameGrabber();
// XFrameGrabber
@@ -33,6 +35,9 @@ public:
virtual OUString SAL_CALL getImplementationName() throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+
+private:
+ glTFHandle* m_pHandle;
};
} // namespace ogl
diff --git a/avmedia/source/opengl/oglplayer.cxx b/avmedia/source/opengl/oglplayer.cxx
index d0ffde395229..f1d514a3cab4 100644
--- a/avmedia/source/opengl/oglplayer.cxx
+++ b/avmedia/source/opengl/oglplayer.cxx
@@ -196,7 +196,10 @@ uno::Reference< media::XFrameGrabber > SAL_CALL OGLPlayer::createFrameGrabber()
throw ( uno::RuntimeException, std::exception )
{
osl::MutexGuard aGuard(m_aMutex);
- OGLFrameGrabber *pFrameGrabber = new OGLFrameGrabber( m_sURL );
+ m_aContext.init();
+ m_pHandle->viewport = glTFViewport({0,0,800,600}); //TODO: Use real values instead of constants.
+ gltf_renderer_set_content(m_pHandle);
+ OGLFrameGrabber *pFrameGrabber = new OGLFrameGrabber( m_pHandle );
return uno::Reference< media::XFrameGrabber >( pFrameGrabber );;
}
diff --git a/avmedia/source/opengl/oglplayer.hxx b/avmedia/source/opengl/oglplayer.hxx
index cf8ac2cdb222..2b9b4154b2a6 100644
--- a/avmedia/source/opengl/oglplayer.hxx
+++ b/avmedia/source/opengl/oglplayer.hxx
@@ -15,6 +15,7 @@
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/media/XPlayer.hpp>
#include <libgltf.h>
+#include <vcl/opengl/OpenGLContext.hxx>
namespace avmedia { namespace ogl {
@@ -56,6 +57,7 @@ public:
private:
OUString m_sURL;
glTFHandle* m_pHandle;
+ OpenGLContext m_aContext;
};
} // namespace ogl
diff --git a/avmedia/source/viewer/mediawindow.cxx b/avmedia/source/viewer/mediawindow.cxx
index 992bb40a3460..e586a587e2ef 100644
--- a/avmedia/source/viewer/mediawindow.cxx
+++ b/avmedia/source/viewer/mediawindow.cxx
@@ -385,19 +385,19 @@ bool MediaWindow::isMediaURL( const OUString& rURL, const OUString& rReferer, bo
-uno::Reference< media::XPlayer > MediaWindow::createPlayer( const OUString& rURL, const OUString& rReferer )
+uno::Reference< media::XPlayer > MediaWindow::createPlayer( const OUString& rURL, const OUString& rReferer, const OUString* pMimeType )
{
- return priv::MediaWindowImpl::createPlayer( rURL, rReferer );
+ return priv::MediaWindowImpl::createPlayer( rURL, rReferer, pMimeType );
}
uno::Reference< graphic::XGraphic > MediaWindow::grabFrame( const OUString& rURL,
const OUString& rReferer,
- bool bAllowToCreateReplacementGraphic,
+ const OUString& sMimeType,
double fMediaTime )
{
- uno::Reference< media::XPlayer > xPlayer( createPlayer( rURL, rReferer ) );
+ uno::Reference< media::XPlayer > xPlayer( createPlayer( rURL, rReferer, &sMimeType ) );
uno::Reference< graphic::XGraphic > xRet;
boost::scoped_ptr< Graphic > apGraphic;
@@ -416,7 +416,7 @@ uno::Reference< graphic::XGraphic > MediaWindow::grabFrame( const OUString& rURL
xRet = xGrabber->grabFrame( fMediaTime );
}
- if( !xRet.is() && bAllowToCreateReplacementGraphic )
+ if( !xRet.is() )
{
awt::Size aPrefSize( xPlayer->getPreferredPlayerWindowSize() );
@@ -428,7 +428,7 @@ uno::Reference< graphic::XGraphic > MediaWindow::grabFrame( const OUString& rURL
}
}
- if( !xRet.is() && !apGraphic.get() && bAllowToCreateReplacementGraphic )
+ if( !xRet.is() && !apGraphic.get() )
{
const BitmapEx aBmpEx( getEmptyLogo() );
apGraphic.reset( new Graphic( aBmpEx ) );
diff --git a/avmedia/source/viewer/mediawindow_impl.cxx b/avmedia/source/viewer/mediawindow_impl.cxx
index f24c6e18c214..515580c65df3 100644
--- a/avmedia/source/viewer/mediawindow_impl.cxx
+++ b/avmedia/source/viewer/mediawindow_impl.cxx
@@ -205,7 +205,7 @@ MediaWindowImpl::~MediaWindowImpl()
delete mpMediaWindowControl;
}
-uno::Reference< media::XPlayer > MediaWindowImpl::createPlayer( const OUString& rURL, const OUString& rReferer, OUString* pMimeType )
+uno::Reference< media::XPlayer > MediaWindowImpl::createPlayer( const OUString& rURL, const OUString& rReferer, const OUString* pMimeType )
{
uno::Reference< media::XPlayer > xPlayer;
diff --git a/avmedia/source/viewer/mediawindow_impl.hxx b/avmedia/source/viewer/mediawindow_impl.hxx
index e0018639fc96..317cea8ef7d1 100644
--- a/avmedia/source/viewer/mediawindow_impl.hxx
+++ b/avmedia/source/viewer/mediawindow_impl.hxx
@@ -94,7 +94,7 @@ namespace avmedia
MediaWindowImpl( Window* parent, MediaWindow* pMediaWindow, bool bInternalMediaControl );
virtual ~MediaWindowImpl();
- static ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > createPlayer( const OUString& rURL, const OUString& rReferer, OUString* pMimeType = 0 );
+ static ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > createPlayer( const OUString& rURL, const OUString& rReferer, const OUString* pMimeType = 0 );
void setURL( const OUString& rURL, OUString const& rTempURL, OUString const& rReferer );