Index: gst/mpegtsmux/mpegtsmux.c
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-bad/gst/mpegtsmux/mpegtsmux.c,v
retrieving revision 1.5
diff -u -r1.5 mpegtsmux.c
--- gst/mpegtsmux/mpegtsmux.c	24 Nov 2008 10:46:01 -0000	1.5
+++ gst/mpegtsmux/mpegtsmux.c	13 Dec 2008 19:45:58 -0000
@@ -399,6 +399,10 @@
   }
 
   if (ts_data->stream != NULL) {
+    gst_structure_get_int (s, "rate",     &ts_data->stream->audio_sampling);
+    gst_structure_get_int (s, "channels", &ts_data->stream->audio_channels);
+    gst_structure_get_int (s, "bitrate",  &ts_data->stream->audio_bitrate);
+
     tsmux_stream_set_buffer_release_func (ts_data->stream, release_buffer_cb);
     tsmux_program_add_stream (mux->program, ts_data->stream);
 
Index: gst/mpegtsmux/tsmux/tsmux.c
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-bad/gst/mpegtsmux/tsmux/tsmux.c,v
retrieving revision 1.3
diff -u -r1.3 tsmux.c
--- gst/mpegtsmux/tsmux/tsmux.c	2 Sep 2008 09:46:04 -0000	1.3
+++ gst/mpegtsmux/tsmux/tsmux.c	13 Dec 2008 19:45:58 -0000
@@ -1000,9 +1000,14 @@
     else
       tsmux_put16 (&pos, 0xE000 | tsmux_stream_get_pid (program->pcr_stream));
 
-    /* FIXME: Write program descriptors if needed, for now write a 
-     * length of 0 */
-    tsmux_put16 (&pos, 0xF000);
+    /* 4 bits reserved, 12 bits program_info_length, descriptor : HDMV */
+    tsmux_put16 (&pos, 0xF00C);
+    tsmux_put16 (&pos, 0x0504);
+    tsmux_put16 (&pos, 0x4844);
+    tsmux_put16 (&pos, 0x4D56);
+    tsmux_put16 (&pos, 0x8804);
+    tsmux_put16 (&pos, 0x0FFF);
+    tsmux_put16 (&pos, 0xFCFC);
 
     /* Write out the entries */
     for (i = 0; i < program->nb_streams; i++) {
Index: gst/mpegtsmux/tsmux/tsmuxstream.c
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-bad/gst/mpegtsmux/tsmux/tsmuxstream.c,v
retrieving revision 1.3
diff -u -r1.3 tsmuxstream.c
--- gst/mpegtsmux/tsmux/tsmuxstream.c	24 Nov 2008 10:46:01 -0000	1.3
+++ gst/mpegtsmux/tsmux/tsmuxstream.c	13 Dec 2008 19:45:59 -0000
@@ -157,7 +157,7 @@
           stream->id_extended = 0x80;
           break;
         case TSMUX_ST_PS_AUDIO_AC3:
-          stream->id_extended = 0x81;
+          stream->id_extended = 0x71;
           break;
         case TSMUX_ST_PS_AUDIO_DTS:
           stream->id_extended = 0x82;
@@ -559,7 +559,7 @@
       ext_len = 1;              /* Only writing 1 byte into the extended fields */
       *data++ = 0x80 | ext_len;
       /* Write the extended streamID */
-      *data++ = 0x80 | stream->id_extended;
+      *data++ = stream->id_extended;
     }
   }
 }
@@ -631,9 +631,28 @@
    * PMT ES_info field */
   pos = buf;
 
