Commit 4c71686e authored by Guillaume Roguez's avatar Guillaume Roguez

media: move-up recordable class

Recordable must not be linked to audio only. We need it for
any media types. So this patch moves it up from media/audio directory
to media.
Also unlink from audio headers by using smart pointers.

Tuleap: #337
Change-Id: Ia697280a9e482897bdf8c3dc7c3152a7133d1397
parent 2c633511
......@@ -26,7 +26,7 @@
#include "audio/ringbufferpool.h"
#include "dring/call_const.h"
#include "client/ring_signal.h"
#include "audio/audiorecorder.h"
#include "sip/sip_utils.h"
#include "ip_utils.h"
#include "array_size.h"
......@@ -261,13 +261,13 @@ Call::toggleRecording()
{
const bool startRecording = Recordable::toggleRecording();
RingBufferPool &rbPool = Manager::instance().getRingBufferPool();
std::string process_id = Recordable::recorder_.getRecorderID();
std::string process_id = Recordable::recorder_->getRecorderID();
if (startRecording) {
rbPool.bindHalfDuplexOut(process_id, id_);
rbPool.bindHalfDuplexOut(process_id, RingBufferPool::DEFAULT_ID);
Recordable::recorder_.start();
Recordable::recorder_->start();
} else {
rbPool.unBindHalfDuplexOut(process_id, id_);
rbPool.unBindHalfDuplexOut(process_id, RingBufferPool::DEFAULT_ID);
......
......@@ -30,7 +30,7 @@
#include "logger.h"
#include "audio/recordable.h"
#include "recordable.h"
#include "ip_utils.h"
#include "ice_transport.h"
......
......@@ -25,6 +25,7 @@
#include "manager.h"
#include "audio/audiolayer.h"
#include "audio/ringbufferpool.h"
#include "audio/audiorecorder.h"
#ifdef RING_VIDEO
#include "sip/sipcall.h"
......@@ -149,7 +150,7 @@ bool Conference::toggleRecording()
const bool startRecording = Recordable::toggleRecording();
auto& rbPool = Manager::instance().getRingBufferPool();
std::string process_id(Recordable::recorder_.getRecorderID());
std::string process_id(Recordable::recorder_->getRecorderID());
// start recording
if (startRecording) {
......@@ -158,7 +159,7 @@ bool Conference::toggleRecording()
rbPool.bindHalfDuplexOut(process_id, RingBufferPool::DEFAULT_ID);
Recordable::recorder_.start();
Recordable::recorder_->start();
} else {
for (const auto &item : participants_)
rbPool.unBindHalfDuplexOut(process_id, item);
......
......@@ -28,7 +28,7 @@
#include <string>
#include <memory>
#include "audio/recordable.h"
#include "recordable.h"
namespace ring {
......
......@@ -65,6 +65,7 @@ class SinkClient;
class PluginManager;
class AudioFile;
class DTMF;
class RingBufferPool;
/** To send multiple string */
typedef std::list<std::string> TokenList;
......
......@@ -17,7 +17,8 @@ libmedia_la_SOURCES = \
media_io_handle.cpp \
media_codec.cpp \
system_codec_container.cpp \
srtp.c
srtp.c \
recordable.cpp
noinst_HEADERS = \
rtp_session.h \
......@@ -31,7 +32,8 @@ noinst_HEADERS = \
media_device.h \
media_codec.h \
system_codec_container.h \
srtp.h
srtp.h \
recordable.h
libmedia_la_LIBADD = \
./audio/libaudio.la
......
......@@ -40,7 +40,6 @@ libaudio_la_SOURCES = \
ringbufferpool.cpp \
audiorecord.cpp \
audiorecorder.cpp \
recordable.cpp \
audiolayer.cpp \
resampler.cpp \
$(RING_SPEEXDSP_SRC) \
......@@ -64,7 +63,6 @@ noinst_HEADERS = \
audiorecord.h \
audiorecorder.h \
audiolayer.h \
recordable.h \
$(RING_SPEEXDSP_HEAD) \
dcblocker.h \
resampler.h \
......
......@@ -19,36 +19,64 @@
*/
#include "recordable.h"
#include "audio/audiorecord.h"
#include "audio/audiorecorder.h"
#include "manager.h"
#include "logger.h"
namespace ring {
Recordable::Recordable() : recAudio_(), recorder_(&recAudio_, Manager::instance().getRingBufferPool())
Recordable::Recordable()
: recAudio_(new AudioRecord)
, recorder_(new AudioRecorder {recAudio_.get(), Manager::instance().getRingBufferPool()})
{
RING_DBG("Set recording options: %s", Manager::instance().audioPreference.getRecordPath().c_str());
recAudio_.setRecordingOptions(AudioFormat::MONO(), Manager::instance().audioPreference.getRecordPath());
auto record_path = Manager::instance().audioPreference.getRecordPath();
RING_DBG("Set recording options: %s", record_path.c_str());
recAudio_->setRecordingOptions(AudioFormat::MONO(), record_path);
}
Recordable::~Recordable()
{
if (recAudio_.isOpenFile())
recAudio_.closeFile();
if (recAudio_->isOpenFile())
recAudio_->closeFile();
}
void Recordable::initRecFilename(const std::string &filename)
void
Recordable::initRecFilename(const std::string &filename)
{
recAudio_.initFilename(filename);
recAudio_->initFilename(filename);
}
std::string Recordable::getFilename() const
std::string
Recordable::getFilename() const
{
return recAudio_.getFilename();
return recAudio_->getFilename();
}
void Recordable::setRecordingFormat(AudioFormat format)
void
Recordable::setRecordingFormat(AudioFormat format)
{
recAudio_.setSndFormat(format);
recAudio_->setSndFormat(format);
}
bool
Recordable::isRecording() const
{
return recAudio_->isRecording();
}
bool
Recordable::toggleRecording()
{
if (not isRecording())
recorder_->init();
return recAudio_->toggleRecording();
}
void
Recordable::stopRecording()
{
recAudio_->stopRecording();
}
} // namespace ring
/*
* Copyright (C) 2004-2015 Savoir-faire Linux Inc.
* Copyright (C) 2004-2016 Savoir-faire Linux Inc.
*
* Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
* Author: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com>
*
* 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
......@@ -18,66 +19,58 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef RECORDABLE_H
#define RECORDABLE_H
#pragma once
#include "audiorecord.h"
#include "audiorecorder.h"
#include "audio/audiobuffer.h"
namespace ring {
#include <string>
#include <memory>
class Recordable {
namespace ring {
public:
class AudioRecord;
class AudioRecorder;
Recordable();
virtual ~Recordable();
class Recordable {
public:
Recordable();
virtual ~Recordable();
/**
* Return recording state (true/false)
*/
bool isRecording() const {
return recAudio_.isRecording();
}
/**
* Return recording state (true/false)
*/
bool isRecording() const;
/**
* This method must be implemented for this interface as calls and conferences
* have different behavior.
* Implementations must call the super method.
*/
virtual bool toggleRecording() {
if (not isRecording())
recorder_.init();
return recAudio_.toggleRecording();
}
/**
* This method must be implemented for this interface as calls and conferences
* have different behavior.
* Implementations must call the super method.
*/
virtual bool toggleRecording();
/**
* Stop recording
*/
void stopRecording() {
recAudio_.stopRecording();
}
/**
* Stop recording
*/
void stopRecording();
/**
* Init the recording file name according to path specified in configuration
*/
void initRecFilename(const std::string &filename);
/**
* Init the recording file name according to path specified in configuration
*/
void initRecFilename(const std::string& filename);
/**
* Return the file path for this recording
*/
virtual std::string getFilename() const;
/**
* Return the file path for this recording
*/
virtual std::string getFilename() const;
/**
* Set recording sampling rate.
*/
void setRecordingFormat(AudioFormat format);
/**
* Set recording sampling rate.
*/
void setRecordingFormat(AudioFormat format);
protected:
AudioRecord recAudio_;
AudioRecorder recorder_;
protected:
std::unique_ptr<AudioRecord> recAudio_;
std::unique_ptr<AudioRecorder> recorder_;
};
} // namespace ring
#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