cmvr-es/cmvr-es/devices/microphone/abstract_microphone.h
xtkuang 428ee328de feat: complete QUIC edge integration
Vendor MsQuic with build and install support, add DeviceManager status to configurable heartbeats, and report only enabled devices.

Add the local QUIC gateway, protocol coverage, real MsQuic E2E tests, process smoke tests, and updated integration documentation.
2026-07-24 12:35:04 +08:00

64 lines
2.1 KiB
C++

//
// Created by xtkuang on 2025/5/8.
//
#ifndef CMVR_ES_ABSTRACT_MICROPHONE_H
#define CMVR_ES_ABSTRACT_MICROPHONE_H
#pragma once
#include <chrono>
#include <cstddef>
#include "devices/abstract_device.h"
#include "cmvr/config/microphone_config/microphone_config.pb.h"
namespace cmvr::device{
class AbstractMicrophone: public AbstractDevice {
public:
AbstractMicrophone() = default;
~AbstractMicrophone() override = default;
DeviceKind kind() const noexcept override { return DeviceKind::Microphone; }
virtual void getState(MicrophoneState &state) {}
DeviceHealthSnapshot healthSnapshot() override {
MicrophoneState state{};
getState(state);
DeviceHealthSnapshot health;
health.error_message = state.error_message;
if (state.is_error) {
health.state = DeviceHealthState::Fault;
} else if (!state.error_message.empty()) {
health.state = DeviceHealthState::Degraded;
} else if (state.is_initialized) {
health.state = DeviceHealthState::Healthy;
}
return health;
}
virtual void startRecording(const std::string& outputFilePath) {}
virtual void stopRecording() {}
virtual void pause() {}
virtual void resume() {}
virtual void setVolume(const int volume) {}
virtual int getVolume() {return 0;}
virtual bool startStreaming() {return true;}
virtual void stopStreaming() {}
virtual void getEncodedFrame(AudioStreamFrameData& frame_data, size_t& index) {}
virtual bool waitEncodedFrame(
AudioStreamFrameData& frame_data,
size_t& index,
std::chrono::milliseconds timeout) {
(void)timeout;
getEncodedFrame(frame_data, index);
return !frame_data.data.empty();
}
virtual bool getLatestEncodedFrame(AudioStreamFrameData& frame_data, size_t& next_index) {
return false;
}
protected:
MicrophoneState state_{};
};
}
#endif //CMVR_ES_ABSTRACT_MICROPHONE_H