tvkitchen / countertop

The entry point for developers who want to set up a TV Kitchen.
https://tv.kitchen
GNU Lesser General Public License v3.0
6 stars 2 forks source link

TypeError: cb is not a function in AbstractIngestionEngine #60

Closed chriszs closed 4 years ago

chriszs commented 4 years ago

Bug

Current Behavior

When I try to inherit from the AbstractIngestionEngine and use it to stream from a file (after fixing #57, #58 and #59), I get:

/Users/chriszs/Desktop/work/tv-kitchen/node_modules/ts-demuxer/dist/index.js:392
            cb(packet);
            ^

TypeError: cb is not a function
    at decode_pes (/Users/chriszs/Desktop/work/tv-kitchen/node_modules/ts-demuxer/dist/index.js:392:13)
    at demux_packet (/Users/chriszs/Desktop/work/tv-kitchen/node_modules/ts-demuxer/dist/index.js:434:12)
    at TSDemuxer.process (/Users/chriszs/Desktop/work/tv-kitchen/node_modules/ts-demuxer/dist/index.js:473:23)
    at Transform._transform (/Users/chriszs/Desktop/work/tv-kitchen/src/components/ingestion/AbstractIngestionEngine.js:137:22)
    at Transform._read (_stream_transform.js:191:10)
    at Transform._write (_stream_transform.js:179:12)
    at writeOrBuffer (_stream_writable.js:352:12)
    at Transform.Writable.write (_stream_writable.js:303:10)
    at Socket.ondata (_stream_readable.js:712:22)
    at Socket.emit (events.js:315:20)

Input

yarn babel-node src/components/ingestion/test.js
// src/components/ingestion/test.js
import 'module-alias/register'
import AbstractIngestionEngine from './AbstractIngestionEngine'

class FileIngestionEngine extends AbstractIngestionEngine {
    constructor(path) {
        super()

        this.path = path
    }

    path = null

    getInputStream = () => fs.createReadStream(this.path)
}

const engine = new FileIngestionEngine(__dirname + '/in.ts')

engine.start()

Expected Behavior

I expected it to not throw that error.

Possible Solutions

The MPEG-TS demuxer's process method seems to require a callback. I gave it this empty one:

this.mpegtsDemuxer.process(mpegtsData,() => {})

Related Issues

57, #58 and #59

slifty commented 4 years ago

These chained nature of these issues reminds me a lot of the structure of a children's book.

slifty commented 4 years ago

Do you know what that callback does? I thought we registered a callback when creating the TSDemuxer instance.

chriszs commented 4 years ago

Good question. My understanding of what happened here and why this fix seemed to work may be wrong. Let me investigate.

chriszs commented 4 years ago

Okay, my suggested "fix" wasn't it. I don't know why that appeared to work.

It was because onDemuxedPacket wasn't set at the time TSDemuxer was instantiated. Moving that up solved it.

slifty commented 4 years ago

Closed by #56