-
Notifications
You must be signed in to change notification settings - Fork 50
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
Demuxer: emit an error in case of unknown data packets and EOF #32
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch!
// We need to silence this error as there may be some incomplete data here | ||
// We still want to try to parse all packets, in case final data is complete | ||
continue | ||
} | ||
|
||
// Update data | ||
if d = dmx.updateData(ds); d != nil { | ||
err = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you resetting err
here? 🤔
imho we still want to return an ErrNoMorePackets
here so that the developer knows the end of stream has been reached.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm not sure about this, in my opinion a read function should return either (data, nil)
or (nil, error)
- in this case, even if we reset the error, it reappears at the next function call and makes the function return (nil, error)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you 👍
At the moment, the demuxer returns (nil, nil) when the stream is finished, there are TS packets in the queue but they're unknown data packets. This patch makes the demuxer emit (nil, ErrNoMorePackets).
FYI I've created a |
Fixes #26
Fixes bluenviron/mediamtx#558
At the moment, demuxer's
NextData()
returns(nil, nil)
when the stream is finished (EOF), there are TS packets in the queue but they're unknown data packets (not PSI or PES).This is due to the fact that
err
is overridden by a call toparseData()
, that sets it tonil
unless there's a parse error.In my opinion, the function:
(nil, ErrNoMorePackets)
in case there are TS packets with payload in the queue but they can't be parsed.(data, nil)
in case the TS packets in the queue are known data packetsThis patch fixes the issue.