Merge remote-tracking branch 'origin/5.5' into 5.6
Change-Id: I8e0f222f110cc23b426f2d68416f5cc3982e30f2
This commit is contained in:
@@ -44,6 +44,7 @@
|
||||
#include <qaudioformat.h>
|
||||
#include <QtCore/qelapsedtimer.h>
|
||||
#include <QtMultimedia/qvideosurfaceformat.h>
|
||||
#include <private/qmultimediautils_p.h>
|
||||
|
||||
#include <gst/audio/audio.h>
|
||||
#include <gst/video/video.h>
|
||||
@@ -1531,6 +1532,15 @@ GList *qt_gst_video_sinks()
|
||||
return list;
|
||||
}
|
||||
|
||||
void qt_gst_util_double_to_fraction(gdouble src, gint *dest_n, gint *dest_d)
|
||||
{
|
||||
#if GST_CHECK_VERSION(0, 10, 26)
|
||||
gst_util_double_to_fraction(src, dest_n, dest_d);
|
||||
#else
|
||||
qt_real_to_fraction(src, dest_n, dest_d);
|
||||
#endif
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, GstCaps *caps)
|
||||
{
|
||||
if (caps) {
|
||||
|
||||
@@ -152,6 +152,7 @@ GstCaps *qt_gst_caps_normalize(GstCaps *caps);
|
||||
const gchar *qt_gst_element_get_factory_name(GstElement *element);
|
||||
gboolean qt_gst_caps_can_intersect(const GstCaps * caps1, const GstCaps * caps2);
|
||||
GList *qt_gst_video_sinks();
|
||||
void qt_gst_util_double_to_fraction(gdouble src, gint *dest_n, gint *dest_d);
|
||||
|
||||
QDebug operator <<(QDebug debug, GstCaps *caps);
|
||||
|
||||
|
||||
@@ -26,7 +26,8 @@ PRIVATE_HEADERS += \
|
||||
qmediaresourcepolicy_p.h \
|
||||
qmediaresourceset_p.h \
|
||||
qmediastoragelocation_p.h \
|
||||
qmediaopenglhelper_p.h
|
||||
qmediaopenglhelper_p.h \
|
||||
qmultimediautils_p.h
|
||||
|
||||
PUBLIC_HEADERS += \
|
||||
qmediabindableinterface.h \
|
||||
@@ -53,7 +54,8 @@ SOURCES += \
|
||||
qmediaresourcepolicy_p.cpp \
|
||||
qmediaresourceset_p.cpp \
|
||||
qmediastoragelocation.cpp \
|
||||
qmultimedia.cpp
|
||||
qmultimedia.cpp \
|
||||
qmultimediautils.cpp
|
||||
|
||||
CONFIG += simd optimize_full
|
||||
|
||||
|
||||
81
src/multimedia/qmultimediautils.cpp
Normal file
81
src/multimedia/qmultimediautils.cpp
Normal file
@@ -0,0 +1,81 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL21$
|
||||
** 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 The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmultimediautils_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
void qt_real_to_fraction(qreal value, int *numerator, int *denominator)
|
||||
{
|
||||
if (!numerator || !denominator)
|
||||
return;
|
||||
|
||||
const int dMax = 1000;
|
||||
int n1 = 0, d1 = 1, n2 = 1, d2 = 1;
|
||||
qreal mid = 0.;
|
||||
while (d1 <= dMax && d2 <= dMax) {
|
||||
mid = qreal(n1 + n2) / (d1 + d2);
|
||||
|
||||
if (qAbs(value - mid) < 0.000001) {
|
||||
if (d1 + d2 <= dMax) {
|
||||
*numerator = n1 + n2;
|
||||
*denominator = d1 + d2;
|
||||
return;
|
||||
} else if (d2 > d1) {
|
||||
*numerator = n2;
|
||||
*denominator = d2;
|
||||
return;
|
||||
} else {
|
||||
*numerator = n1;
|
||||
*denominator = d1;
|
||||
return;
|
||||
}
|
||||
} else if (value > mid) {
|
||||
n1 = n1 + n2;
|
||||
d1 = d1 + d2;
|
||||
} else {
|
||||
n2 = n1 + n2;
|
||||
d2 = d1 + d2;
|
||||
}
|
||||
}
|
||||
|
||||
if (d1 > dMax) {
|
||||
*numerator = n2;
|
||||
*denominator = d2;
|
||||
} else {
|
||||
*numerator = n1;
|
||||
*denominator = d1;
|
||||
}
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
57
src/multimedia/qmultimediautils_p.h
Normal file
57
src/multimedia/qmultimediautils_p.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL21$
|
||||
** 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 The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMULTIMEDIAUTILS_P_H
|
||||
#define QMULTIMEDIAUTILS_P_H
|
||||
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
|
||||
#include <QtMultimedia/qmultimedia.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
Q_MULTIMEDIA_EXPORT void qt_real_to_fraction(qreal value, int *numerator, int *denominator);
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QMULTIMEDIAUTILS_P_H
|
||||
|
||||
@@ -160,8 +160,6 @@ inline QSysInfo::MacVersion qt_OS_limit(QSysInfo::MacVersion osxVersion,
|
||||
|
||||
typedef QPair<qreal, qreal> AVFPSRange;
|
||||
AVFPSRange qt_connection_framerates(AVCaptureConnection *videoConnection);
|
||||
typedef QPair<int, int> AVFRational;
|
||||
AVFRational qt_float_to_rational(qreal par, int limit);
|
||||
|
||||
#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_7, __IPHONE_7_0)
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
|
||||
#include <QtCore/qvector.h>
|
||||
#include <QtCore/qpair.h>
|
||||
#include <private/qmultimediautils_p.h>
|
||||
|
||||
#include <functional>
|
||||
#include <algorithm>
|
||||
@@ -77,42 +78,6 @@ AVFPSRange qt_connection_framerates(AVCaptureConnection *videoConnection)
|
||||
return newRange;
|
||||
}
|
||||
|
||||
AVFRational qt_float_to_rational(qreal par, int limit)
|
||||
{
|
||||
Q_ASSERT(limit > 0);
|
||||
|
||||
// In Qt we represent pixel aspect ratio
|
||||
// as a rational number (we use QSize).
|
||||
// AVFoundation describes dimensions in pixels
|
||||
// and in pixels with width multiplied by PAR.
|
||||
// Represent this PAR as a ratio.
|
||||
int a = 0, b = 1, c = 1, d = 1;
|
||||
qreal mid = 0.;
|
||||
while (b <= limit && d <= limit) {
|
||||
mid = qreal(a + c) / (b + d);
|
||||
|
||||
if (qAbs(par - mid) < 0.000001) {
|
||||
if (b + d <= limit)
|
||||
return AVFRational(a + c, b + d);
|
||||
else if (d > b)
|
||||
return AVFRational(c, d);
|
||||
else
|
||||
return AVFRational(a, b);
|
||||
} else if (par > mid) {
|
||||
a = a + c;
|
||||
b = b + d;
|
||||
} else {
|
||||
c = a + c;
|
||||
d = b + d;
|
||||
}
|
||||
}
|
||||
|
||||
if (b > limit)
|
||||
return AVFRational(c, d);
|
||||
|
||||
return AVFRational(a, b);
|
||||
}
|
||||
|
||||
#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_7, __IPHONE_7_0)
|
||||
|
||||
namespace {
|
||||
@@ -264,10 +229,13 @@ QSize qt_device_format_pixel_aspect_ratio(AVCaptureDeviceFormat *format)
|
||||
if (!res.width || !resPAR.width)
|
||||
return QSize();
|
||||
|
||||
const AVFRational asRatio(qt_float_to_rational(resPAR.width > res.width
|
||||
? res.width / qreal(resPAR.width)
|
||||
: resPAR.width / qreal(res.width), 200));
|
||||
return QSize(asRatio.first, asRatio.second);
|
||||
int n, d;
|
||||
qt_real_to_fraction(resPAR.width > res.width
|
||||
? res.width / qreal(resPAR.width)
|
||||
: resPAR.width / qreal(res.width),
|
||||
&n, &d);
|
||||
|
||||
return QSize(n, d);
|
||||
}
|
||||
|
||||
AVCaptureDeviceFormat *qt_find_best_resolution_match(AVCaptureDevice *captureDevice,
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#include <QtCore/qvector.h>
|
||||
#include <QtCore/qdebug.h>
|
||||
#include <QtCore/qlist.h>
|
||||
#include <private/qmultimediautils_p.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -129,8 +130,9 @@ CMTime qt_adjusted_frame_duration(AVFrameRateRange *range, qreal fps)
|
||||
if (fps >= range.maxFrameRate)
|
||||
return range.minFrameDuration;
|
||||
|
||||
const AVFRational timeAsRational(qt_float_to_rational(1. / fps, 1000));
|
||||
return CMTimeMake(timeAsRational.first, timeAsRational.second);
|
||||
int n, d;
|
||||
qt_real_to_fraction(1. / fps, &n, &d);
|
||||
return CMTimeMake(n, d);
|
||||
}
|
||||
|
||||
void qt_set_framerate_limits(AVCaptureDevice *captureDevice,
|
||||
|
||||
@@ -85,6 +85,10 @@ config_gstreamer_photography {
|
||||
DEFINES += GST_USE_UNSTABLE_API #prevents warnings because of unstable photography API
|
||||
}
|
||||
|
||||
config_gstreamer_encodingprofiles {
|
||||
DEFINES += HAVE_GST_ENCODING_PROFILES
|
||||
}
|
||||
|
||||
OTHER_FILES += \
|
||||
camerabin.json
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
|
||||
#include "camerabinaudioencoder.h"
|
||||
#include "camerabincontainer.h"
|
||||
#include <private/qgstcodecsinfo_p.h>
|
||||
#include <private/qgstutils_p.h>
|
||||
|
||||
#include <QtCore/qdebug.h>
|
||||
@@ -41,8 +40,10 @@
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
CameraBinAudioEncoder::CameraBinAudioEncoder(QObject *parent)
|
||||
:QAudioEncoderSettingsControl(parent),
|
||||
m_codecs(QGstCodecsInfo::AudioEncoder)
|
||||
:QAudioEncoderSettingsControl(parent)
|
||||
#ifdef HAVE_GST_ENCODING_PROFILES
|
||||
, m_codecs(QGstCodecsInfo::AudioEncoder)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
@@ -52,12 +53,21 @@ CameraBinAudioEncoder::~CameraBinAudioEncoder()
|
||||
|
||||
QStringList CameraBinAudioEncoder::supportedAudioCodecs() const
|
||||
{
|
||||
#ifdef HAVE_GST_ENCODING_PROFILES
|
||||
return m_codecs.supportedCodecs();
|
||||
#else
|
||||
return QStringList();
|
||||
#endif
|
||||
}
|
||||
|
||||
QString CameraBinAudioEncoder::codecDescription(const QString &codecName) const
|
||||
{
|
||||
#ifdef HAVE_GST_ENCODING_PROFILES
|
||||
return m_codecs.codecDescription(codecName);
|
||||
#else
|
||||
Q_UNUSED(codecName)
|
||||
return QString();
|
||||
#endif
|
||||
}
|
||||
|
||||
QList<int> CameraBinAudioEncoder::supportedSampleRates(const QAudioEncoderSettings &, bool *) const
|
||||
@@ -96,6 +106,8 @@ void CameraBinAudioEncoder::resetActualSettings()
|
||||
m_actualAudioSettings = m_audioSettings;
|
||||
}
|
||||
|
||||
#ifdef HAVE_GST_ENCODING_PROFILES
|
||||
|
||||
GstEncodingProfile *CameraBinAudioEncoder::createProfile()
|
||||
{
|
||||
QString codec = m_actualAudioSettings.codec();
|
||||
@@ -118,6 +130,8 @@ GstEncodingProfile *CameraBinAudioEncoder::createProfile()
|
||||
return profile;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void CameraBinAudioEncoder::applySettings(GstElement *encoder)
|
||||
{
|
||||
GObjectClass * const objectClass = G_OBJECT_GET_CLASS(encoder);
|
||||
|
||||
@@ -42,10 +42,13 @@
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/pbutils/pbutils.h>
|
||||
|
||||
#ifdef HAVE_GST_ENCODING_PROFILES
|
||||
#include <gst/pbutils/encoding-profile.h>
|
||||
#include <private/qgstcodecsinfo_p.h>
|
||||
#endif
|
||||
|
||||
#include <qaudioformat.h>
|
||||
#include <private/qgstcodecsinfo_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class CameraBinSession;
|
||||
@@ -76,7 +79,9 @@ public:
|
||||
void setActualAudioSettings(const QAudioEncoderSettings&);
|
||||
void resetActualSettings();
|
||||
|
||||
#ifdef HAVE_GST_ENCODING_PROFILES
|
||||
GstEncodingProfile *createProfile();
|
||||
#endif
|
||||
|
||||
void applySettings(GstElement *element);
|
||||
|
||||
@@ -84,7 +89,9 @@ Q_SIGNALS:
|
||||
void settingsChanged();
|
||||
|
||||
private:
|
||||
#ifdef HAVE_GST_ENCODING_PROFILES
|
||||
QGstCodecsInfo m_codecs;
|
||||
#endif
|
||||
|
||||
QAudioEncoderSettings m_actualAudioSettings;
|
||||
QAudioEncoderSettings m_audioSettings;
|
||||
|
||||
@@ -39,8 +39,10 @@
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
CameraBinContainer::CameraBinContainer(QObject *parent)
|
||||
:QMediaContainerControl(parent),
|
||||
m_supportedContainers(QGstCodecsInfo::Muxer)
|
||||
:QMediaContainerControl(parent)
|
||||
#ifdef HAVE_GST_ENCODING_PROFILES
|
||||
, m_supportedContainers(QGstCodecsInfo::Muxer)
|
||||
#endif
|
||||
{
|
||||
//extension for containers hard to guess from mimetype
|
||||
m_fileExtensions["video/x-matroska"] = "mkv";
|
||||
@@ -54,12 +56,21 @@ CameraBinContainer::CameraBinContainer(QObject *parent)
|
||||
|
||||
QStringList CameraBinContainer::supportedContainers() const
|
||||
{
|
||||
#ifdef HAVE_GST_ENCODING_PROFILES
|
||||
return m_supportedContainers.supportedCodecs();
|
||||
#else
|
||||
return QStringList();
|
||||
#endif
|
||||
}
|
||||
|
||||
QString CameraBinContainer::containerDescription(const QString &formatMimeType) const
|
||||
{
|
||||
#ifdef HAVE_GST_ENCODING_PROFILES
|
||||
return m_supportedContainers.codecDescription(formatMimeType);
|
||||
#else
|
||||
Q_UNUSED(formatMimeType)
|
||||
return QString();
|
||||
#endif
|
||||
}
|
||||
|
||||
QString CameraBinContainer::containerFormat() const
|
||||
@@ -69,11 +80,13 @@ QString CameraBinContainer::containerFormat() const
|
||||
|
||||
void CameraBinContainer::setContainerFormat(const QString &format)
|
||||
{
|
||||
#ifdef HAVE_GST_ENCODING_PROFILES
|
||||
if (m_format != format) {
|
||||
m_format = format;
|
||||
m_actualFormat = format;
|
||||
emit settingsChanged();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
QString CameraBinContainer::actualContainerFormat() const
|
||||
@@ -83,7 +96,9 @@ QString CameraBinContainer::actualContainerFormat() const
|
||||
|
||||
void CameraBinContainer::setActualContainerFormat(const QString &containerFormat)
|
||||
{
|
||||
#ifdef HAVE_GST_ENCODING_PROFILES
|
||||
m_actualFormat = containerFormat;
|
||||
#endif
|
||||
}
|
||||
|
||||
void CameraBinContainer::resetActualContainerFormat()
|
||||
@@ -91,6 +106,8 @@ void CameraBinContainer::resetActualContainerFormat()
|
||||
m_actualFormat = m_format;
|
||||
}
|
||||
|
||||
#ifdef HAVE_GST_ENCODING_PROFILES
|
||||
|
||||
GstEncodingContainerProfile *CameraBinContainer::createProfile()
|
||||
{
|
||||
GstCaps *caps;
|
||||
@@ -127,6 +144,8 @@ GstEncodingContainerProfile *CameraBinContainer::createProfile()
|
||||
return profile;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*!
|
||||
Suggest file extension for current container mimetype.
|
||||
*/
|
||||
|
||||
@@ -41,9 +41,11 @@
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/pbutils/pbutils.h>
|
||||
#include <gst/pbutils/encoding-profile.h>
|
||||
|
||||
#ifdef HAVE_GST_ENCODING_PROFILES
|
||||
#include <gst/pbutils/encoding-profile.h>
|
||||
#include <private/qgstcodecsinfo_p.h>
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@@ -66,7 +68,9 @@ public:
|
||||
|
||||
QString suggestedFileExtension(const QString &containerFormat) const;
|
||||
|
||||
#ifdef HAVE_GST_ENCODING_PROFILES
|
||||
GstEncodingContainerProfile *createProfile();
|
||||
#endif
|
||||
|
||||
Q_SIGNALS:
|
||||
void settingsChanged();
|
||||
@@ -76,7 +80,9 @@ private:
|
||||
QString m_actualFormat;
|
||||
QMap<QString, QString> m_fileExtensions;
|
||||
|
||||
#ifdef HAVE_GST_ENCODING_PROFILES
|
||||
QGstCodecsInfo m_supportedContainers;
|
||||
#endif
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
@@ -42,6 +42,8 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#if GST_CHECK_VERSION(0,10,30)
|
||||
|
||||
static QVariant fromGStreamerOrientation(const QVariant &value)
|
||||
{
|
||||
// Note gstreamer tokens either describe the counter clockwise rotation of the
|
||||
@@ -58,6 +60,8 @@ static QVariant fromGStreamerOrientation(const QVariant &value)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static QVariant toGStreamerOrientation(const QVariant &value)
|
||||
{
|
||||
switch (value.toInt()) {
|
||||
@@ -97,7 +101,9 @@ static const QGStreamerMetaDataKeys *qt_gstreamerMetaDataKeys()
|
||||
//metadataKeys->append(QGStreamerMetaDataKey(QMediaMetaData::SubTitle, 0, QVariant::String));
|
||||
//metadataKeys->append(QGStreamerMetaDataKey(QMediaMetaData::Author, 0, QVariant::String));
|
||||
metadataKeys->append(QGStreamerMetaDataKey(QMediaMetaData::Comment, GST_TAG_COMMENT, QVariant::String));
|
||||
#if GST_CHECK_VERSION(0,10,31)
|
||||
metadataKeys->append(QGStreamerMetaDataKey(QMediaMetaData::Date, GST_TAG_DATE_TIME, QVariant::DateTime));
|
||||
#endif
|
||||
metadataKeys->append(QGStreamerMetaDataKey(QMediaMetaData::Description, GST_TAG_DESCRIPTION, QVariant::String));
|
||||
//metadataKeys->append(QGStreamerMetaDataKey(QMediaMetaData::Category, 0, QVariant::String));
|
||||
metadataKeys->append(QGStreamerMetaDataKey(QMediaMetaData::Genre, GST_TAG_GENRE, QVariant::String));
|
||||
@@ -182,12 +188,14 @@ CameraBinMetaData::CameraBinMetaData(QObject *parent)
|
||||
|
||||
QVariant CameraBinMetaData::metaData(const QString &key) const
|
||||
{
|
||||
#if GST_CHECK_VERSION(0,10,30)
|
||||
if (key == QMediaMetaData::Orientation) {
|
||||
return fromGStreamerOrientation(m_values.value(QByteArray(GST_TAG_IMAGE_ORIENTATION)));
|
||||
} else if (key == QMediaMetaData::GPSSpeed) {
|
||||
const double metersPerSec = m_values.value(QByteArray(GST_TAG_GEO_LOCATION_MOVEMENT_SPEED)).toDouble();
|
||||
return (metersPerSec * 3600) / 1000;
|
||||
}
|
||||
#endif
|
||||
|
||||
Q_FOREACH (const QGStreamerMetaDataKey &metadataKey, *qt_gstreamerMetaDataKeys()) {
|
||||
if (metadataKey.qtName == key)
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
#include "camerabincontainer.h"
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
#include <gst/pbutils/encoding-profile.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@@ -131,6 +130,7 @@ qint64 CameraBinRecorder::duration() const
|
||||
|
||||
void CameraBinRecorder::applySettings()
|
||||
{
|
||||
#ifdef HAVE_GST_ENCODING_PROFILES
|
||||
CameraBinContainer *containerControl = m_session->mediaContainerControl();
|
||||
CameraBinAudioEncoder *audioEncoderControl = m_session->audioEncodeControl();
|
||||
CameraBinVideoEncoder *videoEncoderControl = m_session->videoEncodeControl();
|
||||
@@ -172,8 +172,11 @@ void CameraBinRecorder::applySettings()
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAVE_GST_ENCODING_PROFILES
|
||||
|
||||
GstEncodingContainerProfile *CameraBinRecorder::videoProfile()
|
||||
{
|
||||
GstEncodingContainerProfile *containerProfile = m_session->mediaContainerControl()->createProfile();
|
||||
@@ -195,6 +198,8 @@ GstEncodingContainerProfile *CameraBinRecorder::videoProfile()
|
||||
return containerProfile;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void CameraBinRecorder::setState(QMediaRecorder::State state)
|
||||
{
|
||||
if (m_state == state)
|
||||
|
||||
@@ -37,7 +37,10 @@
|
||||
|
||||
#include <qmediarecordercontrol.h>
|
||||
#include "camerabinsession.h"
|
||||
|
||||
#ifdef HAVE_GST_ENCODING_PROFILES
|
||||
#include <gst/pbutils/encoding-profile.h>
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@@ -61,7 +64,10 @@ public:
|
||||
qreal volume() const;
|
||||
|
||||
void applySettings();
|
||||
|
||||
#ifdef HAVE_GST_ENCODING_PROFILES
|
||||
GstEncodingContainerProfile *videoProfile();
|
||||
#endif
|
||||
|
||||
public slots:
|
||||
void setState(QMediaRecorder::State state);
|
||||
|
||||
@@ -308,7 +308,7 @@ static GstCaps *resolutionToCaps(const QSize &resolution,
|
||||
if (frameRate > 0.0) {
|
||||
gint numerator;
|
||||
gint denominator;
|
||||
gst_util_double_to_fraction(frameRate, &numerator, &denominator);
|
||||
qt_gst_util_double_to_fraction(frameRate, &numerator, &denominator);
|
||||
|
||||
gst_caps_set_simple(
|
||||
caps,
|
||||
@@ -404,7 +404,7 @@ void CameraBinSession::setupCaptureResolution()
|
||||
|
||||
if (!qFuzzyIsNull(viewfinderFrameRate)) {
|
||||
int n, d;
|
||||
gst_util_double_to_fraction(viewfinderFrameRate, &n, &d);
|
||||
qt_gst_util_double_to_fraction(viewfinderFrameRate, &n, &d);
|
||||
g_object_set(G_OBJECT(m_videoSrc), "fps-n", n, NULL);
|
||||
g_object_set(G_OBJECT(m_videoSrc), "fps-d", d, NULL);
|
||||
}
|
||||
@@ -798,12 +798,14 @@ void CameraBinSession::start()
|
||||
|
||||
m_recorderControl->applySettings();
|
||||
|
||||
#ifdef HAVE_GST_ENCODING_PROFILES
|
||||
GstEncodingContainerProfile *profile = m_recorderControl->videoProfile();
|
||||
g_object_set (G_OBJECT(m_camerabin),
|
||||
"video-profile",
|
||||
profile,
|
||||
NULL);
|
||||
gst_encoding_profile_unref(profile);
|
||||
#endif
|
||||
|
||||
setAudioCaptureCaps();
|
||||
|
||||
@@ -1065,13 +1067,38 @@ bool CameraBinSession::processBusMessage(const QGstreamerMessage &message)
|
||||
return false;
|
||||
}
|
||||
|
||||
QString CameraBinSession::currentContainerFormat() const
|
||||
{
|
||||
if (!m_muxer)
|
||||
return QString();
|
||||
|
||||
QString format;
|
||||
|
||||
if (GstPad *srcPad = gst_element_get_static_pad(m_muxer, "src")) {
|
||||
if (GstCaps *caps = qt_gst_pad_get_caps(srcPad)) {
|
||||
gchar *capsString = gst_caps_to_string(caps);
|
||||
format = QString::fromLatin1(capsString);
|
||||
if (capsString)
|
||||
g_free(capsString);
|
||||
gst_caps_unref(caps);
|
||||
}
|
||||
gst_object_unref(GST_OBJECT(srcPad));
|
||||
}
|
||||
|
||||
return format;
|
||||
}
|
||||
|
||||
void CameraBinSession::recordVideo()
|
||||
{
|
||||
QString format = currentContainerFormat();
|
||||
if (format.isEmpty())
|
||||
format = m_mediaContainerControl->actualContainerFormat();
|
||||
|
||||
const QString actualFileName = m_mediaStorageLocation.generateFileName(m_sink.isLocalFile() ? m_sink.toLocalFile()
|
||||
: m_sink.toString(),
|
||||
QMediaStorageLocation::Movies,
|
||||
QLatin1String("clip_"),
|
||||
m_mediaContainerControl->suggestedFileExtension(m_mediaContainerControl->actualContainerFormat()));
|
||||
m_mediaContainerControl->suggestedFileExtension(format));
|
||||
|
||||
m_recordingActive = true;
|
||||
m_actualSink = QUrl::fromLocalFile(actualFileName);
|
||||
@@ -1433,14 +1460,28 @@ void CameraBinSession::elementAdded(GstBin *, GstElement *element, CameraBinSess
|
||||
g_signal_connect(G_OBJECT(element), "element-removed", G_CALLBACK(elementRemoved), session);
|
||||
} else if (!factory) {
|
||||
// no-op
|
||||
#if GST_CHECK_VERSION(0,10,31)
|
||||
} else if (gst_element_factory_list_is_type(factory, GST_ELEMENT_FACTORY_TYPE_AUDIO_ENCODER)) {
|
||||
#else
|
||||
} else if (strstr(gst_element_factory_get_klass(factory), "Encoder/Audio") != NULL) {
|
||||
#endif
|
||||
session->m_audioEncoder = element;
|
||||
|
||||
session->m_audioEncodeControl->applySettings(element);
|
||||
#if GST_CHECK_VERSION(0,10,31)
|
||||
} else if (gst_element_factory_list_is_type(factory, GST_ELEMENT_FACTORY_TYPE_VIDEO_ENCODER)) {
|
||||
#else
|
||||
} else if (strstr(gst_element_factory_get_klass(factory), "Encoder/Video") != NULL) {
|
||||
#endif
|
||||
session->m_videoEncoder = element;
|
||||
|
||||
session->m_videoEncodeControl->applySettings(element);
|
||||
#if GST_CHECK_VERSION(0,10,31)
|
||||
} else if (gst_element_factory_list_is_type(factory, GST_ELEMENT_FACTORY_TYPE_MUXER)) {
|
||||
#else
|
||||
} else if (strstr(gst_element_factory_get_klass(factory), "Muxer") != NULL) {
|
||||
#endif
|
||||
session->m_muxer = element;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1450,6 +1491,8 @@ void CameraBinSession::elementRemoved(GstBin *, GstElement *element, CameraBinSe
|
||||
session->m_audioEncoder = 0;
|
||||
else if (element == session->m_videoEncoder)
|
||||
session->m_videoEncoder = 0;
|
||||
else if (element == session->m_muxer)
|
||||
session->m_muxer = 0;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
@@ -195,6 +195,8 @@ private:
|
||||
void updateSupportedViewfinderSettings();
|
||||
static void updateBusyStatus(GObject *o, GParamSpec *p, gpointer d);
|
||||
|
||||
QString currentContainerFormat() const;
|
||||
|
||||
static void elementAdded(GstBin *bin, GstElement *element, CameraBinSession *session);
|
||||
static void elementRemoved(GstBin *bin, GstElement *element, CameraBinSession *session);
|
||||
|
||||
|
||||
@@ -41,9 +41,11 @@
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
CameraBinVideoEncoder::CameraBinVideoEncoder(CameraBinSession *session)
|
||||
:QVideoEncoderSettingsControl(session),
|
||||
m_session(session),
|
||||
m_codecs(QGstCodecsInfo::VideoEncoder)
|
||||
:QVideoEncoderSettingsControl(session)
|
||||
, m_session(session)
|
||||
#ifdef HAVE_GST_ENCODING_PROFILES
|
||||
, m_codecs(QGstCodecsInfo::VideoEncoder)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
@@ -81,12 +83,21 @@ QList< qreal > CameraBinVideoEncoder::supportedFrameRates(const QVideoEncoderSet
|
||||
|
||||
QStringList CameraBinVideoEncoder::supportedVideoCodecs() const
|
||||
{
|
||||
#ifdef HAVE_GST_ENCODING_PROFILES
|
||||
return m_codecs.supportedCodecs();
|
||||
#else
|
||||
return QStringList();
|
||||
#endif
|
||||
}
|
||||
|
||||
QString CameraBinVideoEncoder::videoCodecDescription(const QString &codecName) const
|
||||
{
|
||||
#ifdef HAVE_GST_ENCODING_PROFILES
|
||||
return m_codecs.codecDescription(codecName);
|
||||
#else
|
||||
Q_UNUSED(codecName)
|
||||
return QString();
|
||||
#endif
|
||||
}
|
||||
|
||||
QVideoEncoderSettings CameraBinVideoEncoder::videoSettings() const
|
||||
@@ -150,6 +161,8 @@ QPair<int,int> CameraBinVideoEncoder::rateAsRational(qreal frameRate) const
|
||||
return QPair<int,int>();
|
||||
}
|
||||
|
||||
#ifdef HAVE_GST_ENCODING_PROFILES
|
||||
|
||||
GstEncodingProfile *CameraBinVideoEncoder::createProfile()
|
||||
{
|
||||
QString codec = m_actualVideoSettings.codec();
|
||||
@@ -176,6 +189,8 @@ GstEncodingProfile *CameraBinVideoEncoder::createProfile()
|
||||
return (GstEncodingProfile *)profile;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void CameraBinVideoEncoder::applySettings(GstElement *encoder)
|
||||
{
|
||||
GObjectClass * const objectClass = G_OBJECT_GET_CLASS(encoder);
|
||||
|
||||
@@ -42,8 +42,11 @@
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/pbutils/pbutils.h>
|
||||
|
||||
#ifdef HAVE_GST_ENCODING_PROFILES
|
||||
#include <gst/pbutils/encoding-profile.h>
|
||||
#include <private/qgstcodecsinfo_p.h>
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@@ -74,7 +77,9 @@ public:
|
||||
void setActualVideoSettings(const QVideoEncoderSettings&);
|
||||
void resetActualSettings();
|
||||
|
||||
#ifdef HAVE_GST_ENCODING_PROFILES
|
||||
GstEncodingProfile *createProfile();
|
||||
#endif
|
||||
|
||||
void applySettings(GstElement *encoder);
|
||||
|
||||
@@ -84,7 +89,9 @@ Q_SIGNALS:
|
||||
private:
|
||||
CameraBinSession *m_session;
|
||||
|
||||
#ifdef HAVE_GST_ENCODING_PROFILES
|
||||
QGstCodecsInfo m_codecs;
|
||||
#endif
|
||||
|
||||
QVideoEncoderSettings m_actualVideoSettings;
|
||||
QVideoEncoderSettings m_videoSettings;
|
||||
|
||||
@@ -2,12 +2,9 @@ TEMPLATE = subdirs
|
||||
|
||||
SUBDIRS += \
|
||||
audiodecoder \
|
||||
camerabin \
|
||||
mediaplayer \
|
||||
mediacapture
|
||||
|
||||
config_gstreamer_encodingprofiles {
|
||||
SUBDIRS += camerabin
|
||||
}
|
||||
|
||||
OTHER_FILES += \
|
||||
gstreamer.json
|
||||
|
||||
@@ -150,6 +150,7 @@ QPulseAudioInput::QPulseAudioInput(const QByteArray &device)
|
||||
, m_errorState(QAudio::NoError)
|
||||
, m_deviceState(QAudio::StoppedState)
|
||||
, m_volume(qreal(1.0f))
|
||||
, m_customVolumeRequired(false)
|
||||
, m_pullMode(true)
|
||||
, m_opened(false)
|
||||
, m_bytesAvailable(0)
|
||||
@@ -355,7 +356,8 @@ bool QPulseAudioInput::open()
|
||||
if (actualBufferAttr->tlength != (uint32_t)-1)
|
||||
m_bufferSize = actualBufferAttr->tlength;
|
||||
|
||||
setPulseVolume();
|
||||
if (m_customVolumeRequired)
|
||||
setPulseVolume();
|
||||
|
||||
pulseEngine->unlock();
|
||||
|
||||
@@ -568,6 +570,7 @@ void QPulseAudioInput::setVolume(qreal vol)
|
||||
if (vol >= 0.0 && vol <= 1.0) {
|
||||
QPulseAudioEngine *pulseEngine = QPulseAudioEngine::instance();
|
||||
pulseEngine->lock();
|
||||
m_customVolumeRequired = true;
|
||||
if (!qFuzzyCompare(m_volume, vol)) {
|
||||
m_volume = vol;
|
||||
if (m_opened) {
|
||||
|
||||
@@ -100,6 +100,7 @@ public:
|
||||
QAudio::Error m_errorState;
|
||||
QAudio::State m_deviceState;
|
||||
qreal m_volume;
|
||||
bool m_customVolumeRequired;
|
||||
pa_cvolume m_chVolume;
|
||||
|
||||
private slots:
|
||||
|
||||
Reference in New Issue
Block a user