#include "use_engine.h"
#include "log2ui.h"
#include "roomprofile.h"
///
using namespace rtc;


///
Use_Engine::Use_Engine(QWidget *parent) :QWidget(parent) {
	ui.setupUi(this);
	connect(ui.btn_engInit, SIGNAL(clicked(bool)), this, SLOT(engine_init()));
	connect(ui.btn_engUninit, SIGNAL(clicked(bool)), this, SLOT(engine_uninit()));
	connect(ui.btn_scheduleRoom, SIGNAL(clicked(bool)), this, SLOT(scheduleRoom()));
    //connect(ui.btn_getRoomByRoomId, SIGNAL(clicked(bool)), this, SLOT(getRoomByRoomId()));
    //connect(ui.btn_getRoomByAppRoomId, SIGNAL(clicked(bool)), this, SLOT(getRoomByAppRoomId()));
    //connect(ui.btn_getUsersCount, SIGNAL(clicked(bool)), this, SLOT(getUsersCount()));
	connect(ui.btn_cancelRoom, SIGNAL(clicked(bool)), this, SLOT(cancelRoom()));
}
Use_Engine::~Use_Engine() {
	engine_uninit();
}

bool Use_Engine::isWorking() const {
	return IAVDEngine::Instance()->isWorking();
}
void Use_Engine::enableLog() {
	String logfile = GetLogFile().toUtf8().data();
    IAVDEngine::Instance()->setLogParams("verbose realtstamp stats", logfile);
}
///
bool Use_Engine::engine_init() {
	Result ret = IAVDEngine::Instance()->init(this, CRoomProfile::Instance()->GetSiteUrl().toStdString(), CRoomProfile::Instance()->getAppKey().toStdString(), CRoomProfile::Instance()->getSecretKey().toStdString());
	qDebug() << Utf8Str("Engine 开始初始化 ") << OutputWithRet(ret) << Utf8Str(" 服务器：") << CRoomProfile::Instance()->GetSiteUrl();
	return (RT_SUCCEEDED(ret));
}
bool Use_Engine::engine_uninit() {
	Result ret = IAVDEngine::Instance()->uninit();
	qDebug() << Utf8Str("Engine 释放 ") << OutputWithRet(ret);
	return RT_SUCCEEDED(ret);
}
//
bool Use_Engine::scheduleRoom() {

	return false;
}
bool Use_Engine::getRoomByRoomId() {

	return false;
}
bool Use_Engine::getRoomByAppRoomId() {

	return false;
}
bool Use_Engine::getUsersCount() {

	return false;
}
bool Use_Engine::cancelRoom() {

	return false;
}

///
void Use_Engine::onInitResult(Result result) {
	qDebug() << Utf8Str("Engine 初始化 ") << OutputWithRet(result);
}
void Use_Engine::onUninitResult(Result result) {
	qDebug() << Utf8Str("Engine 被释放 ") << OutputWithRet(result);
}
//
void Use_Engine::onGetRoomResult(uint32 callId, Result result, const RoomInfo& room) {

}
void Use_Engine::onFindRoomsResult(uint32 callId, Result result, const RoomInfosType& rooms) {

}
void Use_Engine::onScheduleRoomResult(uint32 callId, Result result, const RoomId& roomId) {

}
void Use_Engine::onCancelRoomResult(uint32 callId, Result result, const RoomId& roomId){

}
void Use_Engine::onGetUsersCountResult(uint32 callId, Result result, uint32 usersCount, const RoomId& roomId) {

}
void Use_Engine::onCallOutgoingDeviceResult(uint32 callId, Result result, const rtc::UserId& userId){

}
void Use_Engine::onStartMixrecord(uint32 callId, Result result){

}
void Use_Engine::onStopMixrecord(uint32 callId, Result result){

}
