[mythtv] DVB Changes / Patch Applied

Tim Davies tim at opensystems.net.au
Mon Jan 24 05:00:26 EST 2005


Taylor,

I've updated Mark's patch to apply cleanly on the latest Myth CVS, and 
split it into three parts.  This might make it easier to integrate the 
essential bits into CVS.

- oz-ac3.diff - this is required for both PS and TS recording.  It deals 
with channel changes (with a codec change) and chooses the preferred 
audio track, if multiple tracks are recorded.  This is what we *really* 
need in CVS.

- oz-ac3-mpeghack.diff - this is Mark's workaround to get the PS 
playback working properly.  I guess this gets into CVS when it isn't a 
nasty hack anymore!

- oz-ac3-tracksel.diff - this is a nice way to choose the audio track 
that you want.

By the way, LCNs work in Australia.  Here are the relevant entries for 
Australia in dtv_privatetypes (if you want them!):

+--------+-----------+-----------------+---------------+
| sitype | networkid | private_type    | private_value |
+--------+-----------+-----------------+---------------+
| dvb    |      4115 | channel_numbers | 131           |
| dvb    |      4116 | channel_numbers | 131           |
| dvb    |     12803 | channel_numbers | 131           |
| dvb    |      4112 | channel_numbers | 131           |
| dvb    |     12802 | channel_numbers | 131           |
+--------+-----------+-----------------+---------------+

Other network IDs I've found online (but not verified) are 
57,12938,12819,12812,12915,12929.

There are 3 issues that I still have (and will look at if I get time):

- When recording the TS, services with a separate PCR don't seek 
properly.  These recordings can be watched in xine or mplayer with no 
problems.  This might me a problem with mpegts.c?
- When recording a PS, the 1080i channels are blocky.  Something might 
be I/O bound?!?  Doesn't seem to be CPU.
- And changing to two of our HD channels (the 576p stations?!?) results 
in jerky (kinda slow motion) video.  Exiting and "Watching TV" fixes 
it.  No idea on this one!  I think this is TS only.

Other than that, I'm happy.  Hell, I'm happy enough to have bought a 5.1 
receiver...


Tim.


Taylor Jacob wrote:

>I'd like to start by thanking John Pullan, Jesper Sörensen, Marcus Metzler and
>Julian Scheel for all the help along the way with this code.  I'd also like to
>thank the testers who dared to apply this code and play with it.
>
>Also thanks to Isaac for applying the patch even if it took him 4 hours..
>
>The EIT parsing has been tested and works in the UK and North America with
>success, but still may have some issues in other countries.  If anyone has
>issues with this please let me know, and send me some dvbsnoop dumps of your
>EIT plus complete backend dumps.
>
>In addition to fixing bugs found in the new code, we still have plenty of work
>planned.  The main focus next is not 100% clear, but it shall include the
>following:
>
>- Fixing the BE/FE protocol to allow radio services, and also eliminate the "15
>second timeout".
>- Improved EPG parsing that will only be fired of when necessary (currently it
>re-collects data when you change channels).
>- Add support for cascaded DiSEqC devices (switch + motor) for example.
>- DiSEqC setup wizard screen to setup your motor from within setup.
>- Merge in any common code between hdtvrecorder and dvbrecorder, and if
>necessary help that side move twoard utilizing the scaning and table parsing
>routines included in this patch.
>- Fixing AC3 support in Australia if there is anything left to do for them.  I
>was not 100% clear what needed to be done to get their audio working if it
>wasn't already. (Sorry guys).
>
>Major differences between 3.5 and what went into CVS are EPG support, and
>support for LCN (Logical Channel Numbers) used in the UK.  I believe these are
>also used in Australia but need enabling by adding entries in the
>dtv_privatetypes table added with the patch.  If its not evident what needs to
>be added please post but the format is quite simple.
>
>If anyone has any issues please let any of us know, or just post a patch to the
>-dev list.
>
>Taylor
>
>
>_______________________________________________
>mythtv-dev mailing list
>mythtv-dev at mythtv.org
>http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev
>  
>

