Commit 51c32d90 authored by Casian Andrei's avatar Casian Andrei
Browse files

Implement Phonon::AvCapture and get rid of experimental

Switch implementing Phonon::Experimental::AvCapture to Phonon::AvCapture
Put firebathero up against experimental
parent df99d1f9
......@@ -20,16 +20,10 @@ endif (MSVC)
add_definitions(-D_PHONON_BACKEND_VERSION_4_2)
option(PHONON_VLC_NO_EXPERIMENTAL "Do not build anything experimental" true)
if(PHONON_VLC_NO_EXPERIMENTAL)
add_definitions(-DPHONON_VLC_NO_EXPERIMENTAL)
else(PHONON_VLC_NO_EXPERIMENTAL)
add_subdirectory(experimental)
endif(PHONON_VLC_NO_EXPERIMENTAL)
set(phonon_vlc_SRCS
audiooutput.cpp
audiodataoutput.cpp
avcapture.cpp
backend.cpp
debug.cpp
devicemanager.cpp
......@@ -44,7 +38,7 @@ set(phonon_vlc_SRCS
streamreader.cpp
# videodataoutput.cpp
videowidget.cpp
${phonon_vlc_experimental_SRCS})
)
if(APPLE)
list(APPEND phonon_vlc_SRCS
......
......@@ -31,12 +31,9 @@
#include <vlc/vlc.h>
#include "avcapture.h"
#include "mediaobject.h"
#ifndef PHONON_VLC_NO_EXPERIMENTAL
#include <experimental/avcapture.h>
#endif // PHONON_VLC_NO_EXPERIMENTAL
namespace Phonon
{
namespace VLC
......@@ -61,17 +58,15 @@ AudioDataOutput::~AudioDataOutput()
{
}
#ifndef PHONON_VLC_NO_EXPERIMENTAL
void AudioDataOutput::connectToAvCapture(Experimental::AvCapture *avCapture)
void AudioDataOutput::connectToAvCapture(AvCapture *avCapture)
{
connectToMediaObject(avCapture->audioMediaObject());
}
void AudioDataOutput::disconnectFromAvCapture(Experimental::AvCapture *avCapture)
void AudioDataOutput::disconnectFromAvCapture(AvCapture *avCapture)
{
disconnectFromMediaObject(avCapture->audioMediaObject());
}
#endif // PHONON_VLC_NO_EXPERIMENTAL
int AudioDataOutput::dataSize() const
{
......
......@@ -39,6 +39,9 @@ namespace Phonon
{
namespace VLC
{
class AvCapture;
/** \brief Implementation for AudioDataOutput using libVLC
*
* This class makes the capture of raw audio data possible. It sets special options
......@@ -69,21 +72,19 @@ public:
AudioDataOutput(QObject *parent);
~AudioDataOutput();
#ifndef PHONON_VLC_NO_EXPERIMENTAL
/**
* Connect this AudioDataOutput only to the audio media part of the AvCapture.
*
* \see AvCapture
*/
void connectToAvCapture(Experimental::AvCapture *avCapture);
void connectToAvCapture(AvCapture *avCapture);
/**
* Disconnect the AudioDataOutput from the video media of the AvCapture.
*
* \see connectToAvCapture()
*/
void disconnectFromAvCapture(Experimental::AvCapture *avCapture);
#endif//PHONON_VLC_NO_EXPERIMENTAL
void disconnectFromAvCapture(AvCapture *avCapture);
Phonon::AudioDataOutput *frontendObject() const
{
......
......@@ -27,15 +27,12 @@
#include <vlc/vlc.h>
#include "avcapture.h"
#include "backend.h"
#include "debug.h"
#include "devicemanager.h"
#include "mediaobject.h"
#ifndef PHONON_VLC_NO_EXPERIMENTAL
#include <experimental/avcapture.h>
#endif // PHONON_VLC_NO_EXPERIMENTAL
namespace Phonon
{
namespace VLC
......@@ -66,17 +63,15 @@ void AudioOutput::disconnectFromMediaObject(MediaObject *mediaObject)
}
}
#ifndef PHONON_VLC_NO_EXPERIMENTAL
void AudioOutput::connectToAvCapture(Experimental::AvCapture *avCapture)
void AudioOutput::connectToAvCapture(AvCapture *avCapture)
{
connectToMediaObject(avCapture->audioMediaObject());
}
void AudioOutput::disconnectFromAvCapture(Experimental::AvCapture *avCapture)
void AudioOutput::disconnectFromAvCapture(AvCapture *avCapture)
{
disconnectFromMediaObject(avCapture->audioMediaObject());
}
#endif // PHONON_VLC_NO_EXPERIMENTAL
qreal AudioOutput::volume() const
{
......
......@@ -33,6 +33,8 @@ namespace Phonon
namespace VLC
{
class AvCapture;
/** \brief AudioOutput implementation for Phonon-VLC
*
* This class is a SinkNode that implements the AudioOutputInterface from Phonon. It
......@@ -65,22 +67,20 @@ public:
/* Overload */
virtual void disconnectFromMediaObject(MediaObject *mediaObject);
#ifndef PHONON_VLC_NO_EXPERIMENTAL
/**
* Connects the AudioOutput to an AvCapture. connectToMediaObject() is called
* only for the video media of the AvCapture.
*
* \see AvCapture
*/
void connectToAvCapture(Experimental::AvCapture *avCapture);
void connectToAvCapture(AvCapture *avCapture);
/**
* Disconnect the AudioOutput from the audio media of the AvCapture.
*
* \see connectToAvCapture()
*/
void disconnectFromAvCapture(Experimental::AvCapture *avCapture);
#endif // PHONON_VLC_NO_EXPERIMENTAL
void disconnectFromAvCapture(AvCapture *avCapture);
/**
* \return The current volume for this audio output.
......
......@@ -21,15 +21,12 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
*****************************************************************************/
#ifndef PHONON_VLC_NO_EXPERIMENTAL
#include "avcapture.h"
namespace Phonon
{
namespace VLC
{
namespace Experimental
{
AvCapture::AvCapture(QObject* parent)
: QObject(parent),
......@@ -90,14 +87,14 @@ VideoCaptureDevice AvCapture::videoCaptureDevice() const
return m_videoCaptureDevice;
}
void AvCapture::setAudioCaptureDevice(const Phonon::AudioCaptureDevice &device)
void AvCapture::setAudioCaptureDevice(const AudioCaptureDevice &device)
{
m_audioMedia.setSource(device);
m_audioCaptureDevice = device;
setupStateChangedSignal();
}
void AvCapture::setVideoCaptureDevice(const Phonon::VideoCaptureDevice &device)
void AvCapture::setVideoCaptureDevice(const VideoCaptureDevice &device)
{
m_videoMedia.setSource(device);
m_videoCaptureDevice = device;
......@@ -108,7 +105,7 @@ void AvCapture::setupStateChangedSignal()
{
// Disconnect the old media object state change signal
if (m_connectedMO)
disconnect(m_connectedMO, SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SIGNAL(stateChanged(Phonon::State,Phonon::State)));
disconnect(m_connectedMO, SIGNAL(stateChanged(State,State)), this, SIGNAL(stateChanged(State,State)));
// Determine the media object from which the state change signal will be connected
m_connectedMO = NULL;
......@@ -122,11 +119,9 @@ void AvCapture::setupStateChangedSignal()
// Connect the state change signal
if (m_connectedMO)
connect(m_connectedMO, SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SIGNAL(stateChanged(Phonon::State,Phonon::State)));
connect(m_connectedMO, SIGNAL(stateChanged(State,State)), this, SIGNAL(stateChanged(State,State)));
}
} // Experimental namespace
} // VLC namespace
} // Phonon namespace
#endif // PHONON_VLC_NO_EXPERIMENTAL
......@@ -21,32 +21,28 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
*****************************************************************************/
#ifndef PHONON_VLC_NO_EXPERIMENTAL
#ifndef PHONON_VLC_AVCAPTURE_H
#define PHONON_VLC_AVCAPTURE_H
#include "mediaobject.h"
#include <phonon/experimental/avcaptureinterface.h>
#include <phonon/avcaptureinterface.h>
namespace Phonon
{
namespace VLC
{
namespace Experimental
{
class AvCapture : public QObject, public Phonon::Experimental::AvCaptureInterface
class AvCapture : public QObject, public Phonon::AvCaptureInterface
{
Q_OBJECT
Q_INTERFACES(Phonon::Experimental::AvCaptureInterface)
Q_INTERFACES(Phonon::AvCaptureInterface)
public:
AvCapture(QObject *parent);
~AvCapture();
Phonon::State state() const;
State state() const;
void start();
void pause();
void stop();
......@@ -60,7 +56,7 @@ class AvCapture : public QObject, public Phonon::Experimental::AvCaptureInterfac
MediaObject* videoMediaObject();
signals:
void stateChanged(Phonon::State newState, Phonon::State oldState);
void stateChanged(State newState, State oldState);
private:
void setupStateChangedSignal();
......@@ -73,9 +69,7 @@ class AvCapture : public QObject, public Phonon::Experimental::AvCaptureInterfac
MediaObject *m_connectedMO;
};
} // Experimental namespace
} // VLC namespace
} // Phonon namespace
#endif // PHONON_VLC_AVCAPTURE_H
#endif // PHONON_VLC_NO_EXPERIMENTAL
......@@ -42,6 +42,7 @@
#include "audiooutput.h"
#include "audiodataoutput.h"
#include "avcapture.h"
#include "devicemanager.h"
#include "effect.h"
#include "effectmanager.h"
......@@ -52,10 +53,6 @@
//#include "videodataoutput.h"
#include "videowidget.h"
#ifndef PHONON_VLC_NO_EXPERIMENTAL
#include "experimental/avcapture.h"
#endif // PHONON_VLC_NO_EXPERIMENTAL
Q_EXPORT_PLUGIN2(phonon_vlc, Phonon::VLC::Backend)
namespace Phonon
......@@ -134,19 +131,6 @@ Backend::~Backend()
QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const QList<QVariant> &args)
{
#ifndef PHONON_VLC_NO_EXPERIMENTAL
Phonon::Experimental::BackendInterface::Class cex = static_cast<Phonon::Experimental::BackendInterface::Class>(c);
switch (cex) {
case Phonon::Experimental::BackendInterface::AvCaptureClass:
warning() << "createObject() : AvCapture created - WARNING: Experimental!";
return new Experimental::AvCapture(parent);
default:
if ((quint32) cex >= (quint32) Phonon::Experimental::BackendInterface::VideoDataOutputClass)
warning() << "createObject() - experimental : Backend object not available";
}
#endif // PHONON_VLC_NO_EXPERIMENTAL
switch (c) {
case MediaObjectClass:
return new MediaObject(parent);
......@@ -173,6 +157,8 @@ QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const
return new Effect(m_effectManager, args[0].toInt(), parent);
case VideoWidgetClass:
return new VideoWidget(qobject_cast<QWidget *>(parent));
case AvCaptureClass:
return new AvCapture(parent);
default:
error() << "createObject() : Backend object not available";
}
......@@ -412,14 +398,12 @@ bool Backend::connectNodes(QObject *source, QObject *sink)
return true;
}
#ifndef PHONON_VLC_NO_EXPERIMENTAL
Experimental::AvCapture *avCapture = qobject_cast<Experimental::AvCapture *>(source);
AvCapture *avCapture = qobject_cast<AvCapture *>(source);
if (avCapture) {
// Connect the SinkNode to a AvCapture
sinkNode->connectToAvCapture(avCapture);
return true;
}
#endif // PHONON_VLC_NO_EXPERIMENTAL
/*
Effect *effect = qobject_cast<Effect *>(source);
......@@ -446,14 +430,12 @@ bool Backend::disconnectNodes(QObject *source, QObject *sink)
return true;
}
#ifndef PHONON_VLC_NO_EXPERIMENTAL
Experimental::AvCapture *avCapture = qobject_cast<Experimental::AvCapture *>(source);
AvCapture *avCapture = qobject_cast<AvCapture *>(source);
if (avCapture) {
// Disconnect the SinkNode from a AvCapture
sinkNode->disconnectFromAvCapture(avCapture);
return true;
}
#endif // PHONON_VLC_NO_EXPERIMENTAL
/*
Effect *effect = qobject_cast<Effect *>(source);
......
......@@ -30,10 +30,6 @@
#include <phonon/objectdescription.h>
#include <phonon/backendinterface.h>
#ifndef PHONON_VLC_NO_EXPERIMENTAL
#include "phonon/experimental/backendinterface.h"
#endif // PHONON_VLC_NO_EXPERIMENTAL
#include <QtCore/QList>
#include <QtCore/QPointer>
#include <QtCore/QStringList>
......
include_directories(${PHONON_EXPERIMENTAL_INCLUDE_DIR})
set(phonon_vlc_experimental_SRCS
experimental/avcapture.cpp
PARENT_SCOPE
)
......@@ -21,14 +21,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
*****************************************************************************/
#include "sinknode.h"
#include "avcapture.h"
#include "debug.h"
#include "mediaobject.h"
#ifndef PHONON_VLC_NO_EXPERIMENTAL
#include "experimental/avcapture.h"
#endif // PHONON_VLC_NO_EXPERIMENTAL
#include "sinknode.h"
namespace Phonon
{
......@@ -72,19 +68,17 @@ void SinkNode::addToMedia(libvlc_media_t *media)
Q_UNUSED(media);
}
#ifndef PHONON_VLC_NO_EXPERIMENTAL
void SinkNode::connectToAvCapture(Experimental::AvCapture *avCapture)
void SinkNode::connectToAvCapture(AvCapture *avCapture)
{
connectToMediaObject(avCapture->audioMediaObject());
connectToMediaObject(avCapture->videoMediaObject());
}
void SinkNode::disconnectFromAvCapture(Experimental::AvCapture *avCapture)
void SinkNode::disconnectFromAvCapture(AvCapture *avCapture)
{
disconnectFromMediaObject(avCapture->audioMediaObject());
disconnectFromMediaObject(avCapture->videoMediaObject());
}
#endif // PHONON_VLC_NO_EXPERIMENTAL
}
} // Namespace Phonon::VLC
......@@ -33,11 +33,8 @@ namespace Phonon
namespace VLC
{
namespace Experimental
{
class AvCapture;
}
class AvCapture;
class MediaObject;
/** \brief The sink node is essentialy an output for a media object
......@@ -77,7 +74,6 @@ public:
*/
virtual void addToMedia(libvlc_media_t *media);
#ifndef PHONON_VLC_NO_EXPERIMENTAL
/**
* Associates the sink node with the compatible media object owned by the specified AvCapture.
* The sink node knows whether it is compatible with video media or audio media. Here, the
......@@ -89,7 +85,7 @@ public:
* \see connectToMediaObject()
* \see disconnectFromAvCapture()
*/
virtual void connectToAvCapture(Experimental::AvCapture *avCapture);
virtual void connectToAvCapture(AvCapture *avCapture);
/**
* Removes this sink from any of the AvCapture's media objects. If connectToAvCapture() is
......@@ -99,8 +95,7 @@ public:
*
* \see connectToAvCapture()
*/
virtual void disconnectFromAvCapture(Experimental::AvCapture *avCapture);
#endif // PHONON_VLC_NO_EXPERIMENTAL
virtual void disconnectFromAvCapture(AvCapture *avCapture);
protected:
MediaObject *m_mediaObject;
......
......@@ -30,9 +30,7 @@
#include "debug.h"
#ifndef PHONON_VLC_NO_EXPERIMENTAL
#include "experimental/avcapture.h"
#endif // PHONON_VLC_NO_EXPERIMENTAL
#include "avcapture.h"
#include "mediaobject.h"
namespace Phonon
......@@ -88,17 +86,15 @@ void VideoWidget::disconnectFromMediaObject(MediaObject *mediaObject)
disconnect(mediaObject, 0, this, 0);
}
#ifndef PHONON_VLC_NO_EXPERIMENTAL
void VideoWidget::connectToAvCapture(Experimental::AvCapture *avCapture)
void VideoWidget::connectToAvCapture(AvCapture *avCapture)
{
connectToMediaObject(avCapture->videoMediaObject());
}
void VideoWidget::disconnectFromAvCapture(Experimental::AvCapture *avCapture)
void VideoWidget::disconnectFromAvCapture(AvCapture *avCapture)
{
disconnectFromMediaObject(avCapture->videoMediaObject());
}
#endif // PHONON_VLC_NO_EXPERIMENTAL
Phonon::VideoWidget::AspectRatio VideoWidget::aspectRatio() const
{
......
......@@ -32,10 +32,7 @@ namespace Phonon
namespace VLC
{
namespace Experimental
{
class AvCapture;
}
/** \brief Implements the Phonon VideoWidget MediaNode, responsible for displaying video
*
......@@ -78,22 +75,20 @@ public:
*/
void disconnectFromMediaObject(MediaObject *mediaObject);
#ifndef PHONON_VLC_NO_EXPERIMENTAL
/**
* Connects the VideoWidget to an AvCapture. connectToMediaObject() is called
* only for the video media of the AvCapture.
*
* \see AvCapture
*/
void connectToAvCapture(Experimental::AvCapture *avCapture);
void connectToAvCapture(AvCapture *avCapture);
/**
* Disconnect the VideoWidget from the video media of the AvCapture.
*
* \see connectToAvCapture()
*/
void disconnectFromAvCapture(Experimental::AvCapture *avCapture);
#endif // PHONON_VLC_NO_EXPERIMENTAL
void disconnectFromAvCapture(AvCapture *avCapture);
/**
* \return The aspect ratio previously set for the video widget
......
/*****************************************************************************
* libVLC backend for the Phonon library *
* *
* Copyright (C) 2007-2008 Tanguy Krotoff <tkrotoff@gmail.com> *
* Copyright (C) 2008 Lukas Durfina <lukas.durfina@gmail.com> *
* Copyright (C) 2009 Fathi Boudra <fabo@kde.org> *
* Copyright (C) 2009-2010 vlc-phonon AUTHORS *
* *
* 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; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* 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 package; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
*****************************************************************************/
#include "avcapture.h"
namespace Phonon
{
namespace VLC
{
AvCapture::AvCapture(QObject* parent)
: QObject(parent),
m_audioMedia(parent),
m_videoMedia(parent)
{
m_connectedMO = NULL;
}
AvCapture::~AvCapture()
{
stop();
}
State AvCapture::state() const
{
if (m_connectedMO)
return m_connectedMO->state();
return ErrorState;
}
void AvCapture::start()
{
m_audioMedia.play();
m_videoMedia.play();
}
void AvCapture::pause()
{
m_audioMedia.pause();
m_videoMedia.pause();
}
void AvCapture::stop()
{
m_audioMedia.stop();
m_videoMedia.stop();
}
MediaObject* AvCapture::audioMediaObject()
{
return &m_audioMedia;
}
MediaObject* AvCapture::videoMediaObject()
{
return &m_videoMedia;
}
AudioCaptureDevice AvCapture::audioCaptureDevice() const
{
return m_audioCaptureDevice;
}
VideoCaptureDevice AvCapture::videoCaptureDevice() const
{
return m_videoCaptureDevice;
}
void AvCapture::setAudioCaptureDevice(const AudioCaptureDevice &device)
{
m_audioMedia.setSource(device);
m_audioCaptureDevice = device;
setupStateChangedSignal();
}
void AvCapture::setVideoCaptureDevice(const VideoCaptureDevice &device)
{
m_videoMedia.setSource(device);
m_videoCaptureDevice = device;
setupStateChangedSignal();
}
void AvCapture::setupStateChangedSignal()
{
// Disconnect the old media object state change signal
if (m_connectedMO)
disconnect(m_connectedMO, SIGNAL(stateChanged(State,State)), this, SIGNAL(stateChanged(State,State)));
// Determine the media object from which the state change signal will be connected
m_connectedMO = NULL;
if (m_videoCaptureDevice.isValid()) {
m_connectedMO = &m_videoMedia;
} else {
if (m_audioCaptureDevice.isValid()) {
m_connectedMO = &m_audioMedia;
}
}
// Connect the state change signal
if (m_connectedMO)
connect(m_connectedMO, SIGNAL(stateChanged(State,State)), this, SIGNAL(stateChanged(State,State)));