Skip to content

Commit

Permalink
full FrameParams in tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Ehrnsperger committed Jan 1, 2024
1 parent 7f253a0 commit 6f3025c
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 65 deletions.
10 changes: 10 additions & 0 deletions largeString.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ class cLargeString {
*(m_string_end++) = c;
return *this;
}
cLargeString &append(size_t count, char c) {
appendLen(count);
memset(m_string_end, c, count);
m_string_end += count;
return *this;
}
cLargeString &append(const char (&s)[1]) {
// note: every other specific implementation is too slow. memcpy is too fast :)
return *this;
Expand Down Expand Up @@ -116,6 +122,10 @@ template<typename T, std::enable_if_t<std::is_integral_v<T>, bool> = true>
const char *nameData() const { return m_nameData; }
int nameLen() const { return m_nameLen; }
};
template<typename T, std::enable_if_t<std::is_integral_v<T>, bool> = true>
void stringAppend(cLargeString &s, T i) {
s.append(i);
}

inline void append_csv(cLargeString &str, cSv s1) { str.append(s1); }
template<typename... Args>
Expand Down
8 changes: 4 additions & 4 deletions live/js/live/createHtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,19 +144,19 @@ function addColEventRec(s, times, eventprefix, eventid, title, folder, shortText
s.a += '</div>'
}

