From 5e5e5c4fbc228625f40c2d503515879f69c05062 Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Mon, 20 Dec 2021 18:42:58 +0100 Subject: [PATCH] extend detection of isHD and isUHD in case of stored EPG info (event) is missing any information regarding video (e.g. if EPG is missing on a channel) --- coreengine/listelements.c | 10 ++++- coreengine/viewdetail.c | 4 +- coreengine/viewelement.c | 63 +++++++++++++++++++++++----- coreengine/viewelement.h | 4 +- coreengine/viewelementsdisplaymenu.c | 8 +++- 5 files changed, 71 insertions(+), 18 deletions(-) diff --git a/coreengine/listelements.c b/coreengine/listelements.c index c38d65f..14eb7ba 100644 --- a/coreengine/listelements.c +++ b/coreengine/listelements.c @@ -207,8 +207,8 @@ tokenContainer->AddStringToken((int)token_st::shorttext, info->ShortText()); \ tokenContainer->AddStringToken((int)token_st::description, info->Description()); \ tokenContainer->AddIntToken((int)token_it::framesPerSecond, info->FramesPerSecond()); \ - tokenContainer->AddIntToken((int)token_it::isHD, RecordingIsHD(event)); /* detect HD from 'info' */ \ - tokenContainer->AddIntToken((int)token_it::isUHD, RecordingIsUHD(event)); /* detect UHD from 'info' */ \ + tokenContainer->AddIntToken((int)token_it::isHD, RecordingIsHD(event, channelID)); /* detect HD from 'info' */ \ + tokenContainer->AddIntToken((int)token_it::isUHD, RecordingIsUHD(event, channelID)); /* detect UHD from 'info' */ \ tokenContainer->AddIntToken((int)token_it::isRadio, RecordingIsRadio(event, info->FramesPerSecond())); /* detect Radio from 'info' and FPS */ \ tokenContainer->AddIntToken((int)token_it::isRecording, usedRecording->IsInUse() & ruTimer); \ tokenContainer->AddIntToken((int)token_it::isInUse, usedRecording->IsInUse()); \ @@ -2018,6 +2018,7 @@ bool cLeMenuRecordings::Parse(bool forced) { const cEvent *event = NULL; const cRecordingInfo *info = usedRecording->Info(); + tChannelID channelID = tChannelID::InvalidID; if (!info) { delete[] recName; @@ -2035,6 +2036,7 @@ bool cLeMenuRecordings::Parse(bool forced) { if (info->ChannelName() && (strlen(info->ChannelName()) > 0)) { ADD_TOKEN_LMR_ST(recchannelname, info->ChannelName()); ADD_TOKEN_LMR_ST(recchannelid, info->ChannelID().ToString()); + channelID = info->ChannelID(); } else { #if defined (APIVERSNUM) && (APIVERSNUM >= 20301) LOCK_CHANNELS_READ; @@ -2045,6 +2047,7 @@ bool cLeMenuRecordings::Parse(bool forced) { if (channel) { ADD_TOKEN_LMR_ST(recchannelname, channel->Name()); ADD_TOKEN_LMR_ST(recchannelid, *channel->GetChannelID().ToString()); + channelID = channel->GetChannelID(); } } } @@ -2246,6 +2249,7 @@ bool cCeMenuRecordings::Parse(bool forced) { const cEvent *event = NULL; const cRecordingInfo *info = usedRecording->Info(); + tChannelID channelID = tChannelID::InvalidID; if (!info) return true; event = info->GetEvent(); @@ -2255,6 +2259,7 @@ bool cCeMenuRecordings::Parse(bool forced) { if (info->ChannelName() && (strlen(info->ChannelName()) > 0)) { ADD_TOKEN_CMR_ST(recchannelname, info->ChannelName()); ADD_TOKEN_CMR_ST(recchannelid, info->ChannelID().ToString()); + channelID = info->ChannelID(); } else { #if defined (APIVERSNUM) && (APIVERSNUM >= 20301) LOCK_CHANNELS_READ; @@ -2265,6 +2270,7 @@ bool cCeMenuRecordings::Parse(bool forced) { if (channel) { ADD_TOKEN_CMR_ST(recchannelname, channel->Name()); ADD_TOKEN_CMR_ST(recchannelid, *channel->GetChannelID().ToString()); + channelID = channel->GetChannelID(); } } } diff --git a/coreengine/viewdetail.c b/coreengine/viewdetail.c index 9b741eb..4b33d4e 100644 --- a/coreengine/viewdetail.c +++ b/coreengine/viewdetail.c @@ -705,8 +705,8 @@ bool cViewDetailRec::Parse(bool forced) { tokenContainer->AddIntToken((int)eDmDetailedRecIT::durationevent, duration); tokenContainer->AddIntToken((int)eDmDetailedRecIT::durationeventhours, duration / 60); tokenContainer->AddStringToken((int)eDmDetailedRecST::durationeventminutes, *cString::sprintf("%.2d", duration%60)); - tokenContainer->AddIntToken((int)eDmDetailedRecIT::isHD, RecordingIsHD(event)); // detect HD from 'info' - tokenContainer->AddIntToken((int)eDmDetailedRecIT::isUHD, RecordingIsUHD(event)); // detect UHD from 'info' + tokenContainer->AddIntToken((int)eDmDetailedRecIT::isHD, RecordingIsHD(event, tChannelID::InvalidID)); // detect HD from 'info', no fallback to channelID + tokenContainer->AddIntToken((int)eDmDetailedRecIT::isUHD, RecordingIsUHD(event, tChannelID::InvalidID)); // detect UHD from 'info', no fallback to channelID tokenContainer->AddIntToken((int)eDmDetailedRecIT::isRadio, RecordingIsRadio(event, info->FramesPerSecond())); // detect Radio from 'info' and FPS tokenContainer->AddIntToken((int)eDmDetailedRecIT::isRecording, recording->IsInUse() & ruTimer); tokenContainer->AddIntToken((int)eDmDetailedRecIT::isInUse, recording->IsInUse()); diff --git a/coreengine/viewelement.c b/coreengine/viewelement.c index a9405cd..43fb8c3 100644 --- a/coreengine/viewelement.c +++ b/coreengine/viewelement.c @@ -587,18 +587,19 @@ void cViewElement::StopAnimation(void) { /****************************************************************** * helper function (did not find any other common place) ******************************************************************/ -bool RecordingIsHD(const cEvent* event) { +bool RecordingIsHD(const cEvent* event, const tChannelID channelID) { // detect HD from 'info' bool isHD = false; - cComponents *Components = (cComponents *)event->Components(); - if (Components) { + int type = -1; + + if (event) { + cComponents *Components = (cComponents *)event->Components(); + if (Components) { // detect HD (see also ETSI EN 300 468) // Stream: 1 = MPEG2-Video, 2 = MPEG2 Audio, 3 = Untertitel, 4 = AC3-Audio, 5 = H.264-Video, 6 = HEAAC-Audio, 7 = DTS/DTS HD audio, 8 = SRM/CPCM data, 9 = HEVC Video, AC4 Audio // Stream == Video(1|5): 01 = 05 = 4:3, 02 = 03 = 06 = 07 = 16:9, 04 = 08 = >16:9, 09 = 0D = HD 4:3, 0A = 0B = 0E = 0F = HD 16:9, 0C = 10 = HD >16:9 tComponent *Component; - int type = -1; - // #1: HVEC (stream content: 9) Component = Components->GetComponent(0, 9, 0); // recording info: "X 9 " if (Component) { @@ -628,22 +629,45 @@ bool RecordingIsHD(const cEvent* event) { case 0x10: isHD = true; }; + }; }; + + if ((isHD == false) && (type == -1) && (!(channelID == tChannelID::InvalidID))) { + dsyslog("skindesigner: Title='%s' ShortText='%s' isHD=%d type=%d channelID=%s", event->Title(), event->ShortText(), isHD, type, *channelID.ToString()); + // fallback to retrieve via channel (in case of EPG issues) +#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) + LOCK_CHANNELS_READ; + const cChannel *channel = Channels->GetByChannelID(channelID); +#else + const cChannel *channel = Channels.GetByChannelID(channelID); +#endif + if (channel) { + dsyslog("skindesigner: Title='%s' ShortText='%s' isHD=%d type=%d Channel='%s'", event->Title(), event->ShortText(), isHD, type, channel->Name()); + switch (channel->Vtype()) { + case 0x1b: // H.264 + case 0x24: // H.265 + isHD = true; + break; + }; + }; + }; + return isHD; }; -bool RecordingIsUHD(const cEvent* event) { +bool RecordingIsUHD(const cEvent* event, const tChannelID channelID) { // detect UHD from 'info' bool isUHD = false; - cComponents *Components = (cComponents *)event->Components(); - if (Components) { + int type = -1; + + if (event) { + cComponents *Components = (cComponents *)event->Components(); + if (Components) { // detect UHD (see also ETSI EN 300 468) // Stream: 9 = HEVC Video, AC4 Audio // Stream == Video(9): 00|01|02|03 = HD, 04|05|06|07 = UHD tComponent *Component; - int type = -1; - // HVEC (stream content: 9) Component = Components->GetComponent(0, 9, 0); // recording info: "X 9 " if (Component) { @@ -657,7 +681,26 @@ bool RecordingIsUHD(const cEvent* event) { case 0x07: isUHD = true; }; + }; }; + + if ((isUHD == false) && (type == -1) && (!(channelID == tChannelID::InvalidID))) { + // fallback to retrieve via channel (in case of EPG issues) +#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) + LOCK_CHANNELS_READ; + const cChannel *channel = Channels->GetByChannelID(channelID); +#else + const cChannel *channel = Channels.GetByChannelID(channelID); +#endif + if (channel) { + switch (channel->Vtype()) { + case 0x24: // H.265 + isUHD = true; + break; + }; + }; + }; + return isUHD; }; diff --git a/coreengine/viewelement.h b/coreengine/viewelement.h index ed37e1d..86b8afd 100644 --- a/coreengine/viewelement.h +++ b/coreengine/viewelement.h @@ -113,8 +113,8 @@ public: /****************************************************************** * helper function (did not find any other common place) ******************************************************************/ -bool RecordingIsHD(const cEvent* event); -bool RecordingIsUHD(const cEvent* event); +bool RecordingIsHD(const cEvent* event, const tChannelID channelID); +bool RecordingIsUHD(const cEvent* event, const tChannelID channelID); bool RecordingIsRadio(const cEvent* event, const double FramesPerSecond); #endif //__VIEWELEMENT_H diff --git a/coreengine/viewelementsdisplaymenu.c b/coreengine/viewelementsdisplaymenu.c index 710cec6..5bef17a 100644 --- a/coreengine/viewelementsdisplaymenu.c +++ b/coreengine/viewelementsdisplaymenu.c @@ -1236,6 +1236,7 @@ bool cVeDmDetailheaderRec::Parse(bool forced) { #endif tokenContainer->AddIntToken((int)eDmDetailedHeaderRecIT::errors, errors); const cEvent *event = info->GetEvent(); + tChannelID channelID = tChannelID::InvalidID; if (event) { cString recDate = event->GetDateString(); cString recTime = event->GetTimeString(); @@ -1260,8 +1261,6 @@ bool cVeDmDetailheaderRec::Parse(bool forced) { tokenContainer->AddIntToken((int)eDmDetailedHeaderRecIT::durationevent, duration); tokenContainer->AddIntToken((int)eDmDetailedHeaderRecIT::durationeventhours, duration / 60); tokenContainer->AddStringToken((int)eDmDetailedHeaderRecST::durationeventminutes, *cString::sprintf("%.2d", duration%60)); - tokenContainer->AddIntToken((int)eDmDetailedHeaderRecIT::isHD, RecordingIsHD(event)); // detect HD from 'info' - tokenContainer->AddIntToken((int)eDmDetailedHeaderRecIT::isUHD, RecordingIsUHD(event)); // detect UHD from 'info' tokenContainer->AddIntToken((int)eDmDetailedHeaderRecIT::isRadio, RecordingIsRadio(event, info->FramesPerSecond())); // detect Radio from 'info' and FPS tokenContainer->AddIntToken((int)eDmDetailedHeaderRecIT::isRecording, recording->IsInUse() & ruTimer); tokenContainer->AddIntToken((int)eDmDetailedHeaderRecIT::isInUse, recording->IsInUse()); @@ -1271,6 +1270,7 @@ bool cVeDmDetailheaderRec::Parse(bool forced) { tokenContainer->AddStringToken((int)eDmDetailedHeaderRecST::recchannelname, info->ChannelName()); tokenContainer->AddStringToken((int)eDmDetailedHeaderRecST::recchannelid, info->ChannelID().ToString()); tokenContainer->AddIntToken((int)eDmDetailedHeaderRecIT::recchannelnumber, 0); // cannot be provided, for backward compatibility only + channelID = info->ChannelID(); } else { #if defined (APIVERSNUM) && (APIVERSNUM >= 20301) LOCK_CHANNELS_READ; @@ -1282,8 +1282,12 @@ bool cVeDmDetailheaderRec::Parse(bool forced) { tokenContainer->AddStringToken((int)eDmDetailedHeaderRecST::recchannelname, channel->Name()); tokenContainer->AddStringToken((int)eDmDetailedHeaderRecST::recchannelid, *channel->GetChannelID().ToString()); tokenContainer->AddIntToken((int)eDmDetailedHeaderRecIT::recchannelnumber, channel->Number()); + channelID = channel->GetChannelID(); } } + + tokenContainer->AddIntToken((int)eDmDetailedHeaderRecIT::isHD, RecordingIsHD(event, channelID)); // detect HD from 'info' + tokenContainer->AddIntToken((int)eDmDetailedHeaderRecIT::isUHD, RecordingIsUHD(event, channelID)); // detect UHD from 'info' } string recImage = ""; string path = recording->FileName() ? recording->FileName() : "";