From dde5034234fad0f3caff0939c01ee20234f8a05e Mon Sep 17 00:00:00 2001 From: martii Date: Thu, 17 Apr 2014 16:23:36 +0200 Subject: [PATCH] movieplayer: use #defines from record.h for timeshift Conflicts: src/gui/movieplayer.cpp Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/540a060ba97d95b18bf3b102b7b36532730e551a Author: martii Date: 2014-04-17 (Thu, 17 Apr 2014) --- src/driver/record.h | 8 ++--- src/gui/moviebrowser.cpp | 7 ++-- src/gui/movieinfo.cpp | 70 ++++++++++++++++------------------------ src/gui/movieinfo.h | 3 +- src/gui/movieplayer.cpp | 49 ++++++++++++++-------------- 5 files changed, 59 insertions(+), 78 deletions(-) diff --git a/src/driver/record.h b/src/driver/record.h index 365d24f89..224241ae0 100644 --- a/src/driver/record.h +++ b/src/driver/record.h @@ -51,10 +51,10 @@ #define FILENAMEBUFFERSIZE 1024 #define RECORD_MAX_COUNT 8 -#define TSHIFT_MODE_OFF 0 -#define TSHIFT_MODE_TEMPORAER 1 -#define TSHIFT_MODE_PERMANET 2 -#define TSHIFT_MODE_PAUSE 3 +#define TSHIFT_MODE_OFF 0 +#define TSHIFT_MODE_TEMPORARY 1 +#define TSHIFT_MODE_PERMANENT 2 +#define TSHIFT_MODE_PAUSE 3 //FIXME enum record_error_msg_t diff --git a/src/gui/moviebrowser.cpp b/src/gui/moviebrowser.cpp index ad358f76e..810efa4c7 100644 --- a/src/gui/moviebrowser.cpp +++ b/src/gui/moviebrowser.cpp @@ -2313,7 +2313,7 @@ void CMovieBrowser::onDeleteFile(MI_MOVIE_INFO& movieSelectionHandler, bool skip unlink(fname.c_str()); CFile file_xml = movieSelectionHandler.file; - if(m_movieInfo.convertTs2XmlName(&file_xml.Name) == true) + if(m_movieInfo.convertTs2XmlName(file_xml.Name)) { //delFile(file_xml); unlink(file_xml.Name.c_str()); @@ -3452,7 +3452,6 @@ bool CMovieBrowser::getMovieInfoItem(MI_MOVIE_INFO& movie_info, MB_INFO_ITEM ite *item_string=""; tm* tm_tmp; - char text[20]; int i=0; int counter=0; @@ -3503,9 +3502,7 @@ bool CMovieBrowser::getMovieInfoItem(MI_MOVIE_INFO& movie_info, MB_INFO_ITEM ite if(movie_info.bookmarks.user[i].pos != 0) counter++; } - snprintf(text, 8,"%d",counter); - text[9] = 0; // just to make sure string is terminated - *item_string = text; + *item_string = to_string(counter);; break; case MB_INFO_QUALITY: // = 11, snprintf(str_tmp,MAX_STR_TMP,"%d",movie_info.quality); diff --git a/src/gui/movieinfo.cpp b/src/gui/movieinfo.cpp index 1ba69272e..248d438c5 100644 --- a/src/gui/movieinfo.cpp +++ b/src/gui/movieinfo.cpp @@ -80,27 +80,12 @@ CMovieInfo::~CMovieInfo() /************************************************************************ ************************************************************************/ -bool CMovieInfo::convertTs2XmlName(char *char_filename, int size) +bool CMovieInfo::convertTs2XmlName(std::string& filename) { - bool result = false; - std::string filename = char_filename; - if (convertTs2XmlName(&filename) == true) { - strncpy(char_filename, filename.c_str(), size-1); - char_filename[size - 1] = 0; - result = true; - } - return (result); -} - -/************************************************************************ - -************************************************************************/ -bool CMovieInfo::convertTs2XmlName(std::string * filename) -{ - size_t lastdot = filename->find_last_of("."); + size_t lastdot = filename.find_last_of("."); if (lastdot != string::npos) { - filename->erase(lastdot + 1); - filename->append("xml"); + filename.erase(lastdot + 1); + filename.append("xml"); return true; } return false; @@ -252,7 +237,7 @@ bool CMovieInfo::saveMovieInfo(MI_MOVIE_INFO & movie_info, CFile * file) if (file == NULL) { file_xml.Name = movie_info.file.Name; - result = convertTs2XmlName(&file_xml.Name); + result = convertTs2XmlName(file_xml.Name); } else { file_xml.Name = file->Name; } @@ -286,7 +271,7 @@ bool CMovieInfo::loadMovieInfo(MI_MOVIE_INFO * movie_info, CFile * file) if (file == NULL) { // if there is no give file, we use the file name from movie info but we have to convert the ts name to xml name first file_xml.Name = movie_info->file.Name; - result = convertTs2XmlName(&file_xml.Name); + result = convertTs2XmlName(file_xml.Name); } else { file_xml.Name = file->Name; } @@ -664,27 +649,28 @@ bool CMovieInfo::parseXmlQuickFix(char *text, MI_MOVIE_INFO * movie_info) while ((pos = find_next_char('<', text, pos, bytes)) != -1) { pos++; GET_XML_DATA_STRING(text, pos, MI_XML_TAG_CHANNELNAME, movie_info->epgChannel) - GET_XML_DATA_STRING(text, pos, MI_XML_TAG_EPGTITLE, movie_info->epgTitle) - GET_XML_DATA_LONG(text, pos, MI_XML_TAG_ID, movie_info->epgId) - GET_XML_DATA_STRING(text, pos, MI_XML_TAG_INFO1, movie_info->epgInfo1) - GET_XML_DATA_STRING(text, pos, MI_XML_TAG_INFO2, movie_info->epgInfo2) - GET_XML_DATA_LONG(text, pos, MI_XML_TAG_EPGID, movie_info->epgEpgId) - GET_XML_DATA_INT(text, pos, MI_XML_TAG_MODE, movie_info->epgMode) - GET_XML_DATA_INT(text, pos, MI_XML_TAG_VIDEOPID, movie_info->epgVideoPid) - GET_XML_DATA_INT(text, pos, MI_XML_TAG_VIDEOTYPE, movie_info->VideoType) - GET_XML_DATA_STRING(text, pos, MI_XML_TAG_NAME, movie_info->epgChannel) - GET_XML_DATA_INT(text, pos, MI_XML_TAG_VTXTPID, movie_info->epgVTXPID) - GET_XML_DATA_INT(text, pos, MI_XML_TAG_GENRE_MAJOR, movie_info->genreMajor) - GET_XML_DATA_INT(text, pos, MI_XML_TAG_GENRE_MINOR, movie_info->genreMinor) - GET_XML_DATA_STRING(text, pos, MI_XML_TAG_SERIE_NAME, movie_info->serieName) - GET_XML_DATA_INT(text, pos, MI_XML_TAG_LENGTH, movie_info->length) - GET_XML_DATA_STRING(text, pos, MI_XML_TAG_PRODUCT_COUNTRY, movie_info->productionCountry) - GET_XML_DATA_INT(text, pos, MI_XML_TAG_PRODUCT_DATE, movie_info->productionDate) - GET_XML_DATA_INT(text, pos, MI_XML_TAG_PARENTAL_LOCKAGE, movie_info->parentalLockAge) - GET_XML_DATA_INT(text, pos, MI_XML_TAG_QUALITIY, movie_info->quality) - GET_XML_DATA_INT(text, pos, MI_XML_TAG_QUALITY, movie_info->quality) - GET_XML_DATA_INT(text, pos, MI_XML_TAG_DATE_OF_LAST_PLAY, movie_info->dateOfLastPlay) - if (strncmp(&text[pos], MI_XML_TAG_AUDIOPIDS, sizeof(MI_XML_TAG_AUDIOPIDS) - 1) == 0) + GET_XML_DATA_STRING(text, pos, MI_XML_TAG_EPGTITLE, movie_info->epgTitle) + GET_XML_DATA_LONG(text, pos, MI_XML_TAG_ID, movie_info->epgId) + GET_XML_DATA_STRING(text, pos, MI_XML_TAG_INFO1, movie_info->epgInfo1) + GET_XML_DATA_STRING(text, pos, MI_XML_TAG_INFO2, movie_info->epgInfo2) + GET_XML_DATA_LONG(text, pos, MI_XML_TAG_EPGID, movie_info->epgEpgId) + GET_XML_DATA_INT(text, pos, MI_XML_TAG_MODE, movie_info->epgMode) + GET_XML_DATA_INT(text, pos, MI_XML_TAG_VIDEOPID, movie_info->epgVideoPid) + GET_XML_DATA_INT(text, pos, MI_XML_TAG_VIDEOTYPE, movie_info->VideoType) + GET_XML_DATA_STRING(text, pos, MI_XML_TAG_NAME, movie_info->epgChannel) + GET_XML_DATA_INT(text, pos, MI_XML_TAG_VTXTPID, movie_info->epgVTXPID) + GET_XML_DATA_INT(text, pos, MI_XML_TAG_GENRE_MAJOR, movie_info->genreMajor) + GET_XML_DATA_INT(text, pos, MI_XML_TAG_GENRE_MINOR, movie_info->genreMinor) + GET_XML_DATA_STRING(text, pos, MI_XML_TAG_SERIE_NAME, movie_info->serieName) + GET_XML_DATA_INT(text, pos, MI_XML_TAG_LENGTH, movie_info->length) + GET_XML_DATA_STRING(text, pos, MI_XML_TAG_PRODUCT_COUNTRY, movie_info->productionCountry) + GET_XML_DATA_INT(text, pos, MI_XML_TAG_PRODUCT_DATE, movie_info->productionDate) + GET_XML_DATA_INT(text, pos, MI_XML_TAG_PARENTAL_LOCKAGE, movie_info->parentalLockAge) + GET_XML_DATA_INT(text, pos, MI_XML_TAG_QUALITIY, movie_info->quality) + GET_XML_DATA_INT(text, pos, MI_XML_TAG_QUALITY, movie_info->quality) + GET_XML_DATA_INT(text, pos, MI_XML_TAG_DATE_OF_LAST_PLAY, movie_info->dateOfLastPlay) + + if (strncmp(&text[pos], MI_XML_TAG_AUDIOPIDS, sizeof(MI_XML_TAG_AUDIOPIDS) - 1) == 0) pos += sizeof(MI_XML_TAG_AUDIOPIDS); /* parse audio pids */ diff --git a/src/gui/movieinfo.h b/src/gui/movieinfo.h index 99be15e31..64fd90514 100644 --- a/src/gui/movieinfo.h +++ b/src/gui/movieinfo.h @@ -195,8 +195,7 @@ class CMovieInfo public: // Functions CMovieInfo(); ~CMovieInfo(); - bool convertTs2XmlName(std::string* filename); // convert a ts file name in .xml file name - bool convertTs2XmlName(char* filename,int size); // convert a ts file name in .xml file name + bool convertTs2XmlName(std::string& filename); // convert a ts file name in .xml file name bool loadMovieInfo(MI_MOVIE_INFO* movie_info, CFile* file = NULL ); // load movie information for the given .xml filename. If there is no filename, the filename (ts) from movie_info is converted to xml and used instead bool encodeMovieInfoXml(std::string* extMessage, MI_MOVIE_INFO * movie_info); // encode the movie_info structure to xml string bool saveMovieInfo(MI_MOVIE_INFO& movie_info, CFile* file = NULL ); // encode the movie_info structure to xml and save it to the given .xml filename. If there is no filename, the filename (ts) from movie_info is converted to xml and used instead diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index c0887d395..5490e310c 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -42,6 +42,8 @@ #include #include #include +#include +#include #include #include @@ -142,7 +144,7 @@ void CMoviePlayerGui::Init(void) filebrowser->Dirs_Selectable = true; speed = 1; - timeshift = 0; + timeshift = TSHIFT_MODE_OFF; numpida = 0; showStartingHint = false; @@ -240,13 +242,13 @@ int CMoviePlayerGui::exec(CMenuTarget * parent, const std::string & actionKey) else if (actionKey == "fileplayback") { } else if (actionKey == "timeshift") { - timeshift = 1; + timeshift = TSHIFT_MODE_TEMPORARY; } else if (actionKey == "ptimeshift") { - timeshift = 2; + timeshift = TSHIFT_MODE_PERMANENT; } else if (actionKey == "rtimeshift") { - timeshift = 3; + timeshift = TSHIFT_MODE_PAUSE; } #if 0 // TODO ? else if (actionKey == "bookmarkplayback") { @@ -286,8 +288,8 @@ int CMoviePlayerGui::exec(CMenuTarget * parent, const std::string & actionKey) CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO); - if (timeshift) { - timeshift = 0; + if (timeshift != TSHIFT_MODE_OFF){ + timeshift = TSHIFT_MODE_OFF; return menu_return::RETURN_EXIT_ALL; } return menu_ret; @@ -464,7 +466,7 @@ bool CMoviePlayerGui::SelectFile() printf("CMoviePlayerGui::SelectFile: isBookmark %d timeshift %d isMovieBrowser %d\n", isBookmark, timeshift, isMovieBrowser); wakeup_hdd(g_settings.network_nfs_recordingdir.c_str()); - if (timeshift) { + if (timeshift != TSHIFT_MODE_OFF) { t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID(); p_movie_info = CRecordManager::getInstance()->GetMovieInfo(live_channel_id); file_name = CRecordManager::getInstance()->GetFileName(live_channel_id) + ".ts"; @@ -608,7 +610,6 @@ bool CMoviePlayerGui::PlayBackgroundStart(const std::string &file, const std::st is_file_player = true; isHTTP = true; - file_name = file; pretty_name = name; @@ -685,9 +686,8 @@ bool CMoviePlayerGui::PlayFileStart(void) videoDecoder->setBlank(true); clearSubtitle(); - playback->Open(is_file_player ? PLAYMODE_FILE : PLAYMODE_TS); - printf("IS FILE PLAYER: %s\n", is_file_player ? "true": "false" ); + playback->Open(is_file_player ? PLAYMODE_FILE : PLAYMODE_TS); if (p_movie_info) { if (timeshift != TSHIFT_MODE_OFF) { @@ -721,7 +721,7 @@ bool CMoviePlayerGui::PlayFileStart(void) repeat_mode = (repeat_mode_enum) g_settings.movieplayer_repeat_on; playstate = CMoviePlayerGui::PLAY; CVFD::getInstance()->ShowIcon(FP_ICON_PLAY, true); - if (timeshift) { + if(timeshift != TSHIFT_MODE_OFF) { startposition = -1; int i; int towait = (timeshift == 1) ? TIMESHIFT_SECONDS+1 : TIMESHIFT_SECONDS; @@ -735,12 +735,12 @@ bool CMoviePlayerGui::PlayFileStart(void) usleep(20000); } - if (timeshift == 3) { + if (timeshift == TSHIFT_MODE_PAUSE) { startposition = duration; } else { if (g_settings.timeshift_pause) playstate = CMoviePlayerGui::PAUSE; - if (timeshift == 1) + if (timeshift == TSHIFT_MODE_TEMPORARY) startposition = 0; else startposition = duration - TIMESHIFT_SECONDS*1000; @@ -751,7 +751,7 @@ bool CMoviePlayerGui::PlayFileStart(void) playback->SetPosition(startposition, true); /* playback->Start() starts paused */ - if (timeshift == 3) { + if (timeshift == TSHIFT_MODE_PAUSE) { speed = -1; playback->SetSpeed(-1); playstate = CMoviePlayerGui::REW; @@ -759,7 +759,7 @@ bool CMoviePlayerGui::PlayFileStart(void) FileTime.switchMode(position, duration); time_forced = true; } - } else if (!timeshift || !g_settings.timeshift_pause) { + } else if (timeshift == TSHIFT_MODE_OFF || !g_settings.timeshift_pause) { playback->SetSpeed(1); } } @@ -799,7 +799,7 @@ void CMoviePlayerGui::PlayFileLoop(void) neutrino_msg_data_t data; g_RCInput->getMsg(&msg, &data, 10); // 1 secs.. - if ((playstate >= CMoviePlayerGui::PLAY) && (timeshift || (playstate != CMoviePlayerGui::PAUSE))) { + if ((playstate >= CMoviePlayerGui::PLAY) && (timeshift != TSHIFT_MODE_OFF || (playstate != CMoviePlayerGui::PAUSE))) { if (playback->GetPosition(position, duration)) { FileTime.update(position, duration); if (duration > 100) @@ -818,7 +818,7 @@ void CMoviePlayerGui::PlayFileLoop(void) #endif /* in case ffmpeg report incorrect values */ int posdiff = duration - position; - if ((posdiff > 0) && (posdiff < 2000) && !timeshift) + if ((posdiff > 0) && (posdiff < 1000) && timeshift == TSHIFT_MODE_OFF) { int delay = (filelist_it != filelist.end()) ? 5 : 10; if (++eof > delay) { @@ -838,7 +838,7 @@ void CMoviePlayerGui::PlayFileLoop(void) g_PluginList->startPlugin_by_name(g_settings.movieplayer_plugin.c_str ()); } else if (msg == (neutrino_msg_t) g_settings.mpkey_stop) { bool stop_it = true; - if ((timeshift) && (g_settings.temp_timeshift)) + if ((timeshift != TSHIFT_MODE_OFF) && (g_settings.temp_timeshift)) stop_it = (ShowMsg(LOCALE_RECORDINGMENU_MULTIMENU_TIMESHIFT, LOCALE_RECORDINGMENU_MULTIMENU_TIMESHIFT_STOP, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, false) == CMessageBox::mbrYes); if (stop_it) playstate = CMoviePlayerGui::STOPPED; @@ -859,7 +859,7 @@ void CMoviePlayerGui::PlayFileLoop(void) playstate = CMoviePlayerGui::STOPPED; --filelist_it; } - } else if (!timeshift && !isWebTV /* && !isYT */ && (msg == (neutrino_msg_t) g_settings.mpkey_next_repeat_mode)) { + } else if (timeshift == TSHIFT_MODE_OFF && !isWebTV /* && !isYT */ && (msg == (neutrino_msg_t) g_settings.mpkey_next_repeat_mode)) { repeat_mode = (repeat_mode_enum)((int)repeat_mode + 1); if (repeat_mode > (int) REPEAT_ALL) repeat_mode = REPEAT_OFF; @@ -875,7 +875,7 @@ void CMoviePlayerGui::PlayFileLoop(void) speed = 1; playback->SetSpeed(speed); updateLcd(); - if (!timeshift) + if (timeshift == TSHIFT_MODE_OFF) callInfoViewer(); } } else if (msg == (neutrino_msg_t) g_settings.mpkey_pause) { @@ -891,9 +891,8 @@ void CMoviePlayerGui::PlayFileLoop(void) playback->SetSpeed(speed); } updateLcd(); - if (!timeshift) + if (timeshift == TSHIFT_MODE_OFF) callInfoViewer(); - } else if (msg == (neutrino_msg_t) g_settings.mpkey_bookmark) { if (is_file_player) selectChapter(); @@ -933,7 +932,7 @@ void CMoviePlayerGui::PlayFileLoop(void) FileTime.switchMode(position, duration); time_forced = true; } - if (!timeshift) + if (timeshift == TSHIFT_MODE_OFF) callInfoViewer(); } else if (msg == CRCInput::RC_1) { // Jump Backwards 1 minute SetPosition(-60 * 1000); @@ -978,7 +977,7 @@ void CMoviePlayerGui::PlayFileLoop(void) callInfoViewer(); update_lcd = true; clearSubtitle(); - } else if (timeshift && (msg == CRCInput::RC_text || msg == CRCInput::RC_epg || msg == NeutrinoMessages::SHOW_EPG)) { + } else if (timeshift != TSHIFT_MODE_OFF && (msg == CRCInput::RC_text || msg == CRCInput::RC_epg || msg == NeutrinoMessages::SHOW_EPG)) { bool restore = FileTime.IsVisible(); FileTime.kill(); @@ -1080,7 +1079,7 @@ void CMoviePlayerGui::PlayFileEnd(bool restore) void CMoviePlayerGui::callInfoViewer() { - if (timeshift) { + if (timeshift != TSHIFT_MODE_OFF) { g_InfoViewer->showTitle(CNeutrinoApp::getInstance()->channelList->getActiveChannelNumber(), CNeutrinoApp::getInstance()->channelList->getActiveChannelName(), CNeutrinoApp::getInstance()->channelList->getActiveSatellitePosition(),