cras_util.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef MEDIA_AUDIO_CRAS_CRAS_UTIL_H_
  5. #define MEDIA_AUDIO_CRAS_CRAS_UTIL_H_
  6. #include <cras_client.h>
  7. #include <cstdint>
  8. #include <string>
  9. #include <vector>
  10. #include "media/base/media_export.h"
  11. namespace media {
  12. enum class DeviceType { kInput, kOutput };
  13. struct CrasDevice {
  14. CrasDevice();
  15. explicit CrasDevice(struct libcras_node_info* node, DeviceType type);
  16. DeviceType type;
  17. uint64_t id;
  18. uint32_t dev_idx;
  19. uint32_t max_supported_channels;
  20. bool plugged;
  21. bool active;
  22. std::string node_type;
  23. std::string name;
  24. std::string dev_name;
  25. };
  26. class MEDIA_EXPORT CrasUtil {
  27. public:
  28. CrasUtil();
  29. virtual ~CrasUtil();
  30. // Enumerates all devices of |type|.
  31. virtual std::vector<CrasDevice> CrasGetAudioDevices(DeviceType type);
  32. // Returns if system AEC is supported in CRAS.
  33. virtual int CrasGetAecSupported();
  34. // Returns the system AEC group ID. If no group ID is specified, -1 is
  35. // returned.
  36. virtual int CrasGetAecGroupId();
  37. // Returns the default output buffer size.
  38. virtual int CrasGetDefaultOutputBufferSize();
  39. };
  40. } // namespace media
  41. #endif // MEDIA_AUDIO_CRAS_CRAS_UTIL_H_