Pad-added not trigger in nodejs

Hi everyone,

I am trying writing Basic tutorial 3: Dynamic pipelines to TypeScript with node-gtk

But I always cannot recived ‘pad-added’

Am I doing something wrong?

No any log about it

I can play it with CLI: gst-launch-1.0 uridecodebin uri=https://gstreamer.freedesktop.org/data/media/sintel_trailer-480p.webm ! audioconvert ! audioresample ! autoaudiosink

Also I can recived ‘pad-added’ with C

Here is my code:

import Gst from '@girs/node-gst-1.0';

/* Structure to contain all our information, so we can pass it to callbacks */
type CustomData = {
  source?: Gst.Element;
  convert?: Gst.Element;
  resample?: Gst.Element;
  sink?: Gst.Element;
  pipeline?: Gst.Pipeline;
};

(async function main() {
  const data: CustomData = {};
  let terminate = false;

  /* Initialize GStreamer */
  Gst.init(null);

  /* Create the elements */
  data.source = Gst.ElementFactory.make('uridecodebin', 'source');
  data.convert = Gst.ElementFactory.make('audioconvert', 'convert');
  data.resample = Gst.ElementFactory.make('audioresample', 'resample');
  data.sink = Gst.ElementFactory.make('autoaudiosink', 'sink');

  /* Create the empty pipeline */
  data.pipeline = new Gst.Pipeline({ name: 'test-pipeline' });

  if (
    !data.source ||
    !data.convert ||
    !data.resample ||
    !data.sink ||
    !data.pipeline
  ) {
    console.error('Not all elements could be created.');
    return;
  }

  /* Build the pipeline. Note that we are NOT linking the source at this point. We will do it later. */
  data.pipeline.add(data.source);
  data.pipeline.add(data.convert);
  data.pipeline.add(data.resample);
  data.pipeline.add(data.sink);
  if (!data.convert.link(data.resample) || !data.resample.link(data.sink)) {
    console.error('Elements could not be linked.');
    data.pipeline.unref();
    return;
  }

  /* Set the URI to play */
  data.source['uri'] =
    'https://gstreamer.freedesktop.org/data/media/sintel_trailer-480p.webm';

  /* Connect to the pad-added signal */
  data.source.connect('pad-added', (pad: Gst.Pad) => {
    padAddedHandler(data.source, pad, data);
  });

  /* Start playing */
  const ret = data.pipeline.setState(Gst.State.PLAYING);
  if (ret === Gst.StateChangeReturn.FAILURE) {
    console.error('Unable to set the pipeline to the playing state.');
    data.pipeline.unref();
    throw new Error();
  }

  /* Listen to the bus */
  const bus = data.pipeline.getBus();
  do {
    const msg = bus.timedPopFiltered(
      Gst.CLOCK_TIME_NONE,
      Gst.MessageType.STATE_CHANGED |
        Gst.MessageType.ERROR |
        Gst.MessageType.EOS,
    );

    /* Parse message */
    if (msg) {
      switch (msg.type) {
        case Gst.MessageType.ERROR:
          const [err, debugInfo] = msg.parseError();
          console.error(
            `Error received from element ${msg.src.name}: ${err.message}`,
          );
          console.error(`Debugging information: ${debugInfo || 'none'}`);
          err.free();
          terminate = true;
          break;
        case Gst.MessageType.EOS:
          console.log('End-Of-Stream reached.');
          terminate = true;
          break;
        case Gst.MessageType.STATE_CHANGED:
          /* We are only interested in state-changed messages from the pipeline */
          if (msg.src === data.pipeline) {
            const [oldState, newState, pendingState] = msg.parseStateChanged();
            const oldStateName = Gst.Element.stateGetName(oldState);
            const newStateName = Gst.Element.stateGetName(newState);
            console.log(
              `Pipeline state changed from ${oldStateName} to ${newStateName}`,
            );
          }
          break;
        default:
          /* We should not reach here */
          console.error('Unexpected message received.');
          break;
      }
    }
  } while (!terminate);

  /* Free resources */
  bus.unref();
  data.pipeline.setState(Gst.State.NULL);
  data.pipeline.unref();
})();

function padAddedHandler(src: Gst.Element, newPad: Gst.Pad, data: CustomData) {
  const sinkPad = data.convert.getStaticPad('sink');

  do {
    console.log(`Received new pad '${src.name}' from '${data.source.name}':`);

    /* If our converter is already linked, we have nothing to do here */
    if (sinkPad.isLinked()) {
      console.log('We are already linked. Ignoring.');
      break;
    }

    /* Check the new pad's type */
    const newPadCaps = newPad.getCurrentCaps();
    const newPadStruct = newPadCaps.getStructure(0);
    const newPadType = newPadStruct.getName();
    if (!newPadType.startsWith('audio/x-raw')) {
      console.log(
        `It has type '${newPadType}' which is not raw audio. Ignoring.`,
      );
      break;
    }

    /* Attempt the link */
    const ret = newPad.link(sinkPad);
    if (ret !== Gst.PadLinkReturn.OK) {
      console.error(`Type is '${newPadType}' but link failed.`);
    } else {
      console.log(`Link succeeded (type '${newPadType}').`);
    }
  } while (false);

  /* Unreference the sink pad */
  sinkPad.unref();
}

Execution results:

Pipeline state changed from NULL to READY:

Excepted results:

Pipeline state changed from NULL to READY:
Received new pad 'src_0' from 'source':
It has type 'video/x-raw' which is not raw audio. Ignoring.
Received new pad 'src_1' from 'source':
Link succeeded (type 'audio/x-raw').
Pipeline state changed from READY to PAUSED:
Pipeline state changed from PAUSED to PLAYING:

I noticed that the code data.pipeline.setState(Gst.State.PLAYING) does more things than gst_element_set_state(data.pipeline, GST_STATE_PLAYING)

        souphttpsrc gstsouphttpsrc.c:1421:gst_soup_http_src_got_headers:<source> 
          GST_EVENT gstevent.c:998:gst_event_new_segment: creating segment event 
            basesrc gstbasesrc.c:3068:gst_base_src_loop:<source> marking pending 
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
       GST_TYPEFIND gsttypefind.c:72:gst_type_find_register: registering typefind
 GST_PLUGIN_LOADING gstplugin.c:995:_priv_gst_plugin_load_file_for_registry: plug
  typefindfunctions gsttypefindfunctions.c:4726:matroska_type_find: === top-level
  typefindfunctions gsttypefindfunctions.c:4732:matroska_type_find: === done with
  typefindfunctions gsttypefindfunctions.c:4726:matroska_type_find: === top-level
  typefindfunctions gsttypefindfunctions.c:4737:matroska_type_find: audio=1 video
          GST_EVENT gstevent.c:918:gst_event_new_caps: creating caps event video/
GST_ELEMENT_FACTORY gstelementfactory.c:489:gst_element_factory_create_with_prope
GST_ELEMENT_FACTORY gstelementfactory.c:489:gst_element_factory_create_with_prope
   GST_ELEMENT_PADS gstelement.c:758:gst_element_add_pad:<GstTypeFindElement@0x7b
   GST_ELEMENT_PADS gstelement.c:758:gst_element_add_pad:<GstTypeFindElement@0x7b
   GST_ELEMENT_PADS gstelement.c:1016:gst_element_get_static_pad: found pad typef
           GST_PADS gstpad.c:2440:gst_pad_link_prepare: trying to link sink:proxy
           GST_PADS gstpad.c:2621:gst_pad_link_full: linked sink:proxypad1 and ty
          GST_EVENT gstevent.c:1687:gst_event_new_reconfigure: creating reconfigu
   GST_ELEMENT_PADS gstelement.c:758:gst_element_add_pad:<GstDecodeBin@0x7beb7800
