| 1 | /********** |
| 2 | This library is free software; you can redistribute it and/or modify it under |
| 3 | the terms of the GNU Lesser General Public License as published by the |
| 4 | Free Software Foundation; either version 3 of the License, or (at your |
| 5 | option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.) |
| 6 | |
| 7 | This library is distributed in the hope that it will be useful, but WITHOUT |
| 8 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 9 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| 10 | more details. |
| 11 | |
| 12 | You should have received a copy of the GNU Lesser General Public License |
| 13 | along with this library; if not, write to the Free Software Foundation, Inc., |
| 14 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 15 | **********/ |
| 16 | // Copyright (c) 1996-2020 Live Networks, Inc. All rights reserved. |
| 17 | // Generic audio input device (such as a microphone, or an input sound card) |
| 18 | // C++ header |
| 19 | |
| 20 | #ifndef _AUDIO_INPUT_DEVICE_HH |
| 21 | #define _AUDIO_INPUT_DEVICE_HH |
| 22 | |
| 23 | #ifndef _FRAMED_SOURCE_HH |
| 24 | #include "FramedSource.hh" |
| 25 | #endif |
| 26 | |
| 27 | class AudioPortNames { |
| 28 | public: |
| 29 | AudioPortNames(); |
| 30 | virtual ~AudioPortNames(); |
| 31 | |
| 32 | unsigned numPorts; |
| 33 | char** portName; |
| 34 | }; |
| 35 | |
| 36 | class AudioInputDevice: public FramedSource { |
| 37 | public: |
| 38 | unsigned char bitsPerSample() const { return fBitsPerSample; } |
| 39 | unsigned char numChannels() const { return fNumChannels; } |
| 40 | unsigned samplingFrequency() const { return fSamplingFrequency; } |
| 41 | |
| 42 | virtual Boolean setInputPort(int portIndex) = 0; |
| 43 | virtual double getAverageLevel() const = 0; |
| 44 | |
| 45 | static AudioInputDevice* |
| 46 | createNew(UsageEnvironment& env, int inputPortNumber, |
| 47 | unsigned char bitsPerSample, unsigned char numChannels, |
| 48 | unsigned samplingFrequency, unsigned granularityInMS = 20); |
| 49 | static AudioPortNames* getPortNames(); |
| 50 | |
| 51 | static char** allowedDeviceNames; |
| 52 | // If this is set to non-NULL, then it's a NULL-terminated array of strings |
| 53 | // of device names that we are allowed to access. |
| 54 | |
| 55 | protected: |
| 56 | AudioInputDevice(UsageEnvironment& env, |
| 57 | unsigned char bitsPerSample, |
| 58 | unsigned char numChannels, |
| 59 | unsigned samplingFrequency, |
| 60 | unsigned granularityInMS); |
| 61 | // we're an abstract base class |
| 62 | |
| 63 | virtual ~AudioInputDevice(); |
| 64 | |
| 65 | protected: |
| 66 | unsigned char fBitsPerSample, fNumChannels; |
| 67 | unsigned fSamplingFrequency; |
| 68 | unsigned fGranularityInMS; |
| 69 | }; |
| 70 | |
| 71 | #endif |
| 72 | |