summaryrefslogtreecommitdiff
Diffstat
-rw-r--r--tv_input.cpp45
-rw-r--r--tvapi/android/Android.mk2
-rw-r--r--tvapi/android/include/ITv.h100
-rw-r--r--tvapi/android/include/ITvClient.h58
-rw-r--r--tvapi/android/include/ITvService.h68
-rw-r--r--tvapi/android/include/Tv.h161
-rw-r--r--tvapi/android/include/tvcmd.h1188
-rw-r--r--tvapi/android/jni/Android.mk132
-rw-r--r--tvapi/android/jni/android_amlogic_tv.cpp911
-rw-r--r--tvapi/android/jni/cfbc_jni.cpp214
-rw-r--r--tvapi/android/jni/cfbc_test.cpp86
-rw-r--r--tvapi/android/libtvbinder/Android.mk48
-rw-r--r--tvapi/android/libtvbinder/ITv.cpp289
-rw-r--r--tvapi/android/libtvbinder/ITvClient.cpp117
-rw-r--r--tvapi/android/libtvbinder/ITvService.cpp101
-rw-r--r--tvapi/android/libtvbinder/Tv.cpp378
-rw-r--r--tvapi/android/tvserver/Android.mk162
-rw-r--r--tvapi/android/tvserver/TvService.cpp8755
-rw-r--r--tvapi/android/tvserver/TvService.h164
-rw-r--r--tvapi/android/tvserver/main.cpp46
-rwxr-xr-x[-rw-r--r--]tvapi/build/include/.gitignore0
-rw-r--r--tvapi/docs/tv.uml12156
-rw-r--r--tvapi/libtv/Android.mk3
-rw-r--r--tvapi/libtv/audio/audio_alsa.cpp2426
-rw-r--r--tvapi/libtv/audio/audio_alsa.h261
-rw-r--r--tvapi/libtv/audio/audio_android.cpp2070
-rw-r--r--tvapi/libtv/audio/audio_android.h157
-rw-r--r--tvapi/libtv/audio/audio_android_effect.cpp1182
-rw-r--r--tvapi/libtv/audio/audio_android_effect.h131
-rw-r--r--tvapi/libtv/audio/audio_api.cpp4940
-rw-r--r--tvapi/libtv/audio/audio_api.h647
-rw-r--r--tvapi/libtv/audio/audio_effect.cpp456
-rw-r--r--tvapi/libtv/audio/audio_effect.h63
-rw-r--r--tvapi/libtv/include/amstream.h526
-rw-r--r--tvapi/libtv/include/amvecm.h136
-rw-r--r--tvapi/libtv/include/cm.h306
-rw-r--r--tvapi/libtv/include/hdmirx_cec.h508
-rw-r--r--tvapi/libtv/include/ve.h438
-rw-r--r--tvapi/libtv/tv/AutoBackLight.cpp426
-rw-r--r--tvapi/libtv/tv/AutoBackLight.h47
-rw-r--r--tvapi/libtv/tv/CAv.cpp484
-rw-r--r--tvapi/libtv/tv/CAv.h194
-rw-r--r--tvapi/libtv/tv/CFbcCommunication.cpp2326
-rw-r--r--tvapi/libtv/tv/CFbcCommunication.h680
-rw-r--r--tvapi/libtv/tv/CFrontEnd.cpp838
-rw-r--r--tvapi/libtv/tv/CFrontEnd.h227
-rw-r--r--tvapi/libtv/tv/CTv.cpp10755
-rw-r--r--tvapi/libtv/tv/CTv.h1269
-rw-r--r--tvapi/libtv/tv/CTvBooking.cpp324
-rw-r--r--tvapi/libtv/tv/CTvBooking.h167
-rw-r--r--tvapi/libtv/tv/CTvDmx.cpp8
-rw-r--r--tvapi/libtv/tv/CTvDmx.h15
-rw-r--r--tvapi/libtv/tv/CTvEpg.cpp260
-rw-r--r--tvapi/libtv/tv/CTvEpg.h280
-rw-r--r--tvapi/libtv/tv/CTvEv.cpp2
-rw-r--r--tvapi/libtv/tv/CTvEv.h314
-rw-r--r--tvapi/libtv/tv/CTvLog.h8
-rw-r--r--tvapi/libtv/tv/CTvRecord.cpp552
-rw-r--r--tvapi/libtv/tv/CTvRecord.h93
-rw-r--r--tvapi/libtv/tv/CTvSatellite.h43
-rw-r--r--tvapi/libtv/tv/CTvScanner.cpp1417
-rw-r--r--tvapi/libtv/tv/CTvScanner.h319
-rw-r--r--tvapi/libtv/tv/CTvScreenCapture.cpp1060
-rw-r--r--tvapi/libtv/tv/CTvScreenCapture.h351
-rw-r--r--tvapi/libtv/tv/CTvSubtitle.cpp272
-rw-r--r--tvapi/libtv/tv/CTvSubtitle.h469
-rw-r--r--tvapi/libtv/tv/CTvTime.h137
-rw-r--r--tvapi/libtv/tv/CTvVchipCheck.cpp250
-rw-r--r--tvapi/libtv/tv/CTvVchipCheck.h43
-rw-r--r--tvapi/libtv/tv/CUpgradeFBC.cpp974
-rw-r--r--tvapi/libtv/tv/CUpgradeFBC.h284
-rw-r--r--tvapi/libtv/tvconfig/CIniFile.cpp706
-rw-r--r--tvapi/libtv/tvconfig/CIniFile.h79
-rw-r--r--tvapi/libtv/tvconfig/tvconfig.conf58
-rw-r--r--tvapi/libtv/tvconfig/tvconfig.cpp106
-rw-r--r--tvapi/libtv/tvconfig/tvconfig.h40
-rw-r--r--tvapi/libtv/tvdb/CTvChannel.cpp694
-rw-r--r--tvapi/libtv/tvdb/CTvChannel.h575
-rw-r--r--tvapi/libtv/tvdb/CTvDatabase.cpp300
-rw-r--r--tvapi/libtv/tvdb/CTvDatabase.h190
-rw-r--r--tvapi/libtv/tvdb/CTvDimension.cpp714
-rw-r--r--tvapi/libtv/tvdb/CTvDimension.h196
-rw-r--r--tvapi/libtv/tvdb/CTvEvent.cpp482
-rw-r--r--tvapi/libtv/tvdb/CTvEvent.h171
-rw-r--r--tvapi/libtv/tvdb/CTvGroup.cpp88
-rw-r--r--tvapi/libtv/tvdb/CTvGroup.h61
-rw-r--r--tvapi/libtv/tvdb/CTvProgram.cpp1766
-rw-r--r--tvapi/libtv/tvdb/CTvProgram.h1065
-rw-r--r--tvapi/libtv/tvdb/CTvRegion.cpp366
-rw-r--r--tvapi/libtv/tvdb/CTvRegion.h85
-rw-r--r--tvapi/libtv/tvin/CHDMIRxCEC.cpp830
-rw-r--r--tvapi/libtv/tvin/CSourceConnectDetect.cpp448
-rw-r--r--tvapi/libtv/tvin/CTvin.cpp4240
-rw-r--r--tvapi/libtv/tvin/CTvin.h2222
-rw-r--r--tvapi/libtv/tvsetting/CBlobDevice.cpp54
-rw-r--r--tvapi/libtv/tvsetting/CBlobDevice.h101
-rw-r--r--tvapi/libtv/tvsetting/CBlobDeviceE2prom.cpp706
-rw-r--r--tvapi/libtv/tvsetting/CBlobDeviceE2prom.h153
-rw-r--r--tvapi/libtv/tvsetting/CBlobDeviceFile.cpp160
-rw-r--r--tvapi/libtv/tvsetting/CBlobDeviceFile.h53
-rw-r--r--tvapi/libtv/tvsetting/CBlobDeviceRam.cpp258
-rw-r--r--tvapi/libtv/tvsetting/CBlobDeviceRam.h75
-rw-r--r--tvapi/libtv/tvsetting/CTvSetting.cpp4424
-rw-r--r--tvapi/libtv/tvsetting/CTvSettingCfg.h742
-rw-r--r--tvapi/libtv/tvsetting/CTvSettingDeviceFactory.cpp38
-rw-r--r--tvapi/libtv/tvsetting/CTvSettingDeviceFactory.h11
-rw-r--r--tvapi/libtv/tvsetting/TvKeyData.cpp2784
-rw-r--r--tvapi/libtv/tvsetting/audio_cfg.cpp3706
-rw-r--r--tvapi/libtv/tvsetting/audio_cfg.h338
-rw-r--r--tvapi/libtv/tvutils/CCondition.h87
-rw-r--r--tvapi/libtv/tvutils/CFile.cpp250
-rw-r--r--tvapi/libtv/tvutils/CFile.h53
-rw-r--r--tvapi/libtv/tvutils/CHdmiCecCmd.cpp6
-rw-r--r--tvapi/libtv/tvutils/CHdmiCecCmd.h9
-rw-r--r--tvapi/libtv/tvutils/CMsgQueue.cpp144
-rw-r--r--tvapi/libtv/tvutils/CMsgQueue.h44
-rw-r--r--tvapi/libtv/tvutils/CMutex.h116
-rw-r--r--tvapi/libtv/tvutils/CSerialCommunication.cpp118
-rw-r--r--tvapi/libtv/tvutils/CSerialCommunication.h98
-rw-r--r--tvapi/libtv/tvutils/CSerialPort.cpp568
-rw-r--r--tvapi/libtv/tvutils/CSerialPort.h45
-rw-r--r--tvapi/libtv/tvutils/CSqlite.cpp126
-rw-r--r--tvapi/libtv/tvutils/CSqlite.h292
-rw-r--r--tvapi/libtv/tvutils/CThread.cpp212
-rw-r--r--tvapi/libtv/tvutils/CThread.h79
-rw-r--r--tvapi/libtv/tvutils/CTvInput.cpp196
-rw-r--r--tvapi/libtv/tvutils/CTvInput.h49
-rw-r--r--tvapi/libtv/tvutils/serial_base.cpp560
-rw-r--r--tvapi/libtv/tvutils/serial_base.h34
-rw-r--r--tvapi/libtv/tvutils/serial_operate.cpp336
-rw-r--r--tvapi/libtv/tvutils/serial_operate.h72
-rw-r--r--tvapi/libtv/tvutils/tvutils.cpp3822
-rw-r--r--tvapi/libtv/tvutils/tvutils.h238
-rw-r--r--tvapi/libtv/tvutils/zepoll.cpp66
-rw-r--r--tvapi/libtv/tvutils/zepoll.h57
-rw-r--r--tvapi/libtv/version/version.cpp188
-rw-r--r--tvapi/libtv/version/version.h22
-rw-r--r--tvapi/libtv/vpp/CPQdb.cpp3183
-rw-r--r--tvapi/libtv/vpp/CPQdb.h321
-rw-r--r--tvapi/libtv/vpp/CVpp.cpp4772
-rw-r--r--tvapi/libtv/vpp/CVpp.h683
-rw-r--r--tvapi/libtv/vpp/pqdata.cpp216
-rw-r--r--tvapi/tvtests/Android.mk98
-rw-r--r--tvapi/tvtests/android_tvtest.cpp30
-rw-r--r--tvapi/tvtests/comm_test.cpp42
-rw-r--r--tvapi/tvtests/ssm_test.cpp420
-rw-r--r--tvapi/tvtests/tvconfig_test.cpp854
147 files changed, 55964 insertions, 55946 deletions
diff --git a/tvapi/libtv/tvdb/CTvProgram.cpp b/tvapi/libtv/tvdb/CTvProgram.cpp
index 921d67a..c71c757 100644
--- a/tvapi/libtv/tvdb/CTvProgram.cpp
+++ b/tvapi/libtv/tvdb/CTvProgram.cpp
@@ -1,883 +1,883 @@
-//
-//
-// amlogic 2013
-//
-// @ Project : tv
-// @ File Name : CTvProgram.cpp
-// @ Date : 2013-11
-// @ Author :
-//
-//
-
-
-#include "CTvProgram.h"
-#include "CTvDatabase.h"
-#include "CTvChannel.h"
-#include "CTvEvent.h"
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#define LOG_TAG "CTvProgram"
-#endif
-
-CTvProgram::CTvProgram(CTvDatabase::Cursor &c)
-{
- CreateFromCursor(c);
-}
-
-CTvProgram::~CTvProgram()
-{
- //free mem
- // video
- if (mpVideo != NULL) delete mpVideo;
- // audios
- int size = mvAudios.size();
- for (int i = 0; i < size; i++)
- delete mvAudios[i];
- // subtitles
- size = mvSubtitles.size();
- for (int i = 0; i < size; i++)
- delete mvSubtitles[i];
- // teletexts
- size = mvTeletexts.size();
- for (int i = 0; i < size; i++)
- delete mvTeletexts[i];
-}
-
-CTvProgram::CTvProgram(int channelID, int type)
-{
- mpVideo = NULL;
-}
-
-CTvProgram::CTvProgram()
-{
- mpVideo = NULL;
-}
-int CTvProgram::CreateFromCursor(CTvDatabase::Cursor &c)
-{
- int i = 0;
- int col;
- int num, type;
- int major, minor;
- char tmp_buf[256];
- //LOGD("CTvProgram::CreateFromCursor");
- col = c.getColumnIndex("db_id");
- this->id = c.getInt(col);
-
- col = c.getColumnIndex("source_id");
- this->sourceID = c.getInt(col);
-
- col = c.getColumnIndex("src");
- this->src = c.getInt(col);
-
- col = c.getColumnIndex("service_id");
- this->dvbServiceID = c.getInt(col);
-
- col = c.getColumnIndex("db_ts_id");
- this->channelID = c.getInt(col);
-
- col = c.getColumnIndex("name");
- this->name = c.getString(col);
-
- col = c.getColumnIndex("chan_num");
- num = c.getInt(col);
-
- col = c.getColumnIndex("chan_order");
- this->chanOrderNum = c.getInt(col);
-
- col = c.getColumnIndex("major_chan_num");
- major = c.getInt(col);
-
- col = c.getColumnIndex("minor_chan_num");
- minor = c.getInt(col);
-
- col = c.getColumnIndex("aud_track");
- this->audioTrack = c.getInt(col);
-
- //节目号信息初?
- if (src == CTvChannel::MODE_ATSC || (src == CTvChannel::MODE_ANALOG && major > 0)) {
- this->major = major;
- this->minor = minor;
- this->atscMode = true;
- this->minorCheck = MINOR_CHECK_NONE;
- } else {
- this->major = num;
- this->minor = 0;
- this->atscMode = false;
- this->minorCheck = MINOR_CHECK_NONE;
- }
-
- col = c.getColumnIndex("service_type");
- this->type = c.getInt(col);
-
- col = c.getColumnIndex("pmt_pid");
- pmtPID = c.getInt(col);
-
- //LOGD("CTvProgram::CreateFromCursor type = %d", this->type);
- col = c.getColumnIndex("skip");
- this->skip = c.getInt(col);
-
- col = c.getColumnIndex("lock");
- this->lock = (c.getInt(col) != 0);
-
- col = c.getColumnIndex("scrambled_flag");
- this->scrambled = (c.getInt(col) != 0);
-
- col = c.getColumnIndex("favor");
- this->favorite = (c.getInt(col) != 0);
-
- col = c.getColumnIndex("volume");
- this->volume = c.getInt(col);
-
- //Video
- int pid, fmt;
- col = c.getColumnIndex("vid_pid");
- pid = c.getInt(col);
-
- col = c.getColumnIndex("vid_fmt");
- fmt = c.getInt(col);
-
- //LOGD("----------vpid = %d", pid);
- this->mpVideo = new Video(pid, fmt);
- //LOGD("----------vpid = %d", this->mpVideo->getPID());
-
-
- //Audio
- String8 strPids;
- String8 strFmts;
- String8 strLangs;
- int count = 0;
- col = c.getColumnIndex("aud_pids");
- strPids = c.getString(col);
-
- col = c.getColumnIndex("aud_fmts");
- strFmts = c.getString(col);
-
- col = c.getColumnIndex("aud_langs");
- strLangs = c.getString(col);
- col = c.getColumnIndex("current_aud");
- this->currAudTrackIndex = c.getInt(col);
-
- char *tmp;
- Vector<String8> vpid ;
- Vector<String8> vfmt ;
- Vector<String8> vlang;
-
- tmp = strtok(strPids.lockBuffer(strPids.length()), " ");
- while (tmp != NULL) {
- vpid.push_back(String8(tmp));
- tmp = strtok(NULL, " ");
- }
- strPids.unlockBuffer();
-
- tmp = strtok(strFmts.lockBuffer(strFmts.length()), " ");
- while (tmp != NULL) {
- vfmt.push_back(String8(tmp));
- tmp = strtok(NULL, " ");
- }
- strFmts.unlockBuffer();
-
- tmp = strtok(strLangs.lockBuffer(strLangs.length()), " ");
-
- while (tmp != NULL) {
- vlang.push_back(String8(tmp));
- tmp = strtok(NULL, " ");
- }
- strLangs.unlockBuffer();
-
- //check empty aud_langs
- for (i = vlang.size(); i < vpid.size(); i++) {
- sprintf(tmp_buf, "Audio%d", i + 1);
- vlang.push_back(String8(tmp_buf));
- LOGE("%s, aud_langs is empty, add dummy data (%s).\n", "TV", tmp_buf);
- }
-
- //String8 l(vlang[i]);
- for (i = 0; i < vpid.size(); i++) {
- int i_pid = atoi(vpid[i]);
- int i_fmt = atoi(vfmt[i]);
- mvAudios.push_back(new Audio(i_pid, vlang[i], i_fmt));
- }
-
-
-
- /* parse subtitles */
- vpid.clear();
- vlang.clear();
- Vector<String8> vcid;
- Vector<String8> vaid;
- String8 strCids;
- String8 strAids;
-
- col = c.getColumnIndex("sub_pids");
- strPids = c.getString(col);
-
- col = c.getColumnIndex("sub_composition_page_ids");
- strCids = c.getString(col);
-
- col = c.getColumnIndex("sub_ancillary_page_ids");
- strAids = c.getString(col);
-
-
- col = c.getColumnIndex("sub_langs");
- strLangs = c.getString(col);
-
- tmp = strtok(strPids.lockBuffer(strPids.length()), " ");
- while (tmp != NULL) {
- vpid.push_back(String8(tmp));
- tmp = strtok(NULL, " ");
- }
- strPids.unlockBuffer();
-
- tmp = strtok(strCids.lockBuffer(strCids.length()), " ");
- while (tmp != NULL) {
- vcid.push_back(String8(tmp));
- tmp = strtok(NULL, " ");
- }
- strCids.unlockBuffer();
-
- tmp = strtok(strAids.lockBuffer(strAids.length()), " ");
- while (tmp != NULL) {
- vaid.push_back(String8(tmp));
- tmp = strtok(NULL, " ");
- }
- strAids.unlockBuffer();
-
- tmp = strtok(strLangs.lockBuffer(strLangs.length()), " ");
- while (tmp != NULL) {
- vlang.push_back(String8(tmp));
- tmp = strtok(NULL, " ");
- }
- strLangs.unlockBuffer();
-
- //Subtitle
- for (int i = 0; i < vpid.size(); i++) {
- this->mvSubtitles.push_back(new Subtitle(
- atoi(vpid[i]),
- String8(vlang[i]), Subtitle::TYPE_DVB_SUBTITLE,
- atoi(vcid[i]),
- atoi(vaid[i])));
- }
-
- /* parse teletexts */
- int ttx_count = 0, ttx_sub_count = 0;
- String8 str_ttx_pids, str_ttx_types, str_mag_nos, str_page_nos, str_ttx_langs;
- Vector<String8> v_ttx_pids, v_ttx_types, v_mag_nos, v_page_nos, v_ttx_langs;
- col = c.getColumnIndex("ttx_pids");
- str_ttx_pids = c.getString(col);
-
- col = c.getColumnIndex("ttx_types");
- str_ttx_types = c.getString(col);
-
- col = c.getColumnIndex("ttx_magazine_nos");
- str_mag_nos = c.getString(col);
-
- col = c.getColumnIndex("ttx_page_nos");
- str_page_nos = c.getString(col);
-
- col = c.getColumnIndex("ttx_langs");
- str_ttx_langs = c.getString(col);
-
- tmp = strtok(str_ttx_pids.lockBuffer(str_ttx_pids.length()), " ");
- while (tmp != NULL) {
- v_ttx_pids.push_back(String8(tmp));
- tmp = strtok(NULL, " ");
- }
- str_ttx_pids.unlockBuffer();
-
- tmp = strtok(str_ttx_types.lockBuffer(str_ttx_types.length()), " ");
- while (tmp != NULL) {
- v_ttx_types.push_back(String8(tmp));
- tmp = strtok(NULL, " ");
- }
- str_ttx_types.unlockBuffer();
-
- tmp = strtok(str_mag_nos.lockBuffer(str_mag_nos.length()), " ");
- while (tmp != NULL) {
- v_mag_nos.push_back(String8(tmp));
- tmp = strtok(NULL, " ");
- }
- str_mag_nos.unlockBuffer();
-
- tmp = strtok(str_page_nos.lockBuffer(str_page_nos.length()), " ");
- while (tmp != NULL) {
- v_page_nos.push_back(String8(tmp));
- tmp = strtok(NULL, " ");
- }
- str_page_nos.unlockBuffer();
-
- tmp = strtok(str_ttx_langs.lockBuffer(str_ttx_langs.length()), " ");
- while (tmp != NULL) {
- v_ttx_langs.push_back(String8(tmp));
- tmp = strtok(NULL, " ");
- }
- str_ttx_langs.unlockBuffer();
-
-
- for (int i = 0; i < v_ttx_pids.size(); i++) {
- int ttype = atoi(v_ttx_types[i]);
- if (ttype == 0x2 || ttype == 0x5) {
- this->mvSubtitles.push_back(new Subtitle(
- atoi(v_ttx_pids[i].string()),
- String8(v_ttx_langs[i]), Subtitle::TYPE_DTV_TELETEXT,
- atoi(v_mag_nos[i]),
- atoi(v_page_nos[i])));
- } else {
- this->mvTeletexts.push_back(new Teletext(
- atoi(v_ttx_pids[i]),
- String8(v_ttx_langs[i]),
- atoi(v_mag_nos[i]),
- atoi(v_page_nos[i])));
- }
- }
- return 0;
-}
-
-int CTvProgram::selectProgramInChannelByNumber(int channelID, int num, CTvDatabase::Cursor &c)
-{
- String8 cmd = String8("select * from srv_table where db_ts_id = ") + String8::format("%d", channelID) + String8(" and ");
- cmd += String8("chan_num = ") + String8::format("%d", num);
- return CTvDatabase::GetTvDb()->select(cmd, c);
-}
-
-
-int CTvProgram::selectProgramInChannelByNumber(int channelID, int major, int minor, CTvDatabase::Cursor &c)
-{
- String8 cmd = String8("select * from srv_table where db_ts_id = ") + String8::format("%d", channelID) + String8(" and ");
- cmd += String8("major_chan_num = ") + String8::format("%d", major) + String8(" and minor_chan_num = ") + String8::format("%d", minor);
-
- return CTvDatabase::GetTvDb()->select(cmd, c);
-}
-
-/**
- *向数据库添加一个Program,not atscMode
- */
-CTvProgram::CTvProgram(int channelID, int type, int num, int skipFlag)
-{
- CTvChannel channel;
- int ret = CTvChannel::selectByID(channelID, channel);
- if (ret != 0) {
- //Log.d(TAG, "Cannot add new program, invalid channel id "+channelID);
- this->id = -1;
- } else {
- CTvDatabase::Cursor c ;
- selectProgramInChannelByNumber(channelID, num, c);
-
- if (c.moveToFirst()) {
- /*Construct*/
- CreateFromCursor(c);
- } else {
- String8 tpids = String8(""), ttypes = String8(""), tmagnums = String8(""), tpgnums = String8(""), tlangs = String8("");
- String8 spids = String8(""), stypes = String8(""), scpgids = String8(""), sapgids = String8(""), slangs = String8("");
-
- /*add a new atv program to database*/
- String8 cmd = String8("insert into srv_table(db_net_id,db_ts_id,service_id,src,name,service_type,");
- cmd += String8("eit_schedule_flag,eit_pf_flag,running_status,free_ca_mode,volume,aud_track,vid_pid,");
- cmd += String8("vid_fmt,aud_pids,aud_fmts,aud_langs,skip,lock,chan_num,major_chan_num,");
- cmd += String8("minor_chan_num,access_controlled,hidden,hide_guide,source_id,favor,current_aud,");
- cmd += String8("current_sub,sub_pids,sub_types,sub_composition_page_ids,sub_ancillary_page_ids,sub_langs,");
- cmd += String8("current_ttx,ttx_pids,ttx_types,ttx_magazine_nos,ttx_page_nos,ttx_langs,");
- cmd += String8("db_sat_para_id,scrambled_flag,lcn,hd_lcn,sd_lcn,default_chan_num,chan_order) ");
- cmd += String8("values(-1,") + String8::format("%d", channelID) + String8(",65535,") + String8::format("%d", channel.getMode()) + String8(",'',") + String8::format("%d", type) + String8(",");
- cmd += String8("0,0,0,0,0,0,8191,");
- int chanNum = num;
- int majorNum = 0;
- cmd += String8("-1,'','','',") + String8::format("%d", skipFlag) + String8(",0,") + String8::format("%d", chanNum) + String8(",") + String8::format("%d", majorNum) + String8(",");
- cmd += String8("") + /*num.getMinor()*/String8("0") + String8(",0,0,0,-1,0,-1,");
- cmd += String8("-1,'") + spids + String8("','") + stypes + String8("','") + scpgids + String8("','") + sapgids + String8("','") + slangs + String8("',");
- cmd += String8("-1,'") + tpids + String8("','") + ttypes + String8("','") + tmagnums + String8("','") + tpgnums + String8("','") + tlangs + String8("',");
- cmd += String8("-1,0,-1,-1,-1,-1,0)");
- CTvDatabase::GetTvDb()->exeSql(cmd.string());
-
- CTvDatabase::Cursor cr;
- selectProgramInChannelByNumber(channelID, num, cr);
- if (cr.moveToFirst()) {
- /*Construct*/
- CreateFromCursor(cr);
- } else {
- /*A critical error*/
- //Log.d(TAG, "Cannot add new program, sqlite error");
- this->id = -1;
- }
- cr.close();
- }
- c.close();
- }
-
-}
-
-
-/**
- *向数据库添加一个Program,atscMode
- */
-CTvProgram::CTvProgram(int channelID, int type, int major, int minor, int skipFlag)
-{
- CTvChannel channel;
- int ret = CTvChannel::selectByID(channelID, channel);
- if (ret != 0) {
- //Log.d(TAG, "Cannot add new program, invalid channel id "+channelID);
- this->id = -1;
- } else {
- CTvDatabase::Cursor c ;
- selectProgramInChannelByNumber(channelID, major, minor, c);
-
- if (c.moveToFirst()) {
- /*Construct*/
- CreateFromCursor(c);
- } else {
- String8 tpids = String8(""), ttypes = String8(""), tmagnums = String8(""), tpgnums = String8(""), tlangs = String8("");
- String8 spids = String8(""), stypes = String8(""), scpgids = String8(""), sapgids = String8(""), slangs = String8("");
-
- /*add a new atv program to database*/
- String8 cmd = String8("insert into srv_table(db_net_id,db_ts_id,service_id,src,name,service_type,");
- cmd += String8("eit_schedule_flag,eit_pf_flag,running_status,free_ca_mode,volume,aud_track,vid_pid,");
- cmd += String8("vid_fmt,aud_pids,aud_fmts,aud_langs,skip,lock,chan_num,major_chan_num,");
- cmd += String8("minor_chan_num,access_controlled,hidden,hide_guide,source_id,favor,current_aud,");
- cmd += String8("current_sub,sub_pids,sub_types,sub_composition_page_ids,sub_ancillary_page_ids,sub_langs,");
- cmd += String8("current_ttx,ttx_pids,ttx_types,ttx_magazine_nos,ttx_page_nos,ttx_langs,");
- cmd += String8("db_sat_para_id,scrambled_flag,lcn,hd_lcn,sd_lcn,default_chan_num,chan_order) ");
- cmd += String8("values(-1,") + String8::format("%d", channelID) + String8(",65535,") + String8::format("%d", channel.getMode()) + String8(",'',") + String8::format("%d", type) + String8(",");
- cmd += String8("0,0,0,0,0,0,8191,");
- int chanNum = major << 16 | minor;
- int majorNum = major;
- cmd += String8("-1,'','','',") + String8::format("%d", skipFlag) + String8(",0,") + String8::format("%d", chanNum) + String8(",") + String8::format("%d", majorNum) + String8(",");
- cmd += String8("") + String8::format("%d", minor) + String8(",0,0,0,-1,0,-1,");
- cmd += String8("-1,'") + spids + String8("','") + stypes + String8("','") + scpgids + String8("','") + sapgids + String8("','") + slangs + String8("',");
- cmd += String8("-1,'") + tpids + String8("','") + ttypes + String8("','") + tmagnums + String8("','") + tpgnums + String8("','") + tlangs + String8("',");
- cmd += String8("-1,0,-1,-1,-1,-1,0)");
- CTvDatabase::GetTvDb()->exeSql(cmd.string());
-
- CTvDatabase::Cursor cr;
- selectProgramInChannelByNumber(channelID, major, minor, cr);
- if (cr.moveToFirst()) {
- /*Construct*/
- CreateFromCursor(cr);
- } else {
- /*A critical error*/
- //Log.d(TAG, "Cannot add new program, sqlite error");
- this->id = -1;
- }
- cr.close();
- }
- c.close();
- }
-
-}
-/**
- *根据记录ID查找指定TVProgram
-*/
-
-int CTvProgram::selectByID(int id, CTvProgram &prog)
-{
-
- CTvDatabase::Cursor c;
- String8 sql;
- sql = String8("select * from srv_table where srv_table.db_id = ") + String8::format("%d", id);
- CTvDatabase::GetTvDb()->select(sql.string(), c) ;
- if (c.moveToFirst()) {
- prog.CreateFromCursor(c);
- } else {
- c.close();
- return -1;
- }
- c.close();
- return 0;
-}
-
-int CTvProgram::updateVolComp(int progID, int volValue)
-{
- String8 cmd = String8("update srv_table set volume = ") + String8::format("%d", volValue) +
- String8(" where srv_table.db_id = ") + String8::format("%d", progID);
- LOGD("%s, cmd = %s\n", "TV", cmd.string());
- CTvDatabase::GetTvDb()->exeSql(cmd.string());
-
- return 0;
-}
-
-int CTvProgram::getChannel(CTvChannel &c)
-{
- return CTvChannel::selectByID(channelID, c);
-}
-
-int CTvProgram::upDateChannel(CTvChannel &c, int std, int Freq, int fineFreq)
-{
- return CTvChannel::updateByID(channelID, std, Freq, fineFreq);
-}
-
-int CTvProgram::deleteChannelsProgram(CTvChannel &c)
-{
- String8 cmd;
- cmd = String8("delete from srv_table where srv_table.db_ts_id = ") + String8::format("%d", c.getID());
- CTvDatabase::GetTvDb()->exeSql(cmd.string());
- return 0;
-}
-
-
-/**
- *根据节目类型和节目号查找指定TVProgram
-*/
-int CTvProgram::selectByNumber(int type, int num, CTvProgram &prog)
-{
- String8 cmd;
-
- cmd = String8("select * from srv_table where ");
- if (type != TYPE_UNKNOWN) {
- if (type == TYPE_DTV) {
- cmd += String8("(service_type = ") + String8::format("%d", TYPE_TV) + String8(" or service_type = ") + String8::format("%d", TYPE_RADIO) + String8(") and ");
- } else {
- cmd += String8("service_type = ") + String8::format("%d", type) + String8(" and ");
- }
- }
-
- cmd += String8("chan_num = ") + String8::format("%d", num);
-
- CTvDatabase::Cursor c;
- CTvDatabase::GetTvDb()->select(cmd, c);
-
- if (c.moveToFirst()) {
- prog.CreateFromCursor(c);
- } else {
- c.close();
- return -1;
- }
- c.close();
-
- return 0;
-}
-
-/**
- *根据节目类型和节目号查找指定TVProgram
-*/
-int CTvProgram::selectByNumber(int type, int major, int minor, CTvProgram &prog, int minor_check)
-{
- String8 cmd;
-
- cmd = String8("select * from srv_table where ");
- if (type != TYPE_UNKNOWN) {
- if (type == TYPE_DTV) {
- cmd += String8("(service_type = ") + String8::format("%d", TYPE_TV) + String8(" or service_type = ") + String8::format("%d", TYPE_RADIO) + String8(") and ");
- } else {
- cmd += String8("service_type = ") + String8::format("%d", type) + String8(" and ");
- }
- }
-
- if (minor < 0) {
- /*recursive call*/
- /*select dtv program first*/
- //showbo
- int ret = selectByNumber(TYPE_DTV, major, 1, prog, MINOR_CHECK_NEAREST_UP);
- if (ret != 0) {
- /*then try atv program*/
- selectByNumber(TYPE_ATV, major, 0 , prog, MINOR_CHECK_NONE);
- }
- return 0;
- } else if (minor >= 1) {
- if (minor_check == MINOR_CHECK_UP) {
- cmd += String8("major_chan_num = ") + String8::format("%d", major) + String8(" and minor_chan_num >= ") + String8::format("%d", minor) + String8(" ");
- cmd += String8("order by minor_chan_num DESC limit 1");
- } else if (minor_check == MINOR_CHECK_DOWN) {
- cmd += String8("major_chan_num = ") + String8::format("%d", major) + String8(" and minor_chan_num <= ") + String8::format("%d", minor) + String8(" ");
- cmd += String8("order by minor_chan_num limit 1");
- } else if (minor_check == MINOR_CHECK_NEAREST_UP) {
- cmd += String8("major_chan_num = ") + String8::format("%d", major) + String8(" and minor_chan_num >= ") + String8::format("%d", minor) + String8(" ");
- cmd += String8("order by minor_chan_num limit 1");
- } else if (minor_check == MINOR_CHECK_NEAREST_DOWN) {
- cmd += String8("major_chan_num = ") + String8::format("%d", major) + String8(" and minor_chan_num <= ") + String8::format("%d", minor) + String8(" ");
- cmd += String8("order by minor_chan_num DESC limit 1");
- } else {
- cmd += String8("major_chan_num = ") + String8::format("%d", major) + String8(" and minor_chan_num = ") + String8::format("%d", minor);
- }
- } else {
- cmd += String8("major_chan_num = ") + String8::format("%d", major) + String8(" and minor_chan_num = ") + String8::format("%d", minor);
- }
-
-
- CTvDatabase::Cursor c;
- CTvDatabase::GetTvDb()->select(cmd, c);
-
- if (c.moveToFirst()) {
- prog.CreateFromCursor(c);
- } else {
- c.close();
- return -1;
- }
- c.close();
-
- return 0;
-}
-
-
-/**
- *列出一个channel的全部TVProgram
- *@param channelID channel id
- *@param type 节目类型
- */
-int CTvProgram::selectByChannel(int channelID, int type, Vector<sp<CTvProgram> > &out)
-{
-
- //Vector<CTvProgram*> vp;
- String8 cmd = String8("select * from srv_table ");
-
-
- if (type == TYPE_DTV) {
- cmd += String8("where (service_type = ") + String8::format("%d", TYPE_TV) + String8(" or service_type = ") + String8::format("%d", TYPE_RADIO) + String8(") ");
- } else if (type != TYPE_UNKNOWN) {
- cmd += String8("where service_type = ") + String8::format("%d", type) + String8(" ");
- }
-
- cmd += String8(" and db_ts_id = ") + String8::format("%d", channelID) + String8(" order by chan_order");
-
- CTvDatabase::Cursor c;
- int ret = CTvDatabase::GetTvDb()->select(cmd, c);
-
- LOGD("selectByChannel select ret = %d", ret);
-
- if (c.moveToFirst()) {
- do {
- out.add(new CTvProgram(c));
- } while (c.moveToNext());
- }
- c.close();
-
- return 0;
-}
-
-void CTvProgram::deleteProgram(int progId)
-{
- String8 cmd;
-
- cmd = String8("delete from srv_table where srv_table.db_id = ") + String8::format("%d", progId);
- CTvDatabase::GetTvDb()->exeSql(cmd.string());
-}
-
-int CTvProgram::CleanAllProgramBySrvType(int srvType)
-{
- String8 cmd = String8("delete from srv_table where service_type = ") + String8::format("%d", srvType);
- CTvDatabase::GetTvDb()->exeSql(cmd.string());
- return 0;
-}
-
-int CTvProgram::selectByType(int type, int skip, Vector<sp<CTvProgram> > &out)
-{
- String8 cmd = String8("select * from srv_table ");
- LOGD("%s, type= %d\n", "TV", (int)type);
-
- if (type == TYPE_UNKNOWN) {
- cmd += String8("where (service_type = ") + String8::format("%d", TYPE_ATV) +
- String8(" or service_type = ") + String8::format("%d", TYPE_DTV) +
- String8(" or service_type = ") + String8::format("%d", TYPE_RADIO) +
- String8(") ");
- } else {
- cmd += String8("where service_type = ") + String8::format("%d", type) + String8(" ");
- }
-
- if (skip == PROGRAM_SKIP_NO || skip == PROGRAM_SKIP_YES)
- cmd += String8(" and skip = ") + String8::format("%d", skip) + String8(" ");
-
- cmd += String8(" order by chan_order");
-
- CTvDatabase::Cursor c;
- int ret = CTvDatabase::GetTvDb()->select(cmd, c);
-
- LOGD("selectByChannel select ret = %d", ret);
-
- if (c.moveToFirst()) {
- do {
- out.add(new CTvProgram(c));
- } while (c.moveToNext());
- }
- c.close();
-
- return 0;
-}
-
-int CTvProgram::selectByChanID(int type, int skip, Vector < sp < CTvProgram > > &out)
-{
- String8 cmd = String8("select * from srv_table ");
-
- if (type == TYPE_UNKNOWN) {
- cmd += String8("where (service_type = ") + String8::format("%d", TYPE_ATV) +
- String8(" or service_type = ") + String8::format("%d", TYPE_DTV) +
- String8(") ");
- } else {
- cmd += String8("where service_type = ") + String8::format("%d", type) + String8(" ");
- }
-
- if (skip == PROGRAM_SKIP_NO || skip == PROGRAM_SKIP_YES)
- cmd += String8(" and skip = ") + String8::format("%d", PROGRAM_SKIP_NO) +
- String8(" or skip = ") + String8::format("%d", PROGRAM_SKIP_YES) + String8(" ");
-
- cmd += String8(" order by db_id");
-
- CTvDatabase::Cursor c;
- int ret = CTvDatabase::GetTvDb()->select(cmd, c);
-
- if (c.moveToFirst()) {
- do {
- out.add(new CTvProgram(c));
- } while (c.moveToNext());
- }
- c.close();
-
- return 0;
-
-}
-
-int CTvProgram::selectAll(bool no_skip, Vector<sp<CTvProgram> > &out)
-{
- return selectByType(TYPE_UNKNOWN, no_skip, out);
-}
-
-Vector<CTvProgram> CTvProgram::selectByChannel(int channelID)
-{
- Vector<CTvProgram> vProg;
- return vProg;
-}
-
-Vector<CTvProgram> CTvProgram::selectByName(int name)
-{
- Vector<CTvProgram> vProg;
- return vProg;
-}
-
-void CTvProgram::tvProgramDelByChannelID(int channelID)
-{
-
-}
-
-
-String8 CTvProgram::getName()
-{
- return name;
-}
-int CTvProgram::getProgSkipFlag()
-{
- return skip;
-}
-
-/**
- *取得当前的audio索引
- *@param defaultLang 用户未选择语言时,默认的全局语言
- *@return 当前的Audio索引
- */
-int CTvProgram::getCurrentAudio(String8 defaultLang)
-{
- CTvDatabase::Cursor c;
- String8 cmd;
- cmd = String8("select current_aud from srv_table where db_id = ") + String8::format("%d", this->id);
- int ret = CTvDatabase::GetTvDb()->select(cmd, c);
- LOGD("getCurrentAudio a size = %d", mvAudios.size());
- int id = 0;
- if (c.moveToFirst()) {
- id = c.getInt(0);
- LOGD("getCurrentAudio a id = %d", id);
- if (id < 0 && mvAudios.size() > 0) {
- LOGD("getCurrentAudio defaultLang.isEmpty() =%s= %d", defaultLang.string(), defaultLang.isEmpty());
- if (!defaultLang.isEmpty()) {
- for (int i = 0; i < mvAudios.size(); i++) {
- LOGD("getCurrentAudio a mvAudios[i] = %d", mvAudios[i]);
- if (mvAudios[i]->getLang() == defaultLang) {
- id = i;
- break;
- }
- }
- }
-
- if (id < 0) {
- /* still not found, using the first */
- id = 0;
- }
- }
- }
- LOGD("getCurrentAudio a idsss = %d", id);
- c.close();
-
- return id;
-}
-
-int CTvProgram::getCurrAudioTrackIndex()
-{
- int audTrackIdx = -1;
-
- if (-1 == currAudTrackIndex) { // no set field "current_aud"
- audTrackIdx = getCurrentAudio(String8("eng"));
- setCurrAudioTrackIndex(this->id, audTrackIdx);
- } else {
- audTrackIdx = currAudTrackIndex;
- }
-
- return audTrackIdx;
-}
-
-
-void CTvProgram::setCurrAudioTrackIndex(int programId, int audioIndex)
-{
- String8 cmd;
-
- cmd = String8("update srv_table set current_aud = ")
- + String8::format("%d", audioIndex) + String8(" where srv_table.db_id = ") + String8::format("%d", programId);
-
- CTvDatabase::GetTvDb()->exeSql(cmd.string());
-}
-
-void CTvProgram::setFavoriteFlag(int progId, bool bFavor)
-{
- String8 cmd;
-
- cmd = String8("update srv_table set favor = ")
- + String8::format("%d", bFavor ? 1 : 0) + String8(" where srv_table.db_id = ") + String8::format("%d", progId);
-
- CTvDatabase::GetTvDb()->exeSql(cmd.string());
-
-}
-
-void CTvProgram::setSkipFlag(int progId, bool bSkipFlag)
-{
- String8 cmd;
-
- cmd = String8("update srv_table set skip = ") + String8::format("%d", bSkipFlag ? 1 : 0)
- + String8(" where srv_table.db_id = ") + String8::format("%d", progId);
-
- CTvDatabase::GetTvDb()->exeSql(cmd.string());
-}
-
-void CTvProgram::updateProgramName(int progId, String8 strName)
-{
- String8 newName = String8("xxx") + strName;
- String8 cmd;
-
- cmd = String8("update srv_table set name =") + "\'" + String8::format("%s", newName.string()) + "\'"
- + String8(" where srv_table.db_id = ") + String8::format("%d", progId);
-
- CTvDatabase::GetTvDb()->exeSql(cmd.string());
-}
-
-void CTvProgram::swapChanOrder(int ProgId1, int chanOrderNum1, int ProgId2, int chanOrderNum2)
-{
- String8 cmd;
-
- cmd = String8("update srv_table set chan_order = ") + String8::format("%d", chanOrderNum2)
- + String8(" where db_id = ") + String8::format("%d", ProgId1);
- CTvDatabase::GetTvDb()->exeSql(cmd.string());
-
- String8 cmd2;
- cmd2 = String8("update srv_table set chan_order = ") + String8::format("%d", chanOrderNum1)
- + String8(" where db_id = ") + String8::format("%d", ProgId2);
- CTvDatabase::GetTvDb()->exeSql(cmd2.string());
-}
-
-
-void CTvProgram::setLockFlag(int progId, bool bLockFlag)
-{
- String8 cmd;
-
- cmd = String8("update srv_table set lock = ") + String8::format("%d", bLockFlag ? 1 : 0)
- + String8(" where srv_table.db_id = ") + String8::format("%d", progId);
-
- CTvDatabase::GetTvDb()->exeSql(cmd.string());
-}
-bool CTvProgram::getLockFlag()
-{
- return lock;
-}
-
+//
+//
+// amlogic 2013
+//
+// @ Project : tv
+// @ File Name : CTvProgram.cpp
+// @ Date : 2013-11
+// @ Author :
+//
+//
+
+
+#include "CTvProgram.h"
+#include "CTvDatabase.h"
+#include "CTvChannel.h"
+#include "CTvEvent.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#define LOG_TAG "CTvProgram"
+#endif
+
+CTvProgram::CTvProgram(CTvDatabase::Cursor &c)
+{
+ CreateFromCursor(c);
+}
+
+CTvProgram::~CTvProgram()
+{
+ //free mem
+ // video
+ if(mpVideo != NULL) delete mpVideo;
+ // audios
+ int size = mvAudios.size();
+ for(int i = 0; i < size; i++)
+ delete mvAudios[i];
+ // subtitles
+ size = mvSubtitles.size();
+ for(int i = 0; i < size; i++)
+ delete mvSubtitles[i];
+ // teletexts
+ size = mvTeletexts.size();
+ for(int i = 0; i < size; i++)
+ delete mvTeletexts[i];
+}
+
+CTvProgram::CTvProgram(int channelID, int type)
+{
+ mpVideo = NULL;
+}
+
+CTvProgram::CTvProgram()
+{
+ mpVideo = NULL;
+}
+int CTvProgram::CreateFromCursor(CTvDatabase::Cursor &c)
+{
+ int i = 0;
+ int col;
+ int num, type;
+ int major, minor;
+ char tmp_buf[256];
+ //LOGD("CTvProgram::CreateFromCursor");
+ col = c.getColumnIndex("db_id");
+ this->id = c.getInt(col);
+
+ col = c.getColumnIndex("source_id");
+ this->sourceID = c.getInt(col);
+
+ col = c.getColumnIndex("src");
+ this->src = c.getInt(col);
+
+ col = c.getColumnIndex("service_id");
+ this->dvbServiceID = c.getInt(col);
+
+ col = c.getColumnIndex("db_ts_id");
+ this->channelID = c.getInt(col);
+
+ col = c.getColumnIndex("name");
+ this->name = c.getString(col);
+
+ col = c.getColumnIndex("chan_num");
+ num = c.getInt(col);
+
+ col = c.getColumnIndex("chan_order");
+ this->chanOrderNum = c.getInt(col);
+
+ col = c.getColumnIndex("major_chan_num");
+ major = c.getInt(col);
+
+ col = c.getColumnIndex("minor_chan_num");
+ minor = c.getInt(col);
+
+ col = c.getColumnIndex("aud_track");
+ this->audioTrack = c.getInt(col);
+
+ //节目号信息初??
+ if (src == CTvChannel::MODE_ATSC || (src == CTvChannel::MODE_ANALOG && major > 0)) {
+ this->major = major;
+ this->minor = minor;
+ this->atscMode = true;
+ this->minorCheck = MINOR_CHECK_NONE;
+ } else {
+ this->major = num;
+ this->minor = 0;
+ this->atscMode = false;
+ this->minorCheck = MINOR_CHECK_NONE;
+ }
+
+ col = c.getColumnIndex("service_type");
+ this->type = c.getInt(col);
+
+ col = c.getColumnIndex("pmt_pid");
+ pmtPID = c.getInt(col);
+
+ //LOGD("CTvProgram::CreateFromCursor type = %d", this->type);
+ col = c.getColumnIndex("skip");
+ this->skip = c.getInt(col);
+
+ col = c.getColumnIndex("lock");
+ this->lock = (c.getInt(col) != 0);
+
+ col = c.getColumnIndex("scrambled_flag");
+ this->scrambled = (c.getInt(col) != 0);
+
+ col = c.getColumnIndex("favor");
+ this->favorite = (c.getInt(col) != 0);
+
+ col = c.getColumnIndex("volume");
+ this->volume = c.getInt(col);
+
+ //Video
+ int pid, fmt;
+ col = c.getColumnIndex("vid_pid");
+ pid = c.getInt(col);
+
+ col = c.getColumnIndex("vid_fmt");
+ fmt = c.getInt(col);
+
+ //LOGD("----------vpid = %d", pid);
+ this->mpVideo = new Video(pid, fmt);
+ //LOGD("----------vpid = %d", this->mpVideo->getPID());
+
+
+ //Audio
+ String8 strPids;
+ String8 strFmts;
+ String8 strLangs;
+ int count = 0;
+ col = c.getColumnIndex("aud_pids");
+ strPids = c.getString(col);
+
+ col = c.getColumnIndex("aud_fmts");
+ strFmts = c.getString(col);
+
+ col = c.getColumnIndex("aud_langs");
+ strLangs = c.getString(col);
+ col = c.getColumnIndex("current_aud");
+ this->currAudTrackIndex = c.getInt(col);
+
+ char *tmp;
+ Vector<String8> vpid ;
+ Vector<String8> vfmt ;
+ Vector<String8> vlang;
+
+ tmp = strtok(strPids.lockBuffer(strPids.length()), " ");
+ while (tmp != NULL) {
+ vpid.push_back(String8(tmp));
+ tmp = strtok(NULL, " ");
+ }
+ strPids.unlockBuffer();
+
+ tmp = strtok(strFmts.lockBuffer(strFmts.length()), " ");
+ while (tmp != NULL) {
+ vfmt.push_back(String8(tmp));
+ tmp = strtok(NULL, " ");
+ }
+ strFmts.unlockBuffer();
+
+ tmp = strtok(strLangs.lockBuffer(strLangs.length()), " ");
+
+ while (tmp != NULL) {
+ vlang.push_back(String8(tmp));
+ tmp = strtok(NULL, " ");
+ }
+ strLangs.unlockBuffer();
+
+ //check empty aud_langs
+ for(i = vlang.size(); i < vpid.size(); i++) {
+ sprintf(tmp_buf, "Audio%d", i + 1);
+ vlang.push_back(String8(tmp_buf));
+ LOGE("%s, aud_langs is empty, add dummy data (%s).\n", "TV", tmp_buf);
+ }
+
+ //String8 l(vlang[i]);
+ for(i = 0; i < vpid.size(); i++) {
+ int i_pid = atoi(vpid[i]);
+ int i_fmt = atoi(vfmt[i]);
+ mvAudios.push_back(new Audio(i_pid, vlang[i], i_fmt));
+ }
+
+
+
+ /* parse subtitles */
+ vpid.clear();
+ vlang.clear();
+ Vector<String8> vcid;
+ Vector<String8> vaid;
+ String8 strCids;
+ String8 strAids;
+
+ col = c.getColumnIndex("sub_pids");
+ strPids = c.getString(col);
+
+ col = c.getColumnIndex("sub_composition_page_ids");
+ strCids = c.getString(col);
+
+ col = c.getColumnIndex("sub_ancillary_page_ids");
+ strAids = c.getString(col);
+
+
+ col = c.getColumnIndex("sub_langs");
+ strLangs = c.getString(col);
+
+ tmp = strtok(strPids.lockBuffer(strPids.length()), " ");
+ while (tmp != NULL) {
+ vpid.push_back(String8(tmp));
+ tmp = strtok(NULL, " ");
+ }
+ strPids.unlockBuffer();
+
+ tmp = strtok(strCids.lockBuffer(strCids.length()), " ");
+ while (tmp != NULL) {
+ vcid.push_back(String8(tmp));
+ tmp = strtok(NULL, " ");
+ }
+ strCids.unlockBuffer();
+
+ tmp = strtok(strAids.lockBuffer(strAids.length()), " ");
+ while (tmp != NULL) {
+ vaid.push_back(String8(tmp));
+ tmp = strtok(NULL, " ");
+ }
+ strAids.unlockBuffer();
+
+ tmp = strtok(strLangs.lockBuffer(strLangs.length()), " ");
+ while (tmp != NULL) {
+ vlang.push_back(String8(tmp));
+ tmp = strtok(NULL, " ");
+ }
+ strLangs.unlockBuffer();
+
+ //Subtitle
+ for(int i = 0; i < vpid.size(); i++) {
+ this->mvSubtitles.push_back(new Subtitle(
+ atoi(vpid[i]),
+ String8(vlang[i]), Subtitle::TYPE_DVB_SUBTITLE,
+ atoi(vcid[i]),
+ atoi(vaid[i])));
+ }
+
+ /* parse teletexts */
+ int ttx_count = 0, ttx_sub_count = 0;
+ String8 str_ttx_pids, str_ttx_types, str_mag_nos, str_page_nos, str_ttx_langs;
+ Vector<String8> v_ttx_pids, v_ttx_types, v_mag_nos, v_page_nos, v_ttx_langs;
+ col = c.getColumnIndex("ttx_pids");
+ str_ttx_pids = c.getString(col);
+
+ col = c.getColumnIndex("ttx_types");
+ str_ttx_types = c.getString(col);
+
+ col = c.getColumnIndex("ttx_magazine_nos");
+ str_mag_nos = c.getString(col);
+
+ col = c.getColumnIndex("ttx_page_nos");
+ str_page_nos = c.getString(col);
+
+ col = c.getColumnIndex("ttx_langs");
+ str_ttx_langs = c.getString(col);
+
+ tmp = strtok(str_ttx_pids.lockBuffer(str_ttx_pids.length()), " ");
+ while (tmp != NULL) {
+ v_ttx_pids.push_back(String8(tmp));
+ tmp = strtok(NULL, " ");
+ }
+ str_ttx_pids.unlockBuffer();
+
+ tmp = strtok(str_ttx_types.lockBuffer(str_ttx_types.length()), " ");
+ while (tmp != NULL) {
+ v_ttx_types.push_back(String8(tmp));
+ tmp = strtok(NULL, " ");
+ }
+ str_ttx_types.unlockBuffer();
+
+ tmp = strtok(str_mag_nos.lockBuffer(str_mag_nos.length()), " ");
+ while (tmp != NULL) {
+ v_mag_nos.push_back(String8(tmp));
+ tmp = strtok(NULL, " ");
+ }
+ str_mag_nos.unlockBuffer();
+
+ tmp = strtok(str_page_nos.lockBuffer(str_page_nos.length()), " ");
+ while (tmp != NULL) {
+ v_page_nos.push_back(String8(tmp));
+ tmp = strtok(NULL, " ");
+ }
+ str_page_nos.unlockBuffer();
+
+ tmp = strtok(str_ttx_langs.lockBuffer(str_ttx_langs.length()), " ");
+ while (tmp != NULL) {
+ v_ttx_langs.push_back(String8(tmp));
+ tmp = strtok(NULL, " ");
+ }
+ str_ttx_langs.unlockBuffer();
+
+
+ for(int i = 0; i < v_ttx_pids.size(); i++) {
+ int ttype = atoi(v_ttx_types[i]);
+ if (ttype == 0x2 || ttype == 0x5) {
+ this->mvSubtitles.push_back(new Subtitle(
+ atoi(v_ttx_pids[i].string()),
+ String8(v_ttx_langs[i]), Subtitle::TYPE_DTV_TELETEXT,
+ atoi(v_mag_nos[i]),
+ atoi(v_page_nos[i])));
+ } else {
+ this->mvTeletexts.push_back(new Teletext(
+ atoi(v_ttx_pids[i]),
+ String8(v_ttx_langs[i]),
+ atoi(v_mag_nos[i]),
+ atoi(v_page_nos[i])));
+ }
+ }
+ return 0;
+}
+
+int CTvProgram::selectProgramInChannelByNumber(int channelID, int num, CTvDatabase::Cursor &c)
+{
+ String8 cmd = String8("select * from srv_table where db_ts_id = ") + String8::format("%d", channelID) + String8(" and ");
+ cmd += String8("chan_num = ") + String8::format("%d", num);
+ return CTvDatabase::GetTvDb()->select(cmd, c);
+}
+
+
+int CTvProgram::selectProgramInChannelByNumber(int channelID, int major, int minor, CTvDatabase::Cursor &c)
+{
+ String8 cmd = String8("select * from srv_table where db_ts_id = ") + String8::format("%d", channelID) + String8(" and ");
+ cmd += String8("major_chan_num = ") + String8::format("%d", major) + String8(" and minor_chan_num = ") + String8::format("%d", minor);
+
+ return CTvDatabase::GetTvDb()->select(cmd, c);
+}
+
+/**
+ *向数据库添加一个Program,not atscMode
+ */
+CTvProgram::CTvProgram(int channelID, int type, int num, int skipFlag)
+{
+ CTvChannel channel;
+ int ret = CTvChannel::selectByID(channelID, channel);
+ if (ret != 0) {
+ //Log.d(TAG, "Cannot add new program, invalid channel id "+channelID);
+ this->id = -1;
+ } else {
+ CTvDatabase::Cursor c ;
+ selectProgramInChannelByNumber(channelID, num, c);
+
+ if(c.moveToFirst()) {
+ /*Construct*/
+ CreateFromCursor(c);
+ } else {
+ String8 tpids = String8(""), ttypes = String8(""), tmagnums = String8(""), tpgnums = String8(""), tlangs = String8("");
+ String8 spids = String8(""), stypes = String8(""), scpgids = String8(""), sapgids = String8(""), slangs = String8("");
+
+ /*add a new atv program to database*/
+ String8 cmd = String8("insert into srv_table(db_net_id,db_ts_id,service_id,src,name,service_type,");
+ cmd += String8("eit_schedule_flag,eit_pf_flag,running_status,free_ca_mode,volume,aud_track,vid_pid,");
+ cmd += String8("vid_fmt,aud_pids,aud_fmts,aud_langs,skip,lock,chan_num,major_chan_num,");
+ cmd += String8("minor_chan_num,access_controlled,hidden,hide_guide,source_id,favor,current_aud,");
+ cmd += String8("current_sub,sub_pids,sub_types,sub_composition_page_ids,sub_ancillary_page_ids,sub_langs,");
+ cmd += String8("current_ttx,ttx_pids,ttx_types,ttx_magazine_nos,ttx_page_nos,ttx_langs,");
+ cmd += String8("db_sat_para_id,scrambled_flag,lcn,hd_lcn,sd_lcn,default_chan_num,chan_order) ");
+ cmd += String8("values(-1,") + String8::format("%d", channelID) + String8(",65535,") + String8::format("%d", channel.getMode()) + String8(",'',") + String8::format("%d", type) + String8(",");
+ cmd += String8("0,0,0,0,0,0,8191,");
+ int chanNum = num;
+ int majorNum = 0;
+ cmd += String8("-1,'','','',") + String8::format("%d", skipFlag) + String8(",0,") + String8::format("%d", chanNum) + String8(",") + String8::format("%d", majorNum) + String8(",");
+ cmd += String8("") + /*num.getMinor()*/String8("0") + String8(",0,0,0,-1,0,-1,");
+ cmd += String8("-1,'") + spids + String8("','") + stypes + String8("','") + scpgids + String8("','") + sapgids + String8("','") + slangs + String8("',");
+ cmd += String8("-1,'") + tpids + String8("','") + ttypes + String8("','") + tmagnums + String8("','") + tpgnums + String8("','") + tlangs + String8("',");
+ cmd += String8("-1,0,-1,-1,-1,-1,0)");
+ CTvDatabase::GetTvDb()->exeSql(cmd.string());
+
+ CTvDatabase::Cursor cr;
+ selectProgramInChannelByNumber(channelID, num, cr);
+ if(cr.moveToFirst()) {
+ /*Construct*/
+ CreateFromCursor(cr);
+ } else {
+ /*A critical error*/
+ //Log.d(TAG, "Cannot add new program, sqlite error");
+ this->id = -1;
+ }
+ cr.close();
+ }
+ c.close();
+ }
+
+}
+
+
+/**
+ *向数据库添加一个Program,atscMode
+ */
+CTvProgram::CTvProgram(int channelID, int type, int major, int minor, int skipFlag)
+{
+ CTvChannel channel;
+ int ret = CTvChannel::selectByID(channelID, channel);
+ if (ret != 0) {
+ //Log.d(TAG, "Cannot add new program, invalid channel id "+channelID);
+ this->id = -1;
+ } else {
+ CTvDatabase::Cursor c ;
+ selectProgramInChannelByNumber(channelID, major, minor, c);
+
+ if(c.moveToFirst()) {
+ /*Construct*/
+ CreateFromCursor(c);
+ } else {
+ String8 tpids = String8(""), ttypes = String8(""), tmagnums = String8(""), tpgnums = String8(""), tlangs = String8("");
+ String8 spids = String8(""), stypes = String8(""), scpgids = String8(""), sapgids = String8(""), slangs = String8("");
+
+ /*add a new atv program to database*/
+ String8 cmd = String8("insert into srv_table(db_net_id,db_ts_id,service_id,src,name,service_type,");
+ cmd += String8("eit_schedule_flag,eit_pf_flag,running_status,free_ca_mode,volume,aud_track,vid_pid,");
+ cmd += String8("vid_fmt,aud_pids,aud_fmts,aud_langs,skip,lock,chan_num,major_chan_num,");
+ cmd += String8("minor_chan_num,access_controlled,hidden,hide_guide,source_id,favor,current_aud,");
+ cmd += String8("current_sub,sub_pids,sub_types,sub_composition_page_ids,sub_ancillary_page_ids,sub_langs,");
+ cmd += String8("current_ttx,ttx_pids,ttx_types,ttx_magazine_nos,ttx_page_nos,ttx_langs,");
+ cmd += String8("db_sat_para_id,scrambled_flag,lcn,hd_lcn,sd_lcn,default_chan_num,chan_order) ");
+ cmd += String8("values(-1,") + String8::format("%d", channelID) + String8(",65535,") + String8::format("%d", channel.getMode()) + String8(",'',") + String8::format("%d", type) + String8(",");
+ cmd += String8("0,0,0,0,0,0,8191,");
+ int chanNum = major << 16 | minor;
+ int majorNum = major;
+ cmd += String8("-1,'','','',") + String8::format("%d", skipFlag) + String8(",0,") + String8::format("%d", chanNum) + String8(",") + String8::format("%d", majorNum) + String8(",");
+ cmd += String8("") + String8::format("%d", minor) + String8(",0,0,0,-1,0,-1,");
+ cmd += String8("-1,'") + spids + String8("','") + stypes + String8("','") + scpgids + String8("','") + sapgids + String8("','") + slangs + String8("',");
+ cmd += String8("-1,'") + tpids + String8("','") + ttypes + String8("','") + tmagnums + String8("','") + tpgnums + String8("','") + tlangs + String8("',");
+ cmd += String8("-1,0,-1,-1,-1,-1,0)");
+ CTvDatabase::GetTvDb()->exeSql(cmd.string());
+
+ CTvDatabase::Cursor cr;
+ selectProgramInChannelByNumber(channelID, major, minor, cr);
+ if(cr.moveToFirst()) {
+ /*Construct*/
+ CreateFromCursor(cr);
+ } else {
+ /*A critical error*/
+ //Log.d(TAG, "Cannot add new program, sqlite error");
+ this->id = -1;
+ }
+ cr.close();
+ }
+ c.close();
+ }
+
+}
+/**
+ *根据记录ID查找指定TVProgram
+*/
+
+int CTvProgram::selectByID(int id, CTvProgram &prog)
+{
+
+ CTvDatabase::Cursor c;
+ String8 sql;
+ sql = String8("select * from srv_table where srv_table.db_id = ") + String8::format("%d", id);
+ CTvDatabase::GetTvDb()->select(sql.string(), c) ;
+ if(c.moveToFirst()) {
+ prog.CreateFromCursor(c);
+ } else {
+ c.close();
+ return -1;
+ }
+ c.close();
+ return 0;
+}
+
+int CTvProgram::updateVolComp(int progID, int volValue)
+{
+ String8 cmd = String8("update srv_table set volume = ") + String8::format("%d", volValue) +
+ String8(" where srv_table.db_id = ") + String8::format("%d", progID);
+ LOGD("%s, cmd = %s\n", "TV", cmd.string());
+ CTvDatabase::GetTvDb()->exeSql(cmd.string());
+
+ return 0;
+}
+
+int CTvProgram::getChannel(CTvChannel &c)
+{
+ return CTvChannel::selectByID(channelID, c);
+}
+
+int CTvProgram::upDateChannel(CTvChannel &c, int std, int Freq, int fineFreq)
+{
+ return CTvChannel::updateByID(channelID, std, Freq, fineFreq);
+}
+
+int CTvProgram::deleteChannelsProgram(CTvChannel &c)
+{
+ String8 cmd;
+ cmd = String8("delete from srv_table where srv_table.db_ts_id = ") + String8::format("%d", c.getID());
+ CTvDatabase::GetTvDb()->exeSql(cmd.string());
+ return 0;
+}
+
+
+/**
+ *根据节目类型和节目号查找指定TVProgram
+*/
+int CTvProgram::selectByNumber(int type, int num, CTvProgram &prog)
+{
+ String8 cmd;
+
+ cmd = String8("select * from srv_table where ");
+ if(type != TYPE_UNKNOWN) {
+ if(type == TYPE_DTV) {
+ cmd += String8("(service_type = ") + String8::format("%d", TYPE_TV) + String8(" or service_type = ") + String8::format("%d", TYPE_RADIO) + String8(") and ");
+ } else {
+ cmd += String8("service_type = ") + String8::format("%d", type) + String8(" and ");
+ }
+ }
+
+ cmd += String8("chan_num = ") + String8::format("%d", num);
+
+ CTvDatabase::Cursor c;
+ CTvDatabase::GetTvDb()->select(cmd, c);
+
+ if(c.moveToFirst()) {
+ prog.CreateFromCursor(c);
+ } else {
+ c.close();
+ return -1;
+ }
+ c.close();
+
+ return 0;
+}
+
+/**
+ *根据节目类型和节目号查找指定TVProgram
+*/
+int CTvProgram::selectByNumber(int type, int major, int minor, CTvProgram &prog, int minor_check)
+{
+ String8 cmd;
+
+ cmd = String8("select * from srv_table where ");
+ if(type != TYPE_UNKNOWN) {
+ if(type == TYPE_DTV) {
+ cmd += String8("(service_type = ") + String8::format("%d", TYPE_TV) + String8(" or service_type = ") + String8::format("%d", TYPE_RADIO) + String8(") and ");
+ } else {
+ cmd += String8("service_type = ") + String8::format("%d", type) + String8(" and ");
+ }
+ }
+
+ if (minor < 0) {
+ /*recursive call*/
+ /*select dtv program first*/
+ //showbo
+ int ret = selectByNumber(TYPE_DTV, major, 1, prog, MINOR_CHECK_NEAREST_UP);
+ if (ret != 0) {
+ /*then try atv program*/
+ selectByNumber(TYPE_ATV, major, 0 , prog, MINOR_CHECK_NONE);
+ }
+ return 0;
+ } else if (minor >= 1) {
+ if (minor_check == MINOR_CHECK_UP) {
+ cmd += String8("major_chan_num = ") + String8::format("%d", major) + String8(" and minor_chan_num >= ") + String8::format("%d", minor) + String8(" ");
+ cmd += String8("order by minor_chan_num DESC limit 1");
+ } else if (minor_check == MINOR_CHECK_DOWN) {
+ cmd += String8("major_chan_num = ") + String8::format("%d", major) + String8(" and minor_chan_num <= ") + String8::format("%d", minor) + String8(" ");
+ cmd += String8("order by minor_chan_num limit 1");
+ } else if (minor_check == MINOR_CHECK_NEAREST_UP) {
+ cmd += String8("major_chan_num = ") + String8::format("%d", major) + String8(" and minor_chan_num >= ") + String8::format("%d", minor) + String8(" ");
+ cmd += String8("order by minor_chan_num limit 1");
+ } else if (minor_check == MINOR_CHECK_NEAREST_DOWN) {
+ cmd += String8("major_chan_num = ") + String8::format("%d", major) + String8(" and minor_chan_num <= ") + String8::format("%d", minor) + String8(" ");
+ cmd += String8("order by minor_chan_num DESC limit 1");
+ } else {
+ cmd += String8("major_chan_num = ") + String8::format("%d", major) + String8(" and minor_chan_num = ") + String8::format("%d", minor);
+ }
+ } else {
+ cmd += String8("major_chan_num = ") + String8::format("%d", major) + String8(" and minor_chan_num = ") + String8::format("%d", minor);
+ }
+
+
+ CTvDatabase::Cursor c;
+ CTvDatabase::GetTvDb()->select(cmd, c);
+
+ if(c.moveToFirst()) {
+ prog.CreateFromCursor(c);
+ } else {
+ c.close();
+ return -1;
+ }
+ c.close();
+
+ return 0;
+}
+
+
+/**
+ *列出一个channel的全部TVProgram
+ *@param channelID channel id
+ *@param type 节目类型
+ */
+int CTvProgram::selectByChannel(int channelID, int type, Vector<sp<CTvProgram> > &out)
+{
+
+ //Vector<CTvProgram*> vp;
+ String8 cmd = String8("select * from srv_table ");
+
+
+ if(type == TYPE_DTV) {
+ cmd += String8("where (service_type = ") + String8::format("%d", TYPE_TV) + String8(" or service_type = ") + String8::format("%d", TYPE_RADIO) + String8(") ");
+ } else if(type != TYPE_UNKNOWN) {
+ cmd += String8("where service_type = ") + String8::format("%d", type) + String8(" ");
+ }
+
+ cmd += String8(" and db_ts_id = ") + String8::format("%d", channelID) + String8(" order by chan_order");
+
+ CTvDatabase::Cursor c;
+ int ret = CTvDatabase::GetTvDb()->select(cmd, c);
+
+ LOGD("selectByChannel select ret = %d", ret);
+
+ if(c.moveToFirst()) {
+ do {
+ out.add(new CTvProgram(c));
+ } while(c.moveToNext());
+ }
+ c.close();
+
+ return 0;
+}
+
+void CTvProgram::deleteProgram(int progId)
+{
+ String8 cmd;
+
+ cmd = String8("delete from srv_table where srv_table.db_id = ") + String8::format("%d", progId);
+ CTvDatabase::GetTvDb()->exeSql(cmd.string());
+}
+
+int CTvProgram::CleanAllProgramBySrvType(int srvType)
+{
+ String8 cmd = String8("delete from srv_table where service_type = ") + String8::format("%d", srvType);
+ CTvDatabase::GetTvDb()->exeSql(cmd.string());
+ return 0;
+}
+
+int CTvProgram::selectByType(int type, int skip, Vector<sp<CTvProgram> > &out)
+{
+ String8 cmd = String8("select * from srv_table ");
+ LOGD("%s, type= %d\n", "TV", (int)type);
+
+ if (type == TYPE_UNKNOWN) {
+ cmd += String8("where (service_type = ") + String8::format("%d", TYPE_ATV) +
+ String8(" or service_type = ") + String8::format("%d", TYPE_DTV) +
+ String8(" or service_type = ") + String8::format("%d", TYPE_RADIO) +
+ String8(") ");
+ } else {
+ cmd += String8("where service_type = ") + String8::format("%d", type) + String8(" ");
+ }
+
+ if(skip == PROGRAM_SKIP_NO || skip == PROGRAM_SKIP_YES)
+ cmd += String8(" and skip = ") + String8::format("%d", skip) + String8(" ");
+
+ cmd += String8(" order by chan_order");
+
+ CTvDatabase::Cursor c;
+ int ret = CTvDatabase::GetTvDb()->select(cmd, c);
+
+ LOGD("selectByChannel select ret = %d", ret);
+
+ if(c.moveToFirst()) {
+ do {
+ out.add(new CTvProgram(c));
+ } while(c.moveToNext());
+ }
+ c.close();
+
+ return 0;
+}
+
+int CTvProgram::selectByChanID(int type, int skip, Vector < sp < CTvProgram > > &out)
+{
+ String8 cmd = String8("select * from srv_table ");
+
+ if (type == TYPE_UNKNOWN) {
+ cmd += String8("where (service_type = ") + String8::format("%d", TYPE_ATV) +
+ String8(" or service_type = ") + String8::format("%d", TYPE_DTV) +
+ String8(") ");
+ } else {
+ cmd += String8("where service_type = ") + String8::format("%d", type) + String8(" ");
+ }
+
+ if(skip == PROGRAM_SKIP_NO || skip == PROGRAM_SKIP_YES)
+ cmd += String8(" and skip = ") + String8::format("%d", PROGRAM_SKIP_NO) +
+ String8(" or skip = ") + String8::format("%d", PROGRAM_SKIP_YES) + String8(" ");
+
+ cmd += String8(" order by db_id");
+
+ CTvDatabase::Cursor c;
+ int ret = CTvDatabase::GetTvDb()->select(cmd, c);
+
+ if(c.moveToFirst()) {
+ do {
+ out.add(new CTvProgram(c));
+ } while(c.moveToNext());
+ }
+ c.close();
+
+ return 0;
+
+}
+
+int CTvProgram::selectAll(bool no_skip, Vector<sp<CTvProgram> > &out)
+{
+ return selectByType(TYPE_UNKNOWN, no_skip, out);
+}
+
+Vector<CTvProgram> CTvProgram::selectByChannel(int channelID)
+{
+ Vector<CTvProgram> vProg;
+ return vProg;
+}
+
+Vector<CTvProgram> CTvProgram::selectByName(int name)
+{
+ Vector<CTvProgram> vProg;
+ return vProg;
+}
+
+void CTvProgram::tvProgramDelByChannelID(int channelID)
+{
+
+}
+
+
+String8 CTvProgram::getName()
+{
+ return name;
+}
+int CTvProgram::getProgSkipFlag()
+{
+ return skip;
+}
+
+/**
+ *取得当前的audio索引
+ *@param defaultLang 用户未选择语言时,默认的全局语言
+ *@return 当前的Audio索引
+ */
+int CTvProgram::getCurrentAudio(String8 defaultLang)
+{
+ CTvDatabase::Cursor c;
+ String8 cmd;
+ cmd = String8("select current_aud from srv_table where db_id = ") + String8::format("%d", this->id);
+ int ret = CTvDatabase::GetTvDb()->select(cmd, c);
+ LOGD("getCurrentAudio a size = %d", mvAudios.size());
+ int id = 0;
+ if(c.moveToFirst()) {
+ id = c.getInt(0);
+ LOGD("getCurrentAudio a id = %d", id);
+ if (id < 0 && mvAudios.size() > 0) {
+ LOGD("getCurrentAudio defaultLang.isEmpty() =%s= %d", defaultLang.string(), defaultLang.isEmpty());
+ if(!defaultLang.isEmpty()) {
+ for(int i = 0; i < mvAudios.size(); i++) {
+ LOGD("getCurrentAudio a mvAudios[i] = %d", mvAudios[i]);
+ if(mvAudios[i]->getLang() == defaultLang) {
+ id = i;
+ break;
+ }
+ }
+ }
+
+ if (id < 0) {
+ /* still not found, using the first */
+ id = 0;
+ }
+ }
+ }
+ LOGD("getCurrentAudio a idsss = %d", id);
+ c.close();
+
+ return id;
+}
+
+int CTvProgram::getCurrAudioTrackIndex()
+{
+ int audTrackIdx = -1;
+
+ if(-1 == currAudTrackIndex) { // no set field "current_aud"
+ audTrackIdx = getCurrentAudio(String8("eng"));
+ setCurrAudioTrackIndex(this->id, audTrackIdx);
+ } else {
+ audTrackIdx = currAudTrackIndex;
+ }
+
+ return audTrackIdx;
+}
+
+
+void CTvProgram::setCurrAudioTrackIndex(int programId, int audioIndex)
+{
+ String8 cmd;
+
+ cmd = String8("update srv_table set current_aud = ")
+ + String8::format("%d", audioIndex) + String8(" where srv_table.db_id = ") + String8::format("%d", programId);
+
+ CTvDatabase::GetTvDb()->exeSql(cmd.string());
+}
+
+void CTvProgram::setFavoriteFlag(int progId, bool bFavor)
+{
+ String8 cmd;
+
+ cmd = String8("update srv_table set favor = ")
+ + String8::format("%d", bFavor ? 1 : 0) + String8(" where srv_table.db_id = ") + String8::format("%d", progId);
+
+ CTvDatabase::GetTvDb()->exeSql(cmd.string());
+
+}
+
+void CTvProgram::setSkipFlag(int progId, bool bSkipFlag)
+{
+ String8 cmd;
+
+ cmd = String8("update srv_table set skip = ") + String8::format("%d", bSkipFlag ? 1 : 0)
+ + String8(" where srv_table.db_id = ") + String8::format("%d", progId);
+
+ CTvDatabase::GetTvDb()->exeSql(cmd.string());
+}
+
+void CTvProgram::updateProgramName(int progId, String8 strName)
+{
+ String8 newName = String8("xxx") + strName;
+ String8 cmd;
+
+ cmd = String8("update srv_table set name =") + "\'" + String8::format("%s", newName.string()) + "\'"
+ + String8(" where srv_table.db_id = ") + String8::format("%d", progId);
+
+ CTvDatabase::GetTvDb()->exeSql(cmd.string());
+}
+
+void CTvProgram::swapChanOrder(int ProgId1, int chanOrderNum1, int ProgId2, int chanOrderNum2)
+{
+ String8 cmd;
+
+ cmd = String8("update srv_table set chan_order = ") + String8::format("%d", chanOrderNum2)
+ + String8(" where db_id = ") + String8::format("%d", ProgId1);
+ CTvDatabase::GetTvDb()->exeSql(cmd.string());
+
+ String8 cmd2;
+ cmd2 = String8("update srv_table set chan_order = ") + String8::format("%d", chanOrderNum1)
+ + String8(" where db_id = ") + String8::format("%d", ProgId2);
+ CTvDatabase::GetTvDb()->exeSql(cmd2.string());
+}
+
+
+void CTvProgram::setLockFlag(int progId, bool bLockFlag)
+{
+ String8 cmd;
+
+ cmd = String8("update srv_table set lock = ") + String8::format("%d", bLockFlag ? 1 : 0)
+ + String8(" where srv_table.db_id = ") + String8::format("%d", progId);
+
+ CTvDatabase::GetTvDb()->exeSql(cmd.string());
+}
+bool CTvProgram::getLockFlag()
+{
+ return lock;
+}
+