gui/movieplayer.cpp, neutrino.cpp: add webtv subtitles support

This commit is contained in:
[CST] Focus
2015-05-29 15:26:55 +03:00
parent d8dcb1da1b
commit 93a0327930
3 changed files with 28 additions and 6 deletions

View File

@@ -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 <libavcodec/avcodec.h>
}
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

View File

@@ -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

View File

@@ -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()