-------------- next part --------------
diff -ur mythtv-20050124/libs/libmythtv/avformatdecoder.cpp mythtv-20050124-work/libs/libmythtv/avformatdecoder.cpp
--- mythtv-20050124/libs/libmythtv/avformatdecoder.cpp	2005-01-24 12:48:50.000000000 +0800
+++ mythtv-20050124-work/libs/libmythtv/avformatdecoder.cpp	2005-01-24 13:53:45.000000000 +0800
@@ -151,6 +151,7 @@
     audio_channels = -1;
     audio_sample_size = -1;
     audio_sampling_rate = -1;
+    audio_codec = -1;
 
     exitafterdecoded = false;
     ateof = false;
@@ -642,11 +643,8 @@
         {
             VERBOSE(VB_IMPORTANT, 
                     QString("AvFormatDecoder: Could not find decoder for "
-                            "codec (%1) aborting.")
+                            "codec,  ignoring (%1).")
                            .arg(enc->codec_id));
-            av_close_input_file(ic);
-            ic = NULL;
-            scanerror = -1;
             continue;
         }
 
@@ -717,28 +715,31 @@
     return true;
 }
 
-void AvFormatDecoder::CheckAudioParams(int freq, int channels, bool safe)
+void AvFormatDecoder::CheckAudioParams(int freq, int channels, int codec_id, bool safe)
 {
     if (freq <= 0 || channels <= 0)
         return;
 
     if (safe || audio_check_1st == 2)
     {
-        if (freq == audio_sampling_rate && channels == audio_channels)
+        if (freq == audio_sampling_rate && channels == audio_channels && audio_codec == codec_id) 
             return;
         audio_check_1st = 1;
         audio_sampling_rate_2nd = freq;
         audio_channels_2nd = channels;
+        audio_codec_2nd = codec_id; 
         if (safe == false)
             return;
     }
     else
     {
         if (freq != audio_sampling_rate_2nd || channels != audio_channels_2nd ||
-            (freq == audio_sampling_rate && channels == audio_channels))
+            codec_id != audio_codec_2nd ||
+            (freq == audio_sampling_rate && channels == audio_channels && codec_id == audio_codec))
         {
             audio_sampling_rate_2nd = -1;
             audio_channels_2nd = -1;
+            audio_codec_2nd = -1;
             audio_check_1st = 2;
             return;
         }
@@ -753,9 +754,12 @@
     audio_check_1st = 2;
 
     if (audio_channels != -1)
-        VERBOSE(VB_AUDIO, QString("Audio format changed from %1 channels,"
-                " %2hz to %3 channels %4hz").arg(audio_channels)
-                .arg(audio_sampling_rate).arg(channels).arg(freq));
+    {
+        VERBOSE(VB_ALL, QString("Audio format changed from %1 channels,"
+                " %2hz codec %3 to %4 channels %5hz codec %6").arg(audio_channels)
+                .arg(audio_sampling_rate).arg(audio_codec).arg(channels)
+                .arg(freq).arg(codec_id));
+    }
 
     AVCodecContext *enc = &ic->streams[wantedAudioStream]->codec;
     AVCodec *codec = enc->codec;
@@ -1139,7 +1143,7 @@
         wantedAudioStream = audioStreams[currentAudioTrack];
 
         AVCodecContext *e = &ic->streams[wantedAudioStream]->codec;
-        CheckAudioParams(e->sample_rate, e->channels, true);
+        CheckAudioParams(e->sample_rate, e->channels, e->codec_id, true);
     }
 }
 
@@ -1156,7 +1160,7 @@
         wantedAudioStream = audioStreams[currentAudioTrack];
 
         AVCodecContext *e = &ic->streams[wantedAudioStream]->codec;
-        CheckAudioParams(e->sample_rate, e->channels, true);
+        CheckAudioParams(e->sample_rate, e->channels, e->codec_id, true);
     }
 }
 
@@ -1174,15 +1178,20 @@
     wantedAudioStream = audioStreams[currentAudioTrack];
 
     AVCodecContext *e = &ic->streams[wantedAudioStream]->codec;
-    CheckAudioParams(e->sample_rate, e->channels, true);
+    CheckAudioParams(e->sample_rate, e->channels, e->codec_id, true);
     return true;
 }
 
