After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 715147 - tsdemux: Provide PAT/PMT from upstream
tsdemux: Provide PAT/PMT from upstream
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other Linux
: Normal enhancement
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on: 703884
Blocks:
 
 
Reported: 2013-11-25 09:34 UTC by Eric
Modified: 2018-11-03 13:18 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to add 'add-pat' and 'add-pmt' properties to the mpegtsdemux (8.44 KB, patch)
2014-01-03 09:27 UTC, Eric
none Details | Review
Added a function to create an empty section (1.51 KB, patch)
2014-01-03 09:28 UTC, Eric
none Details | Review
Patch to handle Mpeg ts section event. (1.79 KB, patch)
2014-01-09 10:47 UTC, Eric
none Details | Review

Description Eric 2013-11-25 09:34:40 UTC
Hi,
we can't play a mpegts file that does not have a PMT/PAT table because no sink pad is created for such a media.

here is a link to a sample file : 

https://www.dropbox.com/s/ekk4vrzvfymnajv/mpegts_with_not_PAT.mpeg

this file plays ok with mplayer.

Cheers,
Eric
Comment 1 Edward Hervey 2013-11-25 09:57:46 UTC
mplayer only plays one audio track
vlc only plays one audio track

Also : did you miss the discussions on the ml about stream without PAT/PMT ???
Comment 2 Eric 2013-12-09 13:42:15 UTC
Hi Ed,
with mplayer I am able to choose witch audio stream I want to play.

Can you point me to discussion?

Regards,
Eric
Comment 3 Baby octopus 2013-12-19 11:34:48 UTC
VLC doesn't play the file. GOM player plays the video. Mediainfo shows the container type as BDAV(No PAT/PMT)

But honestly what should be the behaviour of tsdemuxer if it doesn't find any PAT and PMT? How will it know what is the PID of each ES in such a case?

Regards,
Jagadish
Comment 4 Eric 2013-12-20 13:39:40 UTC
Giving the demux, programs and pmts via object properties would be nice.

I began writing a patch to the tsdemuxer to allow this behaviour.
For now I am able to have the pipeline build correctly, but unfortunately, the streams don't want to play. I still don't know why. I'll have to investigate this after new year.

Cheers, 
Eric T
Comment 5 Edward Hervey 2013-12-21 06:15:40 UTC
I can see one way to implement this, but *only* once bug #703884 has been implemented.

Once the logic in that bug has been handled, you would then only have to:
1) if more than 100ms (or more) has gone by without a PAT, assume that the PAT is indeed missing
2) For each of the pending PSI/SI streams, check which ones are potential PMT (table_id:0x02). If you have one use that PMT to initialize the program (and carry on as normal)
3) If you haven't found a PMT... you'll have to expose all PES streams
4) For each pending PES, you'll need to pass the data through the typefind functions to figure out what the nature of the stream is. If you have a very high probability match, use those caps and expose the stream
5) If you don't get a very high probability, it might be because we don't have a typefinder for that (might want to create one) or that we don't have enough data yet to typefind it.
Comment 6 Eric 2014-01-02 16:37:39 UTC
Hi Ed,

that sounds good.

Also I tried another approach.

I added two properties to the mpegtsdemux, 
one to add a PAT, and one for a PMT in this way: 

 GstStructure *thePAT = gst_structure_new("pat",
                                          "program-number", G_TYPE_UINT, 1,
                                          "pmt-id", G_TYPE_UINT, 480,
                                          NULL);

 GstStructure *thePMT = gst_structure_new("pmt",
                                          "pmt-pid", G_TYPE_UINT, 480,
                                          "video-pid", G_TYPE_UINT, theVideoPid,
                                          "audio-pid", G_TYPE_UINT, theAudioPid,
                                          "program-number", G_TYPE_UINT, 1,
                                          NULL);
 g_object_set(G_OBJECT(GST_MESSAGE_SRC(aMessage)),
                "add-pat", thePAT,
                "add-pmt", thePMT,
                NULL); 

In the demux I created the a GstMpegTsSection for the PAT and one for the PMT.
Then I call mpegts_base_handle_psi with those struct as argument.

This way I am able to build the whole pipeline, but then I can't manage to actually have the media rendered.

The code is not the nicest as I had to duplicate some function from the mpegts lib, but I can provide it if you want/need.

Regards, 
Eric
Comment 7 Baby octopus 2014-01-02 17:24:47 UTC
Kindly share the patch

Regards,
Jagadish
Comment 8 Eric 2014-01-03 09:27:21 UTC
Created attachment 265208 [details] [review]
Patch to add 'add-pat' and 'add-pmt' properties to the mpegtsdemux