function injectHdSdIcon(elementId, sdhd, channelName) {
function injectHdSdIcon(elementId, sdhd, channelName, frameParams) {
const s = Object.create(null);
s.a = "";
addHdSdIcon(s, sdhd, channelName);
addHdSdIcon(s, sdhd, channelName, frameParams);
document.getElementById(elementId).innerHTML = s.a;
if (typeof liveEnhanced !== 'undefined') liveEnhanced.domReadySetup();
}

function injectErrorHdSdIcon(elementId, numErrors, durationDeviation, sdhd, channelName, duration, numTsFiles) {
function injectErrorHdSdIcon(elementId, numErrors, durationDeviation, sdhd, channelName, duration, numTsFiles, frameParams) {
const s = Object.create(null);
s.a = "";
addErrorIcon(s, numErrors, durationDeviation, duration, numTsFiles);
addHdSdIcon(s, sdhd, channelName);
addHdSdIcon(s, sdhd, channelName, frameParams);
document.getElementById(elementId).innerHTML = s.a;
if (typeof liveEnhanced !== 'undefined') liveEnhanced.domReadySetup();
}
Expand Down
2 changes: 1 addition & 1 deletion live/themes/veltliner/css/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ div.__progress div.__elapsed {
background-color: #FFCC00;
}
img.channel_logo {
background-color: #FFCC00;
background-color: #FFCC0000;
}


Expand Down
13 changes: 7 additions & 6 deletions pages/pageelems.ecpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,14 @@ function addErrorIcon(s, numErrors, durationDeviation, duration, numTsFiles) {
s.a += '\" /> </div>'
}

function addHdSdIcon(s, hdsd, toolTip) {
function addHdSdIcon(s, hdsd, toolTip, frameParams) {
s.a += '<div class=\"recording_sd_hd\"><img class=\"icon\" src=\"<$LiveSetup().GetThemedLinkPrefixImg()$>'
s.a += hdsd
s.a += '.png\" width = \"25px\" title=\"'
if (frameParams.length != 0) {
s.a += frameParams
s.a += '<$$lf$>'
}
s.a += toolTip
s.a += '\" /></div>'
}
Expand Down Expand Up @@ -234,7 +238,7 @@ function existingRecordingSR(s, col_span1, bottomrow, imdb_id, id, archiveDescr,
s.a += '<br/><table><tr><td class=\"noborder\">'
addErrorIcon(s, errors, durationDeviation, duration, numTsFiles)
s.a += '</td><td class=\"noborder\">'
addHdSdIcon(s, hd_sd, channel_name)
addHdSdIcon(s, hd_sd, channel_name, \"\")
s.a += '</td></tr></table>'
<%cpp>
#endif
Expand Down Expand Up @@ -581,12 +585,9 @@ if (LiveSetup().GetUseStreamdev() && LiveFeatures<features::streamdev_server>().
% if (detail > 1) {
<img data-src="img/transparent.png" height="10px" />
<span id="icons-<$epgid$>"></span>
<#
<img src="img/forceError.png" height="0.1px" onerror="injectHdSdIcon(&quot;icons-<$epgid$>&quot;, &quot;<$sdhd$>&quot;, &quot;<$(channel&&channel->Name())?channel->Name():""$>&quot;)"/>
#>
<%cpp> if (sdhd) { </%cpp>
<script class="injectIcons">
injectHdSdIcon(\"icons-<$epgid$>\", \"<$sdhd$>\", \"<$(channel&&channel->Name())?channel->Name():""$>\")
injectHdSdIcon(\"icons-<$epgid$>\", \"<$sdhd$>\", \"<$(channel&&channel->Name())?channel->Name():""$>\", \"\")
</script>
<%cpp>
}
Expand Down
7 changes: 5 additions & 2 deletions pages/recordings.ecpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ function RecordingActionS(s, id, A, Img, Title) {
// [19] : duration
// [20] : size
// [21] : numTsFiles
// [22] : frame parameter text
// befor calling, make sure that all recs[obj_i] exist!
#>
function RecordingsSt_int(s, level, displayFolder, data) {
Expand Down Expand Up @@ -225,7 +226,7 @@ function RecordingsSt_int(s, level, displayFolder, data) {
s.a += obj[20]
s.a += '</div></td><td>'
addErrorIcon(s, obj[10], obj[17], obj[19], obj[21])
addHdSdIcon(s, obj[11], obj[12])
addHdSdIcon(s, obj[11], obj[12], obj[22])
s.a += '</td>' // end column with error / sd/hd image
s.a += '<td><div class=\"recording_name'
s.a += obj[13]
Expand Down Expand Up @@ -723,7 +724,9 @@ if (recording && recording->Info() ) {
recordingErrors = recording->Info()->Errors();
#endif
const char *sdhd = nullptr;
cToSvConcat frameParams;
#if VDRVERSNUM >= 20605
StringAppendFrameParams(frameParams, recording);
switch (recording->Info()->FrameWidth()) {
case 720:
sdhd = "720x576";
Expand Down Expand Up @@ -754,7 +757,7 @@ if (recording && recording->Info() ) {
<img data-src="img/transparent.png" height="10px" />
<span id="icons-<$id$>"></span>
<script class="injectIcons">
injectErrorHdSdIcon(\"icons-<$id$>\", <$cSv(cToSvInt(recordingErrors))$>, <$cSv(cToSvInt(getScraperVideo.m_scraperVideo->getDurationDeviation()))$>, \"<$sdhd$>\", \"<$cSv(recording->Info()->ChannelName())$>\", \"<$duration$>\", <$ GetNumberOfTsFiles(recording) $>)
injectErrorHdSdIcon(\"icons-<$id$>\", <$cSv(cToSvInt(recordingErrors))$>, <$cSv(cToSvInt(getScraperVideo.m_scraperVideo->getDurationDeviation()))$>, \"<$sdhd$>\", \"<$cSv(recording->Info()->ChannelName())$>\", \"<$duration$>\", <$ GetNumberOfTsFiles(recording) $>, \"<$frameParams$>\")
</script>
<%cpp>
}
Expand Down
31 changes: 31 additions & 0 deletions recman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,33 @@


namespace vdrlive {
template<typename T>
void StringAppendFrameParams(T &s, const cRecording *rec) {
#if VDRVERSNUM >= 20605
if (!rec || ! rec->Info() ) return;
if (rec->Info()->FrameWidth() && rec->Info()->FrameHeight() ) {
stringAppend(s, rec->Info()->FrameWidth() );
s.append("x");
stringAppend(s, rec->Info()->FrameHeight() );

if (rec->Info()->FramesPerSecond() > 0) {
s.append("/");
stringAppendFormated(s, "%.2g", rec->Info()->FramesPerSecond() );
if (rec->Info()->ScanType() != stUnknown)
s.append(1, rec->Info()->ScanTypeChar());
}
if (rec->Info()->AspectRatio() != arUnknown) {
s.append(" ");
s.append(cSv(rec->Info()->AspectRatioText()));
}
}
#endif
}

template void StringAppendFrameParams<std::string>(std::string &s, const cRecording *rec);
template void StringAppendFrameParams<cLargeString>(cLargeString &s, const cRecording *rec);
template void StringAppendFrameParams<cToSvConcat<0>>(cToSvConcat<0> &s, const cRecording *rec);
template void StringAppendFrameParams<cToSvConcat<255>>(cToSvConcat<255> &s, const cRecording *rec);

/**
* Implementation of class RecordingsManager:
Expand Down Expand Up @@ -966,6 +993,10 @@ void AppendScraperData(cLargeString &target, cSv s_IMDB_ID, const cTvMedia &s_im
target.append("\",");
// [21] numTsFiles
target.append(NumberTsFiles() );
// [22] frame parameter text
target.append(",\"");
StringAppendFrameParams(target, m_recording);
target.append("\"");
}

void RecordingsItemRec::AppendAsJSArray(cLargeString &target, std::vector<RecordingsItemRecPtr>::const_iterator recIterFirst, std::vector<RecordingsItemRecPtr>::const_iterator recIterLast, bool &first, cSv filter, bool reverse) {
Expand Down
2 changes: 2 additions & 0 deletions recman.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

namespace vdrlive {

template<typename T>
void StringAppendFrameParams(T &s, const cRecording *rec);
// Forward declations from epg_events.h
class EpgInfo;
typedef std::shared_ptr<EpgInfo> EpgInfoPtr;
Expand Down
113 changes: 62 additions & 51 deletions stringhelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,15 @@ template<typename T, std::enable_if_t<std::is_integral_v<T>, bool> = true>
return *this;
}
// =======================
// #include <vdr/channels.h>

// =========================================================
// some performance improvemnt, to get string presentation for channel
// you can also use channelID.ToString()
// in struct tChannelID { (in vdr):
// static tChannelID FromString(const char *s);
// cString ToString(void) const;
// =========================================================
// append tChannelID
cToSvConcat &concat(const tChannelID &channelID) {
int st_Mask = 0xFF000000;
Expand Down Expand Up @@ -953,19 +962,6 @@ class cToSvFormated: public cToSvConcat<N> {
}
};

/*
* channel helper functions (for vdr tChannelID)
*
*/
// #include <vdr/channels.h>

// =========================================================
// some performance improvemnt, to get string presentation for channel
// you can also use channelID.ToString()
// in struct tChannelID { (in vdr):
// static tChannelID FromString(const char *s);
// cString ToString(void) const;
// =========================================================

class cToSvChannel: public cToSvConcat<255> {
public:
Expand All @@ -974,42 +970,23 @@ class cToSvChannel: public cToSvConcat<255> {

// =========================================================
// =========================================================
// Chapter 5: change string: mainly: append to string
// stringAppend: for std::string & cToSvConcat
// =========================================================
// =========================================================

inline void StringRemoveTrailingWhitespace(std::string &str) {
str.erase(remove_trailing_whitespace(str).length());
}

inline int stringAppendAllASCIICharacters(std::string &target, const char *str) {
// append all characters > 31 (signed !!!!). Unsigned: 31 < character < 128
// return number of appended characters
int i = 0;
for (; reinterpret_cast<const signed char*>(str)[i] > 31; i++);
target.append(str, i);
return i;
template<typename T, std::enable_if_t<std::is_integral_v<T>, bool> = true>
inline void stringAppend(std::string &str, T i) {
char buf[20]; // unsigned int 64: max. 20. (18446744073709551615) signed int64: max. 19 (+ sign)
str.append(buf, stringhelpers_internal::itoa(buf, i) - buf);
}
inline void stringAppendRemoveControlCharacters(std::string &target, const char *str) {
// we replace control characters with " " and invalid UTF8 with "?"
// and remove trailing whitespace
for(;;) {
str += stringAppendAllASCIICharacters(target, str);
wint_t cp = getNextUtfCodepoint(str);
if (cp == 0) { StringRemoveTrailingWhitespace(target); return; }
if (cp > 31) stringAppendUtfCodepoint(target, cp);
else target.append(" ");
}
template<std::size_t N, typename T, std::enable_if_t<std::is_integral_v<T>, bool> = true>
inline void stringAppend(cToSvConcat<N> &s, T i) {
s.concat(i);
}
inline void stringAppendRemoveControlCharactersKeepNl(std::string &target, const char *str) {
for(;;) {
str += stringAppendAllASCIICharacters(target, str);
wint_t cp = getNextUtfCodepoint(str);
if (cp == 0) { StringRemoveTrailingWhitespace(target); return; }
if (cp == '\n') { StringRemoveTrailingWhitespace(target); target.append("\n"); continue; }
if (cp > 31) stringAppendUtfCodepoint(target, cp);
else target.append(" ");
}

template<std::size_t N, typename... Args>
inline void stringAppendFormated(cToSvConcat<N> &s, const char *fmt, Args&&... args) {
s.appendFormated(fmt, std::forward<Args>(args)...);
}

// __attribute__ ((format (printf, 2, 3))) can not be used, but should work starting with gcc 13.1
Expand Down Expand Up @@ -1070,26 +1047,60 @@ void stringAppendFormated_slow(std::string &str, const char *fmt, Args&&... args
// =========== stringAppend == for many data types
// =========================================================

template<typename T, std::enable_if_t<std::is_integral_v<T>, bool> = true>
inline void stringAppend(std::string &str, T i) {
char buf[20]; // unsigned int 64: max. 20. (18446744073709551615) signed int64: max. 19 (+ sign)
str.append(buf, stringhelpers_internal::itoa(buf, i) - buf);
}

// strings
inline void stringAppend(std::string &str, const char *s) { if(s) str.append(s); }
inline void stringAppend(std::string &str, const std::string &s) { str.append(s); }
inline void stringAppend(std::string &str, std::string_view s) { str.append(s); }

inline void stringAppend(std::string &str, const tChannelID &channelID) {
str.append(cToSvChannel(channelID));
str.append(cToSvConcat(channelID));
}
template<typename T, typename U, typename... Args>
void stringAppend(std::string &str, const T &n, const U &u, Args&&... args) {
stringAppend(str, n);
stringAppend(str, u, std::forward<Args>(args)...);
}

// =========================================================
// =========================================================
// Chapter 5: change string: mainly: append to string
// =========================================================
// =========================================================

inline void StringRemoveTrailingWhitespace(std::string &str) {
str.erase(remove_trailing_whitespace(str).length());
}

inline int stringAppendAllASCIICharacters(std::string &target, const char *str) {
// append all characters > 31 (signed !!!!). Unsigned: 31 < character < 128
// return number of appended characters
int i = 0;
for (; reinterpret_cast<const signed char*>(str)[i] > 31; i++);
target.append(str, i);
return i;
}
inline void stringAppendRemoveControlCharacters(std::string &target, const char *str) {
// we replace control characters with " " and invalid UTF8 with "?"
// and remove trailing whitespace
for(;;) {
str += stringAppendAllASCIICharacters(target, str);
wint_t cp = getNextUtfCodepoint(str);
if (cp == 0) { StringRemoveTrailingWhitespace(target); return; }
if (cp > 31) stringAppendUtfCodepoint(target, cp);
else target.append(" ");
}
}
inline void stringAppendRemoveControlCharactersKeepNl(std::string &target, const char *str) {
for(;;) {
str += stringAppendAllASCIICharacters(target, str);
wint_t cp = getNextUtfCodepoint(str);
if (cp == 0) { StringRemoveTrailingWhitespace(target); return; }
if (cp == '\n') { StringRemoveTrailingWhitespace(target); target.append("\n"); continue; }
if (cp > 31) stringAppendUtfCodepoint(target, cp);
else target.append(" ");
}
}

// =========================================================
// =========== concatenate =================================
// =========================================================
Expand Down
2 changes: 1 addition & 1 deletion tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ std::istream& operator>>( std::istream& is, tChannelID& ret );
inline
std::ostream& operator<<( std::ostream& os, tChannelID const& id )
{
return os << cToSvChannel(id);
return os << cToSvConcat(id);
}

template<typename... Args> void stringAppendFormated(cLargeString &target, const char *format, Args&&... args) {
Expand Down

0 comments on commit 6f3025c

Please sign in to comment.