From 5c67dbb6f32c059f9d1f852f62ea78f810214c0d Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Fri, 29 May 2015 15:26:55 +0300 Subject: [PATCH] gui/movieplayer.cpp, neutrino.cpp: add webtv subtitles support Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/93a03279307d3df5dfbc520e4fa44df2dca1039f Author: [CST] Focus Date: 2015-05-29 (Fri, 29 May 2015) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/movieplayer.cpp | 17 ++++++++++++++--- src/gui/movieplayer.h | 7 ++++--- src/neutrino.cpp | 10 ++++++++++ 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index 2fba33cd5..9bdd39de5 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -163,6 +163,7 @@ void CMoviePlayerGui::Init(void) max_y = 0; ext_subs = false; iso_file = false; + lock_subs = false; bgThread = 0; info_1 = ""; info_2 = ""; @@ -619,7 +620,7 @@ void* CMoviePlayerGui::bgPlayThread(void *arg) eof++; else eof = 0; - if (eof > 2) { + if (eof > 5) { printf("CMoviePlayerGui::bgPlayThread: playback stopped, try to rezap...\n"); t_channel_id * chid = new t_channel_id; *chid = mp->movie_info.epgId; @@ -633,6 +634,7 @@ void* CMoviePlayerGui::bgPlayThread(void *arg) bgmutex.unlock(); if (res == 0) break; + mp->showSubtitle(0); } printf("%s: play end...\n", __func__); mp->PlayFileEnd(); @@ -1776,7 +1778,7 @@ extern "C" { #include } -void CMoviePlayerGui::clearSubtitle() +void CMoviePlayerGui::clearSubtitle(bool lock) { if ((max_x-min_x > 0) && (max_y-min_y > 0)) frameBuffer->paintBackgroundBoxRel(min_x, min_y, max_x-min_x, max_y-min_y); @@ -1786,6 +1788,7 @@ void CMoviePlayerGui::clearSubtitle() max_x = CFrameBuffer::getInstance()->getScreenX(); max_y = CFrameBuffer::getInstance()->getScreenY(); end_time = 0; + lock_subs = lock; } fb_pixel_t * simple_resize32(uint8_t * orgin, uint32_t * colors, int nb_colors, int ox, int oy, int dx, int dy); @@ -1824,6 +1827,15 @@ bool CMoviePlayerGui::convertSubtitle(std::string &text) void CMoviePlayerGui::showSubtitle(neutrino_msg_data_t data) { + AVSubtitle * sub = (AVSubtitle *) data; + if (lock_subs) { + if (sub) { + avsubtitle_free(sub); + delete sub; + } + return; + } + if (!data) { if (end_time && time_monotonic_ms() > end_time) { printf("************************* hide subs *************************\n"); @@ -1831,7 +1843,6 @@ void CMoviePlayerGui::showSubtitle(neutrino_msg_data_t data) } return; } - AVSubtitle * sub = (AVSubtitle *) data; printf("************************* EVT_SUBT_MESSAGE: num_rects %d fmt %d *************************\n", sub->num_rects, sub->format); #if 0 diff --git a/src/gui/movieplayer.h b/src/gui/movieplayer.h index 572efce5f..40dcd3a67 100644 --- a/src/gui/movieplayer.h +++ b/src/gui/movieplayer.h @@ -104,6 +104,7 @@ class CMoviePlayerGui : public CMenuTarget int min_x, min_y, max_x, max_y; time_t end_time; bool ext_subs; + bool lock_subs; /* playback from MB */ bool isMovieBrowser; @@ -161,10 +162,7 @@ class CMoviePlayerGui : public CMenuTarget bool SelectFile(); void updateLcd(); - void selectSubtitle(); bool convertSubtitle(std::string &text); - void showSubtitle(neutrino_msg_data_t data); - void clearSubtitle(); void selectChapter(); void selectAutoLang(); void parsePlaylist(CFile *file); @@ -205,6 +203,9 @@ class CMoviePlayerGui : public CMenuTarget void Pause(bool b = true); void selectAudioPid(); bool SetPosition(int pos, bool absolute = false); + void selectSubtitle(); + void showSubtitle(neutrino_msg_data_t data); + void clearSubtitle(bool lock = false); }; #endif diff --git a/src/neutrino.cpp b/src/neutrino.cpp index f76cf9064..2d66d6758 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -2358,6 +2358,9 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu) if (g_settings.recording_type != CNeutrinoApp::RECORDING_OFF) CRecordManager::getInstance()->exec(NULL, "Record"); } + else if ((mode == mode_webtv) && msg == (neutrino_msg_t) g_settings.mpkey_subtitle) { + CMoviePlayerGui::getInstance().selectSubtitle(); + } /* after sensitive key bind, check user menu */ else if (usermenu.showUserMenu(msg)) { } @@ -2687,6 +2690,9 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) } return messages_return::handled; } + if (mode == mode_webtv && msg == NeutrinoMessages::EVT_SUBT_MESSAGE) { + CMoviePlayerGui::getInstance().showSubtitle(data); + } if(msg == NeutrinoMessages::EVT_ZAP_COMPLETE) { CZapit::getInstance()->GetAudioMode(g_settings.audio_AnalogMode); if(g_settings.audio_AnalogMode < 0 || g_settings.audio_AnalogMode > 2) @@ -4270,6 +4276,8 @@ void CNeutrinoApp::StopSubtitles() tuxtx_pause_subtitle(true); frameBuffer->paintBackground(); } + if (mode == mode_webtv) + CMoviePlayerGui::getInstance().clearSubtitle(true); } void CNeutrinoApp::StartSubtitles(bool show) @@ -4279,6 +4287,8 @@ void CNeutrinoApp::StartSubtitles(bool show) return; dvbsub_start(0); tuxtx_pause_subtitle(false); + if (mode == mode_webtv) + CMoviePlayerGui::getInstance().clearSubtitle(false); } void CNeutrinoApp::SelectSubtitles()