Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error #3

Open
impleotv opened this issue Jun 6, 2019 · 2 comments
Open

Error #3

impleotv opened this issue Jun 6, 2019 · 2 comments

Comments

@impleotv
Copy link

impleotv commented Jun 6, 2019

Hi,
Looks like a very interested library... Unfortunately, I was't able to demux the ts file (tried few of them).
I used your sample, providing the ts file

var tesladon = require('tesladon');
var H = require('highland');
var fs = require('fs');

H(fs.createReadStream(process.argv[2]))
  .pipe(tesladon.bufferGroup(188))
  .pipe(tesladon.readTSPackets())
  .pipe(tesladon.readPAT(true))
  .pipe(tesladon.readPMTs(true))
  .pipe(tesladon.readPESPackets(true))
  .filter(x => x.type !== 'TSPacket')
  .each(H.log);

I'm getting this error.

Object {type: "ProgramAssociationTable", pid: 0, tableID: "program_association_section", transportStreamID: 1, versionNumber: 0, …}
index.js:4871
TypeError: push is not a function
    at Object.push (d:\WorkTmp\nodemux\node_modules\tesladon\src\readPMTs.js:29:19)
    at setupStreams (d:\WorkTmp\nodemux\node_modules\tesladon\src\readPMTs.js:61:29)

If I'm commenting out the readPMTs function call, it works.
var tesladon = require('tesladon');
var H = require('highland');
var fs = require('fs');

H(fs.createReadStream(process.argv[2]))
  .pipe(tesladon.bufferGroup(188))
  .pipe(tesladon.readTSPackets())
  .pipe(tesladon.readPAT(true))
  //.pipe(tesladon.readPMTs(true))
  .pipe(tesladon.readPESPackets(true))
  .filter(x => x.type !== 'TSPacket')
  .each(H.log);

It is mentioned that

readPMTs() stage only works after the readPATs() stage as it uses the PAT objects to find the pids used for the PMTs.

But, if you capture TS stream, this cannot be guaranteed. Anyhow, is that the reason it fails?

Thanks,

Alex

@rezonant
Copy link

rezonant commented Oct 4, 2020

I also see this crash, I think it is a proper bug. Still looking into what's going

@rezonant
Copy link

rezonant commented Oct 4, 2020

OK so this is a race condition. The stream gets initialized on line 49 of readPMTs.js, and before Highland is able to invoke the genny() generator function, tesladon is already trying to push data into it. If you modify genny() to look like this:

function genny () {
  var push = null;
  var next = null;
  var fn = (hpush, hnext) => {
    console.log(`GENNY INITIALIZED`);
    push = hpush;
    next = hnext;
  };
  return {
    stream : H(fn),
    push : x => { 
      if (push) {
        push(null, x); next(); 
      } else {
        console.error(`ERROR: NO PUSH YET`);
      }
    },
    end : () => { push(null, H.nil); }
  };
}

I've also added a message "CREATING GENNY" right before the call to genny() and "CONSUMING GENNY" right before the stream is piped/consumed.

Then run a test, you'll get:

CREATING GENNY
CONSUMING GENNY
{ type: 'ProgramAssociationTable',
  pid: 0,
  tableID: 'program_association_section',
  transportStreamID: 1,
  versionNumber: 0,
  currentNextIndicator: 1,
  table: { '1': 4096 } }
ERROR NO PUSH YET
{ type: 'ProgramAssociationTable',
  pid: 0,
  tableID: 'program_association_section',
  transportStreamID: 1,
  versionNumber: 0,
  currentNextIndicator: 1,
  table: { '1': 4096 } }
ERROR NO PUSH YET
{ type: 'ProgramAssociationTable',
  pid: 0,
  tableID: 'program_association_section',
  transportStreamID: 1,
  versionNumber: 0,
  currentNextIndicator: 1,
  table: { '1': 4096 } }
ERROR NO PUSH YET
{ type: 'ProgramAssociationTable',
  pid: 0,
  tableID: 'program_association_section',
  transportStreamID: 1,
  versionNumber: 0,
  currentNextIndicator: 1,
  table: { '1': 4096 } }
ERROR NO PUSH YET
{ type: 'ProgramAssociationTable',
  pid: 0,
  tableID: 'program_association_section',
  transportStreamID: 1,
  versionNumber: 0,
  currentNextIndicator: 1,
  table: { '1': 4096 } }
ERROR NO PUSH YET
{ type: 'ProgramAssociationTable',
  pid: 0,
  tableID: 'program_association_section',
  transportStreamID: 1,
  versionNumber: 0,
  currentNextIndicator: 1,
  table: { '1': 4096 } }
ERROR NO PUSH YET
{ type: 'ProgramAssociationTable',
  pid: 0,
  tableID: 'program_association_section',
  transportStreamID: 1,
  versionNumber: 0,
  currentNextIndicator: 1,
  table: { '1': 4096 } }
ERROR NO PUSH YET
{ type: 'ProgramAssociationTable',
  pid: 0,
  tableID: 'program_association_section',
  transportStreamID: 1,
  versionNumber: 0,
  currentNextIndicator: 1,
  table: { '1': 4096 } }
ERROR NO PUSH YET
{ type: 'ProgramAssociationTable',
  pid: 0,
  tableID: 'program_association_section',
  transportStreamID: 1,
  versionNumber: 0,
  currentNextIndicator: 1,
  table: { '1': 4096 } }
ERROR NO PUSH YET
GENNY INITIALIZED // <-----
{ type: 'ProgramAssociationTable',
  pid: 0,
  tableID: 'program_association_section',
  transportStreamID: 1,
  versionNumber: 0,
  currentNextIndicator: 1,
  table: { '1': 4096 } }

After this, I get a crash, but this probably has more to do with my testing insertions than anything else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants