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 724716 - tsparse: setting pipeline to PLAYING -> READY -> PLAYING is broken
tsparse: setting pipeline to PLAYING -> READY -> PLAYING is broken
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other Linux
: Normal normal
: 1.3.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2014-02-19 14:15 UTC by Francois-Xavier
Modified: 2014-02-21 07:11 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test program (9.26 KB, text/x-csrc)
2014-02-19 14:15 UTC, Francois-Xavier
Details
mpegtsbase logs (54.35 KB, application/octet-stream)
2014-02-19 14:15 UTC, Francois-Xavier
Details

Description Francois-Xavier 2014-02-19 14:15:16 UTC
Created attachment 269681 [details]
test program

Hello,

I am building a simple pipeline with the following elements:

dvbbasebin +-- queue -- fakesink
           |
           +-- appsink

The first time I set the pipeline to PLAYING, data reaches the appsink.
But if I set the pipeline to READY (or NULL) and back to PLAYING again, no data reaches the appsink anymore.

I tracked down the issue to mpegtsbase.c which dvbbasebin uses internally (through tsparse).

As stated by the comment in mpegts_base_apply_pat():

/* Applying a new PAT does two things:
 * * It adds the new programs to the list of programs this element handles
 *   and increments at the same time the number of times a program is referenced.
 *
 * * If there was a previously active PAT, It decrements the reference count
 *   of all program it used. If a program is no longer needed, it is removed.
 */

The thing is, setting the pipeline to READY does not destroy the previous PAT.
So setting the pipeline back to PLAYING will a) add the programs again and b) remove all the programs it had just added.

Attached is a sample program I used to reproduce the issue and the logs from GST_DEBUG=mpegtsbase:5.

The interesting part of the logs are:

0:00:15.616250290 25030       0xa6f630 INFO              mpegtsbase mpegtsbase.c:727:mpegts_base_apply_pat:<mpegtsparse2-0> PAT
0:00:15.616261291 25030       0xa6f630 DEBUG             mpegtsbase mpegtsbase.c:370:mpegts_base_add_program:<mpegtsparse2-0> program_number : 0, pmt_pid : 16
0:00:15.616275819 25030       0xa6f630 DEBUG             mpegtsbase mpegtsbase.c:351:mpegts_base_new_program:<mpegtsparse2-0> program_number : 0, pmt_pid : 16
0:00:15.616336896 25030       0xa6f630 FIXME             mpegtsbase mpegtsbase.c:377:mpegts_base_add_program: Refcounting. Setting twice a PID (0x0010) as known PSI
0:00:15.616354217 25030       0xa6f630 DEBUG             mpegtsbase mpegtsbase.c:370:mpegts_base_add_program:<mpegtsparse2-0> program_number : 257, pmt_pid : 110
0:00:15.616363647 25030       0xa6f630 DEBUG             mpegtsbase mpegtsbase.c:351:mpegts_base_new_program:<mpegtsparse2-0> program_number : 257, pmt_pid : 110
0:00:15.616408998 25030       0xa6f630 DEBUG             mpegtsbase mpegtsbase.c:370:mpegts_base_add_program:<mpegtsparse2-0> program_number : 260, pmt_pid : 310
0:00:15.616420434 25030       0xa6f630 DEBUG             mpegtsbase mpegtsbase.c:351:mpegts_base_new_program:<mpegtsparse2-0> program_number : 260, pmt_pid : 310
0:00:15.616486702 25030       0xa6f630 DEBUG             mpegtsbase mpegtsbase.c:370:mpegts_base_add_program:<mpegtsparse2-0> program_number : 261, pmt_pid : 510
0:00:15.616499692 25030       0xa6f630 DEBUG             mpegtsbase mpegtsbase.c:351:mpegts_base_new_program:<mpegtsparse2-0> program_number : 261, pmt_pid : 510
0:00:15.616544534 25030       0xa6f630 DEBUG             mpegtsbase mpegtsbase.c:370:mpegts_base_add_program:<mpegtsparse2-0> program_number : 262, pmt_pid : 610
0:00:15.616554588 25030       0xa6f630 DEBUG             mpegtsbase mpegtsbase.c:351:mpegts_base_new_program:<mpegtsparse2-0> program_number : 262, pmt_pid : 610
0:00:15.616611727 25030       0xa6f630 DEBUG             mpegtsbase mpegtsbase.c:370:mpegts_base_add_program:<mpegtsparse2-0> program_number : 274, pmt_pid : 210
0:00:15.616622808 25030       0xa6f630 DEBUG             mpegtsbase mpegtsbase.c:351:mpegts_base_new_program:<mpegtsparse2-0> program_number : 274, pmt_pid : 210
0:00:15.616669125 25030       0xa6f630 DEBUG             mpegtsbase mpegtsbase.c:370:mpegts_base_add_program:<mpegtsparse2-0> program_number : 373, pmt_pid : 710
0:00:15.616681246 25030       0xa6f630 DEBUG             mpegtsbase mpegtsbase.c:351:mpegts_base_new_program:<mpegtsparse2-0> program_number : 373, pmt_pid : 710
0:00:15.616700867 25030       0xa6f630 INFO              mpegtsbase mpegtsbase.c:793:mpegts_base_apply_pat:<mpegtsparse2-0> PAT removing program 0x0000 0x0010
0:00:15.616718277 25030       0xa6f630 DEBUG             mpegtsbase mpegtsbase.c:439:mpegts_base_remove_program:<mpegtsparse2-0> program_number : 0
0:00:15.616731542 25030       0xa6f630 FIXME             mpegtsbase mpegtsbase.c:804:mpegts_base_apply_pat: Program refcounting : Setting twice a pid (0x0010) as known PSI
0:00:15.616743574 25030       0xa6f630 INFO              mpegtsbase mpegtsbase.c:793:mpegts_base_apply_pat:<mpegtsparse2-0> PAT removing program 0x0101 0x006e
0:00:15.616753661 25030       0xa6f630 DEBUG             mpegtsbase mpegtsbase.c:439:mpegts_base_remove_program:<mpegtsparse2-0> program_number : 257
0:00:15.616762438 25030       0xa6f630 FIXME             mpegtsbase mpegtsbase.c:804:mpegts_base_apply_pat: Program refcounting : Setting twice a pid (0x006e) as known PSI
0:00:15.616772988 25030       0xa6f630 INFO              mpegtsbase mpegtsbase.c:793:mpegts_base_apply_pat:<mpegtsparse2-0> PAT removing program 0x0104 0x0136
0:00:15.616783026 25030       0xa6f630 DEBUG             mpegtsbase mpegtsbase.c:439:mpegts_base_remove_program:<mpegtsparse2-0> program_number : 260
0:00:15.616794347 25030       0xa6f630 FIXME             mpegtsbase mpegtsbase.c:804:mpegts_base_apply_pat: Program refcounting : Setting twice a pid (0x0136) as known PSI
0:00:15.616804148 25030       0xa6f630 INFO              mpegtsbase mpegtsbase.c:793:mpegts_base_apply_pat:<mpegtsparse2-0> PAT removing program 0x0105 0x01fe
0:00:15.616813544 25030       0xa6f630 DEBUG             mpegtsbase mpegtsbase.c:439:mpegts_base_remove_program:<mpegtsparse2-0> program_number : 261
0:00:15.616822345 25030       0xa6f630 FIXME             mpegtsbase mpegtsbase.c:804:mpegts_base_apply_pat: Program refcounting : Setting twice a pid (0x01fe) as known PSI
0:00:15.616831470 25030       0xa6f630 INFO              mpegtsbase mpegtsbase.c:793:mpegts_base_apply_pat:<mpegtsparse2-0> PAT removing program 0x0106 0x0262
0:00:15.616842126 25030       0xa6f630 DEBUG             mpegtsbase mpegtsbase.c:439:mpegts_base_remove_program:<mpegtsparse2-0> program_number : 262
0:00:15.616851467 25030       0xa6f630 FIXME             mpegtsbase mpegtsbase.c:804:mpegts_base_apply_pat: Program refcounting : Setting twice a pid (0x0262) as known PSI
0:00:15.616872369 25030       0xa6f630 INFO              mpegtsbase mpegtsbase.c:793:mpegts_base_apply_pat:<mpegtsparse2-0> PAT removing program 0x0112 0x00d2
0:00:15.616883384 25030       0xa6f630 DEBUG             mpegtsbase mpegtsbase.c:439:mpegts_base_remove_program:<mpegtsparse2-0> program_number : 274
0:00:15.616893845 25030       0xa6f630 FIXME             mpegtsbase mpegtsbase.c:804:mpegts_base_apply_pat: Program refcounting : Setting twice a pid (0x00d2) as known PSI
0:00:15.616904088 25030       0xa6f630 INFO              mpegtsbase mpegtsbase.c:793:mpegts_base_apply_pat:<mpegtsparse2-0> PAT removing program 0x0175 0x02c6
0:00:15.616916695 25030       0xa6f630 DEBUG             mpegtsbase mpegtsbase.c:439:mpegts_base_remove_program:<mpegtsparse2-0> program_number : 373
0:00:15.616928470 25030       0xa6f630 FIXME             mpegtsbase mpegtsbase.c:804:mpegts_base_apply_pat: Program refcounting : Setting twice a pid (0x02c6) as known PSI
0:00:15.617031749 25030       0xa6f630 DEBUG             mpegtsbase mpegtsbase.c:903:mpegts_base_handle_psi: First PAT offset: 63167
0:00:15.663051718 25030       0xa6f630 DEBUG             mpegtsbase mpegtsbase.c:896:mpegts_base_handle_psi: Handling PSI (pid: 0x0011 , table_id: 0x42)
0:00:15.734676190 25030       0xa6f630 DEBUG             mpegtsbase mpegtsbase.c:896:mpegts_base_handle_psi: Handling PSI (pid: 0x0012 , table_id: 0x50)
0:00:15.774083569 25030       0xa6f630 DEBUG             mpegtsbase mpegtsbase.c:896:mpegts_base_handle_psi: Handling PSI (pid: 0x0012 , table_id: 0x50)
0:00:15.781008411 25030       0xa6f630 DEBUG             mpegtsbase mpegtsbase.c:896:mpegts_base_handle_psi: Handling PSI (pid: 0x0001 , table_id: 0x01)
0:00:15.788950526 25030       0xa6f630 DEBUG             mpegtsbase mpegtsbase.c:896:mpegts_base_handle_psi: Handling PSI (pid: 0x0012 , table_id: 0x4f)
0:00:15.789025174 25030       0xa6f630 DEBUG             mpegtsbase mpegtsbase.c:896:mpegts_base_handle_psi: Handling PSI (pid: 0x006e , table_id: 0x02)
0:00:15.789055142 25030       0xa6f630 DEBUG             mpegtsbase mpegtsbase.c:841:mpegts_base_apply_pmt: Applying PMT (program_number:257, pid:0x006e)
0:00:15.789068376 25030       0xa6f630 ERROR             mpegtsbase mpegtsbase.c:879:mpegts_base_apply_pmt: Attempted to apply a PMT on a program that wasn't created