+  /* tag (registration_descriptor), length, format_identifier */
   switch (stream->stream_type) {
+    case TSMUX_ST_AUDIO_AAC:
+      /* FIXME */
+      break;
+    case TSMUX_ST_VIDEO_MPEG4:
+      /* FIXME */
+      break;
+    case TSMUX_ST_VIDEO_H264:
+      *pos++ = 0x05;
+      *pos++ = 8;
+      *pos++ = 0x48;            /* 'H' */
+      *pos++ = 0x44;            /* 'D' */
+      *pos++ = 0x4D;            /* 'M' */
+      *pos++ = 0x56;            /* 'V' */
+      /* FIXME : Not sure about this additional_identification_info */
+      *pos++ = 0xFF;
+      *pos++ = 0x1B;
+      *pos++ = 0x44;
+      *pos++ = 0x3F;
+      break;
     case TSMUX_ST_VIDEO_DIRAC:
-      /* tag (registration_descriptor), length, format_identifier */
       *pos++ = 0x05;
       *pos++ = 4;
       *pos++ = 0x64;            /* 'd' */
@@ -641,6 +660,88 @@
       *pos++ = 0x61;            /* 'a' */
       *pos++ = 0x63;            /* 'c' */
       break;
+    case TSMUX_ST_PS_AUDIO_AC3:
+    {
+      *pos++ = 0x05;
+      *pos++ = 4;
+      *pos++ = 0x41;            /* 'A' */
+      *pos++ = 0x43;            /* 'C' */
+      *pos++ = 0x2D;            /* '-' */
+      *pos++ = 0x33;            /* '3' */
+
+      /* audio_stream_descriptor () | ATSC A/52-2001 Annex A
+       *
+       * descriptor_tag       8 uimsbf
+       * descriptor_length    8 uimsbf
+       * sample_rate_code     3 bslbf
+       * bsid                 5 bslbf
+       * bit_rate_code        6 bslbf
+       * surround_mode        2 bslbf
+       * bsmod                3 bslbf
+       * num_channels         4 bslbf
+       * full_svc             1 bslbf
+       * langcod              8 bslbf
+       * [...]
+       */
+      *pos++ = 0x81;
+      *pos++ = 0x04;
+
+      /* 3 bits sample_rate_code, 5 bits hardcoded bsid (default ver 8) */
+      switch (stream->audio_sampling)
+      {
+        case 48000 : *pos++ = 0x08; break;
+        case 44100 : *pos++ = 0x28; break;
+        case 32000 : *pos++ = 0x48; break;
+        default    : *pos++ = 0xE8; break; /* 48, 44.1 or 32 Khz */
+      }
+
+      /* 1 bit bit_rate_limit, 5 bits bit_rate_code, 2 bits suround_mode */
+      switch (stream->audio_bitrate)
+      {
+        case 32  : *pos++ = 0x00 << 2; break;
+        case 40  : *pos++ = 0x01 << 2; break;
+        case 48  : *pos++ = 0x02 << 2; break;
+        case 56  : *pos++ = 0x03 << 2; break;
+        case 64  : *pos++ = 0x04 << 2; break;
+        case 80  : *pos++ = 0x05 << 2; break;
+        case 96  : *pos++ = 0x06 << 2; break;
+        case 112 : *pos++ = 0x07 << 2; break;
+        case 128 : *pos++ = 0x08 << 2; break;
+        case 160 : *pos++ = 0x09 << 2; break;
+        case 192 : *pos++ = 0x0A << 2; break;
+        case 224 : *pos++ = 0x0B << 2; break;
+        case 256 : *pos++ = 0x0C << 2; break;
+        case 320 : *pos++ = 0x0D << 2; break;
+        case 384 : *pos++ = 0x0E << 2; break;
+        case 448 : *pos++ = 0x0F << 2; break;
+        case 512 : *pos++ = 0x10 << 2; break;
+        case 576 : *pos++ = 0x11 << 2; break;
+        case 640 : *pos++ = 0x12 << 2; break;
+        default  : *pos++ = 0x32 << 2; break; /* 640 Kb/s upper limit */
+      }
+
+      /* 3 bits bsmod, 4 bits num_channels, 1 bit full_svc */
+      switch (stream->audio_channels)
+      {
+        case 1  : *pos++ = 0x01 << 1; break; /* 1/0 */
+        case 2  : *pos++ = 0x02 << 1; break; /* 2/0 */
+        case 3  : *pos++ = 0x0A << 1; break; /* <= 3 */
+        case 4  : *pos++ = 0x0B << 1; break; /* <= 4 */
+        case 5  : *pos++ = 0x0C << 1; break; /* <= 5 */
+        case 6  :
+        default : *pos++ = 0x0D << 1; break; /* <= 6 */
+      }
+
+      *pos++ = 0x00;
+
+      break;
+    }
+    case TSMUX_ST_PS_AUDIO_DTS:
+      /* FIXME */
+      break;
+    case TSMUX_ST_PS_AUDIO_LPCM:
+      /* FIXME */
+      break;
     default:
       break;
   }
Index: gst/mpegtsmux/tsmux/tsmuxstream.h
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-bad/gst/mpegtsmux/tsmux/tsmuxstream.h,v
retrieving revision 1.2
diff -u -r1.2 tsmuxstream.h
--- gst/mpegtsmux/tsmux/tsmuxstream.h	1 Sep 2008 17:41:39 -0000	1.2
+++ gst/mpegtsmux/tsmux/tsmuxstream.h	13 Dec 2008 19:45:59 -0000
@@ -183,6 +183,10 @@
 
   gint   pcr_ref;
   gint64 last_pcr;
+
+  gint audio_sampling;
+  gint audio_channels;
+  gint audio_bitrate;
 };
 
 /* stream management */
