YARP
Yet Another Robot Platform
AudioRecorderWrapper.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #ifndef YARP_DEV_AUDIORECORDERWRAPPER_H
20 #define YARP_DEV_AUDIORECORDERWRAPPER_H
21 
22 #include <cstdio>
23 
24 
25 #include <yarp/os/BufferedPort.h>
26 #include <yarp/dev/PolyDriver.h>
30 #include <yarp/os/Time.h>
31 #include <yarp/os/Network.h>
32 #include <yarp/os/PeriodicThread.h>
33 #include <yarp/os/Vocab.h>
34 #include <yarp/os/Bottle.h>
35 #include <yarp/os/Stamp.h>
36 #include <yarp/os/Log.h>
37 
59 {
60 private:
61  yarp::dev::PolyDriver m_driver;
62  yarp::dev::IAudioGrabberSound* m_mic; //The microphone device
63  double m_period;
64  yarp::os::Port m_rpcPort;
65  yarp::os::Port m_streamingPort;
66  yarp::os::Stamp m_stamp;
67  size_t m_min_number_of_samples_over_network;
68  size_t m_max_number_of_samples_over_network;
69  double m_getSound_timeout;
70  bool m_isDeviceOwned;
71 public:
80 
81  ~AudioRecorderWrapper() override;
82 
83  bool open(yarp::os::Searchable& config) override;
84  bool close() override;
85  bool attachAll(const yarp::dev::PolyDriverList &p) override;
86  bool detachAll() override;
87 
89  void detach();
90 
91  bool threadInit() override;
92  void threadRelease() override;
93  void run() override;
94 
95  bool read(yarp::os::ConnectionReader& connection) override;
96 };
97 
98 #endif // YARP_DEV_AUDIORECORDERWRAPPER_H
AudioRecorderWrapper::read
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: AudioRecorderWrapper.cpp:237
Network.h
yarp::os::Searchable
A base class for nested structures that can be searched.
Definition: Searchable.h:69
yarp::dev::DeviceDriver
Interface implemented by all device drivers.
Definition: DeviceDriver.h:38
AudioRecorderWrapper::attachAll
bool attachAll(const yarp::dev::PolyDriverList &p) override
Attach to a list of objects.
Definition: AudioRecorderWrapper.cpp:281
AudioGrabberInterfaces.h
AudioRecorderWrapper::close
bool close() override
Close the DeviceDriver.
Definition: AudioRecorderWrapper.cpp:144
yarp::dev::PolyDriverList
Definition: PolyDriverList.h:22
ControlBoardInterfaces.h
define control board standard interfaces
AudioRecorderWrapper::detachAll
bool detachAll() override
Detach the object (you must have first called attach).
Definition: AudioRecorderWrapper.cpp:307
yarp::os::Port
A mini-server for network communication.
Definition: Port.h:50
Log.h
AudioRecorderWrapper::AudioRecorderWrapper
AudioRecorderWrapper(const AudioRecorderWrapper &)=delete
yarp::dev::IAudioGrabberSound
Read a YARP-format sound block from a device.
Definition: IAudioGrabberSound.h:26
yarp::os::PortReader
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition: PortReader.h:28
AudioRecorderWrapper::attach
void attach(yarp::dev::IAudioGrabberSound *igrab)
Definition: AudioRecorderWrapper.cpp:317
PolyDriver.h
Stamp.h
yarp::dev::PolyDriver
A container for a device driver.
Definition: PolyDriver.h:27
AudioRecorderWrapper::threadInit
bool threadInit() override
Initialization method.
Definition: AudioRecorderWrapper.cpp:331
AudioRecorderWrapper::~AudioRecorderWrapper
~AudioRecorderWrapper() override
Definition: AudioRecorderWrapper.cpp:52
BufferedPort.h
IMultipleWrapper.h
AudioRecorderWrapper::detach
void detach()
Definition: AudioRecorderWrapper.cpp:322
yarp::os::PeriodicThread
An abstraction for a periodic thread.
Definition: PeriodicThread.h:25
PeriodicThread.h
yarp::os::ConnectionReader
An interface for reading from a network connection.
Definition: ConnectionReader.h:40
yarp::os::Stamp
An abstraction for a time stamp and/or sequence number.
Definition: Stamp.h:25
AudioRecorderWrapper::open
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
Definition: AudioRecorderWrapper.cpp:60
yarp::dev::IMultipleWrapper
Interface for an object that can wrap/attach to to another.
Definition: IMultipleWrapper.h:30
AudioRecorderWrapper
AudioRecorderWrapper: A Wrapper which streams audio over the network, after grabbing it from a device
Definition: AudioRecorderWrapper.h:59
AudioRecorderWrapper::run
void run() override
Loop function.
Definition: AudioRecorderWrapper.cpp:162
Vocab.h
AudioRecorderWrapper::threadRelease
void threadRelease() override
Release method.
Definition: AudioRecorderWrapper.cpp:336
Time.h
AudioRecorderWrapper::operator=
AudioRecorderWrapper & operator=(AudioRecorderWrapper &&)=delete
AudioRecorderWrapper::AudioRecorderWrapper
AudioRecorderWrapper()
Constructor.
Definition: AudioRecorderWrapper.cpp:37
AudioRecorderWrapper::operator=
AudioRecorderWrapper & operator=(const AudioRecorderWrapper &)=delete
Bottle.h
AudioRecorderWrapper::AudioRecorderWrapper
AudioRecorderWrapper(AudioRecorderWrapper &&)=delete