#ifndef __COM_Audio_H__
#define __COM_Audio_H__
#include "ui_use_audio.h"
#include "api/maudio.h"

class Com_Audio :public QWidget
	, public rtc::IMAudio::IListener
{
public:
	Q_OBJECT
public:
	Com_Audio(QWidget *parent = 0);
	~Com_Audio();
public:
	void onAttach();
	void onDetach();
protected:
	virtual void updateLocalMicrophones();
	virtual void updateLocalSpeakers();
	void updateRemotePublishedMicrophones();
	void fillCodecs();
	QString getCurrentCodec();
    rtc::DeviceId getSelectedDeviceId(QListWidget* listw);
	void resetControls(bool enable);
public slots:
	bool on_opencloseMicrophone(bool open);
	bool on_muteMicrophone(bool mute);
	bool on_muteSpeaker(bool mute);
	bool on_monitorAudioLevel(bool enable);
    void localMicrophones_itemChanged();
    void localSpeakers_itemChanged();
	void on_applyPlayoutGain(bool);
	//
	void audio_aec_stateChanged(int);
	void audio_dae_stateChanged(int);
	void audio_agc_stateChanged(int);
	void audio_hpf_stateChanged(int);
	void audio_ns_stateChanged(int);

protected: // c or cpp api imp
	virtual bool   isAttach() const = 0;
	virtual bool   api_engineSetOption(rtc::EngineOption option, void* value) = 0;
	virtual bool   api_roomSetOption(rtc::RoomOption option, std::string& value) = 0;
	virtual Result api_openMicrophone(bool open) = 0;
	virtual Result api_muteMicrophone(bool mute) = 0;
	virtual Result api_muteSpeaker(bool mute) = 0;
	virtual Result api_monitorAudioLevel(bool enable) = 0;
    virtual Result api_setRecordingMicrophone(const rtc::DeviceId& curId) = 0;
    virtual Result api_setPlayoutSpeaker(const rtc::DeviceId& curId) = 0;
	virtual Result api_applyPlayoutGain(float gain) = 0;
public:
	/// IAudio::IListener implementation
    virtual void onMicrophoneStatusNotify(rtc::MicrophoneStatus status, const rtc::UserId& fromUserId);
	virtual void onAudioLevelMonitorNotify(const rtc::AudioInfo& info);
	virtual void onOpenMicrophoneResult(Result result);
	virtual void onCloseMicrophoneResult(Result result);

protected:
	Ui::Use_Audio ui;
};

#endif //__COM_Audio_H__