-bool AvFormatDecoder::autoSelectAudioTrack()
+bool AvFormatDecoder::autoSelectAudioTrack(bool prefer_ac3)
 {
     if (!audioStreams.size())
         return false;
 
+    if (prefer_ac3)
+    {
+        prefer_ac3 = gContext->GetNumSetting("WantAC3", true);
+    }
+
     bool foundAudio = false;
     int minChannels = 1;
     int maxTracks = (audioStreams.size() - 1);
@@ -1197,6 +1206,12 @@
             int tempStream = audioStreams[track];
             AVCodecContext *e = &ic->streams[tempStream]->codec;
 
+            if (((prefer_ac3) && (e->codec_id != CODEC_ID_AC3)) || 
+                ((!prefer_ac3) && (e->codec_id == CODEC_ID_AC3))) 
+            {
+                continue;
+            }
+
             if (e->channels > minChannels)
             {
                 currentAudioTrack = track;
@@ -1207,16 +1222,26 @@
                 VERBOSE(VB_AUDIO, 
                         QString("It has %1 channels and we needed at least %2")
                                .arg(e->channels).arg(minChannels + 1));
+                if (prefer_ac3)
+                {
+                    VERBOSE(VB_ALL, QString("AC3 stream has been selected"));
+                }
 
                 AVCodecContext *e = &ic->streams[wantedAudioStream]->codec;
-                CheckAudioParams(e->sample_rate, e->channels, true);
+                CheckAudioParams(e->sample_rate, e->channels, e->codec_id, true);
                 return true;
             }
         }
         minChannels--;
         if (minChannels < 0)
+        {
+            if (prefer_ac3)
+            {
+                return autoSelectAudioTrack(false);
+            }
             return false;
     }
+    }
 
     return false;
 }
@@ -1233,6 +1258,8 @@
     VERBOSE(VB_ALL, QString("Initializing audio parms from stream #%1.")
             .arg(currentAudioTrack));
 
+    audio_codec = curstream->codec.codec_id;
+
     m_parent->SetEffDsp(curstream->codec.sample_rate * 100);
 
     do_ac3_passthru = curstream->codec.codec_id == CODEC_ID_AC3 &&
@@ -1240,6 +1267,7 @@
 
     if (do_ac3_passthru)
     {
+        VERBOSE(VB_ALL, QString("AC3 passthrough is enabled"));
         // An AC3 stream looks like a 48KHz 2ch audio stream to
         // the sound card
         audio_sample_size = 4;
@@ -1424,7 +1452,9 @@
 
                     if (!do_ac3_passthru)
                         CheckAudioParams(curstream->codec.sample_rate,
-                                         curstream->codec.channels, false);
+                                         curstream->codec.channels, 
+                                         curstream->codec.codec_id,
+                                         false);
 
                     long long temppts = lastapts;
 
diff -ur mythtv-20050124/libs/libmythtv/avformatdecoder.h mythtv-20050124-work/libs/libmythtv/avformatdecoder.h
--- mythtv-20050124/libs/libmythtv/avformatdecoder.h	2005-01-24 12:48:50.000000000 +0800
+++ mythtv-20050124-work/libs/libmythtv/avformatdecoder.h	2005-01-24 13:41:15.000000000 +0800
@@ -78,7 +78,7 @@
     /// Attempt to find the optimal audio stream to use based on the number of channels,
     /// and if we're doing AC3 passthrough.  This will select the highest stream number
     /// that matches our criteria.
-    bool autoSelectAudioTrack();
+    bool autoSelectAudioTrack(bool wantac3 = true);
 
     RingBuffer *getRingBuf(void) { return ringBuffer; }
 
@@ -112,7 +112,7 @@
     bool CheckVideoParams(int width, int height);
 
     /// See if the audio parameters have changed, return true if so.
