}
TVChannelInstance::~TVChannelInstance() {
- LOGD("Entered");
+ LoggerD("Entered");
}
void TVChannelInstance::tune(picojson::value const& args,
picojson::object& out) {
- LOGD("Enter");
+ LoggerD("Enter");
picojson::object tuneOption =
args.get("tuneOption").get<picojson::object>();
double callbackId = args.get("callbackId").get<double>();
windowType = "MAIN";
}
- LOGD("CallbackID %f", callbackId);
+ LoggerD("CallbackID %f", callbackId);
std::shared_ptr<TVChannelManager::TuneData> pTuneData(
new TVChannelManager::TuneData(TuneOption(tuneOption),
stringToWindowType(windowType), callbackId));
void TVChannelInstance::tuneTaskAfter(
std::shared_ptr<TVChannelManager::TuneData> const& _tuneData) {
- LOGD("Enter");
+ LoggerD("Enter");
if (_tuneData->pError) {
picojson::value event = picojson::value(picojson::object());
picojson::object& obj = event.get<picojson::object>();
void TVChannelInstance::tuneTask(
std::shared_ptr<TVChannelManager::TuneData> const& _tuneData) {
- LOGD("Enter");
+ LoggerD("Enter");
TVChannelManager::getInstance()->tune(_tuneData);
}
void TVChannelInstance::tuneUp(picojson::value const& args,
picojson::object& out) {
- LOGD("Enter");
+ LoggerD("Enter");
NavigatorMode navMode;
if (args.contains("tuneMode")) {
windowType = "MAIN";
}
- LOGD("CallbackID %f", callbackId);
+ LoggerD("CallbackID %f", callbackId);
std::shared_ptr<TVChannelManager::TuneData> pTuneData(
new TVChannelManager::TuneData(navMode,
stringToWindowType(windowType), callbackId));
void TVChannelInstance::tuneDown(picojson::value const& args,
picojson::object& out) {
- LOGD("Enter");
+ LoggerD("Enter");
NavigatorMode navMode;
if (args.contains("tuneMode")) {
windowType = "MAIN";
}
- LOGD("CallbackID %f", callbackId);
+ LoggerD("CallbackID %f", callbackId);
std::shared_ptr<TVChannelManager::TuneData> pTuneData(
new TVChannelManager::TuneData(navMode,
stringToWindowType(windowType), callbackId));
}
void TVChannelInstance::onChannelChange(double callbackId) {
- LOGD("Enter");
+ LoggerD("Enter");
try {
WindowType windowType = stringToWindowType("MAIN");
PostMessage(resultCallback.serialize().c_str());
}
} catch (common::PlatformException& e) {
- LOGW("Failed to post message: %s", e.message().c_str());
+ LoggerW("Failed to post message: %s", e.message().c_str());
} catch (...) {
- LOGW("Failed to post message, unknown error");
+ LoggerW("Failed to post message, unknown error");
}
}
picojson::value result(dict);
PostMessage(result.serialize().c_str());
} catch (common::PlatformException& e) {
- LOGW("Failed to post message: %s", e.message().c_str());
+ LoggerW("Failed to post message: %s", e.message().c_str());
} catch (...) {
- LOGW("Failed to post message, unknown error");
+ LoggerW("Failed to post message, unknown error");
}
}
void TVChannelInstance::onNoSignal(double callbackId) {
picojson::value result(dict);
PostMessage(result.serialize().c_str());
} catch (common::PlatformException& e) {
- LOGW("Failed to post message: %s", e.message().c_str());
+ LoggerW("Failed to post message: %s", e.message().c_str());
} catch (...) {
- LOGW("Failed to post message, unknown error");
+ LoggerW("Failed to post message, unknown error");
}
}
void TVChannelInstance::findChannel(const picojson::value& args,
picojson::object& out) {
- LOGD("Enter");
+ LoggerD("Enter");
std::function<void(std::shared_ptr<TVChannelManager::FindChannelData>)>
asyncWork = std::bind(
&TVChannelManager::findChannel,
void TVChannelInstance::findChannelResult(
const std::shared_ptr<TVChannelManager::FindChannelData>& data) {
- LOGD("Enter");
+ LoggerD("Enter");
picojson::value::object dict;
dict["callbackId"] = picojson::value(data->callbackId);
if (data->error) {
void TVChannelInstance::getChannelList(const picojson::value& args,
picojson::object& out) {
- LOGD("Enter");
+ LoggerD("Enter");
std::function<void(std::shared_ptr<TVChannelManager::GetChannelListData>)>
asyncWork = std::bind(
&TVChannelManager::getChannelList,
void TVChannelInstance::getProgramList(
const picojson::value& args, picojson::object& out) {
- LOGD("Enter");
+ LoggerD("Enter");
std::function<void(std::shared_ptr<TVChannelManager::GetProgramListData>)>
asyncWork = std::bind(
&TVChannelManager::getProgramList,
TVChannelManager::TVChannelManager() :
m_listener(NULL) {
- LOGD("Enter");
+ LoggerD("Enter");
int ret = TVServiceAPI::CreateService(&m_pService);
if (TV_SERVICE_API_SUCCESS != ret) {
- LOGE("Failed to create tvs-api service: %d", ret);
+ LoggerE("Failed to create tvs-api service: %d", ret);
throw common::UnknownException("Failed to create tvs-api service");
}
}
}
void TVChannelManager::tune(std::shared_ptr<TuneData> const& _pTuneData) {
- LOGD("Enter");
+ LoggerD("Enter");
try {
std::unique_lock<std::mutex> lock(tuneMutex);
CriteriaFilter filter = CriteriaFilter(tvMode.serviceMode);
if (tuneOption.isMajorSet()) {
- LOGD("MAJOR: %d", tuneOption.getMajor());
+ LoggerD("MAJOR: %d", tuneOption.getMajor());
filter.filterWhere(MAJOR, static_cast<int>(tuneOption.getMajor()));
}
if (tuneOption.isMinorSet()) {
- LOGD("MINOR: %d", tuneOption.getMinor());
+ LoggerD("MINOR: %d", tuneOption.getMinor());
filter.filterWhere(MINOR, static_cast<int>(tuneOption.getMinor()));
}
if (tuneOption.isPtcSet()) {
- LOGD("PTC: %d", tuneOption.getPtc());
+ LoggerD("PTC: %d", tuneOption.getPtc());
filter.filterWhere(CHANNEL_NUMBER,
static_cast<int>(tuneOption.getPtc()));
}
if (tuneOption.isOriginalNetworkIDSet()) {
- LOGD("ORIGINAL_NETWORK_ID: %d", tuneOption.getOriginalNetworkID());
+ LoggerD("ORIGINAL_NETWORK_ID: %d", tuneOption.getOriginalNetworkID());
filter.filterWhere(ORIGINAL_NETWORK_ID,
static_cast<int>(tuneOption.getOriginalNetworkID()));
}
if (tuneOption.isProgramNumberSet()) {
- LOGD("PROGRAM_NUMBER: %d", tuneOption.getProgramNumber());
+ LoggerD("PROGRAM_NUMBER: %d", tuneOption.getProgramNumber());
filter.filterWhere(PROGRAM_NUMBER,
static_cast<int>(tuneOption.getProgramNumber()));
}
if (tuneOption.isSourceIDSet()) {
- LOGD("SOURCE_ID: %d", tuneOption.getSourceID());
+ LoggerD("SOURCE_ID: %d", tuneOption.getSourceID());
filter.filterWhere(SOURCE_ID,
static_cast<int>(tuneOption.getSourceID()));
}
if (tuneOption.isTransportStreamIDSet()) {
- LOGD("TRANSPORT_STREAM_ID: %d", tuneOption.getTransportStreamID());
+ LoggerD("TRANSPORT_STREAM_ID: %d", tuneOption.getTransportStreamID());
filter.filterWhere(TRANSPORT_STREAM_ID,
static_cast<int>(tuneOption.getTransportStreamID()));
}
TCServiceData foundService;
int ret = getService()->FindService(*pCriteria, foundService);
if (TV_SERVICE_API_METHOD_SUCCESS != ret) {
- LOGE("Failed to find channel: %d", ret);
+ LoggerE("Failed to find channel: %d", ret);
throw common::NotFoundException("Failed to find channel");
}
ret = getNavigation(getProfile(windowType), 0)->SetService(serviceId);
if (TV_SERVICE_API_METHOD_SUCCESS != ret) {
- LOGE("Failed to set selected channel: %d", ret);
+ LoggerE("Failed to set selected channel: %d", ret);
throw common::UnknownException(
"Failed to set selected channel");
}
} catch (common::PlatformException const& _error) {
_pTuneData->pError.reset(
new common::PlatformException(_error.name(), _error.message()));
- LOGE("Some exception caught");
+ LoggerE("Some exception caught");
}
}
}
void TVChannelManager::tuneUp(std::shared_ptr<TuneData> const& _pTuneData) {
- LOGD("Enter");
+ LoggerD("Enter");
try {
std::unique_lock<std::mutex> lock(tuneMutex);
currentServiceId,
previousService);
if (TV_SERVICE_API_METHOD_SUCCESS != ret) {
- LOGE("Failed to find previous channel: %d", ret);
+ LoggerE("Failed to find previous channel: %d", ret);
throw common::NotFoundException("Failed to find previous channel");
}
TCServiceId serviceId = previousService.Get<TCServiceId>(SERVICE_ID);
// if GetNextService's result is same with current service id,
// it means failure to find previous channel.
if (currentServiceId == serviceId) {
- LOGE("Failed to find previous channel: %d", ret);
+ LoggerE("Failed to find previous channel: %d", ret);
throw common::NotFoundException("Failed to find next channel");
}
ret = getNavigation(getProfile(windowType), 0)->SetService(serviceId);
if (TV_SERVICE_API_METHOD_SUCCESS != ret) {
- LOGE("Failed to set selected channel: %d", ret);
+ LoggerE("Failed to set selected channel: %d", ret);
throw common::UnknownException(
"Failed to set selected channel");
}
} catch (common::PlatformException const& _error) {
_pTuneData->pError.reset(
new common::PlatformException(_error.name(), _error.message()));
- LOGE("Some exception caught");
+ LoggerE("Some exception caught");
}
}
void TVChannelManager::tuneDown(std::shared_ptr<TuneData> const& _pTuneData) {
- LOGD("Enter");
+ LoggerD("Enter");
try {
std::unique_lock<std::mutex> lock(tuneMutex);
currentServiceId,
nextService);
if (TV_SERVICE_API_METHOD_SUCCESS != ret) {
- LOGE("Failed to find previous channel: %d", ret);
+ LoggerE("Failed to find previous channel: %d", ret);
throw common::NotFoundException("Failed to find previous channel");
}
TCServiceId serviceId = nextService.Get<TCServiceId>(SERVICE_ID);
// if GetNextService's result is same with current service id,
// it means failure to find previous channel.
if (currentServiceId == serviceId) {
- LOGE("Failed to find previous channel: %d", ret);
+ LoggerE("Failed to find previous channel: %d", ret);
throw common::NotFoundException("Failed to find previous channel");
}
ret = getNavigation(getProfile(windowType), 0)->SetService(serviceId);
if (TV_SERVICE_API_METHOD_SUCCESS != ret) {
- LOGE("Failed to set selected channel: %d", ret);
+ LoggerE("Failed to set selected channel: %d", ret);
throw common::UnknownException(
"Failed to set selected channel");
}
} catch (common::PlatformException const& _error) {
_pTuneData->pError.reset(
new common::PlatformException(_error.name(), _error.message()));
- LOGE("Some exception caught");
+ LoggerE("Some exception caught");
}
}
IServiceNavigation* TVChannelManager::getNavigation(EProfile profileId,
u_int16_t screenId) {
- LOGD("Enter");
+ LoggerD("Enter");
IServiceNavigation* navigation;
int ret = TVServiceAPI::CreateServiceNavigation(profileId, screenId,
&navigation);
if (TV_SERVICE_API_SUCCESS != ret) {
- LOGE("Failed to create service navigation: %d", ret);
+ LoggerE("Failed to create service navigation: %d", ret);
throw common::UnknownException("Failed to create service navigation");
}
return navigation;
}
TSTvMode TVChannelManager::getTvMode(IServiceNavigation* pNavigation) {
- LOGD("Enter");
+ LoggerD("Enter");
TSTvMode tvMode;
int ret = pNavigation->GetTvMode(tvMode);
if (TV_SERVICE_API_METHOD_SUCCESS != ret) {
- LOGE("Failed to get current tv mode: %d", ret);
+ LoggerE("Failed to get current tv mode: %d", ret);
throw common::UnknownException("Failed to get current tv mode");
}
- LOGD("tvMode : antenna - %d, service - %d", tvMode.antennaMode,
+ LoggerD("tvMode : antenna - %d, service - %d", tvMode.antennaMode,
tvMode.serviceMode);
return tvMode;
}
std::unique_ptr<TCCriteriaHelper> TVChannelManager::getBasicCriteria(
TSTvMode tvMode, ENavigationMode naviMode) {
- LOGD("Enter");
+ LoggerD("Enter");
std::unique_ptr < TCCriteriaHelper > pCriteria(new TCCriteriaHelper());
bool found = TCNavigationModeHelper::GetNavigationCriteria(tvMode, naviMode,
*pCriteria);
if (!found) {
- LOGE("Failed to create navigation criteria");
+ LoggerE("Failed to create navigation criteria");
throw common::UnknownException("Failed to create navigation criteria");
}
return pCriteria;
TCServiceData TVChannelManager::getCurrentServiceInfo(
IServiceNavigation* _pNavigation, TSTvMode _mode,
std::unique_ptr<TCCriteriaHelper> const& _pCriteria) {
- LOGD("Enter");
+ LoggerD("Enter");
TCServiceData serviceData;
int ret = _pNavigation->GetCurrentServiceInfo(_mode, *_pCriteria,
serviceData);
if (TV_SERVICE_API_METHOD_SUCCESS != ret) {
- LOGE("Failed to get current service info: %d", ret);
+ LoggerE("Failed to get current service info: %d", ret);
throw common::UnknownException("Failed to get current service info");
}
return serviceData;
std::unique_ptr<ChannelInfo> TVChannelManager::getCurrentChannel(
WindowType _windowType) {
- LOGD("Entered %d", _windowType);
+ LoggerD("Entered %d", _windowType);
std::unique_ptr < TCCriteriaHelper > pCriteria(new TCCriteriaHelper());
pCriteria->Fetch(SERVICE_ID);
TCServiceData serviceData = getCurrentServiceInfo(navigation, tvMode,
pCriteria);
- LOGD("Current channel id: %llu",
+ LoggerD("Current channel id: %llu",
serviceData.Get < TCServiceId > (SERVICE_ID));
std::unique_ptr<ChannelInfo> pChannel(new ChannelInfo());
pChannel->fromApiData(serviceData);
}
EProfile TVChannelManager::getProfile(WindowType windowType) {
- LOGD("Enter");
+ LoggerD("Enter");
switch (windowType) {
case MAIN:
return PROFILE_TYPE_MAIN;
// case PIP:
// return PROFILE_TYPE_PIP;
default:
- LOGE("Unsupported window type: %d", windowType);
+ LoggerE("Unsupported window type: %d", windowType);
}
}
TCServiceId TVChannelManager::getCurrentChannelId(WindowType _windowType) {
- LOGD("Enter");
+ LoggerD("Enter");
// Navigation
IServiceNavigation* navigation = getNavigation(getProfile(_windowType),
SCREENID);
}
ProgramInfo* TVChannelManager::getCurrentProgram(WindowType _windowType) {
- LOGD("Enter");
+ LoggerD("Enter");
IServiceGuide* guide;
int ret = TVServiceAPI::CreateServiceGuide(&guide);
if (TV_SERVICE_API_SUCCESS != ret) {
- LOGE("Failed to create service guide: %d", ret);
+ LoggerE("Failed to create service guide: %d", ret);
throw common::UnknownException("Failed to create service guide");
}
ret = guide->GetPresentProgram(getCurrentChannelId(_windowType),
programData);
if (TV_SERVICE_API_METHOD_SUCCESS != ret) {
- LOGE("Failed to get current program: %d", ret);
+ LoggerE("Failed to get current program: %d", ret);
throw common::UnknownException("Failed to get current program");
}
ProgramInfo* program = new ProgramInfo();
ISignalSubscriber* TVChannelManager::createSubscriber(
EventListener* pListener) {
- LOGD("Enter");
+ LoggerD("Enter");
m_listener = pListener;
ISignalSubscriber* pSubscriber;
int ret = TVServiceAPI::CreateSignalSubscriber(signalListener,
&pSubscriber);
if (TV_SERVICE_API_SUCCESS != ret) {
- LOGW("Failed to create tvs-api SignalSubscriber");
+ LoggerW("Failed to create tvs-api SignalSubscriber");
}
return pSubscriber;
}
void TVChannelManager::registerListener(ISignalSubscriber* pSubscriber) {
- LOGD("Enter");
+ LoggerD("Enter");
pSubscriber->Unsubscribe(SIGNAL_TUNE_SUCCESS);
int ret = pSubscriber->Subscribe(SIGNAL_TUNE_SUCCESS);
if (TV_SERVICE_API_METHOD_SUCCESS != ret) {
- LOGW("Failed to add listener: SIGNAL_TUNE_SUCCESS");
+ LoggerW("Failed to add listener: SIGNAL_TUNE_SUCCESS");
}
pSubscriber->Unsubscribe(SIGNAL_TUNER_LOCK_FAIL);
ret = pSubscriber->Subscribe(SIGNAL_TUNER_LOCK_FAIL);
if (TV_SERVICE_API_METHOD_SUCCESS != ret) {
- LOGW("Failed to add listener: SIGNAL_TUNER_LOCK_FAIL");
+ LoggerW("Failed to add listener: SIGNAL_TUNER_LOCK_FAIL");
}
pSubscriber->Unsubscribe(SIGNAL_EPG_COMPLETED);
ret = pSubscriber->Subscribe(SIGNAL_EPG_COMPLETED);
if (TV_SERVICE_API_METHOD_SUCCESS != ret) {
- LOGW("Failed to add listener: SIGNAL_EPG_COMPLETED");
+ LoggerW("Failed to add listener: SIGNAL_EPG_COMPLETED");
}
}
int TVChannelManager::signalListener(ESignalType type, EProfile _profile,
u_int16_t _screenID, TSSignalData data, void*) {
- LOGD("Enter: %d", type);
+ LoggerD("Enter: %d", type);
if (!getInstance()->m_listener) {
- LOGE("Listener is empty, ignoring message");
+ LoggerE("Listener is empty, ignoring message");
return 0;
}
if (it != getInstance()->m_callbackTuneMap.end()) {
callbackID = it->second;
}
- LOGD("CallbackID %f", callbackID);
+ LoggerD("CallbackID %f", callbackID);
switch (type) {
case SIGNAL_TUNE_SUCCESS:
getInstance()->m_listener->onEPGReceived(callbackID);
break;
default:
- LOGW("Unrecognized event type");
+ LoggerW("Unrecognized event type");
}
return 0;
}
cd = iconv_open("UTF-8", "UCS-2BE");
if (cd == (iconv_t) - 1) {
- LOGE("Failed to open iconv");
+ LoggerE("Failed to open iconv");
}
r = iconv(cd, &in, &in_len, &out, &out_len);
if (r == (size_t) - 1) {
- LOGE("Failed convert string to utf8");
+ LoggerE("Failed convert string to utf8");
}
iconv_close(cd);
void TVChannelManager::findChannel(
const std::shared_ptr<FindChannelData>& data) {
- LOGD("Enter");
+ LoggerD("Enter");
try {
IServiceNavigation* navigation =
getNavigation(getProfile(WindowType::MAIN), 0);
std::list<TCServiceData*> resultServices;
int ret = m_pService->FindServiceList(*criteria, resultServices);
if (TV_SERVICE_API_METHOD_FAILURE == ret) {
- LOGE("Failed to find channel: %d", ret);
+ LoggerE("Failed to find channel: %d", ret);
throw common::NotFoundException("Failed to find channel");
}
- LOGD("Found channels: %d", resultServices.size());
+ LoggerD("Found channels: %d", resultServices.size());
auto it = resultServices.begin();
for (; it != resultServices.end(); ++it) {
ChannelInfo *channelInfo = new ChannelInfo();
void TVChannelManager::getChannelList(
const std::shared_ptr<GetChannelListData>& data) {
- LOGD("Enter");
+ LoggerD("Enter");
try {
IServiceNavigation* navigation =
getNavigation(getProfile(WindowType::MAIN), 0);
std::list<TCServiceData*> resultServices;
int ret = m_pService->FindServiceList(*criteria, resultServices);
if (TV_SERVICE_API_METHOD_FAILURE == ret) {
- LOGE("Failed to find channels: %d", ret);
+ LoggerE("Failed to find channels: %d", ret);
throw common::NotFoundException("Failed to find channels");
}
- LOGD("Found channels: %d", resultServices.size());
+ LoggerD("Found channels: %d", resultServices.size());
auto it = resultServices.begin();
for (; it != resultServices.end(); ++it) {
ChannelInfo *channelInfo = new ChannelInfo();
void TVChannelManager::getProgramList(
const std::shared_ptr<GetProgramListData>& data) {
- LOGD("Enter");
+ LoggerD("Enter");
try {
IServiceGuide* guide;
int ret = TVServiceAPI::CreateServiceGuide(&guide);
if (TV_SERVICE_API_SUCCESS != ret) {
- LOGE("Failed to create service guide: %d", ret);
+ LoggerE("Failed to create service guide: %d", ret);
throw common::UnknownException("Failed to create service guide");
}
ret = guide->GetProgramList(data->channelId,
data->startTime, data->duration, programList);
if (TV_SERVICE_API_METHOD_FAILURE == ret) {
- LOGE("Failed to get program list.");
+ LoggerE("Failed to get program list.");
throw common::NotFoundException("Failed to get program list.");
}
- LOGD("Found programs: %d", programList.size());
+ LoggerD("Found programs: %d", programList.size());
auto it = programList.begin();
for (; it != programList.end(); ++it) {