akanchi / mpegts

A simple implementation of mpegts(including muxer and demuxer)
MIT License
24 stars 17 forks source link

Overwriting PES and mux/demux errors. #8

Open andersc opened 4 years ago

andersc commented 4 years ago

Just want to let you know that I fixed a bunch of errors in the multiplexer and demux in my fork if you want to fix in your project.

Fixes here -> My fork

In general..

Using std::string to work with binary (non string) data is a bad idea The PES Header is destroyed in some cases The data is corrupt when building some size PES frames..

If you run the unit tests I made you will catch all of the errors that I found so far..

I also added mBroken to indicate broken PES frames.

You can close this at any time.. This is the only way for me to make you aware of the errors since we decided not to merge my fork earlier I can't create pull requests.

/Anders

akanchi commented 4 years ago

I will confirm these issue, thanks

maddanio commented 3 years ago

@andersc can you outline the neccessary fixes? we also used a fork and are restrcutruring a bit. also your code seems to have moved into a repo which has no shared history with this one, so its hard to merge

maddanio commented 3 years ago

I just checked, the only use of string is in PMTElementInfo, should that be replaces by vector or such?

andersc commented 3 years ago

@maddanio I made so many changes to the original repo it's not possible for me to be that specific. Just fork my clone to get to where I'm at ->

https://github.com/Unit-X/mpegts

Then just pullrequest from there.

/Anders

maddanio commented 3 years ago

Ok, i tried porting your unit tests, but I think its too hard, so i switched to your fork. One thing: in both versions the demuxer is sensitive to the block size it is fed. Basically the simple buffer borders must somehow align with the demuxer granularity, otherwise things just fail oddly. I would advice a streaming input here, i.e. either an std istream or a callback. Easiest would likely be the latter, and then plug that into simple buffer.

andersc commented 3 years ago

OK. Great you found a bug. Would it be possible for you to write a failing unit test? Then I'll fix it. Or provide more detailed information.

maddanio commented 3 years ago

Hmm, thats tricky, I think you kinda assert that packet size is divisible by 188 in your tests, which seems to be a magic number. its kinda obvious though that it is fragile like that, as the demuxer very rarely checks for emptiness of the buffer, i.e. it being used up, but happily reads from it the rest of the time. in debug mode that will probably trigger the assertions in the simple buffer

maddanio commented 3 years ago

let me try...

maddanio commented 3 years ago

https://github.com/Unit-X/mpegts/issues/1