Commit a60625cc authored by Avik Pal's avatar Avik Pal
Browse files

Moved source code and created the staging place for the new libsound library

REVIEW: 118601
parent 0723b8d3
......@@ -40,6 +40,7 @@ include_directories(
${QT_INCLUDE}
${KDE4_INCLUDES}
${CMAKE_CURRENT_BINARY_DIR}
${artikulate_SOURCE_DIR}
)
# set the source code files from which Artikulate is compiled
......@@ -62,7 +63,7 @@ set(artikulateCore_SRCS
core/resources/skeletonresource.cpp
core/player.cpp
core/recorder.cpp
core/soundbackends/soundbackendinterface.cpp
libsound/soundbackends/soundbackendinterface.cpp
ui/newcoursedialog.cpp
)
......@@ -92,7 +93,7 @@ include_directories(
)
set(artikulateCore_SRCS
${artikulateCore_SRCS}
core/soundbackends/qtgstreamerbackend.cpp
libsound/soundbackends/qtgstreamerbackend.cpp
)
set(artikulateCoreTargetLibs
${artikulateCoreTargetLibs}
......
......@@ -26,6 +26,7 @@
#include <QGst/Init>
#include <QGst/ElementFactory>
#include <QGst/ChildProxy>
#include <QGst/PropertyProbe>
#include <QGst/Pipeline>
#include <QGst/Pad>
#include <QGst/Event>
......@@ -48,12 +49,40 @@ QtGStreamerBackend::QtGStreamerBackend()
return;
}
m_availableDevices.insert("", i18nc("default sound device", "Default"));
src->setState(QGst::StateReady);
QGst::ChildProxyPtr childProxy = src.dynamicCast<QGst::ChildProxy>();
if (childProxy && childProxy->childrenCount() > 0) {
//the actual source is the first child
//this source usually implements the property probe interface
m_audioProbe = childProxy->childByIndex(0).dynamicCast<QGst::PropertyProbe>();
}
//we got a reference to the underlying propertyProbe, so we don't need src anymore.
src->setState(QGst::StateNull);
//Most sources and sinks have a "device" property which supports probe
//and probing it returns all the available devices on the system.
//Here we try to make use of that to list the system's devices
//and if it fails, we just leave the source to use its default device.
if (m_audioProbe && m_audioProbe->propertySupportsProbe("device")) {
//get a list of devices that the element supports
QList<QGlib::Value> devices = m_audioProbe->probeAndGetValues("device");
Q_FOREACH(const QGlib::Value & device, devices) {
//set the element's device to the current device and retrieve its
//human-readable name through the "device-name" property
m_audioProbe->setProperty("device", device);
QString deviceName = m_audioProbe->property("device-name").toString();
m_availableDevices.insert(device.toString(), QString("%1 (%2)").arg(deviceName, device.toString()));
}
} else {
m_availableDevices.insert("", i18nc("@item:inlistbox default sound device", "Default"));
}
}
QtGStreamerBackend::~QtGStreamerBackend()
{
m_pipeline.clear();
m_audioProbe.clear();
}
QString QtGStreamerBackend::identifier()
......@@ -94,6 +123,16 @@ QGst::BinPtr QtGStreamerBackend::createAudioSrcBin()
return QGst::BinPtr();
}
QGst::ElementPtr src = audioBin->getElementByName("audiosrc");
src->setState(QGst::StateReady);
QGst::ChildProxyPtr childProxy = src.dynamicCast<QGst::ChildProxy>();
if (childProxy && childProxy->childrenCount() > 0) {
//the actual source is the first child
QGst::ObjectPtr realSrc = childProxy->childByIndex(0);
// realSrc->setProperty("device", ""); //FIXME when setting device pipeline breaks with creation error
}
return audioBin;
}
......@@ -177,9 +216,7 @@ void QtGStreamerBackend::stopPipeline()
QStringList QtGStreamerBackend::devices() const
{
//TODO qtgstreamer backend currently only provides access to default backend,
//reenable selection by using Gst::Device
//TODO switch to human readable device names
return m_availableDevices.keys();
}
......
......@@ -26,6 +26,7 @@
#include <QString>
#include <QGst/global.h>
#include <QGst/PropertyProbe>
#include <QGst/Pipeline>
class QtGStreamerBackend : public SoundBackendInterface
......@@ -51,6 +52,7 @@ private:
void stopPipeline();
QGst::BinPtr createAudioSrcBin();
QGst::PropertyProbePtr m_audioProbe;
QGst::PipelinePtr m_pipeline;
QString m_device;
QMap<QString, QString> m_availableDevices; //!> (identifier,human readable name)
......
......@@ -22,7 +22,7 @@
#define SOUNDBACKENDINTERFACE_H
#include <QObject>
#include "../capturedevicecontroller.h"
#include "core/capturedevicecontroller.h"
class SoundBackendInterface : public QObject
{
......
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