Skip to content

Commit

Permalink
Adds support for outputting XML versions of MPEG PSIP tables.
Browse files Browse the repository at this point in the history
So far only the tables in mpegtables.{h,cpp} are supported, but theis is easily extended to the others.
  • Loading branch information
daniel-kristjansson committed Nov 2, 2011
1 parent 45130c1 commit c8ce9e4
Show file tree
Hide file tree
Showing 8 changed files with 453 additions and 133 deletions.
31 changes: 29 additions & 2 deletions mythtv/libs/libmythbase/util.cpp
Expand Up @@ -34,11 +34,12 @@ using namespace std;
#endif

// Qt headers
#include <QReadWriteLock>
#include <QNetworkProxy>
#include <QFileInfo>
#include <QFile>
#include <QDir>
#include <QFileInfo>
#include <QUrl>
#include <QNetworkProxy>

// Myth headers
#include "mythcorecontext.h"
Expand Down Expand Up @@ -1587,4 +1588,30 @@ void wrapList(QStringList &list, int width)
}
}

QString xml_indent(uint level)
{
static QReadWriteLock rw_lock;
static QMap<uint,QString> cache;

rw_lock.lockForRead();
QMap<uint,QString>::const_iterator it = cache.find(level);
if (it != cache.end())
{
QString tmp = *it;
rw_lock.unlock();
return tmp;
}
rw_lock.unlock();

QString ret = "";
for (uint i = 0; i < level; i++)
ret += " ";

rw_lock.lockForWrite();
cache[level] = ret;
rw_lock.unlock();

return ret;
}

/* vim: set expandtab tabstop=4 shiftwidth=4: */
7 changes: 7 additions & 0 deletions mythtv/libs/libmythbase/util.h
Expand Up @@ -91,6 +91,13 @@ inline int lerp(float r, int a, int b)
inline float sq(float a) { return a*a; }
inline int sq(int a) { return a*a; }

static inline QString xml_bool_to_string(bool val)
{
return (val) ? "true" : "false";
}

MBASE_PUBLIC QString xml_indent(uint level);

MBASE_PUBLIC bool IsMACAddress(QString MAC);
MBASE_PUBLIC bool WakeOnLAN(QString MAC);
MBASE_PUBLIC QString FileHash(QString filename);
Expand Down
20 changes: 12 additions & 8 deletions mythtv/libs/libmythtv/mpeg/mpegdescriptors.cpp
Expand Up @@ -464,21 +464,25 @@ QString MPEGDescriptor::toStringXML(uint level) const
QString indent_1 = indent(level+1);
QString str;

str += indent_0 + "<DESCRIPTOR>\n";
str += indent_1 + QString("<TAG>0x%1</TAG>\n")
str += indent_0 + "<Descriptor>\n";
str += indent_1 + QString("<Tag>0x%1</Tag>\n")
.arg(DescriptorTag(),2,16,QChar('0'));
str += indent_1 + QString("<DESCRIPTION>%1</DESCRIPTION>\n")
str += indent_1 + QString("<Description>%1</Description>\n")
.arg(DescriptorTagString(),0,16);

str += indent_1 + "<DATA>";
str += indent_1 + "<Data>";
for (uint i = 0; i < DescriptorLength(); i++)
{
if (((i%8) == 0) && i)
str += "\n" + indent_1 + " ";
str += QString("0x%1 ").arg(_data[i+2],2,16,QChar('0'));
str = str.trimmed();
str += "</DATA>\n";
}

str += "\n" + indent_1 + "</Data>\n";

str += indent_1 + "<DECODED>" + toString() + "</DECODED>";
str += indent_1 + "<Decoded>" + toString() + "</Decoded>\n";

str += indent_0 + "</DESCRIPTOR>";
str += indent_0 + "</Descriptor>";

return str;
}
Expand Down

0 comments on commit c8ce9e4

Please sign in to comment.