YARP
Yet Another Robot Platform
AudioRecorderWrapper.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-License-Identifier: LGPL-2.1-or-later
4  */
5 
6 #ifndef YARP_DEV_AUDIORECORDERWRAPPER_H
7 #define YARP_DEV_AUDIORECORDERWRAPPER_H
8 
9 #include <cstdio>
10 
11 
12 #include <yarp/os/BufferedPort.h>
13 #include <yarp/dev/PolyDriver.h>
17 #include <yarp/os/Time.h>
18 #include <yarp/os/Network.h>
19 #include <yarp/os/PeriodicThread.h>
20 #include <yarp/os/Vocab.h>
21 #include <yarp/os/Bottle.h>
22 #include <yarp/os/Stamp.h>
23 #include <yarp/os/Log.h>
24 
27 
50 {
51 private:
52  yarp::dev::PolyDriver m_driver;
53  yarp::dev::IAudioGrabberSound* m_mic = nullptr; //The microphone device
54  double m_period;
55  yarp::os::Port m_rpcPort;
56  yarp::os::Port m_streamingPort;
57  yarp::os::Port m_statusPort;
58  yarp::os::Stamp m_stamp;
59  size_t m_min_number_of_samples_over_network;
60  size_t m_max_number_of_samples_over_network;
61  yarp::dev::AudioBufferSize m_current_buffer_size;
62  yarp::dev::AudioBufferSize m_max_buffer_size;
63  double m_getSound_timeout;
64  bool m_isDeviceOwned =false;
65  bool m_isRecording=false;
66  AudioRecorderStatusThread* m_statusThread = nullptr;
67  AudioRecorderDataThread* m_dataThread =nullptr;
68  bool m_debug_enabled = false;
69 
70 private:
71  double m_debug_last_time=0;
72 
73 public:
82 
83  ~AudioRecorderWrapper() override;
84 
85  bool open(yarp::os::Searchable& config) override;
86  bool close() override;
87  bool attachAll(const yarp::dev::PolyDriverList &p) override;
88  bool detachAll() override;
89 
91  void detach();
92 
93  bool read(yarp::os::ConnectionReader& connection) override;
96 };
97 
98 //----------------------------------------------------------------
100 {
101 public:
103 
104 public:
106 
107  bool threadInit() override { return true; }
108  void threadRelease() override { return; }
109  void run() override;
110 };
111 
112 //----------------------------------------------------------------
114 {
115 public:
117 
118 public:
120 
121  bool threadInit() override { return true; }
122  void threadRelease() override { return; }
123  void run() override;
124 };
125 
126 #endif // YARP_DEV_AUDIORECORDERWRAPPER_H
define control board standard interfaces
void run() override
Loop function.
void threadRelease() override
Release method.
AudioRecorderWrapper * m_ARW
bool threadInit() override
Initialization method.
AudioRecorderDataThread(AudioRecorderWrapper *mi)
AudioRecorderStatusThread(AudioRecorderWrapper *mi)
bool threadInit() override
Initialization method.
void threadRelease() override
Release method.
AudioRecorderWrapper * m_ARW
void run() override
Loop function.
AudioRecorderWrapper: A Wrapper which streams audio over the network, after grabbing it from a device
bool detachAll() override
Detach the object (you must have first called attach).
AudioRecorderWrapper()
Constructor.
AudioRecorderWrapper(const AudioRecorderWrapper &)=delete
AudioRecorderWrapper & operator=(const AudioRecorderWrapper &)=delete
bool close() override
Close the DeviceDriver.
AudioRecorderWrapper & operator=(AudioRecorderWrapper &&)=delete
bool attachAll(const yarp::dev::PolyDriverList &p) override
Attach to a list of objects.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
void attach(yarp::dev::IAudioGrabberSound *igrab)
AudioRecorderWrapper(AudioRecorderWrapper &&)=delete
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Interface implemented by all device drivers.
Definition: DeviceDriver.h:35
Read a YARP-format sound block from a device.
Interface for an object that can wrap/attach to to another.
A container for a device driver.
Definition: PolyDriver.h:24
An interface for reading from a network connection.
An abstraction for a periodic thread.
PeriodicThread(double period, ShouldUseSystemClock useSystemClock=ShouldUseSystemClock::No, PeriodicThreadClock clockAccuracy=PeriodicThreadClock::Relative)
Constructor.
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition: PortReader.h:25
A mini-server for network communication.
Definition: Port.h:47
A base class for nested structures that can be searched.
Definition: Searchable.h:66
An abstraction for a time stamp and/or sequence number.
Definition: Stamp.h:22