mirror of
https://gitee.com/openharmony/third_party_ffmpeg
synced 2024-11-27 13:10:37 +00:00
rtpenc_chain: Return an error code instead of just a plain pointer
Also check the return value in sapenc. Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
parent
93cef6f923
commit
68c813081b
@ -43,9 +43,9 @@ int ff_mov_init_hinting(AVFormatContext *s, int index, int src_index)
|
|||||||
track->enc->codec_type = AVMEDIA_TYPE_DATA;
|
track->enc->codec_type = AVMEDIA_TYPE_DATA;
|
||||||
track->enc->codec_tag = track->tag;
|
track->enc->codec_tag = track->tag;
|
||||||
|
|
||||||
track->rtp_ctx = ff_rtp_chain_mux_open(s, src_st, NULL,
|
ret = ff_rtp_chain_mux_open(&track->rtp_ctx, s, src_st, NULL,
|
||||||
RTP_MAX_PACKET_SIZE);
|
RTP_MAX_PACKET_SIZE);
|
||||||
if (!track->rtp_ctx)
|
if (ret < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
/* Copy the RTP AVStream timebase back to the hint AVStream */
|
/* Copy the RTP AVStream timebase back to the hint AVStream */
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
#include "avio_internal.h"
|
#include "avio_internal.h"
|
||||||
#include "libavutil/opt.h"
|
#include "libavutil/opt.h"
|
||||||
|
|
||||||
AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st,
|
int ff_rtp_chain_mux_open(AVFormatContext **out, AVFormatContext *s,
|
||||||
URLContext *handle, int packet_size)
|
AVStream *st, URLContext *handle, int packet_size)
|
||||||
{
|
{
|
||||||
AVFormatContext *rtpctx = NULL;
|
AVFormatContext *rtpctx = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
@ -34,17 +34,23 @@ AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st,
|
|||||||
uint8_t *rtpflags;
|
uint8_t *rtpflags;
|
||||||
AVDictionary *opts = NULL;
|
AVDictionary *opts = NULL;
|
||||||
|
|
||||||
if (!rtp_format)
|
if (!rtp_format) {
|
||||||
|
ret = AVERROR(ENOSYS);
|
||||||
goto fail;
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
/* Allocate an AVFormatContext for each output stream */
|
/* Allocate an AVFormatContext for each output stream */
|
||||||
rtpctx = avformat_alloc_context();
|
rtpctx = avformat_alloc_context();
|
||||||
if (!rtpctx)
|
if (!rtpctx) {
|
||||||
|
ret = AVERROR(ENOMEM);
|
||||||
goto fail;
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
rtpctx->oformat = rtp_format;
|
rtpctx->oformat = rtp_format;
|
||||||
if (!avformat_new_stream(rtpctx, NULL))
|
if (!avformat_new_stream(rtpctx, NULL)) {
|
||||||
|
ret = AVERROR(ENOMEM);
|
||||||
goto fail;
|
goto fail;
|
||||||
|
}
|
||||||
/* Pass the interrupt callback on */
|
/* Pass the interrupt callback on */
|
||||||
rtpctx->interrupt_callback = s->interrupt_callback;
|
rtpctx->interrupt_callback = s->interrupt_callback;
|
||||||
/* Copy the max delay setting; the rtp muxer reads this. */
|
/* Copy the max delay setting; the rtp muxer reads this. */
|
||||||
@ -76,14 +82,15 @@ AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st,
|
|||||||
av_free(ptr);
|
av_free(ptr);
|
||||||
}
|
}
|
||||||
avformat_free_context(rtpctx);
|
avformat_free_context(rtpctx);
|
||||||
return NULL;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rtpctx;
|
*out = rtpctx;
|
||||||
|
return 0;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
av_free(rtpctx);
|
av_free(rtpctx);
|
||||||
if (handle)
|
if (handle)
|
||||||
ffurl_close(handle);
|
ffurl_close(handle);
|
||||||
return NULL;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
#include "url.h"
|
#include "url.h"
|
||||||
|
|
||||||
AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st,
|
int ff_rtp_chain_mux_open(AVFormatContext **out, AVFormatContext *s,
|
||||||
URLContext *handle, int packet_size);
|
AVStream *st, URLContext *handle, int packet_size);
|
||||||
|
|
||||||
#endif /* AVFORMAT_RTPENC_CHAIN_H */
|
#endif /* AVFORMAT_RTPENC_CHAIN_H */
|
||||||
|
@ -606,11 +606,13 @@ static int rtsp_open_transport_ctx(AVFormatContext *s, RTSPStream *rtsp_st)
|
|||||||
s->ctx_flags |= AVFMTCTX_NOHEADER;
|
s->ctx_flags |= AVFMTCTX_NOHEADER;
|
||||||
|
|
||||||
if (s->oformat && CONFIG_RTSP_MUXER) {
|
if (s->oformat && CONFIG_RTSP_MUXER) {
|
||||||
rtsp_st->transport_priv = ff_rtp_chain_mux_open(s, st,
|
int ret = ff_rtp_chain_mux_open(&rtsp_st->transport_priv, s, st,
|
||||||
rtsp_st->rtp_handle,
|
rtsp_st->rtp_handle,
|
||||||
RTSP_TCP_MAX_PACKET_SIZE);
|
RTSP_TCP_MAX_PACKET_SIZE);
|
||||||
/* Ownership of rtp_handle is passed to the rtp mux context */
|
/* Ownership of rtp_handle is passed to the rtp mux context */
|
||||||
rtsp_st->rtp_handle = NULL;
|
rtsp_st->rtp_handle = NULL;
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
} else if (rt->transport == RTSP_TRANSPORT_RDT && CONFIG_RTPDEC)
|
} else if (rt->transport == RTSP_TRANSPORT_RDT && CONFIG_RTPDEC)
|
||||||
rtsp_st->transport_priv = ff_rdt_parse_open(s, st->index,
|
rtsp_st->transport_priv = ff_rdt_parse_open(s, st->index,
|
||||||
rtsp_st->dynamic_protocol_context,
|
rtsp_st->dynamic_protocol_context,
|
||||||
|
@ -150,8 +150,10 @@ static int sap_write_header(AVFormatContext *s)
|
|||||||
ret = AVERROR(EIO);
|
ret = AVERROR(EIO);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
s->streams[i]->priv_data = contexts[i] =
|
ret = ff_rtp_chain_mux_open(&contexts[i], s, s->streams[i], fd, 0);
|
||||||
ff_rtp_chain_mux_open(s, s->streams[i], fd, 0);
|
if (ret < 0)
|
||||||
|
goto fail;
|
||||||
|
s->streams[i]->priv_data = contexts[i];
|
||||||
av_strlcpy(contexts[i]->filename, url, sizeof(contexts[i]->filename));
|
av_strlcpy(contexts[i]->filename, url, sizeof(contexts[i]->filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user