mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-28 07:51:19 +02:00
*neutrino record: reworked some code parts from last multirec commits
- avoids using of boolean structures for record modes calls, handling of enum calls from record manager class should be easier - remove boolean structure from infoviewer - use commonly member name for count of recordings, GetRecordCount should be more plausible than GetRecmapSize git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-beta@1693 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
@@ -73,6 +73,7 @@ bool sectionsd_getComponentTagsUniqueKey(const event_id_t uniqueKey, CSectionsdC
|
||||
|
||||
extern "C" {
|
||||
#include <driver/genpsi.h>
|
||||
#include "record.h"
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
@@ -682,6 +683,24 @@ const std::string CRecordManager::GetFileName(t_channel_id channel_id)
|
||||
return filename;
|
||||
}
|
||||
|
||||
int CRecordManager::GetRecordMode()
|
||||
{
|
||||
if (RecordingStatus() || IsTimeshift())
|
||||
{
|
||||
int records = GetRecmapSize();
|
||||
if (RecordingStatus() && !IsTimeshift())
|
||||
return RECMODE_REC;
|
||||
else if (IsTimeshift() && (records == 1))
|
||||
return RECMODE_TSHIFT;
|
||||
else if (IsTimeshift() && (records > 1))
|
||||
return RECMODE_REC_TSHIFT;
|
||||
else
|
||||
return RECMODE_OFF;
|
||||
}
|
||||
else
|
||||
return RECMODE_OFF;
|
||||
}
|
||||
|
||||
bool CRecordManager::Record(const t_channel_id channel_id, const char * dir, bool timeshift)
|
||||
{
|
||||
CTimerd::RecordingInfo eventinfo;
|
||||
@@ -708,7 +727,7 @@ bool CRecordManager::Record(const t_channel_id channel_id, const char * dir, boo
|
||||
|
||||
bool CRecordManager::Record(const CTimerd::RecordingInfo * const eventinfo, const char * dir, bool timeshift)
|
||||
{
|
||||
CRecordInstance * inst;
|
||||
CRecordInstance * inst = NULL;
|
||||
record_error_msg_t error_msg = RECORD_OK;
|
||||
/* for now, empty eventinfo.recordingDir means this is direct record, FIXME better way ?
|
||||
* neutrino check if this channel_id already recording, may be not needed */
|
||||
@@ -751,7 +770,9 @@ bool CRecordManager::Record(const CTimerd::RecordingInfo * const eventinfo, cons
|
||||
else
|
||||
newdir = Directory;
|
||||
|
||||
inst = new CRecordInstance(eventinfo, newdir, timeshift, StreamVTxtPid, StreamPmtPid);
|
||||
if (inst == NULL)
|
||||
inst = new CRecordInstance(eventinfo, newdir, timeshift, StreamVTxtPid, StreamPmtPid);
|
||||
|
||||
error_msg = inst->Record();
|
||||
if(error_msg == RECORD_OK) {
|
||||
recmap.insert(std::pair<t_channel_id, CRecordInstance*>(eventinfo->channel_id, inst));
|
||||
@@ -782,7 +803,7 @@ bool CRecordManager::Record(const CTimerd::RecordingInfo * const eventinfo, cons
|
||||
RunStopScript();
|
||||
RestoreNeutrino();
|
||||
|
||||
printf("%s: error code: %d\n", __FUNCTION__, error_msg);
|
||||
printf("[recordmanager] %s: error code: %d\n", __FUNCTION__, error_msg);
|
||||
//FIXME: Use better error message
|
||||
DisplayErrorMessage(g_Locale->getText(
|
||||
error_msg == RECORD_BUSY ? LOCALE_STREAMING_BUSY :
|
||||
@@ -1099,7 +1120,7 @@ int CRecordManager::exec(CMenuTarget* parent, const std::string & actionKey )
|
||||
char rec_msg[256];
|
||||
char rec_msg1[256];
|
||||
int records = recmap.size();
|
||||
int i = 0;
|
||||
|
||||
snprintf(rec_msg1, sizeof(rec_msg1)-1, "%s", g_Locale->getText(LOCALE_RECORDINGMENU_MULTIMENU_ASK_STOP_ALL));
|
||||
snprintf(rec_msg, sizeof(rec_msg)-1, rec_msg1, records);
|
||||
if(ShowMsgUTF(LOCALE_SHUTDOWN_RECODING_QUERY, rec_msg,
|
||||
@@ -1109,6 +1130,7 @@ int CRecordManager::exec(CMenuTarget* parent, const std::string & actionKey )
|
||||
snprintf(rec_msg, sizeof(rec_msg)-1, rec_msg1, records);
|
||||
CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, rec_msg);
|
||||
hintBox->paint();
|
||||
int i = 0;
|
||||
int recording_ids[RECORD_MAX_COUNT];
|
||||
t_channel_id channel_ids[RECORD_MAX_COUNT];
|
||||
t_channel_id channel_id;
|
||||
@@ -1167,7 +1189,7 @@ int CRecordManager::exec(CMenuTarget* parent, const std::string & actionKey )
|
||||
|
||||
bool CRecordManager::ShowMenu(void)
|
||||
{
|
||||
int select = -1, i = 0, shortcut = 1, recmap_size = recmap.size();
|
||||
int select = -1, recmap_size = recmap.size();
|
||||
char cnt[5];
|
||||
CMenuForwarderNonLocalized * item;
|
||||
CMenuForwarder * iteml;
|
||||
@@ -1189,11 +1211,13 @@ bool CRecordManager::ShowMenu(void)
|
||||
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));
|
||||
mutex.lock();
|
||||
|
||||
int i = 0 , shortcut = 1;
|
||||
for(recmap_iterator_t it = recmap.begin(); it != recmap.end(); it++) {
|
||||
t_channel_id channel_id = it->first;
|
||||
CRecordInstance * inst = it->second;
|
||||
|
@@ -104,7 +104,7 @@ class CRecordInstance
|
||||
record_error_msg_t MakeFileName(CZapitChannel * channel);
|
||||
bool SaveXml();
|
||||
record_error_msg_t Start(CZapitChannel * channel /*, APIDList &apid_list*/);
|
||||
public:
|
||||
public:
|
||||
CRecordInstance(const CTimerd::RecordingInfo * const eventinfo, std::string &dir, bool timeshift = false, bool stream_vtxt_pid = false, bool stream_pmt_pid = false);
|
||||
~CRecordInstance();
|
||||
|
||||
@@ -156,6 +156,14 @@ class CRecordManager : public CMenuTarget, public CChangeObserver
|
||||
void SetTimeshiftMode(CRecordInstance * inst=NULL, int mode=TSHIFT_MODE_OFF);
|
||||
|
||||
public:
|
||||
enum record_modes_t
|
||||
{
|
||||
RECMODE_OFF = 0,
|
||||
RECMODE_REC = 1,
|
||||
RECMODE_TSHIFT = 2,
|
||||
RECMODE_REC_TSHIFT = 3,
|
||||
};
|
||||
|
||||
CRecordManager();
|
||||
~CRecordManager();
|
||||
|
||||
@@ -198,8 +206,9 @@ class CRecordManager : public CMenuTarget, public CChangeObserver
|
||||
int recordingstatus;
|
||||
bool doGuiRecord();
|
||||
bool changeNotify(const neutrino_locale_t OptionName, void * /*data*/);
|
||||
int GetRecmapSize() { return recmap.size(); };
|
||||
int GetRecordCount() { return recmap.size(); };
|
||||
bool IsTimeshift(t_channel_id channel_id=0);
|
||||
void StartTimeshift();
|
||||
int GetRecordMode();
|
||||
};
|
||||
#endif
|
||||
|
@@ -289,48 +289,51 @@ void CInfoViewer::paintTime (bool show_dot, bool firstPaint)
|
||||
void CInfoViewer::showRecordIcon (const bool show)
|
||||
{
|
||||
CRecordManager * crm = CRecordManager::getInstance();
|
||||
recordModeActive = crm->RecordingStatus() || crm->IsTimeshift();
|
||||
int rec_mode = crm->GetRecordMode();
|
||||
|
||||
recordModeActive = rec_mode != CRecordManager::RECMODE_OFF; /*crm->RecordingStatus() || crm->IsTimeshift();*/
|
||||
if (recordModeActive)
|
||||
{
|
||||
std::string Icon_Rec = NEUTRINO_ICON_REC_GRAY, Icon_Ts = NEUTRINO_ICON_AUTO_SHIFT_GRAY;
|
||||
t_channel_id cci = g_RemoteControl->current_channel_id;
|
||||
bool status_ts = crm->IsTimeshift(cci);
|
||||
bool status_rec = crm->RecordingStatus(cci) && !status_ts;
|
||||
if (status_ts)
|
||||
Icon_Ts = NEUTRINO_ICON_AUTO_SHIFT;
|
||||
if (status_rec)
|
||||
Icon_Rec = NEUTRINO_ICON_REC;
|
||||
|
||||
if (rec_mode == CRecordManager::RECMODE_TSHIFT)
|
||||
Icon_Ts = NEUTRINO_ICON_AUTO_SHIFT;
|
||||
|
||||
if (rec_mode == CRecordManager::RECMODE_REC)
|
||||
Icon_Rec = NEUTRINO_ICON_REC;
|
||||
|
||||
int records = crm->GetRecmapSize();
|
||||
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;
|
||||
int records = crm->GetRecordCount();
|
||||
|
||||
const int radius = RADIUS_MIN;
|
||||
const int ChanName_X = BoxStartX + ChanWidth + SHADOW_OFFSET;
|
||||
const int icon_space = 3, box_posY = 12;
|
||||
int box_len = 0, rec_icon_posX = 0, ts_icon_posX = 0;
|
||||
|
||||
int rec_icon_w = 0, rec_icon_h = 0, ts_icon_w = 0, ts_icon_h = 0;
|
||||
frameBuffer->getIconSize(Icon_Rec.c_str(), &rec_icon_w, &rec_icon_h);
|
||||
frameBuffer->getIconSize(Icon_Ts.c_str(), &ts_icon_w, &ts_icon_h);
|
||||
int chanH = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight ()
|
||||
* (g_settings.screen_yres / 100);
|
||||
|
||||
int chanH = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight () * (g_settings.screen_yres / 100);
|
||||
if (chanH < rec_icon_h)
|
||||
chanH = rec_icon_h;
|
||||
const int box_posX = ChanName_X + SHADOW_OFFSET;
|
||||
|
||||
char records_msg[8];
|
||||
snprintf(records_msg, sizeof(records_msg)-1, "%d%s", records, "x");
|
||||
int TextWidth = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getRenderWidth(records_msg)
|
||||
* (g_settings.screen_xres / 100);
|
||||
if (modus_rec)
|
||||
|
||||
if (rec_mode == CRecordManager::RECMODE_REC)
|
||||
{
|
||||
box_len = rec_icon_w + TextWidth + icon_space*5;
|
||||
rec_icon_posX = box_posX + icon_space*2;
|
||||
}else if (modus_ts)
|
||||
}
|
||||
else if (rec_mode == CRecordManager::RECMODE_TSHIFT)
|
||||
{
|
||||
box_len = ts_icon_w + icon_space*4;
|
||||
ts_icon_posX = box_posX + icon_space*2;
|
||||
}else if (modus_ts_rec)
|
||||
}
|
||||
else if (rec_mode == CRecordManager::RECMODE_REC_TSHIFT)
|
||||
{
|
||||
box_len = ts_icon_w + rec_icon_w + TextWidth + icon_space*7;
|
||||
ts_icon_posX = box_posX + icon_space*2;
|
||||
@@ -338,30 +341,35 @@ void CInfoViewer::showRecordIcon (const bool show)
|
||||
records--;
|
||||
snprintf(records_msg, sizeof(records_msg)-1, "%d%s", records, "x");
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
if (rec_mode == CRecordManager::RECMODE_REC)
|
||||
{
|
||||
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)
|
||||
}
|
||||
else if (rec_mode == CRecordManager::RECMODE_TSHIFT)
|
||||
{
|
||||
frameBuffer->paintIcon(Icon_Ts, ts_icon_posX, BoxStartY + box_posY + (chanH - ts_icon_h)/2);
|
||||
}else if (modus_ts_rec)
|
||||
}
|
||||
else if (rec_mode == CRecordManager::RECMODE_REC_TSHIFT)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}else
|
||||
}
|
||||
else
|
||||
{
|
||||
if (modus_rec)
|
||||
if (rec_mode == CRecordManager::RECMODE_REC)
|
||||
frameBuffer->paintBoxRel(rec_icon_posX, BoxStartY + box_posY + (chanH - rec_icon_h)/2, rec_icon_w, rec_icon_h, COL_INFOBAR_PLUS_0);
|
||||
else if (modus_ts)
|
||||
else if (rec_mode == CRecordManager::RECMODE_TSHIFT)
|
||||
frameBuffer->paintBoxRel(ts_icon_posX, BoxStartY + box_posY + (chanH - ts_icon_h)/2, ts_icon_w, ts_icon_h, COL_INFOBAR_PLUS_0);
|
||||
else if (modus_ts_rec)
|
||||
else if (rec_mode == CRecordManager::RECMODE_REC_TSHIFT)
|
||||
frameBuffer->paintBoxRel(ts_icon_posX, BoxStartY + box_posY + (chanH - rec_icon_h)/2, ts_icon_w + rec_icon_w + icon_space*2, rec_icon_h, COL_INFOBAR_PLUS_0);
|
||||
}
|
||||
}
|
||||
|
@@ -109,11 +109,13 @@ CStreamInfo2::~CStreamInfo2 ()
|
||||
ts_close();
|
||||
}
|
||||
|
||||
void CStreamInfo2::exec()
|
||||
int CStreamInfo2::exec()
|
||||
{
|
||||
paint(paint_mode);
|
||||
doSignalStrengthLoop();
|
||||
hide();
|
||||
|
||||
return menu_return::RETURN_EXIT_ALL;
|
||||
}
|
||||
|
||||
int CStreamInfo2::exec (CMenuTarget * parent, const std::string &)
|
||||
@@ -125,7 +127,7 @@ int CStreamInfo2::exec (CMenuTarget * parent, const std::string &)
|
||||
paint (paint_mode);
|
||||
doSignalStrengthLoop ();
|
||||
hide ();
|
||||
return menu_return::RETURN_REPAINT;
|
||||
return menu_return::RETURN_EXIT_ALL;
|
||||
}
|
||||
|
||||
int CStreamInfo2::doSignalStrengthLoop ()
|
||||
@@ -197,7 +199,7 @@ int CStreamInfo2::doSignalStrengthLoop ()
|
||||
if(snrscale && sigscale)
|
||||
showSNR ();
|
||||
if(pmt_version != current_pmt_version && delay_counter > delay){
|
||||
current_pmt_version = pmt_version;
|
||||
current_pmt_version = pmt_version;
|
||||
paint_techinfo (x + 10, y+ hheight +5);
|
||||
}
|
||||
delay_counter++;
|
||||
@@ -280,7 +282,7 @@ void CStreamInfo2::paint_signal_fe_box(int _x, int _y, int w, int h)
|
||||
int y1;
|
||||
int xd = w/4;
|
||||
std::string tuner_name = g_Locale->getText(LOCALE_STREAMINFO_SIGNAL);
|
||||
tuner_name += ": ";
|
||||
tuner_name += ": ";
|
||||
tuner_name += CFrontend::getInstance()->getInfo()->name;
|
||||
g_Font[font_small]->RenderString(_x, _y+iheight+15, width-10, tuner_name.c_str(), COL_INFOBAR, 0, true);
|
||||
|
||||
@@ -889,7 +891,7 @@ void CStreamInfo2::paintCASystem(int xpos, int ypos)
|
||||
}
|
||||
}
|
||||
int spaceoffset = 0 ;
|
||||
|
||||
|
||||
for(i=0 ; i<11; i++){
|
||||
if(caids[i] == true)
|
||||
if(spaceoffset < array[i])
|
||||
@@ -969,7 +971,7 @@ int CStreamInfo2::ts_setup ()
|
||||
vpid = g_RemoteControl->current_PIDs.PIDs.vpid;
|
||||
if(g_RemoteControl->current_PIDs.APIDs.size() > 0)
|
||||
apid = g_RemoteControl->current_PIDs.APIDs[g_RemoteControl->current_PIDs.PIDs.selected_apid].pid;
|
||||
|
||||
|
||||
if(vpid == 0 && apid == 0)
|
||||
return -1;
|
||||
|
||||
|
@@ -103,7 +103,7 @@ class CStreamInfo2 : public CMenuTarget
|
||||
|
||||
CStreamInfo2();
|
||||
~CStreamInfo2();
|
||||
void exec();
|
||||
int exec();
|
||||
|
||||
void hide();
|
||||
int exec(CMenuTarget* parent, const std::string & actionKey);
|
||||
|
Reference in New Issue
Block a user