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