Jan 3, 2021, 23:06 by jon@jonb.org:
On Sun, Jan 3, 2021, at 12:50 PM, Andreas Rheinhardt wrote:
It would be better if you used ff_alloc_extradata(): It also already frees the extradata that might be present. And it does only set the extradata_size after the allocation succeeded. But it is of course even better if you actually errored out in case of allocation failure.
Furthermore, your patch will lead to "declaration after statement" (or something like that) warnings, because FFmpeg only allows variable declarations at the beginning of each block (this is a remnant from C90).
Thanks Andreas!
The patch now uses ff_alloc_extradata, and I moved the bitstream writer into its own function so it can create the bs variable on the stack.
I wasn't sure of the best way to error out, since ff_rtp_parse_open doesn't return an error value. So I log the error and return NULL. Please advise if there is a better way.
+ /* Input sample rate (0 = unspecified) */> + bytestream_put_le32 (&bs, 0); Put in 48000 here. Stream copy will preserve extradata, and we don't want to generate weird streams, even if our decoder ignores this.
+ /* Channel count */> + bytestream_put_byte (&bs, codecpar->channels);> + /* Mapping family */> + bytestream_put_byte (&bs, 0x0); This will only work for mono and stereo. The decoder will error out if more than 2 channels are present. For now maybe error out if the number of channels is greater than 2?