fix detection of timeshifted channel

- trigger recording menu on first press of STOP button
- disable recording stop via REC button
- disable menu entry "record current channel" when current channel is already recorded
- disable menu entry "timeshift" when current channel is already recorded or timeshifted
- flag timeshifted channel with prefix "[TS]"

Big thanks to micha-bbg!

For reference: http://www.dbox2world.net/board293-coolstream-hd1/board314-coolstream-development/p133623-anzeige-f%C3%BCr-laufende-aufnahmen/#post133623

git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-beta@1638 e54a6e83-5905-42d5-8d5c-058d10e6a962


Origin commit data
------------------
Branch: ni/coolstream
Commit: a645062f6d
Author: gixxpunk <thomas.harfmann@gmail.com>
Date: 2011-08-30 (Tue, 30 Aug 2011)

Origin message was:
------------------
- fix detection of timeshifted channel
- trigger recording menu on first press of STOP button
- disable recording stop via REC button
- disable menu entry "record current channel" when current channel is already recorded
- disable menu entry "timeshift" when current channel is already recorded or timeshifted
- flag timeshifted channel with prefix "[TS]"

Big thanks to micha-bbg!

For reference: http://www.dbox2world.net/board293-coolstream-hd1/board314-coolstream-development/p133623-anzeige-f%C3%BCr-laufende-aufnahmen/#post133623

git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-beta@1638 e54a6e83-5905-42d5-8d5c-058d10e6a962


------------------
This commit was generated by Migit
This commit is contained in:
gixxpunk
2011-08-30 18:00:37 +00:00
parent 1a96b6b4b0
commit 38378ea206
4 changed files with 109 additions and 70 deletions

View File

