--- /dev/null
+// Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "tvchannel/criteria_filter.h"
+#include <common/logger.h>
+
+namespace extension {
+namespace tvchannel {
+
+CriteriaFilter::CriteriaFilter(EServiceMode _mode) :
+ m_mode(_mode) {
+}
+
+void CriteriaFilter::filterWhere(int32_t columnName,
+ const int32_t columnValue) {
+ if (m_mode == SERVICE_MODE_ATSC && columnName == ORIGINAL_NETWORK_ID) {
+ LOGD("ORIGINAL_NETWORK_ID not supported");
+ return;
+ }
+ if ((m_mode == SERVICE_MODE_DVB || m_mode == SERVICE_MODE_DVBNT)
+ && (columnName == MINOR || columnName == SOURCE_ID)) {
+ LOGD("%d not supported", columnName);
+ return;
+ }
+ if (m_mode == SERVICE_MODE_ISDB && columnName == SOURCE_ID) {
+ LOGD("SOURCE_ID not supported");
+ return;
+ }
+
+ columnMap[columnName] = columnValue;
+}
+
+void CriteriaFilter::getFilteredCriteria(std::unique_ptr < TCCriteriaHelper > & _pCriteria) {
+ for (auto it = columnMap.begin(); it != columnMap.end(); ++it) {
+ _pCriteria->Where(it->first, it->second);
+ }
+}
+
+void CriteriaFilter::resetFilter() {
+ columnMap.clear();
+}
+
+} // namespace tvchannel
+} // namespace extension
--- /dev/null
+// Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SRC_TVCHANNEL_CRITERIA_FILTER_H_
+#define SRC_TVCHANNEL_CRITERIA_FILTER_H_
+
+#include <ServiceNavigationDataType.h>
+#include <CriteriaHelper.h>
+#include <stdint.h>
+#include <map>
+#include <memory>
+
+namespace extension {
+namespace tvchannel {
+
+class CriteriaFilter {
+ public:
+ explicit CriteriaFilter(EServiceMode mode);
+ void filterWhere(int32_t columnName, const int32_t columnValue);
+ void getFilteredCriteria(std::unique_ptr < TCCriteriaHelper > & _pCriteria);
+ void resetFilter();
+ private:
+ EServiceMode m_mode;
+ std::map<int32_t, int32_t> columnMap;
+};
+
+} // namespace tvchannel
+} // namespace extension
+
+#endif // SRC_TVCHANNEL_CRITERIA_FILTER_H_
#include "common/logger.h"
#include "common/task-queue.h"
#include <NavigationModeHelper.h>
+#include "tvchannel/criteria_filter.h"
namespace extension {
namespace tvchannel {
pCriteria->Fetch(CHANNEL_TYPE);
pCriteria->Fetch(CHANNEL_NUMBER);
+ CriteriaFilter filter = CriteriaFilter(tvMode.serviceMode);
+
if (tuneOption.isMajorSet()) {
LOGD("MAJOR: %d", tuneOption.getMajor());
- pCriteria->Where(MAJOR, static_cast<int>(tuneOption.getMajor()));
+ filter.filterWhere(MAJOR, static_cast<int>(tuneOption.getMajor()));
}
if (tuneOption.isMinorSet()) {
LOGD("MINOR: %d", tuneOption.getMinor());
- pCriteria->Where(MINOR, static_cast<int>(tuneOption.getMinor()));
+ filter.filterWhere(MINOR, static_cast<int>(tuneOption.getMinor()));
}
if (tuneOption.isPtcSet()) {
LOGD("PTC: %d", tuneOption.getPtc());
- pCriteria->Where(CHANNEL_NUMBER,
+ filter.filterWhere(CHANNEL_NUMBER,
static_cast<int>(tuneOption.getPtc()));
}
if (tuneOption.isOriginalNetworkIDSet()) {
LOGD("ORIGINAL_NETWORK_ID: %d", tuneOption.getOriginalNetworkID());
- pCriteria->Where(ORIGINAL_NETWORK_ID,
+ filter.filterWhere(ORIGINAL_NETWORK_ID,
static_cast<int>(tuneOption.getOriginalNetworkID()));
}
if (tuneOption.isProgramNumberSet()) {
LOGD("PROGRAM_NUMBER: %d", tuneOption.getProgramNumber());
- pCriteria->Where(PROGRAM_NUMBER,
+ filter.filterWhere(PROGRAM_NUMBER,
static_cast<int>(tuneOption.getProgramNumber()));
}
if (tuneOption.isSourceIDSet()) {
LOGD("SOURCE_ID: %d", tuneOption.getSourceID());
- pCriteria->Where(SOURCE_ID,
+ filter.filterWhere(SOURCE_ID,
static_cast<int>(tuneOption.getSourceID()));
}
if (tuneOption.isTransportStreamIDSet()) {
LOGD("TRANSPORT_STREAM_ID: %d", tuneOption.getTransportStreamID());
- pCriteria->Where(TRANSPORT_STREAM_ID,
+ filter.filterWhere(TRANSPORT_STREAM_ID,
static_cast<int>(tuneOption.getTransportStreamID()));
}
+ filter.getFilteredCriteria(pCriteria);
+
TCServiceData foundService;
int ret = getService()->FindService(*pCriteria, foundService);
if (TV_SERVICE_API_METHOD_SUCCESS != ret) {
criteria->Fetch(TRANSPORT_STREAM_ID);
criteria->Fetch(ORIGINAL_NETWORK_ID);
criteria->Fetch(LCN);
- criteria->Where(MAJOR, static_cast<int>(data->major));
- criteria->Where(MINOR, static_cast<int>(data->minor));
+
+ CriteriaFilter filter = CriteriaFilter(
+ getTvMode(navigation).serviceMode);
+ filter.filterWhere(MAJOR, static_cast<int>(data->major));
+ filter.filterWhere(MINOR, static_cast<int>(data->minor));
+ filter.getFilteredCriteria(criteria);
std::list<TCServiceData*> resultServices;
int ret = m_pService->FindServiceList(*criteria, resultServices);