[mythtv] [PATCH] HDTV Recorder Patch

Daniel Thor Kristjansson danielk at mrl.nyu.edu
Sat Nov 13 21:23:45 UTC 2004

The patch is too big (34K) to attach, so here's the link:

This is the HDTV Recorder patch I've been working on for some time now. 
I released this a couple weeks ago and there seem to be no new bugs 
introduced by this patch. The only caveat is that the pmt-tracking patch 
I posted earlier today needs to be in cvs before this can be committed, 
or it will break Live TV.

This patch adds only one desirable user visible feature, multiple audio 
streams. But more importantly it parses the PSIP data present in ATSC 
streams, and it separates out general MPEG stream parsing from ATSC 
stream parsing. This will allow code to be shared with the DVB recorder 
which should lower maintenance problems in the long run.

This is also a major cleanup of hdtvrecorder.cpp. It no longer needs to 
rewrite the pid's of recordings because of the pmt tracking added to 
ffmpeg. And due to the existance of the TSPacket class and the PMT and 
PAT classes we no longer need obscure parsing code. The CRC of the 
tables is checked so that a momentary loss of signal won't compromise 
the stream as much (I still don't CRC check the video stream). I've also 
added a few defines, such as WHACK_A_BUG_VIDEO, WHACK_A_BUG_AUDIO, and 
FAKE_VIDEO which make it easier to test changes.

It's unfortunately a rather large patch, but it's mostly new code that 
and the only significant changes are to hdtv-recorder. To apply this 
patch untar hdtv-recorder.tbz inside the mythtv directory, enter the new 
dtk-patches directory, and run apply-patches.sh. This will copy over the 
new files (and hdtvrecorder.{cpp,h} due to all the changes) and will 
patch tv_play.cpp channel.{h,cpp}, and libmythtv.pro

Here's a basic description of the changes and new files. There is more 
information within the files.

Changed Files:
channel.h:      Adds FAKE_VIDEO define, which allows the use
   of debugging streams in hdtv-recorder
channel.cpp:    Small fix for CheckSignal (plus FAKE_VIDEO)
tv_play.cpp     Adds some asserts
libmythtv.pro:  Adds the new files to the linux compile
hdtvrecorder.{h,cpp}:    These files are a completely rewritten using
   MPEGStreamData to track the program, pids, and the PAT and PMT Tables,
   and ATSCStreamData to handle the PSIP tables.

New Files:
mpegstreamdata.{h,cpp}:  These files implement the MPEGStreamData
   class which handles MPEG specific data in the DTV Stream. It also
   includes a PAT and PMT rewriter which allows stripping the stream
   down to just one program.

atscstreamdata.{h,cpp}:  These files implement ATSCStreamData which
   extends the MPEGStreamData class to handle PSIP tables.

mpegtables.{h,cpp}:      These files implement the basic PSIPTable
   class and the two MPEG specific table classes for the PAT and PMT.
   In addition the MPEG Adaptation Field Control table is implemented

atsctables.{h,cpp}:      These files implement most of the ATSC PSIP
   table set. Included are MGT, VCT Terra, EIT, ETT, and STT.
   MGT: The Master Guide Table tells you what pid various tables are
        using, and the current version.
   STT: The SystemTimeTable  reports the current GPS time at the
        transmitter. And the current GPS_UTC offset.
   VCT Terra: The Terrestrial Virtual Channel Table gives you various
        information about the channel.
   EIT: This reports on event information. EIT[0] is always the current
        event info, while each additional EIT block describes another
        3 hours of TV programming.
   ETT: Depending on what the MGT Tells you an ETT describes either
        additional Event information (TV Guide data) or Channel
        information ("You are watching WPIX, New Yorks Number one Movie

atscdescriptors.{h,cpp}: These files implement classes that parse the
   various ATSC descriptors. This includes the Caption Service
   Descriptor, the Registration Descriptor, the Audio Stream Descriptor,
   and the Content Identifier Descrptor. It also includes the classes
   that decode the ISO 639 Language Code, and the Multiple String
    Caption Service Descriptor: This describes the current captions, and
      is either in the PMT or in the VCT Terra.
    Registration Descriptor: We don't use this, decoded for completeness.
    Audio Stream Descriptor: This describes the audio in a ATSC stream
      it includes useful information such as what language the stream
      is in, what the encoding and bitrate is, and whether it's a
      complete or partial stream (i.e. just the dialog or just the
    Content Identifier Descriptor: This is like an ISBN for programming
      and is intended to make managing a library of recordings simpler.
    ISO 639 Language Code: This is not a descriptor really, but a code
      used in ATSC Descriptors and tables to tell you what language
      something is in.
    Multiple String Structure: This also is not a descriptor but
      an encoding used in various descriptors and tables to encode
      a list of strings.

atscdescriptorsmap.cpp:  This file contains the iso639 to QString
   map used by the ISO639LanguageCode class. It is in it's own file
   because g++ takes forever and a day to compile this.

pespacket.{h,cpp}:       This contains the a basic PES packet class
   and pes packet assembler used to construct all the tables we use
   out of ts packets. It works but I plan to replace it with the DVB
   pes packet assembler once that code stabilizes.

tspacket.{h,cpp}:        This contains two closely interconnected
   classes the TSHeader and TSPacket. The first parses the 4 byte
   header of a Transport Stream Packet, and the second parses
   the optional start of field pointer, but mostly just allows
   for easy cloning of an entire TSPacket.

-- Daniel

More information about the mythtv-dev mailing list