GST_ELEMENT_FACTORY gstelementfactory.c:489:gst_element_factory_create_with_prope
   GST_ELEMENT_PADS gstelement.c:758:gst_element_add_pad:<GstQueue2@0x7beb7803656
   GST_ELEMENT_PADS gstelement.c:758:gst_element_add_pad:<GstQueue2@0x7beb7803656
   GST_ELEMENT_PADS gstutils.c:1818:gst_element_link_pads_full: trying to link el
   GST_ELEMENT_PADS gstelement.c:1016:gst_element_get_static_pad: found pad typef
   GST_ELEMENT_PADS gstelement.c:1016:gst_element_get_static_pad: found pad queue
           GST_PADS gstutils.c:1634:prepare_link_maybe_ghosting: typefindelement0
           GST_PADS gstpad.c:2440:gst_pad_link_prepare: trying to link typefindel
           GST_PADS gstpad.c:4398:gst_pad_peer_query:<queue2-0:src> pad has no pe
           GST_PADS gstpad.c:2621:gst_pad_link_full: linked typefindelement0:src 
          GST_EVENT gstevent.c:1687:gst_event_new_reconfigure: creating reconfigu
   GST_ELEMENT_PADS gstutils.c:1818:gst_element_link_pads_full: trying to link el
   GST_ELEMENT_PADS gstelement.c:1016:gst_element_get_static_pad: found pad queue
   GST_ELEMENT_PADS gstelement.c:1016:gst_element_get_static_pad: found pad decod
           GST_PADS gstutils.c:1634:prepare_link_maybe_ghosting: queue2-0 and dec
           GST_PADS gstpad.c:2440:gst_pad_link_prepare: trying to link queue2-0:s
           GST_PADS gstpad.c:2621:gst_pad_link_full: linked queue2-0:src and deco
          GST_EVENT gstevent.c:1687:gst_event_new_reconfigure: creating reconfigu
          GST_EVENT gstpad.c:6017:gst_pad_send_event_unchecked:<queue2-0:src> Rec
         GST_STATES gstbin.c:2480:gst_bin_element_set_state:<typefind> current NU
         GST_STATES gstelement.c:2824:gst_element_continue_state:<typefind> compl
         GST_STATES gstelement.c:2724:_priv_gst_element_state_changed:<typefind> 
         GST_STATES gstbin.c:2939:gst_bin_change_state_func:<decodebin0> child 't
         GST_STATES gstelement.c:2796:gst_element_continue_state:<decodebin0> com
         GST_STATES gstelement.c:2724:_priv_gst_element_state_changed:<decodebin0
         GST_STATES gstelement.c:2804:gst_element_continue_state:<decodebin0> con
         GST_STATES gstbin.c:2480:gst_bin_element_set_state:<typefind> current RE
         GST_STATES gstelement.c:2824:gst_element_continue_state:<typefind> compl
         GST_STATES gstelement.c:2724:_priv_gst_element_state_changed:<typefind> 
         GST_STATES gstbin.c:2939:gst_bin_change_state_func:<decodebin0> child 't
         GST_STATES gstelement.c:2796:gst_element_continue_state:<queue2-0> commi
         GST_STATES gstelement.c:2724:_priv_gst_element_state_changed:<queue2-0> 
         GST_STATES gstelement.c:2804:gst_element_continue_state:<queue2-0> conti
               task gsttask.c:531:gst_task_set_lock: setting stream lock 0x7beb78
           GST_PADS gstpad.c:6363:gst_pad_start_task:<queue2-0:src> created task 
         GST_STATES gstelement.c:2824:gst_element_continue_state:<queue2-0> compl
         GST_STATES gstelement.c:2724:_priv_gst_element_state_changed:<queue2-0> 
           typefind gsttypefindelement.c:183:gst_type_find_element_have_type:<typ
             queue2 gstqueue2.c:2400:gst_queue2_locked_enqueue: got caps: video/w
           GST_PADS gstpad.c:4398:gst_pad_peer_query:<typefind:src> pad has no pe
          GST_EVENT gstevent.c:918:gst_event_new_caps: creating caps event video/
   GST_ELEMENT_PADS gstelement.c:1016:gst_element_get_static_pad: found pad typef
   GST_ELEMENT_PADS gstelement.c:1016:gst_element_get_static_pad: found pad typef
           GST_PADS gstpad.c:2440:gst_pad_link_prepare: trying to link typefind:s
           GST_PADS gstpad.c:2621:gst_pad_link_full: linked typefind:src and deco
          GST_EVENT gstevent.c:1687:gst_event_new_reconfigure: creating reconfigu
   GST_ELEMENT_PADS gstpad.c:2145:gst_pad_unlink: unlinking typefind:src(0x7beb78
   GST_ELEMENT_PADS gstpad.c:2200:gst_pad_unlink: unlinked typefind:src and decod
           GST_PADS gstpad.c:2440:gst_pad_link_prepare: trying to link typefind:s
           GST_PADS gstpad.c:2621:gst_pad_link_full: linked typefind:src and deco
          GST_EVENT gstevent.c:1687:gst_event_new_reconfigure: creating reconfigu
   GST_ELEMENT_PADS gstpad.c:2145:gst_pad_unlink: unlinking typefind:src(0x7beb78
   GST_ELEMENT_PADS gstpad.c:2200:gst_pad_unlink: unlinked typefind:src and decod
 GST_PLUGIN_LOADING gstplugin.c:995:_priv_gst_plugin_load_file_for_registry: plug
GST_ELEMENT_FACTORY gstelementfactory.c:489:gst_element_factory_create_with_prope
   GST_ELEMENT_PADS gstelement.c:758:gst_element_add_pad:<GstMatroskaDemux@0x7beb
           GST_PADS gstpad.c:2440:gst_pad_link_prepare: trying to link typefind:s
           GST_PADS gstpad.c:2621:gst_pad_link_full: linked typefind:src and matr
          GST_EVENT gstevent.c:1687:gst_event_new_reconfigure: creating reconfigu
         GST_STATES gstelement.c:2824:gst_element_continue_state:<matroskademux0>
         GST_STATES gstelement.c:2724:_priv_gst_element_state_changed:<matroskade
   GST_ELEMENT_PADS gstelement.c:1013:gst_element_get_static_pad: no such pad 'vi
   GST_ELEMENT_PADS gstelement.c:1013:gst_element_get_static_pad: no such pad 'au
   GST_ELEMENT_PADS gstelement.c:1013:gst_element_get_static_pad: no such pad 'su
         GST_STATES gstelement.c:2824:gst_element_continue_state:<matroskademux0>
         GST_STATES gstelement.c:2724:_priv_gst_element_state_changed:<matroskade
           typefind gsttypefindelement.c:183:gst_type_find_element_have_type:<typ
 matroskareadcommon matroska-read-common.c:1601:gst_matroska_read_common_parse_he
      matroskademux matroska-demux.c:5528:gst_matroska_demux_check_seekability:<m
      matroskademux matroska-demux.c:1727:gst_matroska_demux_add_stream:<matroska
   GST_ELEMENT_PADS gstelement.c:1016:gst_element_get_static_pad: found pad matro
          GST_EVENT gstevent.c:918:gst_event_new_caps: creating caps event video/
   GST_ELEMENT_PADS gstelement.c:758:gst_element_add_pad:<matroskademux0> adding 
GST_ELEMENT_FACTORY gstelementfactory.c:489:gst_element_factory_create_with_prope
   GST_ELEMENT_PADS gstelement.c:1016:gst_element_get_static_pad: found pad matro
         GST_STATES gstelement.c:2796:gst_element_continue_state:<multiqueue0> co
         GST_STATES gstelement.c:2724:_priv_gst_element_state_changed:<multiqueue
         GST_STATES gstelement.c:2804:gst_element_continue_state:<multiqueue0> co
         GST_STATES gstelement.c:2824:gst_element_continue_state:<multiqueue0> co
         GST_STATES gstelement.c:2724:_priv_gst_element_state_changed:<multiqueue
           GST_PADS gstpad.c:2440:gst_pad_link_prepare: trying to link matroskade
           GST_PADS gstpad.c:2621:gst_pad_link_full: linked matroskademux0:video_
          GST_EVENT gstevent.c:1687:gst_event_new_reconfigure: creating reconfigu
   GST_ELEMENT_PADS gstpad.c:2145:gst_pad_unlink: unlinking matroskademux0:video_
   GST_ELEMENT_PADS gstpad.c:2200:gst_pad_unlink: unlinked matroskademux0:video_0
   GST_ELEMENT_PADS gstelement.c:758:gst_element_add_pad:<multiqueue0> adding pad
   GST_ELEMENT_PADS gstelement.c:758:gst_element_add_pad:<multiqueue0> adding pad
               task gsttask.c:531:gst_task_set_lock: setting stream lock 0x7beb60
           GST_PADS gstpad.c:6363:gst_pad_start_task:<multiqueue0:src_0> created 
           GST_PADS gstpad.c:2440:gst_pad_link_prepare: trying to link matroskade
           GST_PADS gstpad.c:2621:gst_pad_link_full: linked matroskademux0:video_
          GST_EVENT gstevent.c:1687:gst_event_new_reconfigure: creating reconfigu
           GST_PADS gstpad.c:2440:gst_pad_link_prepare: trying to link multiqueue
           GST_PADS gstpad.c:2621:gst_pad_link_full: linked multiqueue0:src_0 and
          GST_EVENT gstevent.c:1687:gst_event_new_reconfigure: creating reconfigu
   GST_ELEMENT_PADS gstpad.c:2145:gst_pad_unlink: unlinking multiqueue0:src_0(0x7
   GST_ELEMENT_PADS gstpad.c:2200:gst_pad_unlink: unlinked multiqueue0:src_0 and 
           GST_PADS gstpad.c:2440:gst_pad_link_prepare: trying to link multiqueue
           GST_PADS gstpad.c:2621:gst_pad_link_full: linked multiqueue0:src_0 and
          GST_EVENT gstevent.c:1687:gst_event_new_reconfigure: creating reconfigu
   GST_ELEMENT_PADS gstpad.c:2145:gst_pad_unlink: unlinking multiqueue0:src_0(0x7
   GST_ELEMENT_PADS gstpad.c:2200:gst_pad_unlink: unlinked multiqueue0:src_0 and 
          vadisplay gstvadisplay_drm.c:155:gst_va_display_drm_create_va_display:<
          vadisplay gstvadisplay.c:353:_va_info:<vadisplaydrm0> VA info: VA-API v
          vadisplay gstvadisplay.c:353:_va_info:<vadisplaydrm0> VA info: Trying t
          vadisplay gstvadisplay.c:353:_va_info:<vadisplaydrm0> VA info: Found in
          vadisplay gstvadisplay.c:353:_va_info:<vadisplaydrm0> VA info: va_openD
          vadisplay gstvadisplay.c:405:gst_va_display_initialize:<vadisplaydrm0> 
          vadisplay gstvadisplay.c:176:_gst_va_display_filter_driver: VA-API driv
                 va gstvadevice_linux.c:104:gst_va_device_find_devices: Found VA-
          vadisplay gstvadisplay_drm.c:155:gst_va_display_drm_create_va_display:<
          vadisplay gstvadisplay.c:353:_va_info:<vadisplaydrm1> VA info: VA-API v
          vadisplay gstvadisplay.c:353:_va_info:<vadisplaydrm1> VA info: Trying t
          vadisplay gstvadisplay.c:353:_va_info:<vadisplaydrm1> VA info: va_openD
          vadisplay gstvadisplay.c:401:gst_va_display_initialize:<vadisplaydrm1> 
          vadisplay gstvavideoformat.c:458:fix_map: GST_VIDEO_FORMAT_ARGB => { fo
          vadisplay gstvavideoformat.c:458:fix_map: GST_VIDEO_FORMAT_BGRA => { fo
          vadisplay gstvavideoformat.c:458:fix_map: GST_VIDEO_FORMAT_ABGR => { fo
          vadisplay gstvavideoformat.c:458:fix_map: GST_VIDEO_FORMAT_RGBA => { fo
          vadisplay gstvavideoformat.c:458:fix_map: GST_VIDEO_FORMAT_xRGB => { fo
          vadisplay gstvavideoformat.c:458:fix_map: GST_VIDEO_FORMAT_BGRx => { fo
          vadisplay gstvavideoformat.c:458:fix_map: GST_VIDEO_FORMAT_xBGR => { fo
          vadisplay gstvavideoformat.c:458:fix_map: GST_VIDEO_FORMAT_RGBx => { fo
 GST_PLUGIN_LOADING gstplugin.c:995:_priv_gst_plugin_load_file_for_registry: plug
GST_ELEMENT_FACTORY gstelementfactory.c:489:gst_element_factory_create_with_prope
   GST_ELEMENT_PADS gstelement.c:758:gst_element_add_pad:<GstVideoDecoder@0x7beb6
   GST_ELEMENT_PADS gstelement.c:758:gst_element_add_pad:<GstVideoDecoder@0x7beb6
           GST_PADS gstpad.c:2440:gst_pad_link_prepare: trying to link multiqueue
           GST_PADS gstpad.c:2621:gst_pad_link_full: linked multiqueue0:src_0 and
          GST_EVENT gstevent.c:1687:gst_event_new_reconfigure: creating reconfigu
           GST_PADS gstpad.c:4398:gst_pad_peer_query:<vavp8dec0:src> pad has no p
        GST_CONTEXT gstvautils.c:83:pad_query:<vavp8dec0:src> pad peer query fail
        GST_CONTEXT gstvautils.c:83:pad_query:<vavp8dec0:sink> pad peer query fai
        GST_CONTEXT gstvautils.c:152:gst_va_context_query:<vavp8dec0> posting nee
          vadisplay gstvadisplay_drm.c:155:gst_va_display_drm_create_va_display:<
          vadisplay gstvadisplay.c:353:_va_info:<vadisplaydrm2> VA info: VA-API v
          vadisplay gstvadisplay.c:353:_va_info:<vadisplaydrm2> VA info: Trying t
          vadisplay gstvadisplay.c:353:_va_info:<vadisplaydrm2> VA info: Found in
          vadisplay gstvadisplay.c:353:_va_info:<vadisplaydrm2> VA info: va_openD
          vadisplay gstvadisplay.c:405:gst_va_display_initialize:<vadisplaydrm2> 
          vadisplay gstvadisplay.c:176:_gst_va_display_filter_driver: VA-API driv
        GST_CONTEXT gstvautils.c:197:gst_va_element_propagate_display_context:<va
         GST_STATES gstelement.c:2824:gst_element_continue_state:<vavp8dec0> comp
         GST_STATES gstelement.c:2724:_priv_gst_element_state_changed:<vavp8dec0>
           GST_PADS gstpad.c:4398:gst_pad_peer_query:<vavp8dec0:src> pad has no p
   GST_ELEMENT_PADS gstelement.c:1016:gst_element_get_static_pad: found pad vavp8
           GST_PADS gstpad.c:2440:gst_pad_link_prepare: trying to link vavp8dec0:
           GST_PADS gstpad.c:2621:gst_pad_link_full: linked vavp8dec0:src and dec
          GST_EVENT gstevent.c:1687:gst_event_new_reconfigure: creating reconfigu
          GST_EVENT gstpad.c:6017:gst_pad_send_event_unchecked:<vavp8dec0:src> Re
         GST_STATES gstelement.c:2824:gst_element_continue_state:<vavp8dec0> comp
         GST_STATES gstelement.c:2724:_priv_gst_element_state_changed:<vavp8dec0>
           GST_PADS gstpad.c:4398:gst_pad_peer_query:<'':decodepad1> pad has no p
       videodecoder gstvideodecoder.c:1631:gst_video_decoder_sink_event_default:<
      matroskademux matroska-demux.c:1727:gst_matroska_demux_add_stream:<matroska
   GST_ELEMENT_PADS gstelement.c:1016:gst_element_get_static_pad: found pad matro
          GST_EVENT gstevent.c:918:gst_event_new_caps: creating caps event audio/
   GST_ELEMENT_PADS gstelement.c:758:gst_element_add_pad:<matroskademux0> adding 
           GST_PADS gstpad.c:2440:gst_pad_link_prepare: trying to link matroskade
           GST_PADS gstpad.c:2621:gst_pad_link_full: linked matroskademux0:audio_
          GST_EVENT gstevent.c:1687:gst_event_new_reconfigure: creating reconfigu
   GST_ELEMENT_PADS gstpad.c:2145:gst_pad_unlink: unlinking matroskademux0:audio_
   GST_ELEMENT_PADS gstpad.c:2200:gst_pad_unlink: unlinked matroskademux0:audio_0
   GST_ELEMENT_PADS gstelement.c:758:gst_element_add_pad:<multiqueue0> adding pad
   GST_ELEMENT_PADS gstelement.c:758:gst_element_add_pad:<multiqueue0> adding pad
               task gsttask.c:531:gst_task_set_lock: setting stream lock 0x7beb60
           GST_PADS gstpad.c:6363:gst_pad_start_task:<multiqueue0:src_1> created 
           GST_PADS gstpad.c:2440:gst_pad_link_prepare: trying to link matroskade
           GST_PADS gstpad.c:2621:gst_pad_link_full: linked matroskademux0:audio_
          GST_EVENT gstevent.c:1687:gst_event_new_reconfigure: creating reconfigu
           GST_PADS gstpad.c:2440:gst_pad_link_prepare: trying to link multiqueue
           GST_PADS gstpad.c:2621:gst_pad_link_full: linked multiqueue0:src_1 and
          GST_EVENT gstevent.c:1687:gst_event_new_reconfigure: creating reconfigu
   GST_ELEMENT_PADS gstpad.c:2145:gst_pad_unlink: unlinking multiqueue0:src_1(0x7
   GST_ELEMENT_PADS gstpad.c:2200:gst_pad_unlink: unlinked multiqueue0:src_1 and 
           GST_PADS gstpad.c:2440:gst_pad_link_prepare: trying to link multiqueue
           GST_PADS gstpad.c:2621:gst_pad_link_full: linked multiqueue0:src_1 and
          GST_EVENT gstevent.c:1687:gst_event_new_reconfigure: creating reconfigu
   GST_ELEMENT_PADS gstpad.c:2145:gst_pad_unlink: unlinking multiqueue0:src_1(0x7
   GST_ELEMENT_PADS gstpad.c:2200:gst_pad_unlink: unlinked multiqueue0:src_1 and 
 GST_PLUGIN_LOADING gstplugin.c:995:_priv_gst_plugin_load_file_for_registry: plug
GST_ELEMENT_FACTORY gstelementfactory.c:489:gst_element_factory_create_with_prope
   GST_ELEMENT_PADS gstelement.c:758:gst_element_add_pad:<GstAudioDecoder@0x7beb6
   GST_ELEMENT_PADS gstelement.c:758:gst_element_add_pad:<GstAudioDecoder@0x7beb6
           GST_PADS gstpad.c:2440:gst_pad_link_prepare: trying to link multiqueue
           GST_PADS gstpad.c:2621:gst_pad_link_full: linked multiqueue0:src_1 and
          GST_EVENT gstevent.c:1687:gst_event_new_reconfigure: creating reconfigu
         GST_STATES gstelement.c:2824:gst_element_continue_state:<vorbisdec0> com
         GST_STATES gstelement.c:2724:_priv_gst_element_state_changed:<vorbisdec0
   GST_ELEMENT_PADS gstelement.c:1016:gst_element_get_static_pad: found pad vorbi
           GST_PADS gstpad.c:2440:gst_pad_link_prepare: trying to link vorbisdec0
           GST_PADS gstpad.c:2621:gst_pad_link_full: linked vorbisdec0:src and de
          GST_EVENT gstevent.c:1687:gst_event_new_reconfigure: creating reconfigu
          GST_EVENT gstpad.c:6017:gst_pad_send_event_unchecked:<vorbisdec0:src> R
         GST_STATES gstelement.c:2824:gst_element_continue_state:<vorbisdec0> com
         GST_STATES gstelement.c:2724:_priv_gst_element_state_changed:<vorbisdec0
       audiodecoder gstaudiodecoder.c:2539:gst_audio_decoder_sink_eventfunc:<vorb
          GST_EVENT gstevent.c:998:gst_event_new_segment: creating segment event 
           GST_PADS gstpad.c:4398:gst_pad_peer_query:<'':decodepad1> pad has no p
           GST_PADS gstpad.c:4398:gst_pad_peer_query:<'':decodepad1> pad has no p
       audiodecoder gstaudiodecoder.c:2539:gst_audio_decoder_sink_eventfunc:<vorb
       videodecoder gstvideodecoder.c:1631:gst_video_decoder_sink_event_default:<
          GST_EVENT gstevent.c:918:gst_event_new_caps: creating caps event audio/
           GST_PADS gstpad.c:4398:gst_pad_peer_query:<'':decodepad2> pad has no p
           GST_PADS gstpad.c:4398:gst_pad_peer_query:<'':decodepad1> pad has no p
           GST_PADS gstpad.c:4398:gst_pad_peer_query:<'':decodepad1> pad has no p
           vavp8dec gstvabasedec.c:1163:gst_va_base_dec_set_output_state:<vavp8de
          GST_EVENT gstevent.c:918:gst_event_new_caps: creating caps event video/
   GST_ELEMENT_PADS gstelement.c:758:gst_element_add_pad:<decodebin0> adding pad 
           GST_PADS gstpad.c:2440:gst_pad_link_prepare: trying to link decodebin0
           GST_PADS gstpad.c:2621:gst_pad_link_full: linked decodebin0:src_0 and 
          GST_EVENT gstevent.c:1687:gst_event_new_reconfigure: creating reconfigu
   GST_ELEMENT_PADS gstelement.c:758:gst_element_add_pad:<source> adding pad 'src

These logs are executed in C between gst_element_set_state(data.pipeline, GST_STATE_PLAYING) and when ‘pad-added’ is triggered.

Is this bug caused by the single thread of nodejs?

But I understand that these operations should be run under C

I used a dirty trick to make the code to work:

/* Start playing */
data.pipeline.setState(Gst.State.PAUSED); // Add the line
await new Promise((resolve) => setTimeout(resolve, 1000)); // Add the line
const ret = data.pipeline.setState(Gst.State.PLAYING);
if (ret === Gst.StateChangeReturn.FAILURE) {
  console.error('Unable to set the pipeline to the playing state.');
  data.pipeline.unref();
  throw new Error();
}

Start the pipeline in PAUSED state and wait one second before playing.

Execution results:

Received new pad 'src_0' from 'source':
It has type 'video/x-raw' which is not raw audio. Ignoring.
Received new pad 'src_1' from 'source':
Link succeeded (type 'audio/x-raw').
Pipeline state changed from NULL to READY:
Pipeline state changed from READY to PAUSED:
Pipeline state changed from PAUSED to PLAYING:

You can notice that the result of the execution is still different with C

In C, the ‘pad-added’ is triggered after Pipeline state changed from NULL to READY

But I still want to know the root cause. Does anyone have an idea about this?

I tried another way to make it works
Avoids magic number 1000

/* Start playing */
let ret = data.pipeline.setState(Gst.State.PLAYING);
while (ret === Gst.StateChangeReturn.ASYNC) {
  await new Promise((resolve) => setTimeout(resolve, 100));
  const [returnType, state, pending] = data.pipeline.getState(
    100 * Gst.MSECOND,
  );
  ret = returnType;
}
if (ret === Gst.StateChangeReturn.FAILURE) {
  console.error('Unable to set the pipeline to the playing state.');
  data.pipeline.unref();
  throw new Error();
}

Although I still don’t understand what happen