[TV][Channel] Modification for different TV standards.
authorLukasz Foniok <l.foniok@samsung.com>
Thu, 29 Jan 2015 13:16:36 +0000 (14:16 +0100)
committerPawel Andruszkiewicz <p.andruszkie@samsung.com>
Mon, 2 Feb 2015 13:09:37 +0000 (22:09 +0900)
[Verification] Tune feature should work regardles of which tv standard is used.

Change-Id: Ia142ab700ae98af12b74205c15d82ab3a54b4410
Signed-off-by: Lukasz Foniok <l.foniok@samsung.com>
src/tvchannel/criteria_filter.cc [new file with mode: 0644]
src/tvchannel/criteria_filter.h [new file with mode: 0644]
src/tvchannel/tvchannel.gyp
src/tvchannel/tvchannel_manager.cc

diff --git a/src/tvchannel/criteria_filter.cc b/src/tvchannel/criteria_filter.cc
new file mode 100644 (file)
index 0000000..eb2d2b6
--- /dev/null
@@ -0,0 +1,45 @@
+// 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
diff --git a/src/tvchannel/criteria_filter.h b/src/tvchannel/criteria_filter.h
new file mode 100644 (file)
index 0000000..3331995
--- /dev/null
@@ -0,0 +1,31 @@
+// 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_
index fe641bc..ddc2af3 100644 (file)
@@ -43,7 +43,9 @@
         'types.h',
         'types.cc',
         'tune_option.h',
-        'tune_option.cc'
+        'tune_option.cc',
+        'criteria_filter.h',
+        'criteria_filter.cc'
       ],
     },
   ],
index 5ac90bb..9bcd8a6 100644 (file)
@@ -12,6 +12,7 @@
 #include "common/logger.h"
 #include "common/task-queue.h"
 #include <NavigationModeHelper.h>
+#include "tvchannel/criteria_filter.h"
 
 namespace extension {
 namespace tvchannel {
@@ -56,40 +57,44 @@ void TVChannelManager::tune(std::shared_ptr<TuneData> const& _pTuneData) {
         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) {
@@ -455,8 +460,12 @@ void TVChannelManager::findChannel(
         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);