This is a attempt in experimental stage.
I successed in getting the pipeline build for my media, but then it didn't render any output.
Comment 9 Eric 2014-01-03 09:28:23 UTC
Created attachment 265209 [details] [review]
Added a function to create an empty section
Comment 10 Edward Hervey 2014-01-06 07:14:54 UTC
(In reply to comment #6)
> Hi Ed,
> 
> that sounds good.
> 
> Also I tried another approach.
> 

  As is that approach is not acceptable

> The code is not the nicest as I had to duplicate some function from the mpegts
> lib, but I can provide it if you want/need.

  Why not just ... use that library instead of duplicating code from it ?

  An acceptable change would be to have tsdemux/tsparse accept PAT/PMT as downstream events (i.e. coming from upstream). This would also be the longer-term way of handling fast-dvb-startup also (dvbsrc/dvbbasebin could cache the PAT/PMT for various channels and push-them asap as in-band events to notify tsparse/tsemux of upcoming streams).

  In your case it would then end up being:
  1) Create PAT/PMT sections with the mpeg-ts lib
  2) Wrap them as GstEvent
  3) Set/Send those events on tsdemux/tsparse

  There is another bug report regarding adding support for MpegTSSsection as GstEvent, you could re-use/extend that (and I should review it :()
Comment 11 Edward Hervey 2014-01-06 07:28:57 UTC
The bug about sections : https://bugzilla.gnome.org/show_bug.cgi?id=671136
Comment 12 Eric 2014-01-06 08:59:45 UTC
Hi, 
thx for the info.
Sorry for the code duplication, I knew it was ugly, but it was quick :)

The GstEvent approach seems actually better. I'll have a look at it!

Cheers,
Eric
Comment 13 Eric 2014-01-06 09:12:24 UTC
Shall I :

- Move the code I wrote in the SetPropertie to the mpegtslib and create to function to create the the Sections in the lib.

-Create a custom event to send PMT/PAT downstream.

-Add code to handle those events in the demux

Am I correct with this?
Comment 14 Eric 2014-01-06 09:16:25 UTC
Actually I see the Jesper has writen code to create the sections allready...
Comment 15 Eric 2014-01-09 10:47:29 UTC
Created attachment 265822 [details] [review]
Patch to handle Mpeg ts section event.

Need mpegts lib form head with patch from https://bugzilla.gnome.org/show_bug.cgi?id=671136 to build.
Comment 16 Eric 2014-01-09 10:49:48 UTC
Known bugs :
- the media doesn't seem to be seekable, and the seek is doesn't exit...
- The audio and the video are not sync, 1 or 2 second latency...
Comment 17 Eric 2014-01-09 12:49:52 UTC
First bug should linked to (In reply to comment #16)
> Known bugs :
> - the media doesn't seem to be seekable, and the seek is doesn't exit...
must be linked to https://bugzilla.gnome.org/show_bug.cgi?id=721835

> - The audio and the video are not sync, 1 or 2 second latency...
Comment 18 Edward Hervey 2014-02-25 12:50:33 UTC
Eric, those various bugs you mention have been updated. Might want to rebase your patch.

Furthermore, I've had yet-another-idea to speed up stream type detection (i.e. steps 4/5 from Comment #5).

Instead of passing the data through typefind, we can also analyze the various PES start codes and data to identify the stream type.

vlc does that and has covered a good amount of solutions : http://git.videolan.org/?p=vlc.git;a=blob;f=modules/demux/ps.h;h=c36bdcdb0b585418628b1e27968ccc1d60cc7ade;hb=HEAD#l81
Comment 19 Eric 2014-02-25 13:32:03 UTC
Hi, thx fir the update, I'll have a look to the updated code in the next week(s).

(In reply to comment #18)
> Eric, those various bugs you mention have been updated. Might want to rebase
> your patch.
> 
> Furthermore, I've had yet-another-idea to speed up stream type detection (i.e.
> steps 4/5 from Comment #5).
> 
> Instead of passing the data through typefind, we can also analyze the various
> PES start codes and data to identify the stream type.
> 
> vlc does that and has covered a good amount of solutions :
> http://git.videolan.org/?p=vlc.git;a=blob;f=modules/demux/ps.h;h=c36bdcdb0b585418628b1e27968ccc1d60cc7ade;hb=HEAD#l81
Comment 20 Edward Hervey 2018-05-05 08:47:02 UTC
This is definitely still valid, but renaming the title accordingly.
Comment 21 GStreamer system administrator 2018-11-03 13:18:48 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/117.