diff --git a/src/call.cpp b/src/call.cpp index 364e84229b574b2eb8489b0543ea97fafabac08d..52ca55e84fe77778bfd9cb4850a22fe8cb66f759 100644 --- a/src/call.cpp +++ b/src/call.cpp @@ -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); diff --git a/src/call.h b/src/call.h index 245451174b6d18fda011b035896c2597582f827b..d4b3ac7d623eb54774e8c835b58120a68b93330c 100644 --- a/src/call.h +++ b/src/call.h @@ -30,7 +30,7 @@ #include "logger.h" -#include "audio/recordable.h" +#include "recordable.h" #include "ip_utils.h" #include "ice_transport.h" diff --git a/src/conference.cpp b/src/conference.cpp index 46b15c4f8d47e4ee9a42324cdba0597d1e013f7b..d38dd9190114a08d61f8acbfd99dd6f8bbd6b9d7 100644 --- a/src/conference.cpp +++ b/src/conference.cpp @@ -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); diff --git a/src/conference.h b/src/conference.h index d55dd5396bd42e81510940ae3c9ece188bf3f58e..91d1e27cad8d329a67fa54369cb4f1625f990d45 100644 --- a/src/conference.h +++ b/src/conference.h @@ -28,7 +28,7 @@ #include <string> #include <memory> -#include "audio/recordable.h" +#include "recordable.h" namespace ring { diff --git a/src/manager.h b/src/manager.h index 9700ba5173fc0566d3462b57b249423610d7aa5a..688c9a087c30c43ed772e738f6d75dddaa72bed2 100644 --- a/src/manager.h +++ b/src/manager.h @@ -65,6 +65,7 @@ class SinkClient; class PluginManager; class AudioFile; class DTMF; +class RingBufferPool; /** To send multiple string */ typedef std::list<std::string> TokenList; diff --git a/src/media/Makefile.am b/src/media/Makefile.am index 730b78c04ff3f6de564a3dade1b9ff61d02d7203..c30f17df788705ab03a7b07e9d7603992a278a49 100644 --- a/src/media/Makefile.am +++ b/src/media/Makefile.am @@ -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 diff --git a/src/media/audio/Makefile.am b/src/media/audio/Makefile.am index b6c52fa7fc5d54dc01262abdcd7a32c23a7e5dd0..0b4a8de7e97633aff22cd37ad54d6dd85682056b 100644 --- a/src/media/audio/Makefile.am +++ b/src/media/audio/Makefile.am @@ -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 \ diff --git a/src/media/audio/recordable.cpp b/src/media/audio/recordable.cpp deleted file mode 100644 index 163059c1bc815b84f65112f8f1d43cb1c4727de0..0000000000000000000000000000000000000000 --- a/src/media/audio/recordable.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2004-2015 Savoir-faire Linux Inc. - * - * Author: Alexandre Savard <alexandre.savard@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 - * the Free Software Foundation; either version 3 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "recordable.h" -#include "manager.h" -#include "logger.h" - -namespace ring { - -Recordable::Recordable() : recAudio_(), recorder_(&recAudio_, Manager::instance().getRingBufferPool()) -{ - RING_DBG("Set recording options: %s", Manager::instance().audioPreference.getRecordPath().c_str()); - recAudio_.setRecordingOptions(AudioFormat::MONO(), Manager::instance().audioPreference.getRecordPath()); -} - -Recordable::~Recordable() -{ - if (recAudio_.isOpenFile()) - recAudio_.closeFile(); -} - -void Recordable::initRecFilename(const std::string &filename) -{ - recAudio_.initFilename(filename); -} - -std::string Recordable::getFilename() const -{ - return recAudio_.getFilename(); -} - -void Recordable::setRecordingFormat(AudioFormat format) -{ - recAudio_.setSndFormat(format); -} - -} // namespace ring diff --git a/src/media/audio/recordable.h b/src/media/audio/recordable.h deleted file mode 100644 index 2bc781d22041c7375c35deeccabb18004ebbfa6b..0000000000000000000000000000000000000000 --- a/src/media/audio/recordable.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2004-2015 Savoir-faire Linux Inc. - * - * Author: Alexandre Savard <alexandre.savard@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 - * the Free Software Foundation; either version 3 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef RECORDABLE_H -#define RECORDABLE_H - -#include "audiorecord.h" -#include "audiorecorder.h" - -namespace ring { - -class Recordable { - - public: - - Recordable(); - virtual ~Recordable(); - - /** - * Return recording state (true/false) - */ - bool isRecording() const { - return recAudio_.isRecording(); - } - - /** - * 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(); - } - - /** - * Stop recording - */ - void stopRecording() { - recAudio_.stopRecording(); - } - - /** - * 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; - - /** - * Set recording sampling rate. - */ - void setRecordingFormat(AudioFormat format); - - protected: - AudioRecord recAudio_; - AudioRecorder recorder_; -}; - -} // namespace ring - -#endif diff --git a/src/media/recordable.cpp b/src/media/recordable.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5e98b12b21fa661d22c74ced85638ff5e07e5759 --- /dev/null +++ b/src/media/recordable.cpp @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2004-2015 Savoir-faire Linux Inc. + * + * Author: Alexandre Savard <alexandre.savard@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 + * the Free Software Foundation; either version 3 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "recordable.h" +#include "audio/audiorecord.h" +#include "audio/audiorecorder.h" +#include "manager.h" +#include "logger.h" + +namespace ring { + +Recordable::Recordable() + : recAudio_(new AudioRecord) + , recorder_(new AudioRecorder {recAudio_.get(), Manager::instance().getRingBufferPool()}) +{ + 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(); +} + +void +Recordable::initRecFilename(const std::string &filename) +{ + recAudio_->initFilename(filename); +} + +std::string +Recordable::getFilename() const +{ + return recAudio_->getFilename(); +} + +void +Recordable::setRecordingFormat(AudioFormat 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 diff --git a/src/media/recordable.h b/src/media/recordable.h new file mode 100644 index 0000000000000000000000000000000000000000..870feb65013908b99de5b43f34de997217eda09b --- /dev/null +++ b/src/media/recordable.h @@ -0,0 +1,76 @@ +/* + * 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 + * the Free Software Foundation; either version 3 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#pragma once + +#include "audio/audiobuffer.h" + +#include <string> +#include <memory> + +namespace ring { + +class AudioRecord; +class AudioRecorder; + +class Recordable { +public: + Recordable(); + virtual ~Recordable(); + + /** + * 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(); + + /** + * Stop recording + */ + void stopRecording(); + + /** + * 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; + + /** + * Set recording sampling rate. + */ + void setRecordingFormat(AudioFormat format); + +protected: + std::unique_ptr<AudioRecord> recAudio_; + std::unique_ptr<AudioRecorder> recorder_; +}; + +} // namespace ring