Commit 1e417b92 authored by Akhil K Gangadharan's avatar Akhil K Gangadharan

Merge branch 'akhilkgangadharan/kdenlive-patch6.3' into HEAD

parents 7b495c3d a8df61a5
Pipeline #1288 passed with stage
in 15 minutes and 21 seconds
......@@ -57,7 +57,7 @@ find_package(KF5 REQUIRED COMPONENTS Archive Bookmarks CoreAddons Config ConfigW
# Qt
set(QT_MIN_VERSION 5.7.0)
find_package(Qt5 REQUIRED COMPONENTS Core DBus Widgets Svg Quick Concurrent QuickWidgets)
find_package(Qt5 REQUIRED COMPONENTS Core DBus Widgets Svg Quick Concurrent QuickWidgets Multimedia)
find_package(Qt5 OPTIONAL_COMPONENTS WebKitWidgets QUIET)
add_definitions(-DQT_NO_CAST_TO_ASCII -DQT_NO_URL_CAST_FROM_STRING)
set(DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
......
......@@ -132,6 +132,7 @@ target_link_libraries(kdenliveLib
Qt5::Quick
Qt5::QuickWidgets
Qt5::Concurrent
Qt5::Multimedia
${OPENGL_LIBRARIES}
${OPENGLES_LIBRARIES}
${MLT_LIBRARIES}
......
......@@ -8,6 +8,7 @@ set(kdenlive_SRCS
${kdenlive_SRCS}
capture/managecapturesdialog.cpp
capture/mltdevicecapture.cpp
capture/mediacapture.cpp
PARENT_SCOPE)
/*
Copyright (C) 2019 Akhil K Gangadharan <helloimakhil@gmail.com>
This file is part of Kdenlive. See www.kdenlive.org.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License or (at your option) version 3 or any later version
accepted by the membership of KDE e.V. (or its successor approved
by the membership of KDE e.V.), which shall act as a proxy
defined in Section 14 of version 3 of the license.
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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QCameraInfo>
#include <QUrl>
#include "mediacapture.h"
MediaCapture::MediaCapture(QObject* parent)
: QObject(parent)
, m_audioRecorder(new QAudioRecorder(this))
{
QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
foreach (const QCameraInfo& cameraInfo, cameras) {
if (cameraInfo == QCameraInfo::defaultCamera()) {
m_camera = new QCamera(cameraInfo, this);
break;
}
}
m_videoRecorder = new QMediaRecorder(m_camera, this);
connect(m_videoRecorder, SIGNAL(error(QMediaRecorder::Error)), this, SLOT(displayErrorMessage()));
}
MediaCapture::~MediaCapture()
{
delete m_audioRecorder;
delete m_videoRecorder;
delete m_camera;
}
void MediaCapture::displayErrorMessage()
{
qDebug() << " ERROR : QMediarecorder - Capture failed";
}
void MediaCapture::recordAudioOnly()
{
if (m_audioRecorder->state() == QMediaRecorder::StoppedState) {
m_aSettings.setBitRate(48000);
QString container = "audio/x-wav";
m_audioRecorder->setEncodingSettings(m_aSettings, QVideoEncoderSettings(),
container);
m_audioRecorder->record();
} else {
m_audioRecorder->stop();
}
}
void MediaCapture::pauseAudioOnly()
{
if (m_audioRecorder->state() != QMediaRecorder::PausedState)
m_audioRecorder->stop();
else
m_audioRecorder->record();
}
void MediaCapture::recordVideo()
{
m_camera->setCaptureMode(QCamera::CaptureVideo);
m_camera->start();
if (m_videoRecorder->state() == QMediaRecorder::StoppedState) {
QString container = "video/mpeg";
m_videoRecorder->record();
} else {
m_videoRecorder->stop();
}
}
void MediaCapture::pauseVideo()
{
if (m_videoRecorder->state() != QMediaRecorder::PausedState) {
m_videoRecorder->stop();
m_camera->stop();
} else
m_videoRecorder->record();
}
void MediaCapture::setOutputLocations(QUrl path, bool checkAudio,
bool checkVideo)
{
if (!path.isEmpty()) {
if (checkAudio && checkVideo) {
m_videoRecorder->setOutputLocation(path);
} else if (checkAudio && !checkVideo)
m_audioRecorder->setOutputLocation(path);
}
return;
}
void MediaCapture::recordVideoOnly()
{
// TODO
}
void MediaCapture::pauseVideoOnly()
{
// TODO
}
QStringList MediaCapture::getAudioDevices()
{
return m_audioRecorder->audioInputs();
}
void MediaCapture::setAudioDevice(QString audioDevice)
{
m_audioRecorder->setAudioInput(audioDevice);
}
void MediaCapture::setAudioVolume(qreal volume)
{
m_audioRecorder->setVolume(volume);
}
\ No newline at end of file
/*
Copyright (C) 2019 Akhil K Gangadharan <akhilam512@gmail.com>
This file is part of Kdenlive. See www.kdenlive.org.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License or (at your option) version 3 or any later version
accepted by the membership of KDE e.V. (or its successor approved
by the membership of KDE e.V.), which shall act as a proxy
defined in Section 14 of version 3 of the license.
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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MEDIACAPTURE_H
#define MEDIACAPTURE_H
#include <QMediaRecorder>
#include <QAudioRecorder>
#include <QAudioEncoderSettings>
#include <QVideoEncoderSettings>
#include <QCamera>
#include <QStringList>
QT_BEGIN_NAMESPACE
class QAudioRecorder;
class QAudioProbe;
class QAudioBuffer;
QT_END_NAMESPACE
class QAudioLevel;
class QAudioWaveform;
class MediaCapture : public QObject
{
Q_OBJECT
public:
MediaCapture(QObject *parent);
~MediaCapture();
void recordAudioOnly();
void pauseAudioOnly();
void recordVideo();
void pauseVideo();
void recordVideoOnly();
void pauseVideoOnly();
void setOutputLocations(QUrl, bool, bool);
QStringList getAudioDevices();
void setAudioDevice(QString);
void setAudioVolume(qreal);
public slots:
void displayErrorMessage();
private:
QAudioRecorder *m_audioRecorder;
QMediaRecorder *m_videoRecorder;
QCamera *m_camera;
QAudioEncoderSettings m_aSettings;
QVideoEncoderSettings m_vSettings;
};
#endif
......@@ -459,6 +459,16 @@
<group name="capture">
<entry name="defaultaudiocapture" type="Int">
<label>Default audio capture system.</label>
<default>0</default>
</entry>
<entry name="audiocapturevolume" type="Int">
<label>Audio capture volume</label>
<default>100</default>
</entry>
<entry name="defaultcapture" type="Int">
<label>Default video capture system.</label>
<default>0</default>
......
......@@ -141,7 +141,8 @@ Monitor::Monitor(Kdenlive::MonitorId id, MonitorManager *manager, QWidget *paren
, m_editMarker(nullptr)
, m_forceSizeFactor(0)
, m_lastMonitorSceneType(MonitorSceneDefault)
{
, m_capture(new MediaCapture(this))
{
auto *layout = new QVBoxLayout;
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
......@@ -267,7 +268,7 @@ Monitor::Monitor(Kdenlive::MonitorId id, MonitorManager *manager, QWidget *paren
// Create Volume slider popup
m_audioSlider = new QSlider(Qt::Vertical);
m_audioSlider->setRange(0, 100);
m_audioSlider->setValue(100);
m_audioSlider->setValue(KdenliveSettings::volume());
connect(m_audioSlider, &QSlider::valueChanged, this, &Monitor::slotSetVolume);
auto *widgetslider = new QWidgetAction(this);
widgetslider->setText(i18n("Audio volume"));
......@@ -331,7 +332,6 @@ Monitor::Monitor(Kdenlive::MonitorId id, MonitorManager *manager, QWidget *paren
/*QWidget *spacer = new QWidget(this);
spacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
m_toolbar->addWidget(spacer);*/
m_toolbar->addSeparator();
int tm = 0;
int bm = 0;
......@@ -1972,25 +1972,46 @@ void Monitor::slotSwitchRec(bool enable)
}
}
bool Monitor::startCapture(const QString &params, const QString &path, Mlt::Producer *p)
bool Monitor::startCapture(bool checkAudio, bool checkVideo, QUrl path, QString audioDevice)
{
// TODO
m_controller = nullptr;
if (/* DISABLES CODE */ (false)) { // render->updateProducer(p)) {
m_glMonitor->reconfigureMulti(params, path, p->profile());
return true;
m_capture->setOutputLocations(path, checkAudio, checkVideo);
m_capture->setAudioDevice(audioDevice);
if (checkAudio && checkVideo) {
m_capture->recordVideo();
} else if (checkAudio) {
m_capture->recordAudioOnly();
} else if (checkVideo) {
m_capture->recordVideoOnly();
}
return false;
return true;
}
bool Monitor::stopCapture()
bool Monitor::stopCapture(bool checkAudio, bool checkVideo)
{
m_glMonitor->stopCapture();
slotOpenClip(nullptr);
m_glMonitor->reconfigure(profile());
if (m_capture) {
if (checkAudio && checkVideo) {
m_capture->pauseVideo();
} else if (checkAudio && !checkVideo) {
m_capture->pauseAudioOnly();
} else if (checkVideo && !checkAudio) {
m_capture->pauseVideoOnly();
}
slotOpenClip(nullptr);
}
// TODO remove else
return true;
}
QStringList Monitor::getAudioCaptureDevices()
{
return m_capture->getAudioDevices();
}
void Monitor::doKeyPressEvent(QKeyEvent *ev)
{
keyPressEvent(ev);
......@@ -2078,7 +2099,7 @@ void Monitor::panView(QPoint diff)
}
void Monitor::requestSeek(int pos)
{
{
m_glMonitor->seek(pos);
}
......@@ -2140,3 +2161,8 @@ void Monitor::setConsumerProperty(const QString &name, const QString &value)
{
m_glMonitor->setConsumerProperty(name, value);
}
void Monitor::setAudioCaptureVolume(int volume)
{
m_capture->setAudioVolume(volume);
}
\ No newline at end of file
......@@ -26,6 +26,7 @@
#include "gentime.h"
#include "scopes/sharedframe.h"
#include "timecodedisplay.h"
#include "capture/mediacapture.h"
#include <QDomElement>
#include <QElapsedTimer>
......@@ -136,8 +137,8 @@ public:
void switchDropFrames(bool drop);
void updateMonitorGamma();
void mute(bool, bool updateIconOnly = false) override;
bool startCapture(const QString &params, const QString &path, Mlt::Producer *p);
bool stopCapture();
bool startCapture(bool, bool, QUrl, QString);
bool stopCapture(bool, bool);
void reparent();
/** @brief Returns the action displaying record toolbar */
QAction *recAction();
......@@ -162,6 +163,9 @@ public:
void slotZoomOut();
/** @brief Set a property on the MLT consumer */
void setConsumerProperty(const QString &name, const QString &value);
std::unique_ptr<MediaCapture> m_capture;
QStringList getAudioCaptureDevices();
void setAudioCaptureVolume(int);
protected:
void mousePressEvent(QMouseEvent *event) override;
......@@ -180,7 +184,6 @@ protected:
void enterEvent(QEvent *event) override;
void leaveEvent(QEvent *event) override;
virtual QStringList mimeTypes() const;
private:
std::shared_ptr<ProjectClip> m_controller;
/** @brief The QQuickView that handles our monitor display (video and qml overlay) **/
......@@ -231,6 +234,7 @@ private:
MonitorAudioLevel *m_audioMeterWidget;
QElapsedTimer m_droppedTimer;
double m_displayedFps;
void adjustScrollBars(float horizontal, float vertical);
void loadQmlScene(MonitorSceneType type);
void updateQmlDisplay(int currentOverlay);
......@@ -328,7 +332,7 @@ public slots:
/** @brief Check current position to show relevant infos in qml view (markers, zone in/out, etc). */
void checkOverlay(int pos = -1);
void refreshMonitorIfActive(bool directUpdate = false) override;
signals:
void seekPosition(int);
/** @brief Request a timeline seeking if diff is true, position is a relative offset, otherwise an absolute position */
......
This diff is collapsed.
......@@ -38,13 +38,15 @@ class QAction;
class QToolBar;
class QComboBox;
class QCheckBox;
class QSlider;
class QToolButton;
namespace Mlt {
class Producer;
}
class RecManager : public QObject
{
{
Q_OBJECT
enum CaptureDevice {
......@@ -63,6 +65,8 @@ public:
QAction *switchAction() const;
/** @brief: stop capture and hide rec panel **/
void stop();
bool recordAudio;
bool recordVideo;
private:
Monitor *m_monitor;
......@@ -75,10 +79,13 @@ private:
QAction *m_playAction;
QAction *m_showLogAction;
QToolBar *m_recToolbar;
QToolButton *m_audioCaptureButton;
QComboBox *m_screenCombo{nullptr};
QComboBox *m_device_selector;
QComboBox *m_audio_device;
QCheckBox *m_recVideo;
QCheckBox *m_recAudio;
QSlider *m_audioCaptureSlider;
Mlt::Producer *createV4lProducer();
private slots:
......@@ -88,11 +95,13 @@ private slots:
void slotReadProcessInfo();
void showRecConfig();
void slotVideoDeviceChanged(int ix = -1);
void slotAudioDeviceChanged(int ix = -1);
void slotShowLog();
void slotSetVolume(int);
signals:
void addClipToProject(const QUrl &);
void warningMessage(const QString &, int timeout = 5000, const QList<QAction *> &actions = QList<QAction *>());
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment