blob: a39f56ce9ea4a9be2bd3da227e0bc5c52f6b7abb
1 | // |
2 | // |
3 | // amlogic 2013 |
4 | // |
5 | // @ Project : tv |
6 | // @ File Name : CTvRegion.cpp |
7 | // @ Date : 2013-11 |
8 | // @ Author : |
9 | // |
10 | // |
11 | #define LOG_TAG "CTvRegion" |
12 | |
13 | #include "CTvRegion.h" |
14 | #include "CTvDatabase.h" |
15 | |
16 | CTvRegion::CTvRegion(CTvDatabase db __unused) |
17 | { |
18 | } |
19 | |
20 | CTvRegion::CTvRegion() |
21 | { |
22 | } |
23 | |
24 | CTvRegion::~CTvRegion() |
25 | { |
26 | } |
27 | |
28 | CTvRegion CTvRegion::selectByID() |
29 | { |
30 | CTvRegion r; |
31 | return r; |
32 | } |
33 | |
34 | int CTvRegion::getChannelListByName(char *name, Vector<sp<CTvChannel> > &vcp) |
35 | { |
36 | if (name == NULL) |
37 | return -1; |
38 | |
39 | String8 cmd; |
40 | cmd = String8("select * from region_table where name = ") + String8("\'") + name + String8("\'"); |
41 | |
42 | CTvDatabase::Cursor c; |
43 | CTvDatabase::GetTvDb()->select(cmd, c); |
44 | int col, size = 0; |
45 | int id; |
46 | int mode; |
47 | int frequency = 0; |
48 | int bandwidth; |
49 | int modulation; |
50 | int symbolRate; |
51 | int ofdmMode; |
52 | int channelNum = 0; |
53 | |
54 | if (c.moveToFirst()) { |
55 | do { |
56 | col = c.getColumnIndex("db_id"); |
57 | id = c.getInt(col); |
58 | col = c.getColumnIndex("fe_type"); |
59 | mode = c.getInt(col); |
60 | col = c.getColumnIndex("frequency"); |
61 | frequency = c.getInt(col); |
62 | col = c.getColumnIndex("modulation"); |
63 | modulation = c.getInt(col); |
64 | col = c.getColumnIndex("bandwidth"); |
65 | bandwidth = c.getInt(col); |
66 | col = c.getColumnIndex("symbol_rate"); |
67 | symbolRate = c.getInt(col); |
68 | col = c.getColumnIndex("ofdm_mode"); |
69 | ofdmMode = c.getInt(col); |
70 | col = c.getColumnIndex("logical_channel_num"); |
71 | channelNum = c.getInt(col); |
72 | vcp.add(new CTvChannel(id, mode, frequency, bandwidth, modulation, symbolRate, ofdmMode, channelNum)); |
73 | size++; |
74 | } while (c.moveToNext()); |
75 | } |
76 | c.close(); |
77 | |
78 | return size; |
79 | } |
80 | |
81 | int CTvRegion::getChannelListByNameAndFreqRange(char *name, int beginFreq, int endFreq, Vector<sp<CTvChannel> > &vcp) |
82 | { |
83 | if (name == NULL) |
84 | return -1; |
85 | int ret = 0; |
86 | String8 cmd; |
87 | cmd = String8("select * from region_table where name = ") + String8("\'") + name + String8("\'") |
88 | + String8(" and frequency >= ") + String8::format("%d", beginFreq) + String8(" and frequency <= ") |
89 | + String8::format("%d", endFreq); |
90 | |
91 | CTvDatabase::Cursor c; |
92 | CTvDatabase::GetTvDb()->select(cmd, c); |
93 | int col, size = 0; |
94 | int id; |
95 | int mode; |
96 | int frequency = 0; |
97 | int bandwidth; |
98 | int modulation; |
99 | int symbolRate; |
100 | int ofdmMode; |
101 | int channelNum = 0; |
102 | |
103 | do { |
104 | if (c.moveToFirst()) { |
105 | do { |
106 | col = c.getColumnIndex("db_id"); |
107 | id = c.getInt(col); |
108 | col = c.getColumnIndex("fe_type"); |
109 | mode = c.getInt(col); |
110 | col = c.getColumnIndex("frequency"); |
111 | frequency = c.getInt(col); |
112 | col = c.getColumnIndex("modulation"); |
113 | modulation = c.getInt(col); |
114 | col = c.getColumnIndex("bandwidth"); |
115 | bandwidth = c.getInt(col); |
116 | col = c.getColumnIndex("symbol_rate"); |
117 | symbolRate = c.getInt(col); |
118 | col = c.getColumnIndex("ofdm_mode"); |
119 | ofdmMode = c.getInt(col); |
120 | col = c.getColumnIndex("logical_channel_num"); |
121 | channelNum = c.getInt(col); |
122 | vcp.add(new CTvChannel(id, mode, frequency, bandwidth, modulation, symbolRate, ofdmMode, channelNum)); |
123 | size++; |
124 | } while (c.moveToNext()); |
125 | } else { |
126 | ret = -1; |
127 | break; |
128 | } |
129 | } while (false); |
130 | |
131 | c.close(); |
132 | return ret; |
133 | } |
134 | |
135 | void CTvRegion::selectByCountry() |
136 | { |
137 | } |
138 | |
139 | Vector<String8> CTvRegion::getAllCountry() |
140 | { |
141 | Vector<String8> vStr; |
142 | return vStr; |
143 | } |
144 | |
145 | CTvChannel CTvRegion::getChannels() |
146 | { |
147 | CTvChannel p; |
148 | return p; |
149 | } |
150 | |
151 | int CTvRegion::getLogicNumByNameAndfreq(char *name, int freq) |
152 | { |
153 | int ret = 0; |
154 | int col = 0; |
155 | |
156 | if (name == NULL) |
157 | return -1; |
158 | |
159 | String8 cmd; |
160 | cmd = String8("select * from region_table where name = ") + String8("\'") + name + String8("\'"); |
161 | cmd += String8(" and frequency = ") + String8::format("%d", freq); |
162 | |
163 | |
164 | CTvDatabase::Cursor c; |
165 | CTvDatabase::GetTvDb()->select(cmd, c); |
166 | if (c.moveToFirst()) { |
167 | col = c.getColumnIndex("logical_channel_num"); |
168 | ret = c.getInt(col); |
169 | } |
170 | c.close(); |
171 | |
172 | return ret; |
173 | } |
174 | |
175 |