-    void CheckAudioParams(int freq, int channels, bool safe);
+    void CheckAudioParams(int freq, int channels, int codec, bool safe);
     void SetupAudioStream(void);
 
     int EncodeAC3Frame(unsigned char* data, int len, short *samples,
@@ -136,10 +136,12 @@
     int audio_sample_size;
     int audio_sampling_rate;
     int audio_channels;
+    int audio_codec;
 
     int audio_check_1st;         ///< Used by CheckAudioParams
     int audio_sampling_rate_2nd; ///< Used by CheckAudioParams
     int audio_channels_2nd;      ///< Used by CheckAudioParams
+    int audio_codec_2nd;         ///< Used by CheckAudioParams
 
     int bitrate;
 
diff -ur mythtv-20050124/libs/libmythtv/dvbrecorder.cpp mythtv-20050124-work/libs/libmythtv/dvbrecorder.cpp
--- mythtv-20050124/libs/libmythtv/dvbrecorder.cpp	2005-01-24 12:48:51.000000000 +0800
+++ mythtv-20050124-work/libs/libmythtv/dvbrecorder.cpp	2005-01-24 15:32:04.000000000 +0800
@@ -48,6 +48,7 @@
 
 #include "RingBuffer.h"
 #include "programinfo.h"
+#include "mythcontext.h"
 
 #include "transform.h"
 #include "dvbtypes.h"
@@ -353,7 +354,7 @@
     else
     {
         // PES recording currently only supports one video and one audio PID (I think???)
-        ElementaryPIDObject *as = m_pmt.PreferredAudioStream();
+        ElementaryPIDObject *as = m_pmt.PreferredAudioStream(gContext->GetNumSetting("WantAC3", true));
         ElementaryPIDObject *vs = m_pmt.PreferredVideoStream();
 //        ElementaryPIDObject *sub = m_pmt.PreferredSubtitleStream();
 
diff -ur mythtv-20050124/libs/libmythtv/sitypes.cpp mythtv-20050124-work/libs/libmythtv/sitypes.cpp
--- mythtv-20050124/libs/libmythtv/sitypes.cpp	2005-01-24 06:45:30.000000000 +0800
+++ mythtv-20050124-work/libs/libmythtv/sitypes.cpp	2005-01-24 15:41:44.000000000 +0800
@@ -291,12 +291,11 @@
 
 // Try to auto detect which audio stream to use
 // NOTE!!! This is only used for PS recording via transform.c!
-ElementaryPIDObject *PMTObject::PreferredAudioStream()
+ElementaryPIDObject *PMTObject::PreferredAudioStream(bool prefer_ac3 = false)
 {
     QValueList<ElementaryPIDObject>::Iterator pit;
 
     // Change this if you prefer AC3
-    bool prefer_ac3 = false;
     if (prefer_ac3)
     {
         for (pit = Components.begin(); pit != Components.end(); ++pit)
diff -ur mythtv-20050124/libs/libmythtv/sitypes.h mythtv-20050124-work/libs/libmythtv/sitypes.h
--- mythtv-20050124/libs/libmythtv/sitypes.h	2005-01-24 06:45:30.000000000 +0800
+++ mythtv-20050124-work/libs/libmythtv/sitypes.h	2005-01-24 15:34:52.000000000 +0800
@@ -403,7 +403,7 @@
     bool OnAir() { return TelevisionService(); }
     bool FTA() { return !hasCA; }
 
-    ElementaryPIDObject *PreferredAudioStream();
+    ElementaryPIDObject *PreferredAudioStream(bool prefer_ac3);
     ElementaryPIDObject *PreferredVideoStream();
     ElementaryPIDObject *PreferredSubtitleStream();
 
diff -ur mythtv-20050124/programs/mythfrontend/globalsettings.cpp mythtv-20050124-work/programs/mythfrontend/globalsettings.cpp
--- mythtv-20050124/programs/mythfrontend/globalsettings.cpp	2005-01-24 12:48:55.000000000 +0800
+++ mythtv-20050124-work/programs/mythfrontend/globalsettings.cpp	2005-01-24 13:41:15.000000000 +0800
@@ -185,6 +185,17 @@
     return gc;
 }
 
+static GenericCheckBox *WantAC3()
+{
+    GenericCheckBox *gc = new GenericCheckBox("WantAC3");
+    gc->setLabel(QObject::tr("Use Dolby digital audio where available"));
+    gc->setValue(true);
+    gc->setHelpText(QObject::tr("Where a Dolby digital sound track is "
+                       "available (usually digital TV) use it. If this is not"
+                       " set then Dolby audio will be disabled"));
+    return gc;
+}
+
 static GenericCheckBox *AC3PassThrough()
 {
     GenericCheckBox *gc = new GenericCheckBox("AC3PassThru");
@@ -1914,6 +1925,7 @@
          setUseLabel(false);
 
          addChild(AudioOutputDevice());
+         addChild(WantAC3());
          addChild(AC3PassThrough());
          addChild(AggressiveBuffer());
 
-------------- next part --------------
diff -ur mythtv-20050124-work/libs/libavformat/mpeg.c mythtv-20050124-work2/libs/libavformat/mpeg.c
--- mythtv-20050124-work/libs/libavformat/mpeg.c	2005-01-09 07:30:33.000000000 +0800
+++ mythtv-20050124-work2/libs/libavformat/mpeg.c	2005-01-24 16:10:30.975930384 +0800
@@ -1498,12 +1498,6 @@
     if (len < 0)
         return len;
     
-    /* now find stream */
-    for(i=0;i<s->nb_streams;i++) {
-        st = s->streams[i];
-        if (st->id == startcode)
-            goto found;
-    }
     if (startcode >= 0x1e0 && startcode <= 0x1ef) {
         type = CODEC_TYPE_VIDEO;
         codec_id = CODEC_ID_MPEG2VIDEO;
@@ -1525,15 +1519,46 @@
         url_fskip(&s->pb, len);
         goto redo;
     }
+
+    /* now find stream */
+    for(i=0;i<s->nb_streams;i++) {
+        st = s->streams[i];
+        if ((st->id == startcode) || 
+           ((type == CODEC_TYPE_AUDIO) && 
+            (st->codec.codec_type == CODEC_TYPE_AUDIO)))
+            {
+                goto found;
+            }
+    }   
+
     /* no stream found: add a new stream */
     st = av_new_stream(s, startcode);
     if (!st) 
         goto skip;
+ 
     st->codec.codec_type = type;
     st->codec.codec_id = codec_id;
+
+    /*notify the callback of the change in streams*/
+    if (s->streams_changed) {
+        s->streams_changed(s->stream_change_data);
+    }  
+
+ found:
+
+    if ((type == CODEC_TYPE_AUDIO) &&
+        (st->id != startcode))
+    {
+        st->codec.codec_id = codec_id;		
+        st->id = startcode;
+        /*notify the callback of the change in streams*/
+        if (s->streams_changed) {
+            s->streams_changed(s->stream_change_data);
+        }
+    }
+
     if (codec_id != CODEC_ID_PCM_S16BE)
         st->need_parsing = 1;
- found:
     if (startcode >= 0xa0 && startcode <= 0xbf) {
         int b1, freq;
 
diff -ur mythtv-20050124-work/libs/libmythtv/dvbdev/transform.c mythtv-20050124-work2/libs/libmythtv/dvbdev/transform.c
--- mythtv-20050124-work/libs/libmythtv/dvbdev/transform.c	2005-01-24 12:48:54.000000000 +0800
+++ mythtv-20050124-work2/libs/libmythtv/dvbdev/transform.c	2005-01-24 16:12:47.307204880 +0800
@@ -426,6 +426,7 @@
         if (p->cid == PRIVATE_STREAM1){
             switch (streamid & 0xF8){
             case 0x80:
+                p->buf[8] = p->hlength;
                 p->count += 4;
                 p->buf[9] = streamid;
                 p->buf[10] = 0;
@@ -473,18 +474,17 @@
         case PRIV_TS_AC3: /* keep this as default */
         default:
         {
-            int ac3_off;
-            ac3_off = get_ac3info(data, count, &ai,0);
-            if (ac3_off>=0 && ai.framesize){
+            /*
+             * add in a dummy 4 byte audio header
+             * to match mpeg dvd standard. The values
+             * will be filled in later (in send_ipack)
+             * when it has a full packet to search
+             */
                 p->buf[p->count] = 0x80;
-                p->buf[p->count+1] = (p->size - p->count
-                              - 4 - ac3_off)/ 
-                    ai.framesize + 1;
-                p->buf[p->count+2] = (ac3_off >> 8)& 0xFF;
-                p->buf[p->count+3] = (ac3_off)& 0xFF;
+                p->buf[p->count+1] = 0;
+                p->buf[p->count+2] = 0;
+                p->buf[p->count+3] = 0;
                 p->count+=4;
-                
-            }
         }
         break;
         }
-------------- next part --------------
diff -ur mythtv-20050124-work2/libs/libmythtv/NuppelVideoPlayer.cpp mythtv-20050124-work3/libs/libmythtv/NuppelVideoPlayer.cpp
--- mythtv-20050124-work2/libs/libmythtv/NuppelVideoPlayer.cpp	2005-01-24 12:48:50.000000000 +0800
+++ mythtv-20050124-work3/libs/libmythtv/NuppelVideoPlayer.cpp	2005-01-24 16:17:05.000000000 +0800
@@ -4289,6 +4289,13 @@
         return false;
 }
 
+QString NuppelVideoPlayer::getCurrentAudioTrackDescription()
+{
+    if (decoder)
+        return decoder->getCurrentAudioTrackDescription();
+    else
+        return QString("Unknown audio");
+}
 
 int NuppelVideoPlayer::getCurrentAudioTrack()
 {
diff -ur mythtv-20050124-work2/libs/libmythtv/NuppelVideoPlayer.h mythtv-20050124-work3/libs/libmythtv/NuppelVideoPlayer.h
--- mythtv-20050124-work2/libs/libmythtv/NuppelVideoPlayer.h	2005-01-24 12:48:50.000000000 +0800
+++ mythtv-20050124-work3/libs/libmythtv/NuppelVideoPlayer.h	2005-01-24 16:17:05.000000000 +0800
@@ -203,6 +203,7 @@
     void decCurrentAudioTrack();
     bool setCurrentAudioTrack(int trackNo);
     int getCurrentAudioTrack();
+    QString getCurrentAudioTrackDescription();
 
     long long CalcMaxFFTime(long long ff);
 
diff -ur mythtv-20050124-work2/libs/libmythtv/avformatdecoder.cpp mythtv-20050124-work3/libs/libmythtv/avformatdecoder.cpp
--- mythtv-20050124-work2/libs/libmythtv/avformatdecoder.cpp	2005-01-24 13:53:45.000000000 +0800
+++ mythtv-20050124-work3/libs/libmythtv/avformatdecoder.cpp	2005-01-24 16:20:30.000000000 +0800
@@ -715,6 +715,24 @@
     return true;
 }
 
+QString AvFormatDecoder::getCurrentAudioTrackDescription()
+{
+    switch (audio_codec)
+    {
+        case CODEC_ID_AC3:
+
+            return QString("Dolby Digital ");
+        case CODEC_ID_MP2:
+            return QString("%1 kHz, %2 channel MPEG audio").
+                arg(audio_sampling_rate/1000).
+                arg(audio_channels);
+        default:
+            return QString("%1 kHz, %2 channel audio").
+                arg(audio_sampling_rate/1000).
+                arg(audio_channels);	
+    }		
+}
+
 void AvFormatDecoder::CheckAudioParams(int freq, int channels, int codec_id, bool safe)
 {
     if (freq <= 0 || channels <= 0)
diff -ur mythtv-20050124-work2/libs/libmythtv/avformatdecoder.h mythtv-20050124-work3/libs/libmythtv/avformatdecoder.h
--- mythtv-20050124-work2/libs/libmythtv/avformatdecoder.h	2005-01-24 13:41:15.000000000 +0800
+++ mythtv-20050124-work3/libs/libmythtv/avformatdecoder.h	2005-01-24 16:17:05.000000000 +0800
@@ -68,6 +68,7 @@
 
     void SetPixelFormat(const int);
 
+    virtual QString getCurrentAudioTrackDescription();
     virtual void incCurrentAudioTrack();
     virtual void decCurrentAudioTrack();
     virtual bool setCurrentAudioTrack(int trackNo);
diff -ur mythtv-20050124-work2/libs/libmythtv/decoderbase.h mythtv-20050124-work3/libs/libmythtv/decoderbase.h
--- mythtv-20050124-work2/libs/libmythtv/decoderbase.h	2005-01-09 07:30:34.000000000 +0800
+++ mythtv-20050124-work3/libs/libmythtv/decoderbase.h	2005-01-24 16:17:05.000000000 +0800
@@ -64,6 +64,7 @@
 
     const int getCurrentAudioTrack() const { return currentAudioTrack;}
     virtual void incCurrentAudioTrack(){}
+    virtual QString getCurrentAudioTrackDescription(){ return QString("Unknown"); }
     virtual void decCurrentAudioTrack(){}
     virtual bool setCurrentAudioTrack(int){ return false;}
                                                           
diff -ur mythtv-20050124-work2/libs/libmythtv/dtvrecorder.h mythtv-20050124-work3/libs/libmythtv/dtvrecorder.h
--- mythtv-20050124-work2/libs/libmythtv/dtvrecorder.h	2005-01-09 07:30:34.000000000 +0800
+++ mythtv-20050124-work3/libs/libmythtv/dtvrecorder.h	2005-01-24 16:17:05.000000000 +0800
@@ -54,6 +54,8 @@
 
     void GetBlankFrameMap(QMap<long long, int> &blank_frame_map);
     virtual void Reset();
+    virtual void incCurrentAudioTrack(){}
+    virtual void decCurrentAudioTrack(){}
   protected:
     void FinishRecording(void);
     void FindKeyframes(const TSPacket* tspacket);
diff -ur mythtv-20050124-work2/libs/libmythtv/dvbrecorder.cpp mythtv-20050124-work3/libs/libmythtv/dvbrecorder.cpp
--- mythtv-20050124-work2/libs/libmythtv/dvbrecorder.cpp	2005-01-24 15:32:04.000000000 +0800
+++ mythtv-20050124-work3/libs/libmythtv/dvbrecorder.cpp	2005-01-24 16:17:57.000000000 +0800
@@ -1014,3 +1014,16 @@
 //TODO
 }
 
+void DVBRecorder::incCurrentAudioTrack()
+{
+     ElementaryPIDObject *as = m_pmt.IncAudioStream();
+     if (as)
+        OpenFilters(as->PID, as->Type);
+}
+
+void DVBRecorder::decCurrentAudioTrack()
+{
+     ElementaryPIDObject *as = m_pmt.DecAudioStream();
+     if (as)
+        OpenFilters(as->PID, as->Type);
+}
diff -ur mythtv-20050124-work2/libs/libmythtv/dvbrecorder.h mythtv-20050124-work3/libs/libmythtv/dvbrecorder.h
--- mythtv-20050124-work2/libs/libmythtv/dvbrecorder.h	2005-01-24 12:48:51.000000000 +0800
+++ mythtv-20050124-work3/libs/libmythtv/dvbrecorder.h	2005-01-24 16:17:05.000000000 +0800
@@ -34,6 +34,8 @@
 
     void StartRecording(void);
     void Reset(void);
+    void incCurrentAudioTrack();
+    void decCurrentAudioTrack();
 
 public slots:
     void ChannelChanged(dvb_channel_t& chan);
diff -ur mythtv-20050124-work2/libs/libmythtv/sitypes.cpp mythtv-20050124-work3/libs/libmythtv/sitypes.cpp
--- mythtv-20050124-work2/libs/libmythtv/sitypes.cpp	2005-01-24 15:41:44.000000000 +0800
+++ mythtv-20050124-work3/libs/libmythtv/sitypes.cpp	2005-01-24 16:52:00.564455400 +0800
@@ -289,6 +289,66 @@
     hasVideo = false;
 }
 
+ElementaryPIDObject *PMTObject::DecAudioStream()
+{
+    bool found = false;
+    QValueList<ElementaryPIDObject>::Iterator pit;
+    for (pit = Components.end(); pit != Components.begin(); --pit)
+    {
+        if (found)
+        {
+            switch ((*pit).Record && ((*pit).Type))
+            {
+                case ES_TYPE_AUDIO_MPEG1:
+                case ES_TYPE_AUDIO_MPEG2:
+                case ES_TYPE_AUDIO_AAC:
+                case ES_TYPE_AUDIO_AC3:
+                case ES_TYPE_AUDIO_DTS:
+                    return &(*pit);
+                    break;
+            }
+        }
+        if ((&(*pit) == currentAudioPID) || (currentAudioPID == NULL))
+        {
+            found = true;
+        }	
+    }
+    // didn't find a track after current, search again from
+    // the beginning
+    currentAudioPID = NULL;
+    return DecAudioStream();			
+}
+
+ElementaryPIDObject *PMTObject::IncAudioStream()
+{
+    bool found = false;
+    QValueList<ElementaryPIDObject>::Iterator pit;
+    for (pit = Components.begin(); pit != Components.end(); ++pit)
+    {
+        if (found)
+        {
+            switch ((*pit).Record && ((*pit).Type))
+            {
+                case ES_TYPE_AUDIO_MPEG1:
+                case ES_TYPE_AUDIO_MPEG2:
+                case ES_TYPE_AUDIO_AAC:
+                case ES_TYPE_AUDIO_AC3:
+                case ES_TYPE_AUDIO_DTS:
+                    return &(*pit);
+                    break;
+            }
+        }
+        if ((&(*pit) == currentAudioPID) || (currentAudioPID == NULL))
+        {
+            found = true;
+        }		
+    }
+    // didn't find a track after current, search again from
+    // the beginning
+    currentAudioPID = NULL;
+    return IncAudioStream();
+}
+ 
 // Try to auto detect which audio stream to use
 // NOTE!!! This is only used for PS recording via transform.c!
 ElementaryPIDObject *PMTObject::PreferredAudioStream(bool prefer_ac3 = false)
diff -ur mythtv-20050124-work2/libs/libmythtv/sitypes.h mythtv-20050124-work3/libs/libmythtv/sitypes.h
--- mythtv-20050124-work2/libs/libmythtv/sitypes.h	2005-01-24 15:34:52.000000000 +0800
+++ mythtv-20050124-work3/libs/libmythtv/sitypes.h	2005-01-24 16:43:10.000000000 +0800
@@ -403,6 +403,9 @@
     bool OnAir() { return TelevisionService(); }
     bool FTA() { return !hasCA; }
 
+    ElementaryPIDObject *DecAudioStream();
+    ElementaryPIDObject *IncAudioStream();
+
     ElementaryPIDObject *PreferredAudioStream(bool prefer_ac3);
     ElementaryPIDObject *PreferredVideoStream();
     ElementaryPIDObject *PreferredSubtitleStream();
@@ -417,6 +420,7 @@
     bool hasCA;
     bool hasAudio;
     bool hasVideo;
+    ElementaryPIDObject *currentAudioPID;
 };
 
 /* PAT Handler */
diff -ur mythtv-20050124-work2/libs/libmythtv/tv_play.cpp mythtv-20050124-work3/libs/libmythtv/tv_play.cpp
--- mythtv-20050124-work2/libs/libmythtv/tv_play.cpp	2005-01-24 12:48:53.000000000 +0800
+++ mythtv-20050124-work3/libs/libmythtv/tv_play.cpp	2005-01-24 16:17:06.000000000 +0800
@@ -1592,11 +1592,8 @@
                 activenvp->incCurrentAudioTrack();
                 if ( activenvp->getCurrentAudioTrack() )
                 {
-                    QString msg = QString("%1 %2")
-                                  .arg(tr("Audio track"))
-                                  .arg(activenvp->getCurrentAudioTrack());
-
-                    osd->SetSettingsText(msg, 3);
+                    osd->SetSettingsText(
+			activenvp->getCurrentAudioTrackDescription(), 3);
                 }
             }
         }
@@ -1607,11 +1604,8 @@
                 activenvp->decCurrentAudioTrack();
                 if ( activenvp->getCurrentAudioTrack() )
                 {
-                    QString msg = QString("%1 %2")
-                                  .arg(tr("Audio track"))
-                                  .arg(activenvp->getCurrentAudioTrack());
-
-                    osd->SetSettingsText(msg, 3);
+                    osd->SetSettingsText(
+			activenvp->getCurrentAudioTrackDescription(), 3);
                 }
 
             }