As one can notice all the programs are added and immediately removed right afterwards.

mpegts_base_reset() which is called on the PAUSED --> READY transition no longer cleans up the PAT and the following comment explains why:

  /* FIXME : Commenting the Following lines is to be in sync with the following
   * commit
   *
   * 61a885613316ce7657c36a6cd215b43f9dc67b79
   *     mpegtsparse: don't free PAT structure which may still be needed later
   */

  /* if (base->pat != NULL) */
  /*   gst_structure_free (base->pat); */
  /* base->pat = NULL; */

I uncommented the code as follows:

  if (base->pat != NULL)
    g_ptr_array_unref (base->pat);
  base->pat = NULL;


It solved the PLAYING -- READY -- PLAYING issue. However I didn't look further into the bug described in the comment and rather leave that to experts :)
Comment 1 Francois-Xavier 2014-02-19 14:15:57 UTC
Created attachment 269682 [details]
mpegtsbase logs
Comment 2 Sebastian Dröge (slomo) 2014-02-19 20:37:06 UTC
I think the PAT and everything else stream related should be freed when going to READY. Nothing of the previous stream should be still around afterwards as it might conflict with the next stream.

Edward, what do you think?
Comment 3 Edward Hervey 2014-02-21 07:04:34 UTC
Agreed, we should uncomment it. It's related to the stream and in READY we should clear anything stream-related.

It might have been commented for DVB start-up ages ago (if you re-use mpegtsparse), but we have a better plan for that now (cache it in dvbbasebin and re-send it if/when needed).
Comment 4 Edward Hervey 2014-02-21 07:11:26 UTC
commit fc34d163d8c184231beb5632cb1421717beca7bf
Author: Edward Hervey <edward@collabora.com>
Date:   Fri Feb 21 14:06:24 2014 +0100

    mpegtsbase: Uncomment PAT clearup in _reset
    
    The PAT is related to the stream, we therefore want it cleared along
    with anything stream related.
    
    This commented section was from the (old) mpegtsparse and *might* have
    been related to speeding up DVB start-up. But we have another plan for that.
    
    Fixes https://bugzilla.gnome.org/show_bug.cgi?id=724716