qtvideo-node-0.2.1+14.04.20140304/ 0000755 0000152 0177776 00000000000 12305354454 016507 5 ustar pbuser nogroup 0000000 0000000 qtvideo-node-0.2.1+14.04.20140304/unittests/ 0000755 0000152 0177776 00000000000 12305354454 020551 5 ustar pbuser nogroup 0000000 0000000 qtvideo-node-0.2.1+14.04.20140304/unittests/shadervideonode/ 0000755 0000152 0177776 00000000000 12305354454 023714 5 ustar pbuser nogroup 0000000 0000000 qtvideo-node-0.2.1+14.04.20140304/unittests/shadervideonode/camera.cpp 0000644 0000152 0177776 00000001515 12305354242 025645 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "camera_compatibility_layer.h"
void android_camera_update_preview_texture(CameraControl *)
{
}
void android_camera_get_preview_texture_transformation(CameraControl *, GLfloat *)
{
}
qtvideo-node-0.2.1+14.04.20140304/unittests/shadervideonode/shadervideonode.pro 0000644 0000152 0177776 00000002325 12305354252 027577 0 ustar pbuser nogroup 0000000 0000000 CONFIG += testcase
CONFIG += no_private_qt_headers_warning
TARGET = tst_shadervideonode
# We don't want to install unit tests anywhere as it doesn't make sense
target.CONFIG += no_default_install
include(../../coverage.pri)
QT += testlib multimedia opengl quick-private
# This is to avoid a segfault in shadervideonode.cpp when it tries to call
# glGenTextures(), since the platform currently does not support real OpenGL
# when running unit tests.
DEFINES += TST_NO_OPENGL
SOURCES += tst_shadervideonode.cpp \
../../src/shadervideomaterial.cpp \
../../src/shadervideonode.cpp \
../../src/shadervideoshader.cpp \
../../src/snapshotgenerator.cpp \
../../src/qsgvideonode_p.cpp \
camera.cpp \
player.cpp
HEADERS += . ../../src/shadervideomaterial.h \
../../src/shadervideonode.h \
../../src/shadervideoshader.h \
../../src/snapshotgenerator.h \
../../src/private/qtmultimediaquickdefs_p.h \
../../src/private/qsgvideonode_p.h \
camera_compatibility_layer.h \
media_compatibility_layer.h \
surface_texture_client_hybris.h
INCLUDEPATH += ../../src /usr/include/hybris/camera /usr/include/hybris/media /usr/include/libqtubuntu-media-signals
LIBS += -lqtubuntu-media-signals
qtvideo-node-0.2.1+14.04.20140304/unittests/shadervideonode/camera_compatibility_layer.h 0000644 0000152 0177776 00000001531 12305354242 031435 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include
struct CameraControl {
int dummy;
};
void android_camera_update_preview_texture(CameraControl *);
void android_camera_get_preview_texture_transformation(CameraControl *, GLfloat *);
qtvideo-node-0.2.1+14.04.20140304/unittests/shadervideonode/tst_shadervideonode.cpp 0000644 0000152 0177776 00000005563 12305354242 030461 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include
#include
#include
#include
#include
#include "camera_compatibility_layer.h"
#include "surface_texture_client_hybris.h"
#define private public
#include "shadervideonode.h"
class tst_ShaderVideoNode : public QObject
{
Q_OBJECT
private slots:
void testCameraSetCurrentFrame();
void testTextureIdSetCurrentFrame();
};
class GLTextureBuffer : public QAbstractVideoBuffer
{
public:
GLTextureBuffer(unsigned int textureId) :
QAbstractVideoBuffer(QAbstractVideoBuffer::GLTextureHandle),
m_textureId(textureId)
{
}
MapMode mapMode() const { return NotMapped; }
uchar *map(MapMode mode, int *numBytes, int *bytesPerLine)
{
Q_UNUSED(mode);
Q_UNUSED(numBytes);
Q_UNUSED(bytesPerLine);
return (uchar*)0;
}
void unmap() {}
QVariant handle() const
{
return QVariant::fromValue(m_textureId);
}
private:
unsigned int m_textureId;
};
void tst_ShaderVideoNode::testCameraSetCurrentFrame()
{
QVideoSurfaceFormat format;
ShaderVideoNode node(format);
CameraControl *cc = new CameraControl;
QVideoFrame frame(new GLTextureBuffer(1), QSize(320, 240), QVideoFrame::Format_RGB32);
node.setCurrentFrame(frame);
QCOMPARE(QVariant(QMetaType::VoidStar, node.m_material->cameraControl()),
QVariant(QMetaType::VoidStar, 0));
frame.setMetaData("CamControl", QVariant::fromValue((void*)cc));
node.setCurrentFrame(frame);
QCOMPARE(QVariant(QMetaType::VoidStar, node.m_material->cameraControl()),
QVariant(QMetaType::VoidStar, cc));
}
void tst_ShaderVideoNode::testTextureIdSetCurrentFrame()
{
QVideoSurfaceFormat format;
ShaderVideoNode node(format);
QVideoFrame frame(new GLTextureBuffer(1), QSize(1920, 80), QVideoFrame::Format_RGB32);
node.setCurrentFrame(frame);
QCOMPARE(node.m_material->textureId(), (const GLuint)0);
frame.setMetaData("TextureId", 70001);
frame.setMetaData("SurfaceTextureClient", 0x1);
node.setCurrentFrame(frame);
QCOMPARE(node.m_material->textureId(), (const GLuint)70001);
}
QTEST_MAIN(tst_ShaderVideoNode)
#include "tst_shadervideonode.moc"
qtvideo-node-0.2.1+14.04.20140304/unittests/shadervideonode/media_compatibility_layer.h 0000644 0000152 0177776 00000004723 12305354242 031272 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Authored by: Jim Hodapp
*/
#ifndef MEDIA_COMPATIBILITY_LAYER_H_
#define MEDIA_COMPATIBILITY_LAYER_H_
#include
#include
#include
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*on_msg_set_video_size)(int height, int width, void *context);
typedef void (*on_video_texture_needs_update)(void *context);
typedef void (*on_msg_error)(void *context);
struct MediaPlayerWrapper;
// ----- Start of C API ----- //
void android_media_set_video_size_cb(MediaPlayerWrapper *mp, on_msg_set_video_size cb, void *context);
void android_media_set_video_texture_needs_update_cb(MediaPlayerWrapper *mp, on_video_texture_needs_update cb, void *context);
void android_media_set_error_cb(MediaPlayerWrapper *mp, on_msg_error cb, void *context);
MediaPlayerWrapper *android_media_new_player();
int android_media_set_data_source(MediaPlayerWrapper *mp, const char* url);
int android_media_set_preview_texture(MediaPlayerWrapper *mp, int texture_id);
void android_media_update_surface_texture(MediaPlayerWrapper *mp);
void android_media_surface_texture_get_transformation_matrix(MediaPlayerWrapper *mp, GLfloat*matrix);
int android_media_play(MediaPlayerWrapper *mp);
int android_media_pause(MediaPlayerWrapper *mp);
int android_media_stop(MediaPlayerWrapper *mp);
bool android_media_is_playing(MediaPlayerWrapper *mp);
int android_media_seek_to(MediaPlayerWrapper *mp, int msec);
int android_media_get_current_position(MediaPlayerWrapper *mp, int *msec);
int android_media_get_duration(MediaPlayerWrapper *mp, int *msec);
int android_media_get_volume(MediaPlayerWrapper *mp, int *volume);
int android_media_set_volume(MediaPlayerWrapper *mp, int volume);
#ifdef __cplusplus
}
#endif
#endif // CAMERA_COMPATIBILITY_LAYER_H_
qtvideo-node-0.2.1+14.04.20140304/unittests/shadervideonode/player.cpp 0000644 0000152 0177776 00000001755 12305354242 025717 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "surface_texture_client_hybris.h"
#include
typedef void* SurfaceTextureClientHybris;
void surface_texture_client_get_transformation_matrix(SurfaceTextureClientHybris stc, float *matrix)
{
Q_UNUSED(stc);
Q_UNUSED(matrix);
}
void surface_texture_client_update_texture(SurfaceTextureClientHybris stc)
{
Q_UNUSED(stc);
}
qtvideo-node-0.2.1+14.04.20140304/unittests/unittests.pro 0000644 0000152 0177776 00000000056 12305354242 023331 0 ustar pbuser nogroup 0000000 0000000 TEMPLATE = subdirs
SUBDIRS += shadervideonode
qtvideo-node-0.2.1+14.04.20140304/videonode.pro 0000644 0000152 0177776 00000000120 12305354242 021171 0 ustar pbuser nogroup 0000000 0000000 TEMPLATE = subdirs
include(coverage.pri)
SUBDIRS += \
src \
unittests
qtvideo-node-0.2.1+14.04.20140304/coverage.pri 0000644 0000152 0177776 00000003555 12305354242 021021 0 ustar pbuser nogroup 0000000 0000000 # Coverage
CONFIG(coverage) {
OBJECTS_DIR =
MOC_DIR =
TOP_SRC_DIR = $$PWD
LIBS += -lgcov
QMAKE_CXXFLAGS += --coverage
QMAKE_LDFLAGS += --coverage
QMAKE_EXTRA_TARGETS += coverage cov
QMAKE_EXTRA_TARGETS += clean-gcno clean-gcda coverage-html \
generate-coverage-html clean-coverage-html coverage-gcovr \
generate-gcovr generate-coverage-gcovr clean-coverage-gcovr
clean-gcno.commands = \
"@echo Removing old coverage instrumentation"; \
"find -name '*.gcno' -print | xargs -r rm"
clean-gcda.commands = \
"@echo Removing old coverage results"; \
"find -name '*.gcda' -print | xargs -r rm"
coverage-html.depends = clean-gcda check generate-coverage-html
generate-coverage-html.commands = \
"@echo Collecting coverage data"; \
"lcov --directory $${TOP_SRC_DIR} --capture --output-file coverage.info --no-checksum --compat-libtool"; \
"lcov --extract coverage.info \"*/src/*.cpp\" -o coverage.info"; \
"lcov --remove coverage.info \"moc_*.cpp\" -o coverage.info"; \
"LANG=C genhtml --prefix $${TOP_SRC_DIR} --output-directory coverage-html --title \"Code Coverage\" --legend --show-details coverage.info"
clean-coverage-html.depends = clean-gcda
clean-coverage-html.commands = \
"lcov --directory $${TOP_SRC_DIR} -z"; \
"rm -rf coverage.info coverage-html"
coverage-gcovr.depends = clean-gcda check generate-coverage-gcovr
generate-coverage-gcovr.commands = \
"@echo Generating coverage GCOVR report"; \
"gcovr -x -r $${TOP_SRC_DIR} -o $${TOP_SRC_DIR}/coverage.xml -e \".*/moc_.*\" -e \"tests/.*\" -e \".*\\.h\""
clean-coverage-gcovr.depends = clean-gcda
clean-coverage-gcovr.commands = \
"rm -rf $${TOP_SRC_DIR}/coverage.xml"
QMAKE_CLEAN += *.gcda *.gcno coverage.info coverage.xml
}
qtvideo-node-0.2.1+14.04.20140304/src/ 0000755 0000152 0177776 00000000000 12305354454 017276 5 ustar pbuser nogroup 0000000 0000000 qtvideo-node-0.2.1+14.04.20140304/src/snapshotgenerator.cpp 0000644 0000152 0177776 00000012377 12305354242 023555 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "snapshotgenerator.h"
#include
#include
#include
#include
#include
SnapshotGenerator::SnapshotGenerator()
: m_width(0),
m_height(0),
position_loc(0),
v_matrix_loc(0),
tex_coord_loc(0),
sampler_loc(0),
tex_matrix_loc(0)
{
}
/**
* @brief SnapshotGenerator::snapshot
* @param textureId Texture to be stored as QImage
* @return Image containing the content of the last texture
*/
QImage SnapshotGenerator::snapshot(GLuint textureId, const CameraControl *control)
{
Q_ASSERT(textureId > 0);
Q_ASSERT(control != NULL);
QGLFramebufferObject fbo(m_width, m_height);
QPainter paint(&fbo);
fbo.bind();
#ifdef __arm__
QOpenGLShaderProgram program;
program.addShaderFromSourceCode(QOpenGLShader::Vertex, vertexShader());
program.addShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShader());
program.link();
program.bind();
glViewport(0, 0, m_width, m_height);
position_loc = program.attributeLocation("a_position");
v_matrix_loc = program.uniformLocation("v_matrix");
sampler_loc = program.uniformLocation("s_texture");
tex_coord_loc = program.attributeLocation("a_texCoord");
tex_matrix_loc = program.uniformLocation("m_texMatrix");
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
GLfloat vVertices[] = {
0.0f, 00.0f, 0.0f, // Position 0
0.0f, 1.0f, 0.0f, // Position 1
1.0f, 1.0f, 0.0f, // Position 2
1.0f, 00.0f, 0.0f, // Position 3
};
vVertices[4] = m_height;
vVertices[6] = m_width;
vVertices[7] = m_height;
vVertices[9] = m_width;
GLfloat tVertices[] = {
0.0f, 1.0f, // TexCoord 1
0.0f, 0.0f, // TexCoord 0
1.0f, 0.0f, // TexCoord 3
1.0f, 1.0f // TexCoord 2
};
GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
program.enableAttributeArray(position_loc);
program.setAttributeArray(position_loc, vVertices, 3);
QMatrix4x4 pmvMatrix;
pmvMatrix.ortho(QRect(0,0,m_width,m_height));
program.setUniformValue(v_matrix_loc, pmvMatrix);
program.enableAttributeArray(tex_coord_loc);
program.setAttributeArray(tex_coord_loc, tVertices, 2);
program.enableAttributeArray(sampler_loc);
program.setUniformValue(sampler_loc, 0);
program.enableAttributeArray(tex_matrix_loc);
GLfloat textureMatrix[16];
android_camera_get_preview_texture_transformation(const_cast(control), textureMatrix);
QMatrix4x4 texMat(textureMatrix);
texMat = texMat.transposed();
program.setUniformValue(tex_matrix_loc, texMat);
glBindTexture(GL_TEXTURE_2D, textureId);
glActiveTexture(GL_TEXTURE0);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
#endif
return fbo.toImage();
}
void SnapshotGenerator::setSize(int width, int height)
{
m_width = width;
m_height = height;
}
const char *SnapshotGenerator::vertexShader() const
{
return
"#extension GL_OES_EGL_image_external : require \n"
"attribute vec4 a_position; \n"
"uniform highp mat4 v_matrix; \n"
"attribute vec2 a_texCoord; \n"
"uniform mat4 m_texMatrix; \n"
"varying vec2 v_texCoord; \n"
"void main() \n"
"{ \n"
" gl_Position = v_matrix * a_position; \n"
" v_texCoord = (m_texMatrix * vec4(a_texCoord, 0.0, 1.0)).xy;\n"
"} \n";
}
const char *SnapshotGenerator::fragmentShader() const
{
return
"#extension GL_OES_EGL_image_external : require \n"
"precision mediump float; \n"
"varying vec2 v_texCoord; \n"
"uniform samplerExternalOES s_texture; \n"
"void main() \n"
"{ \n"
" gl_FragColor = texture2D( s_texture, v_texCoord );\n"
"} \n";
}
qtvideo-node-0.2.1+14.04.20140304/src/shadervideoshader.cpp 0000644 0000152 0177776 00000006347 12305354242 023473 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "shadervideoshader.h"
#include "shadervideomaterial.h"
ShaderVideoShader::ShaderVideoShader(QVideoFrame::PixelFormat pixelFormat)
: QSGMaterialShader(),
m_pixelFormat(pixelFormat)
{
}
void ShaderVideoShader::updateState(const RenderState &state,
QSGMaterial *newMaterial,
QSGMaterial *oldMaterial)
{
Q_UNUSED(oldMaterial);
ShaderVideoMaterial *mat = dynamic_cast(newMaterial);
program()->setUniformValue(m_id_Texture, 0);
if (state.isMatrixDirty())
program()->setUniformValue(m_id_matrix, state.combinedMatrix());
mat->bind();
// if (state.isOpacityDirty()) {
// mat->m_opacity = state.opacity();
// mat->updateBlending();
// program()->setUniformValue(m_id_opacity, GLfloat(mat->m_opacity));
// }
}
char const *const *ShaderVideoShader::attributeNames() const
{
static const char *names[] = {
"qt_VertexPosition",
"qt_VertexTexCoord",
0
};
return names;
}
const char *ShaderVideoShader::vertexShader() const
{
const char *shader =
"uniform highp mat4 qt_Matrix; \n"
"attribute highp vec4 qt_VertexPosition; \n"
"attribute highp vec2 qt_VertexTexCoord; \n"
"varying highp vec2 qt_TexCoord; \n"
"uniform mat4 s_tex_Matrix; \n"
"void main() { \n"
" qt_TexCoord = (s_tex_Matrix * vec4(qt_VertexTexCoord, 0.0, 1.0)).xy;\n"
" gl_Position = qt_Matrix * qt_VertexPosition; \n"
"}";
return shader;
}
const char *ShaderVideoShader::fragmentShader() const
{
static const char *shader =
"#extension GL_OES_EGL_image_external : require \n"
"uniform samplerExternalOES sTexture; \n"
"uniform lowp float opacity; \n"
"varying highp vec2 qt_TexCoord; \n"
"void main() \n"
"{ \n"
" gl_FragColor = texture2D( sTexture, qt_TexCoord );\n"
"} \n";
return shader;
}
void ShaderVideoShader::initialize()
{
m_id_matrix = program()->uniformLocation("qt_Matrix");
m_id_Texture = program()->uniformLocation("sTexture");
m_id_opacity = program()->uniformLocation("opacity");
m_tex_matrix = program()->uniformLocation("s_tex_Matrix");
}
qtvideo-node-0.2.1+14.04.20140304/src/shadervideonode.h 0000644 0000152 0177776 00000003051 12305354242 022604 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef SHADERVIDEONODE_H
#define SHADERVIDEONODE_H
#include
#include
#include
class CameraControl;
class ShaderVideoMaterial;
class SnapshotGenerator;
class ShaderVideoNode : public QObject, public QSGVideoNode
{
Q_OBJECT
public:
typedef void* SurfaceTextureClientHybris;
ShaderVideoNode(const QVideoSurfaceFormat &format);
~ShaderVideoNode();
QVideoFrame::PixelFormat pixelFormat() const;
void setCurrentFrame(const QVideoFrame &frame);
private Q_SLOTS:
void onSetSnapshotSize(const QSize &size);
void onTakeSnapshot(const CameraControl *control);
private:
void getGLTextureID();
void deleteTextureID();
QVideoSurfaceFormat m_format;
ShaderVideoMaterial *m_material;
GLuint m_textureId;
SurfaceTextureClientHybris m_surfaceTextureClient;
SnapshotGenerator *m_snapshotGenerator;
};
#endif // SHADERVIDEONODE_H
qtvideo-node-0.2.1+14.04.20140304/src/private/ 0000755 0000152 0177776 00000000000 12305354454 020750 5 ustar pbuser nogroup 0000000 0000000 qtvideo-node-0.2.1+14.04.20140304/src/private/qsgvideonode_p.h 0000644 0000152 0177776 00000006756 12305354252 024141 0 ustar pbuser nogroup 0000000 0000000 /****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSGVIDEONODE_P_H
#define QSGVIDEONODE_P_H
#include
#include
#include
#include
#include
QT_BEGIN_NAMESPACE
const QLatin1String QSGVideoNodeFactoryPluginKey("sgvideonodes");
class Q_MULTIMEDIAQUICK_EXPORT QSGVideoNode : public QSGGeometryNode
{
public:
QSGVideoNode();
virtual void setCurrentFrame(const QVideoFrame &frame) = 0;
virtual QVideoFrame::PixelFormat pixelFormat() const = 0;
void setTexturedRectGeometry(const QRectF &boundingRect, const QRectF &textureRect, int orientation);
private:
QRectF m_rect;
QRectF m_textureRect;
int m_orientation;
};
class Q_MULTIMEDIAQUICK_EXPORT QSGVideoNodeFactoryInterface
{
public:
virtual QList supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType) const = 0;
virtual QSGVideoNode *createNode(const QVideoSurfaceFormat &format) = 0;
};
#define QSGVideoNodeFactoryInterface_iid "org.qt-project.qt.sgvideonodefactory/5.0"
Q_DECLARE_INTERFACE(QSGVideoNodeFactoryInterface, QSGVideoNodeFactoryInterface_iid)
class Q_MULTIMEDIAQUICK_EXPORT QSGVideoNodeFactoryPlugin : public QObject, public QSGVideoNodeFactoryInterface
{
Q_OBJECT
Q_INTERFACES(QSGVideoNodeFactoryInterface)
public:
virtual QList supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType) const = 0;
virtual QSGVideoNode *createNode(const QVideoSurfaceFormat &format) = 0;
};
QT_END_NAMESPACE
#endif // QSGVIDEONODE_H
qtvideo-node-0.2.1+14.04.20140304/src/private/qtmultimediaquickdefs_p.h 0000644 0000152 0177776 00000005010 12305354252 026026 0 ustar pbuser nogroup 0000000 0000000 /****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#ifndef QMULTIMEDIAQUICKDEFS_P_H
#define QMULTIMEDIAQUICKDEFS_P_H
#include
#ifndef QT_STATIC
# if defined(QT_BUILD_QTMM_QUICK_LIB)
# define Q_MULTIMEDIAQUICK_EXPORT Q_DECL_EXPORT
# else
# define Q_MULTIMEDIAQUICK_EXPORT Q_DECL_IMPORT
# endif
#else
# define Q_MULTIMEDIAQUICK_EXPORT
#endif
#endif // QMULTIMEDIAQUICKDEFS_P_H
qtvideo-node-0.2.1+14.04.20140304/src/shadervideomaterial.cpp 0000644 0000152 0177776 00000007644 12305354242 024024 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifdef QT_OPENGL_ES_2
# define TEXTURE_TARGET GL_TEXTURE_EXTERNAL_OES
#else
# define TEXTURE_TARGET GL_TEXTURE_2D
# define GL_GLEXT_PROTOTYPES
#endif
#include
#include
#include "shadervideomaterial.h"
#include "shadervideoshader.h"
#include
#include
ShaderVideoShader *ShaderVideoMaterial::m_videoShader = 0;
ShaderVideoMaterial::ShaderVideoMaterial(const QVideoSurfaceFormat &format)
: m_format(format),
m_camControl(0),
m_textureId(0),
m_surfaceTextureClient(0)
{
}
QSGMaterialShader *ShaderVideoMaterial::createShader() const
{
if (!m_videoShader) {
m_videoShader = new ShaderVideoShader(m_format.pixelFormat());
}
return m_videoShader;
}
QSGMaterialType *ShaderVideoMaterial::type() const
{
static QSGMaterialType theType;
return &theType;
}
void ShaderVideoMaterial::setCamControl(CameraControl *cc)
{
if (m_camControl != cc) {
m_camControl = cc;
}
}
CameraControl *ShaderVideoMaterial::cameraControl() const
{
return m_camControl;
}
void ShaderVideoMaterial::setTextureId(GLuint textureId)
{
m_textureId = textureId;
}
void ShaderVideoMaterial::setSurfaceTextureClient(SurfaceTextureClientHybris surface_texture_client)
{
m_surfaceTextureClient = surface_texture_client;
}
void ShaderVideoMaterial::bind()
{
if (!m_camControl && !m_textureId) {
return;
}
if (m_camControl != NULL) {
android_camera_update_preview_texture(m_camControl);
android_camera_get_preview_texture_transformation(m_camControl, m_textureMatrix);
}
else {
surface_texture_client_update_texture(m_surfaceTextureClient);
surface_texture_client_get_transformation_matrix(m_surfaceTextureClient, static_cast(m_textureMatrix));
}
undoAndroidYFlip(m_textureMatrix);
glUniformMatrix4fv(m_videoShader->m_tex_matrix, 1, GL_FALSE, m_textureMatrix);
glTexParameteri(TEXTURE_TARGET, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(TEXTURE_TARGET, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(TEXTURE_TARGET, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(TEXTURE_TARGET, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
void ShaderVideoMaterial::undoAndroidYFlip(GLfloat matrix[])
{
// The android matrix flips the y coordinate
// The android matrix has it's texture coordinates not from 0..1 but in between there
// The higher value is stored in m[13], the lower one is the higher one minus the height
GLfloat height = -matrix[5]; // invert because of the flipping
GLfloat offset = matrix[13] - height;
matrix[5] = height;
matrix[13] = offset;
}
/*!
* \brief ShaderVideoMaterial::printGLMaxtrix
* Prints a OpenGL matrix (GLfloat m[16]) to std out.
* This function stays here for convenience in case some more debugging is necessary for the android
* transformation matrix.
* \param matrix Matrix to be printed to std out
*/
void ShaderVideoMaterial::printGLMaxtrix(GLfloat matrix[])
{
qDebug() << matrix[0] << matrix[4] << matrix[8] << matrix[12];
qDebug() << matrix[1] << matrix[5] << matrix[9] << matrix[13];
qDebug() << matrix[2] << matrix[6] << matrix[10] << matrix[14];
qDebug() << matrix[3] << matrix[7] << matrix[11] << matrix[15];
}
qtvideo-node-0.2.1+14.04.20140304/src/shadervideonodeplugin.cpp 0000644 0000152 0177776 00000003200 12305354242 024352 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "shadervideonodeplugin.h"
#include "shadervideonode.h"
#include
QList ShaderVideoNodePlugin::supportedPixelFormats(
QAbstractVideoBuffer::HandleType handleType) const
{
QList pixelFormats;
if (handleType == QAbstractVideoBuffer::GLTextureHandle) {
pixelFormats.append(QVideoFrame::Format_RGB32);
pixelFormats.append(QVideoFrame::Format_ARGB32);
pixelFormats.append(QVideoFrame::Format_BGR32);
pixelFormats.append(QVideoFrame::Format_BGRA32);
pixelFormats.append(QVideoFrame::Format_User); // handling a GL texture of the aal library for the camera
}
return pixelFormats;
}
QSGVideoNode *ShaderVideoNodePlugin::createNode(const QVideoSurfaceFormat &format)
{
qDebug() << Q_FUNC_INFO;
if (supportedPixelFormats(format.handleType()).contains(format.pixelFormat()))
return new ShaderVideoNode(format);
return 0;
}
qtvideo-node-0.2.1+14.04.20140304/src/qsgvideonode_p.cpp 0000644 0000152 0177776 00000010434 12305354252 023006 0 ustar pbuser nogroup 0000000 0000000 /****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "private/qsgvideonode_p.h"
QT_BEGIN_NAMESPACE
QSGVideoNode::QSGVideoNode()
: m_orientation(-1)
{
}
/* Helpers */
static inline void qSetGeom(QSGGeometry::TexturedPoint2D *v, const QPointF &p)
{
v->x = p.x();
v->y = p.y();
}
static inline void qSetTex(QSGGeometry::TexturedPoint2D *v, const QPointF &p)
{
v->tx = p.x();
v->ty = p.y();
}
/* Update the vertices and texture coordinates. Orientation must be in {0,90,180,270} */
void QSGVideoNode::setTexturedRectGeometry(const QRectF &rect, const QRectF &textureRect, int orientation)
{
if (rect == m_rect && textureRect == m_textureRect && orientation == m_orientation)
return;
m_rect = rect;
m_textureRect = textureRect;
m_orientation = orientation;
QSGGeometry *g = geometry();
if (g == 0)
g = new QSGGeometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4);
QSGGeometry::TexturedPoint2D *v = g->vertexDataAsTexturedPoint2D();
// Set geometry first
qSetGeom(v + 0, rect.topLeft());
qSetGeom(v + 1, rect.bottomLeft());
qSetGeom(v + 2, rect.topRight());
qSetGeom(v + 3, rect.bottomRight());
// and then texture coordinates
switch (orientation) {
default:
// tl, bl, tr, br
qSetTex(v + 0, textureRect.topLeft());
qSetTex(v + 1, textureRect.bottomLeft());
qSetTex(v + 2, textureRect.topRight());
qSetTex(v + 3, textureRect.bottomRight());
break;
case 90:
// tr, tl, br, bl
qSetTex(v + 0, textureRect.topRight());
qSetTex(v + 1, textureRect.topLeft());
qSetTex(v + 2, textureRect.bottomRight());
qSetTex(v + 3, textureRect.bottomLeft());
break;
case 180:
// br, tr, bl, tl
qSetTex(v + 0, textureRect.bottomRight());
qSetTex(v + 1, textureRect.topRight());
qSetTex(v + 2, textureRect.bottomLeft());
qSetTex(v + 3, textureRect.topLeft());
break;
case 270:
// bl, br, tl, tr
qSetTex(v + 0, textureRect.bottomLeft());
qSetTex(v + 1, textureRect.bottomRight());
qSetTex(v + 2, textureRect.topLeft());
qSetTex(v + 3, textureRect.topRight());
break;
}
if (!geometry())
setGeometry(g);
markDirty(DirtyGeometry);
}
QT_END_NAMESPACE
qtvideo-node-0.2.1+14.04.20140304/src/shadervideomaterial.h 0000644 0000152 0177776 00000003572 12305354252 023466 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef SHADERVIDEOMATERIAL_H
#define SHADERVIDEOMATERIAL_H
#include
#if (QT_VERSION < QT_VERSION_CHECK(5, 2, 0))
#include
#else
#include
#endif
#include
#include
struct CameraControl;
struct MediaPlayerWrapper;
class ShaderVideoShader;
class ShaderVideoMaterial : public QSGMaterial
{
public:
typedef void* SurfaceTextureClientHybris;
ShaderVideoMaterial(const QVideoSurfaceFormat &format);
QSGMaterialShader *createShader() const;
virtual QSGMaterialType *type() const;
void setCamControl(CameraControl *cc);
CameraControl *cameraControl() const;
void setTextureId(GLuint textureId);
GLuint textureId() const { return m_textureId; }
void setSurfaceTextureClient(SurfaceTextureClientHybris surface_texture_client);
void bind();
private:
void undoAndroidYFlip(GLfloat matrix[]);
void printGLMaxtrix(GLfloat matrix[]);
QVideoSurfaceFormat m_format;
CameraControl *m_camControl;
GLuint m_textureId;
SurfaceTextureClientHybris m_surfaceTextureClient;
static ShaderVideoShader *m_videoShader; // the shader is cached in the Qt scene graph
GLfloat m_textureMatrix[16];
};
#endif // SHADERVIDEOMATERIAL_H
qtvideo-node-0.2.1+14.04.20140304/src/shadervideonode.cpp 0000644 0000152 0177776 00000012436 12305354242 023146 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "shadervideonode.h"
#include "shadervideomaterial.h"
#include "snapshotgenerator.h"
#include
#include
/*!
* \brief ShaderVideoNode::ShaderVideoNode
* \param format
*/
ShaderVideoNode::ShaderVideoNode(const QVideoSurfaceFormat &format) :
m_format(format),
m_textureId(0),
m_surfaceTextureClient(0)
{
m_material = new ShaderVideoMaterial(format);
setMaterial(m_material);
m_snapshotGenerator = new SnapshotGenerator;
connect(SharedSignal::instance(), SIGNAL(setSnapshotSize(const QSize&)), this, SLOT(onSetSnapshotSize(const QSize&)));
connect(SharedSignal::instance(), SIGNAL(takeSnapshot(const CameraControl*)), this, SLOT(onTakeSnapshot(const CameraControl*)));
}
/*!
* \brief ShaderVideoNode::~ShaderVideoNode
*/
ShaderVideoNode::~ShaderVideoNode()
{
deleteTextureID();
delete m_snapshotGenerator;
}
/*!
* \brief ShaderVideoNode::pixelFormat \reimp
* \return
*/
QVideoFrame::PixelFormat ShaderVideoNode::pixelFormat() const
{
return m_format.pixelFormat();
}
/*!
* \brief ShaderVideoNode::setCurrentFrame draws the new frame. If the frame's
* texture ID (stored in the hanlde) is empty, a new texture is created and send
* back.
* \param frame
*/
void ShaderVideoNode::setCurrentFrame(const QVideoFrame &frame)
{
void *ci = 0;
if (frame.availableMetaData().contains("CamControl")) {
ci = frame.metaData("CamControl").value();
if (ci == 0) {
qWarning() << "No valid camera control pointer in video frame";
return;
}
m_material->setCamControl((CameraControl*)ci);
} else if (frame.availableMetaData().contains("TextureId") &&
frame.availableMetaData().contains("SurfaceTextureClient")) {
m_textureId = frame.metaData("TextureId").value();
if (m_textureId == 0) {
qWarning() << "No valid textureId in video frame";
return;
}
m_material->setTextureId(m_textureId);
m_surfaceTextureClient = reinterpret_cast
(frame.metaData("SurfaceTextureClient").value());
if (m_surfaceTextureClient == 0) {
qWarning() << "No valid SurfaceTextureClient instance in video frame";
return;
}
m_material->setSurfaceTextureClient(m_surfaceTextureClient);
} else if (!frame.availableMetaData().contains("CamControl") &&
!frame.availableMetaData().contains("TextureId")) {
qWarning() << "No camera control or texture id instance included in video frame";
m_material->setCamControl(0);
m_material->setTextureId(0);
return;
}
if (frame.handle().toUInt() == 0) {
// Client requests a new texture
if (m_textureId != 0)
deleteTextureID();
getGLTextureID();
// Prevent drawing
m_material->setCamControl(0);
} else {
// Draw the frame
markDirty(DirtyMaterial);
}
}
/*!
* \brief ShaderVideoNode::onSetSnapshotSize sets the target size for the snapshot
* \param size
*/
void ShaderVideoNode::onSetSnapshotSize(const QSize &size)
{
Q_ASSERT(m_snapshotGenerator != NULL);
m_snapshotGenerator->setSize(size.width(), size.height());
}
/*!
* \brief ShaderVideoNode::onTakeSnapshot creates an image of the current frame
* and sends it back to the client (camera/mediaplayer)
* \param control
*/
void ShaderVideoNode::onTakeSnapshot(const CameraControl *control)
{
Q_ASSERT(m_textureId > 0);
Q_ASSERT(control != NULL);
Q_ASSERT(m_snapshotGenerator != NULL);
QImage snapshot = m_snapshotGenerator->snapshot(m_textureId, control);
// Signal the QVideoRendererControl instance that a snapshot has been taken
Q_EMIT SharedSignal::instance()->snapshotTaken(snapshot);
}
/*!
* \brief ShaderVideoNode::getGLTextureID creates a new texture, and sends it
* back to the client (camera/mediaplayer)
*/
void ShaderVideoNode::getGLTextureID()
{
// This is to avoid a segfault in shadervideonode.cpp when it tries to call
// glGenTextures(), since the platform currently does not support real OpenGL
// when running unit tests.
#ifndef TST_NO_OPENGL
glGenTextures(1, &m_textureId);
#else
m_textureId = 700001;
#endif
if (m_textureId == 0) {
qWarning() << "Unable to get texture ID";
return;
}
Q_EMIT SharedSignal::instance()->textureCreated(static_cast(m_textureId));
}
/*!
* \brief ShaderVideoNode::deleteTextureID
*/
void ShaderVideoNode::deleteTextureID()
{
#ifndef TST_NO_OPENGL
if (m_textureId)
glDeleteTextures(1, &m_textureId);
#endif
m_textureId = 0;
}
qtvideo-node-0.2.1+14.04.20140304/src/shadervideonodeplugin.h 0000644 0000152 0177776 00000002341 12305354242 024024 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef SHADERVIDEONODEPLUGIN_H
#define SHADERVIDEONODEPLUGIN_H
#include
#include
class ShaderVideoNodePlugin : public QObject, public QSGVideoNodeFactoryInterface
{
Q_OBJECT
Q_INTERFACES(QSGVideoNodeFactoryInterface)
Q_PLUGIN_METADATA(IID "org.qt-project.qt.sgvideonodefactory/5.0" FILE "shadervideonode.json")
public:
QList supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType) const;
QSGVideoNode *createNode(const QVideoSurfaceFormat &format);
};
#endif // SHADERVIDEONODEPLUGIN_H
qtvideo-node-0.2.1+14.04.20140304/src/src.pro 0000644 0000152 0177776 00000001370 12305354252 020604 0 ustar pbuser nogroup 0000000 0000000 TARGET = shadervideonode
TEMPLATE = lib
CONFIG += plugin
QT += multimedia opengl quick-private
include(../coverage.pri)
PLUGIN_TYPE = video/videonode
target.path += $$[QT_INSTALL_PLUGINS]/$${PLUGIN_TYPE}
INSTALLS = target
INCLUDEPATH += /usr/include/hybris/camera /usr/include/hybris/media /usr/include/libqtubuntu-media-signals
LIBS += -lhybris_ics -lcamera -lmedia -lqtubuntu-media-signals
OTHER_FILES += shadervideonode.json
HEADERS += \
shadervideonodeplugin.h \
shadervideomaterial.h \
shadervideoshader.h \
shadervideonode.h \
snapshotgenerator.h
SOURCES += \
shadervideonodeplugin.cpp \
shadervideomaterial.cpp \
shadervideoshader.cpp \
shadervideonode.cpp \
snapshotgenerator.cpp \
qsgvideonode_p.cpp
qtvideo-node-0.2.1+14.04.20140304/src/snapshotgenerator.h 0000644 0000152 0177776 00000002562 12305354242 023215 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef SNAPSHOTGENERATOR_H
#define SNAPSHOTGENERATOR_H
#include
#include
class CameraControl;
class SnapshotGenerator
{
public:
SnapshotGenerator();
QImage snapshot(GLuint textureId, const CameraControl *control);
void setSize(int width, int height);
private:
const char *vertexShader() const;
const char *fragmentShader() const;
GLuint loadShader(GLenum shaderType, const char* pSource);
GLuint createProgram(const char* pVertexSource, const char* pFragmentSource);
int m_width;
int m_height;
GLint position_loc;
GLint v_matrix_loc;
GLint tex_coord_loc;
GLint sampler_loc;
GLint tex_matrix_loc;
QImage m_snapshotImage;
};
#endif // SNAPSHOTGENERATOR_H
qtvideo-node-0.2.1+14.04.20140304/src/shadervideoshader.h 0000644 0000152 0177776 00000002626 12305354252 023135 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef SHADERVIDEOSHADER_H
#define SHADERVIDEOSHADER_H
#include
#if (QT_VERSION < QT_VERSION_CHECK(5, 2, 0))
#include
#else
#include
#endif
#include
class ShaderVideoShader : public QSGMaterialShader
{
public:
ShaderVideoShader(QVideoFrame::PixelFormat pixelFormat);
void updateState(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial);
char const *const *attributeNames() const;
int m_tex_matrix;
protected:
const char *vertexShader() const;
const char *fragmentShader() const;
void initialize();
int m_id_matrix;
int m_id_Texture;
int m_id_opacity;
QVideoFrame::PixelFormat m_pixelFormat;
};
#endif // SHADERVIDEOSHADER_H
qtvideo-node-0.2.1+14.04.20140304/src/shadervideonode.json 0000644 0000152 0177776 00000000041 12305354242 023322 0 ustar pbuser nogroup 0000000 0000000 {
"Keys": ["sgvideonodes"]
}
qtvideo-node-0.2.1+14.04.20140304/COPYING 0000644 0000152 0177776 00000016743 12305354242 017550 0 ustar pbuser nogroup 0000000 0000000 GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.