diff -ur mythtv-20050124-work2/libs/libmythtv/tv_rec.cpp mythtv-20050124-work3/libs/libmythtv/tv_rec.cpp
--- mythtv-20050124-work2/libs/libmythtv/tv_rec.cpp	2005-01-24 12:48:53.000000000 +0800
+++ mythtv-20050124-work3/libs/libmythtv/tv_rec.cpp	2005-01-24 16:17:06.000000000 +0800
@@ -2323,3 +2323,13 @@
     pthread_mutex_unlock(&db_lock);
 }
 
+void TVRec::incCurrentAudioTrack()
+{
+#ifdef USING_DVB
+#endif
+}
+void TVRec::decCurrentAudioTrack()
+{
+#ifdef USING_DVB
+#endif
+}
diff -ur mythtv-20050124-work2/libs/libmythtv/tv_rec.h mythtv-20050124-work3/libs/libmythtv/tv_rec.h
--- mythtv-20050124-work2/libs/libmythtv/tv_rec.h	2005-01-24 12:48:53.000000000 +0800
+++ mythtv-20050124-work3/libs/libmythtv/tv_rec.h	2005-01-24 16:17:06.000000000 +0800
@@ -140,6 +140,8 @@
 
     int GetCaptureCardNum(void) { return m_capturecardnum; }
 
+    void incCurrentAudioTrack();
+    void decCurrentAudioTrack();
  protected:
     void RunTV(void);
     static void *EventThread(void *param);


More information about the mythtv-dev mailing list