blob: c5a4318a41037b6c959175e85294c63af990c769
1 | // |
2 | // |
3 | // amlogic 2013 |
4 | // |
5 | // @ Project : tv |
6 | // @ File Name : CTvDatabase.h |
7 | // @ Date : 2013-11 |
8 | // @ Author : |
9 | // |
10 | // |
11 | #include <am_db.h> |
12 | #if !defined(_CTVDATABASE_H) |
13 | #define _CTVDATABASE_H |
14 | // 使用AM_DB |
15 | #include <unistd.h> |
16 | #include <stdlib.h> |
17 | #include <utils/String8.h> |
18 | #include <utils/Log.h> |
19 | #include <utils/Vector.h> |
20 | #include <utils/RefBase.h> |
21 | #include <tvutils/CSqlite.h> |
22 | |
23 | #include "CTvLog.h" |
24 | |
25 | |
26 | using namespace android; |
27 | //根据现在情况需求,此类只针对电视功能绑定的单文件数据库,与AM_DB有关联性 |
28 | //无解的关联 |
29 | class CTvDatabase: public CSqlite |
30 | { |
31 | public: |
32 | static const char *DEFAULT_DB_PATH; |
33 | static const int DB_VERSION = 8; |
34 | static const char *DB_VERSION_FIELD; |
35 | |
36 | static const char feTypes[][32]; |
37 | static const char srvTypes[][32]; |
38 | static const char vidFmts[][32]; |
39 | static const char audFmts[][32]; |
40 | static const char mods[][32]; |
41 | static const char bandwidths[][32]; |
42 | static const char lnbPowers[][32]; |
43 | static const char sig22K[][32]; |
44 | static const char tonebursts[][32]; |
45 | static const char diseqc10s[][32]; |
46 | static const char diseqc11s[][32]; |
47 | static const char motors[][32]; |
48 | static const char ofdmModes[][32]; |
49 | static const char atvVideoStds[][32]; |
50 | static const char atvAudioStds[][32]; |
51 | template<typename T> |
52 | int StringToIndex(const T &t, const char *item) |
53 | { |
54 | if (item == NULL) return -1; |
55 | int size = sizeof(t) / sizeof(t[0]); |
56 | for (int i = 0; i < size; i++) { |
57 | if (strcmp(t[i], item) == 0) return i; |
58 | } |
59 | return -1; |
60 | } |
61 | public: |
62 | CTvDatabase(); |
63 | //直接指定数据库连接句柄 |
64 | //CTvDatabase(char* path, sqlite3 * h); |
65 | static CTvDatabase *GetTvDb(); |
66 | static void deleteTvDb(); |
67 | ~CTvDatabase(); |
68 | //用指定路径创建TV数据库. |
69 | int UnInitTvDb(); |
70 | int InitTvDb(const char *path); |
71 | //showboz test |
72 | class ChannelPara : public LightRefBase<ChannelPara> |
73 | { |
74 | public: |
75 | int mode; |
76 | int freq; |
77 | int symbol_rate; |
78 | int modulation; |
79 | int bandwidth; |
80 | int polar; |
81 | }; |
82 | |
83 | static int getChannelParaList(char *path, Vector<sp<ChannelPara> > &vcp); |
84 | |
85 | int importDbToXml(); |
86 | int importXmlToDB(const char *xmlPath); |
87 | bool isAtv256ProgInsertForSkyworth(); |
88 | int insert256AtvProgForSkyworth(); |
89 | int ClearDbTable(); |
90 | int clearDbAllProgramInfoTable(); |
91 | private: |
92 | static CTvDatabase *mpDb; |
93 | int isFreqListExist(void); |
94 | }; |
95 | |
96 | #endif //_CTVDATABASE_H |
97 |