AudioInputDevice.hh 2.3 KB

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