Currently, AVStream contains an embedded AVCodecContext instance, which
is used by demuxers to export stream parameters to the caller and by
muxers to receive stream parameters from the caller. It is also used
internally as the codec context that is passed to parsers.
In addition, it is also widely used by the callers as the decoding (when
demuxer) or encoding (when muxing) context, though this has been
officially discouraged since Libav 11.
There are multiple important problems with this approach:
- the fields in AVCodecContext are in general one of
* stream parameters
* codec options
* codec state
However, it's not clear which ones are which. It is consequently
unclear which fields are a demuxer allowed to set or a muxer allowed to
read. This leads to erratic behaviour depending on whether decoding or
encoding is being performed or not (and whether it uses the AVStream
embedded codec context).
- various synchronization issues arising from the fact that the same
context is used by several different APIs (muxers/demuxers,
parsers, bitstream filters and encoders/decoders) simultaneously, with
there being no clear rules for who can modify what and the different
processes being typically delayed with respect to each other.
- avformat_find_stream_info() making it necessary to support opening
and closing a single codec context multiple times, thus
complicating the semantics of freeing various allocated objects in the
codec context.
Those problems are resolved by replacing the AVStream embedded codec
context with a newly added AVCodecParameters instance, which stores only
the stream parameters exported by the demuxers or read by the muxers.
The packetizer only supports splitting at GOB headers - if
such aren't available frequently enough, it splits at any
random byte offset (not at a macroblock boundary either, which
would be allowed by the spec) and sends a payload header pretend
that it starts with a GOB header.
As long as a receiver doesn't try to handle such cases cleverly
but just drops broken frames, this shouldn't matter too much
in practice.
Signed-off-by: Martin Storsjö <martin@martin.st>
By using ff_avc_write_annexb_extradata instead of the h264_mp4toannexb
BSF, the code for doing the conversion itself is kept much shorter,
there's less state to restore at the end, we don't risk leaving the
AVCodecContext in an inconsistent state if returning early due to
errors, etc.
Also add a missing free if the base64 encoding fails.
Signed-off-by: Martin Storsjö <martin@martin.st>
This avoids a memory leak (or having to worry about freeing the
config string) if the colorspace isn't accepted.
Signed-off-by: Martin Storsjö <martin@martin.st>
Optional sdp speex payload parameter is outputed only when
data is encoded. It's not printed in case of stream copy.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This packetization scheme simply places the full packets into the
RTP packet without any extra header bytes.
Signed-off-by: Martin Storsjö <martin@martin.st>
* libspeex audio codec is no longer considered unsupported
when using rtp as output format.
* SDP rtpmap is added for speex payload, formatted according to RFC
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This requires all NAL units to fit within single RTP packets. It
doesn't change the actual packetization for packets that fit, but
errors out and gives a helpful hint if the NAL units would have to
be split, and signals the right packetization mode in the SDP.
Signed-off-by: Martin Storsjö <martin@martin.st>
According to newer RFCs, this packetization scheme should only
be used for interfacing with legacy systems.
Implementing this packetization mode properly requires parsing
the full H263 bitstream to find macroblock boundaries (and knowing
their macroblock and gob numbers and motion vector predictors).
This implementation tries to look for GOB headers (which
can be inserted by using -ps <small number>), but if the GOBs
aren't small enough to fit into the MTU, the packetizer blindly
splits packets at any offset and claims it to be a GOB boundary
(by using Mode A from the RFC). While not correct, this seems
to work with some receivers.
Signed-off-by: Martin Storsjö <martin@martin.st>
If the sdp is generated before the rtp muxer is initialized
(e.g. as when called from the rtsp muxer), this has to be done,
otherwise the rtp muxer doesn't know that the input really is
in mp4 format.
Signed-off-by: Martin Storsjö <martin@martin.st>
Specifying the payload type is useful when the type number has
already been negotiated before creating the stream, for example
in SIP protocol.
Signed-off-by: Martin Storsjö <martin@martin.st>
Move the identical code in rtp_write_header() and
ff_sdp_write_media() inside ff_rtp_get_payload_type()
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
This is enabled with an AVOption on the RTP muxer. The SDP
generator looks for a latm flag in the rtpflags field.
Signed-off-by: Martin Storsjö <martin@martin.st>