Skip to content

Commit

Permalink
Adds 'damaged' video property for poor recordings.
Browse files Browse the repository at this point in the history
This sets the 'warning' state for the Watch Recordings list item if the
property is set and also adds a 'videoquality' statetypes for those themes
that wish to use an icon for this property.

The idea is that the recording is perhaps watchable, but this gives you
a warning that a there may be a serious problem with the recording so
you should perhaps check it before inviting a friend over to watch it
with you.

The property is set whenever RecordingQuality::IsDamaged() returns true.
This is primarily based gaps in the recording with extra weight given
to gaps at the beginning and end of the scheduled program slot. In the
future we may add transport stream discontinuity or other recorder
specific quality metrics.
  • Loading branch information
daniel-kristjansson committed Dec 12, 2011
1 parent f5f6b85 commit 72d4370
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 13 deletions.
2 changes: 1 addition & 1 deletion mythtv/bindings/perl/MythTV.pm
Expand Up @@ -114,7 +114,7 @@ package MythTV;
# schema version supported in the main code. We need to check that the schema
# version in the database is as expected by the bindings, which are expected
# to be kept in sync with the main code.
our $SCHEMA_VERSION = "1288";
our $SCHEMA_VERSION = "1289";

# NUMPROGRAMLINES is defined in mythtv/libs/libmythtv/programinfo.h and is
# the number of items in a ProgramInfo QStringList group used by
Expand Down
2 changes: 1 addition & 1 deletion mythtv/bindings/python/MythTV/static.py
Expand Up @@ -5,7 +5,7 @@
"""

OWN_VERSION = (0,25,-1,3)
SCHEMA_VERSION = 1288
SCHEMA_VERSION = 1289
NVSCHEMA_VERSION = 1007
MUSICSCHEMA_VERSION = 1018
PROTO_VERSION = '70'
Expand Down
10 changes: 7 additions & 3 deletions mythtv/libs/libmyth/programinfo.cpp
Expand Up @@ -3693,23 +3693,27 @@ int64_t ProgramInfo::QueryTotalFrames(void) const
return frames;
}

void ProgramInfo::SaveResolutionProperty(VideoProperty vid_flags)
void ProgramInfo::SaveVideoProperties(uint mask, uint vid_flags)
{
MSqlQuery query(MSqlQuery::InitCon());

LOG(VB_RECORD, LOG_INFO,
QString("SaveVideoProperties(0x%1, 0x%2)")
.arg(mask,2,16,QChar('0')).arg(vid_flags,2,16,QChar('0')));

query.prepare(
"UPDATE recordedprogram "
"SET videoprop = ((videoprop+0) & :OTHERFLAGS) | :FLAGS "
"WHERE chanid = :CHANID AND starttime = :STARTTIME");

query.bindValue(":OTHERFLAGS", ~(VID_1080|VID_720));
query.bindValue(":OTHERFLAGS", ~mask);
query.bindValue(":FLAGS", vid_flags);
query.bindValue(":CHANID", chanid);
query.bindValue(":STARTTIME", startts);
query.exec();

uint videoproperties = GetVideoProperties();
videoproperties &= ~(VID_1080|VID_720);
videoproperties &= ~mask;
videoproperties |= vid_flags;
properties &= ~kVideoPropertyMask;
properties |= videoproperties << kVideoPropertyOffset;
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmyth/programinfo.h
Expand Up @@ -552,7 +552,7 @@ class MPUBLIC ProgramInfo
void SaveFrameRate(uint64_t frame, uint framerate);
void SaveTotalDuration(int64_t duration);
void SaveTotalFrames(int64_t frames);
void SaveResolutionProperty(VideoProperty vid_flags);
void SaveVideoProperties(uint mask, uint video_property_flags);
void SaveMarkupFlag(MarkTypes type) const;
void ClearMarkupFlag(MarkTypes type) const { ClearMarkupMap(type); }
void UpdateLastDelete(bool setTime) const;
Expand Down
7 changes: 4 additions & 3 deletions mythtv/libs/libmyth/programtypes.h
Expand Up @@ -177,10 +177,11 @@ typedef enum VideoProps {
VID_AVC = 0x04,
VID_720 = 0x08,
VID_1080 = 0x10,
} VideoProperty; // has 5 bits in ProgramInfo::properties
#define kVideoPropertyBits 5
VID_DAMAGED = 0x20,
} VideoProperty; // has 6 bits in ProgramInfo::properties
#define kVideoPropertyBits 6
#define kVideoPropertyOffset kAudioPropertyBits
#define kVideoPropertyMask (0x1f<<kVideoPropertyOffset)
#define kVideoPropertyMask (0x3f<<kVideoPropertyOffset)

/// if SubtitleTypes changes, the audioprop column in program and
/// recordedprogram has to changed accordingly
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythbase/mythversion.h
Expand Up @@ -51,7 +51,7 @@
* MythTV Python Bindings
* mythtv/bindings/python/MythTV/static.py
*/
#define MYTH_DATABASE_VERSION "1288"
#define MYTH_DATABASE_VERSION "1289"


MBASE_PUBLIC const char *GetMythSourceVersion();
Expand Down
10 changes: 10 additions & 0 deletions mythtv/libs/libmythtv/dbcheck.cpp
Expand Up @@ -6022,6 +6022,16 @@ NULL
return false;
}

if (dbver == "1288")
{
const char *updates[] = {
"ALTER TABLE recordedprogram CHANGE COLUMN videoprop videoprop "
" SET('HDTV', 'WIDESCREEN', 'AVC', '720', '1080', 'DAMAGED') NOT NULL; ",
NULL
};
if (!performActualUpdate(updates, "1289", dbver))
return false;
}
return true;
}

Expand Down
7 changes: 4 additions & 3 deletions mythtv/libs/libmythtv/tv_rec.cpp
Expand Up @@ -877,9 +877,10 @@ void TVRec::FinishedRecording(RecordingInfo *curRec, RecordingQuality *recq)

// Get the width and set the videoprops
uint avg_height = curRec->QueryAverageHeight();
curRec->SaveResolutionProperty(
(avg_height > 1000) ? VID_1080 :
((avg_height > 700) ? VID_720 : VID_UNKNOWN));
curRec->SaveVideoProperties(
VID_1080 | VID_720 | VID_DAMAGED,
((avg_height > 1000) ? VID_1080 : ((avg_height > 700) ? VID_720 : 0)) |
((is_good&&false) ? 0 : VID_DAMAGED));

// Make sure really short recordings have positive run time.
if (curRec->GetRecordingEndTime() <= curRec->GetRecordingStartTime())
Expand Down
25 changes: 25 additions & 0 deletions mythtv/programs/mythfrontend/playbackbox.cpp
Expand Up @@ -269,6 +269,9 @@ static QString extract_main_state(const ProgramInfo &pginfo, const TV *player)
state = "disabled";
}

if (state == "normal" && (pginfo.GetVideoProperties() & VID_DAMAGED))
state = "warning";

return state;
}

Expand Down Expand Up @@ -1095,6 +1098,28 @@ void PlaybackBox::updateIcons(const ProgramInfo *pginfo)
iconState->Reset();

iconMap.clear();
iconMap["damaged"] = VID_DAMAGED;

iconState = dynamic_cast<MythUIStateType *>(GetChild("videoquality"));
haveIcon = false;
if (pginfo && iconState)
{
for (it = iconMap.begin(); it != iconMap.end(); ++it)
{
if (pginfo->GetVideoProperties() & (*it))
{
if (iconState->DisplayState(it.key()))
{
haveIcon = true;
break;
}
}
}
}

if (iconState && !haveIcon)
iconState->Reset();
iconMap.clear();
iconMap["deafsigned"] = SUB_SIGNED;
iconMap["onscreensub"] = SUB_ONSCREEN;
iconMap["subtitles"] = SUB_NORMAL;
Expand Down
Binary file added mythtv/themes/default/damaged.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 72d4370

Please sign in to comment.