@@ -98,6 +98,7 @@ CRecordInstance::CRecordInstance(const CTimerd::RecordingInfo * const eventinfo,
cMovieInfo = new CMovieInfo();
recMovieInfo = new MI_MOVIE_INFO();
record = NULL;
tshift_mode = TSHIFT_MODE_OFF;
}
CRecordInstance::~CRecordInstance()
@@ -670,19 +671,6 @@ CRecordInstance * CRecordManager::FindInstance(t_channel_id channel_id)
return NULL;
}
bool CRecordManager::IsTimeshift(t_channel_id channel_id)
{
bool ret;
mutex.lock();
CRecordInstance * inst = FindInstance(channel_id);
mutex.unlock();
if(inst && inst->Timeshift())
ret = true;
else
ret = false;
return ret;
}
MI_MOVIE_INFO * CRecordManager::GetMovieInfo(t_channel_id channel_id)
{
//FIXME copy MI_MOVIE_INFO ?
@@ -825,7 +813,7 @@ bool CRecordManager::StartAutoRecord()
bool CRecordManager::StopAutoRecord()
{
bool found;
bool found = false;
printf("%s: autoshift %d\n", __FUNCTION__, autoshift);
@@ -1037,6 +1025,81 @@ int CRecordManager::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data
return messages_return::unhandled;
}
bool CRecordManager::IsTimeshift(t_channel_id channel_id)
{
bool ret = false;
CRecordInstance * inst;
mutex.lock();
if (channel_id != 0)
{
inst = FindInstance(channel_id);
if(inst && inst->tshift_mode)
ret = true;
else
ret = false;
}else
{
for(recmap_iterator_t it = recmap.begin(); it != recmap.end(); it++)
{
inst = it->second;
if(inst && inst->tshift_mode)
{
mutex.unlock();
return true;
}
}
}
mutex.unlock();
return ret;
}
void CRecordManager::SetTimeshiftMode(CRecordInstance * inst, int mode)
{
CRecordInstance * tmp_inst;
mutex.lock();
for(recmap_iterator_t it = recmap.begin(); it != recmap.end(); it++)
{
tmp_inst = it->second;
if (tmp_inst)
tmp_inst->tshift_mode = TSHIFT_MODE_OFF;
}
mutex.unlock();
if (inst)
inst->tshift_mode = mode;
}
void CRecordManager::StartTimeshift()
{
if(g_RemoteControl->is_video_started)
{
std::string tmode;
bool res = true;
if(RecordingStatus(live_channel_id))
{
tmode = "ptimeshift"; // already recording, pause
SetTimeshiftMode(FindInstance(live_channel_id), TSHIFT_MODE_PAUSE);
}else
{
if(g_settings.temp_timeshift)
{
res = StartAutoRecord();
SetTimeshiftMode(FindInstance(live_channel_id), TSHIFT_MODE_TEMPORAER);
}else
{
res = Record(live_channel_id);
SetTimeshiftMode(FindInstance(live_channel_id), TSHIFT_MODE_PERMANET);
}
tmode = "timeshift"; // record just started
}
if(res)
{
CMoviePlayerGui::getInstance().exec(NULL, tmode);
if(g_settings.temp_timeshift)
ShowMenu();
}
}
}
int CRecordManager::exec(CMenuTarget* parent, const std::string & actionKey )
{
if(parent)
@@ -1100,31 +1163,12 @@ int CRecordManager::exec(CMenuTarget* parent, const std::string & actionKey )
}else if(actionKey == "Record")
{
printf("[neutrino] direct record\n");
if(CRecordManager::getInstance()->RecordingStatus(live_channel_id))
CRecordManager::getInstance()->AskToStop(live_channel_id);
else
if(!CRecordManager::getInstance()->RecordingStatus(live_channel_id))
CRecordManager::getInstance()->Record(live_channel_id);
return menu_return::RETURN_EXIT_ALL;
}else if(actionKey == "Timeshift")
{
if(g_RemoteControl->is_video_started)
{
std::string tmode;
bool res = true;
if(CRecordManager::getInstance()->RecordingStatus(live_channel_id))
{
tmode = "ptimeshift"; // already recording, pause
}else
{
if(g_settings.temp_timeshift)
res = CRecordManager::getInstance()->StartAutoRecord();
else
res = CRecordManager::getInstance()->Record(live_channel_id);
tmode = "timeshift"; // record just started
}
if(res)
CMoviePlayerGui::getInstance().exec(NULL, tmode);
}
StartTimeshift();
return menu_return::RETURN_EXIT_ALL;
}
@@ -1147,18 +1191,19 @@ bool CRecordManager::ShowMenu(void)
menu.addIntroItems(NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, CMenuWidget::BTN_TYPE_CANCEL);
// Record / Timeshift
iteml = new CMenuForwarder(LOCALE_RECORDINGMENU_MULTIMENU_REC_AKT, true, NULL,
bool status_ts = IsTimeshift(live_channel_id);
bool status_rec = RecordingStatus(live_channel_id) && !status_ts;
iteml = new CMenuForwarder(LOCALE_RECORDINGMENU_MULTIMENU_REC_AKT, (!status_rec && !status_ts), NULL,
this, "Record", CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED);
menu.addItem(iteml, false);
iteml = new CMenuForwarder(LOCALE_RECORDINGMENU_MULTIMENU_TIMESHIFT, true, NULL,
iteml = new CMenuForwarder(LOCALE_RECORDINGMENU_MULTIMENU_TIMESHIFT, !status_ts, NULL,
this, "Timeshift", CRCInput::RC_yellow, NEUTRINO_ICON_BUTTON_YELLOW);
menu.addItem(iteml, false);
if(recmap_size > 0)
{
menu.addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_MAINMENU_RECORDING_STOP));
//FIXME do we need "Start current channel record" menu point ?
mutex.lock();
for(recmap_iterator_t it = recmap.begin(); it != recmap.end(); it++) {
t_channel_id channel_id = it->first;
@@ -1167,7 +1212,13 @@ bool CRecordManager::ShowMenu(void)
channel_ids[i] = channel_id;
recording_ids[i] = inst->GetRecordingId();
std::string title;
inst->GetRecordString(title);
if (inst->tshift_mode)
{
std::string tmp_title;
inst->GetRecordString(tmp_title);
title = "[TS] " + tmp_title;
}else
inst->GetRecordString(title);
sprintf(cnt, "%d", i);
item = new CMenuForwarderNonLocalized(title.c_str(), true, NULL,
selector, cnt, CRCInput::convertDigitToKey((recmap_size == 1) ? 0 : shortcut++));

View File

@@ -51,6 +51,11 @@
#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
//FIXME
enum record_error_msg_t
{
@@ -114,6 +119,7 @@ class CRecordInstance
void GetRecordString(std::string& str);
const char * GetFileName() { return filename; };
bool Timeshift() { return autoshift; };
int tshift_mode;
};
typedef std::map<t_channel_id, CRecordInstance*> recmap_t;
@@ -147,6 +153,7 @@ class CRecordManager : public CMenuTarget, public CChangeObserver
void StartNextRecording();
void StopPostProcess();
CRecordInstance * FindInstance(t_channel_id);
void SetTimeshiftMode(CRecordInstance * inst=NULL, int mode=TSHIFT_MODE_OFF);
public:
CRecordManager();
@@ -192,6 +199,7 @@ class CRecordManager : public CMenuTarget, public CChangeObserver
bool doGuiRecord();
bool changeNotify(const neutrino_locale_t OptionName, void * /*data*/);
int GetRecmapSize() { return recmap.size(); };
bool IsTimeshift(t_channel_id channel_id);
bool IsTimeshift(t_channel_id channel_id=0);
void StartTimeshift();
};
#endif

View File

@@ -289,7 +289,7 @@ void CInfoViewer::paintTime (bool show_dot, bool firstPaint)
void CInfoViewer::showRecordIcon (const bool show)
{
CRecordManager * crm = CRecordManager::getInstance();
recordModeActive = crm->RecordingStatus() || crm->Timeshift();
recordModeActive = crm->RecordingStatus() || crm->IsTimeshift();
if (recordModeActive)
{
std::string Icon_Rec = NEUTRINO_ICON_REC_GRAY, Icon_Ts = NEUTRINO_ICON_AUTO_SHIFT_GRAY;
@@ -302,10 +302,10 @@ void CInfoViewer::showRecordIcon (const bool show)
Icon_Rec = NEUTRINO_ICON_REC;
int records = crm->GetRecmapSize();
bool modus_rec = crm->RecordingStatus() && !crm->Timeshift();
bool modus_ts = crm->Timeshift() && (records == 1);
bool modus_ts_rec = crm->Timeshift() && (records > 1);
//printf("\n##### ts %d - rec %d - ts_rec %d\n \n", modus_ts, modus_rec, modus_ts_rec);
bool modus_rec = crm->RecordingStatus() && !crm->IsTimeshift();
bool modus_ts = crm->IsTimeshift() && (records == 1);
bool modus_ts_rec = crm->IsTimeshift() && (records > 1);
int rec_icon_w = 0, rec_icon_h = 0, ts_icon_w = 0, ts_icon_h = 0;
const int radius = RADIUS_MIN;
const int ChanName_X = BoxStartX + ChanWidth + SHADOW_OFFSET;
@@ -340,21 +340,17 @@ void CInfoViewer::showRecordIcon (const bool show)
}
if (show)
{
frameBuffer->paintBoxRel(box_posX + SHADOW_OFFSET, BoxStartY + box_posY + SHADOW_OFFSET, box_len, chanH, COL_INFOBAR_SHADOW_PLUS_0, radius);
frameBuffer->paintBoxRel(box_posX, BoxStartY + box_posY , box_len, chanH, COL_INFOBAR_PLUS_0, radius);
if (modus_rec)
{
frameBuffer->paintBoxRel(box_posX + SHADOW_OFFSET, BoxStartY + box_posY + SHADOW_OFFSET, box_len, chanH, COL_INFOBAR_SHADOW_PLUS_0, radius);
frameBuffer->paintBoxRel(box_posX, BoxStartY + box_posY , box_len, chanH, COL_INFOBAR_PLUS_0, radius);
g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->RenderString (rec_icon_posX + rec_icon_w + icon_space, BoxStartY + box_posY + chanH, box_len, records_msg, COL_INFOBAR, 0, true);
frameBuffer->paintIcon(Icon_Rec, rec_icon_posX, BoxStartY + box_posY + (chanH - rec_icon_h)/2);
}else if (modus_ts)
{
frameBuffer->paintBoxRel(box_posX + SHADOW_OFFSET, BoxStartY + box_posY + SHADOW_OFFSET, box_len, chanH, COL_INFOBAR_SHADOW_PLUS_0, radius);
frameBuffer->paintBoxRel(box_posX, BoxStartY + box_posY , box_len, chanH, COL_INFOBAR_PLUS_0, radius);
frameBuffer->paintIcon(Icon_Ts, ts_icon_posX, BoxStartY + box_posY + (chanH - ts_icon_h)/2);
}else if (modus_ts_rec)
{
frameBuffer->paintBoxRel(box_posX + SHADOW_OFFSET, BoxStartY + box_posY + SHADOW_OFFSET, box_len, chanH, COL_INFOBAR_SHADOW_PLUS_0, radius);
frameBuffer->paintBoxRel(box_posX, BoxStartY + box_posY , box_len, chanH, COL_INFOBAR_PLUS_0, radius);
g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->RenderString(rec_icon_posX + rec_icon_w + icon_space, BoxStartY + box_posY + chanH, box_len, records_msg, COL_INFOBAR, 0, true);
frameBuffer->paintIcon(Icon_Rec, rec_icon_posX, BoxStartY + box_posY + (chanH - rec_icon_h)/2);
frameBuffer->paintIcon(Icon_Ts, ts_icon_posX, BoxStartY + box_posY + (chanH - ts_icon_h)/2);

View File

@@ -2304,21 +2304,7 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu)
g_PluginList->start_plugin_by_name(g_settings.onekey_plugin.c_str(), 0);
}
else if(msg == (neutrino_msg_t) g_settings.key_timeshift) {
if(g_RemoteControl->is_video_started) {
std::string tmode;
bool res = true;
if(CRecordManager::getInstance()->RecordingStatus(live_channel_id)) {
tmode = "ptimeshift"; // already recording, pause
} else {
if(g_settings.temp_timeshift)
res = CRecordManager::getInstance()->StartAutoRecord();
else
res = CRecordManager::getInstance()->Record(live_channel_id);
tmode = "timeshift"; // record just started
}
if(res)
CMoviePlayerGui::getInstance().exec(NULL, tmode);
}
CRecordManager::getInstance()->StartTimeshift();
}
else if(msg == CRCInput::RC_rewind) {
if(g_RemoteControl->is_video_started) {
@@ -2328,9 +2314,7 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu)
}
else if( msg == CRCInput::RC_record /* || msg == CRCInput::RC_stop*/ ) {
printf("[neutrino] direct record\n");
if(CRecordManager::getInstance()->RecordingStatus(live_channel_id)) {
CRecordManager::getInstance()->AskToStop(live_channel_id);
} else {
if(!CRecordManager::getInstance()->RecordingStatus(live_channel_id)) {
#if 0 // uncomment, if ChooseRecDir and g_settings.recording_choose_direct_rec_dir ever used to select recording dir
CRecordManager::getInstance()->recordingstatus = 1;
CRecordManager::getInstance()->doGuiRecord();