rtpdec: Use .init instead of .alloc to set default values
The ugly error handling in rdt gets improved in a later commit. Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
parent
88434f9725
commit
78791c086b
@ -298,6 +298,9 @@ rdt_parse_packet (AVFormatContext *ctx, PayloadContext *rdt, AVStream *st,
|
|||||||
int seq = 1, res;
|
int seq = 1, res;
|
||||||
AVIOContext pb;
|
AVIOContext pb;
|
||||||
|
|
||||||
|
if (!rdt->rmctx)
|
||||||
|
return AVERROR(EINVAL);
|
||||||
|
|
||||||
if (rdt->audio_pkt_cnt == 0) {
|
if (rdt->audio_pkt_cnt == 0) {
|
||||||
int pos;
|
int pos;
|
||||||
|
|
||||||
@ -521,20 +524,9 @@ ff_real_parse_sdp_a_line (AVFormatContext *s, int stream_index,
|
|||||||
real_parse_asm_rulebook(s, s->streams[stream_index], p);
|
real_parse_asm_rulebook(s, s->streams[stream_index], p);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PayloadContext *
|
static av_cold int rdt_init(AVFormatContext *s, int st_index, PayloadContext *rdt)
|
||||||
rdt_new_context (void)
|
|
||||||
{
|
{
|
||||||
PayloadContext *rdt = av_mallocz(sizeof(PayloadContext));
|
return avformat_open_input(&rdt->rmctx, "", &ff_rdt_demuxer, NULL);
|
||||||
int ret;
|
|
||||||
if (!rdt)
|
|
||||||
return NULL;
|
|
||||||
ret = avformat_open_input(&rdt->rmctx, "", &ff_rdt_demuxer, NULL);
|
|
||||||
if (ret < 0) {
|
|
||||||
av_free(rdt);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return rdt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -559,8 +551,9 @@ static RTPDynamicProtocolHandler rdt_ ## n ## _handler = { \
|
|||||||
.enc_name = s, \
|
.enc_name = s, \
|
||||||
.codec_type = t, \
|
.codec_type = t, \
|
||||||
.codec_id = AV_CODEC_ID_NONE, \
|
.codec_id = AV_CODEC_ID_NONE, \
|
||||||
|
.priv_data_size = sizeof(PayloadContext), \
|
||||||
|
.init = rdt_init, \
|
||||||
.parse_sdp_a_line = rdt_parse_sdp_line, \
|
.parse_sdp_a_line = rdt_parse_sdp_line, \
|
||||||
.alloc = rdt_new_context, \
|
|
||||||
.free = rdt_free_context, \
|
.free = rdt_free_context, \
|
||||||
.parse_packet = rdt_parse_packet \
|
.parse_packet = rdt_parse_packet \
|
||||||
}
|
}
|
||||||
|
@ -38,13 +38,10 @@ struct PayloadContext {
|
|||||||
int channels;
|
int channels;
|
||||||
};
|
};
|
||||||
|
|
||||||
static PayloadContext *amr_new_context(void)
|
static av_cold int amr_init(AVFormatContext *s, int st_index, PayloadContext *data)
|
||||||
{
|
{
|
||||||
PayloadContext *data = av_mallocz(sizeof(PayloadContext));
|
|
||||||
if (!data)
|
|
||||||
return data;
|
|
||||||
data->channels = 1;
|
data->channels = 1;
|
||||||
return data;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int amr_handle_packet(AVFormatContext *ctx, PayloadContext *data,
|
static int amr_handle_packet(AVFormatContext *ctx, PayloadContext *data,
|
||||||
@ -189,8 +186,9 @@ RTPDynamicProtocolHandler ff_amr_nb_dynamic_handler = {
|
|||||||
.enc_name = "AMR",
|
.enc_name = "AMR",
|
||||||
.codec_type = AVMEDIA_TYPE_AUDIO,
|
.codec_type = AVMEDIA_TYPE_AUDIO,
|
||||||
.codec_id = AV_CODEC_ID_AMR_NB,
|
.codec_id = AV_CODEC_ID_AMR_NB,
|
||||||
|
.priv_data_size = sizeof(PayloadContext),
|
||||||
|
.init = amr_init,
|
||||||
.parse_sdp_a_line = amr_parse_sdp_line,
|
.parse_sdp_a_line = amr_parse_sdp_line,
|
||||||
.alloc = amr_new_context,
|
|
||||||
.parse_packet = amr_handle_packet,
|
.parse_packet = amr_handle_packet,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -198,7 +196,8 @@ RTPDynamicProtocolHandler ff_amr_wb_dynamic_handler = {
|
|||||||
.enc_name = "AMR-WB",
|
.enc_name = "AMR-WB",
|
||||||
.codec_type = AVMEDIA_TYPE_AUDIO,
|
.codec_type = AVMEDIA_TYPE_AUDIO,
|
||||||
.codec_id = AV_CODEC_ID_AMR_WB,
|
.codec_id = AV_CODEC_ID_AMR_WB,
|
||||||
|
.priv_data_size = sizeof(PayloadContext),
|
||||||
|
.init = amr_init,
|
||||||
.parse_sdp_a_line = amr_parse_sdp_line,
|
.parse_sdp_a_line = amr_parse_sdp_line,
|
||||||
.alloc = amr_new_context,
|
|
||||||
.parse_packet = amr_handle_packet,
|
.parse_packet = amr_handle_packet,
|
||||||
};
|
};
|
||||||
|
@ -269,13 +269,10 @@ static int vp8_handle_packet(AVFormatContext *ctx, PayloadContext *vp8,
|
|||||||
return AVERROR(EAGAIN);
|
return AVERROR(EAGAIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PayloadContext *vp8_new_context(void)
|
static av_cold int vp8_init(AVFormatContext *s, int st_index, PayloadContext *vp8)
|
||||||
{
|
{
|
||||||
PayloadContext *vp8 = av_mallocz(sizeof(PayloadContext));
|
|
||||||
if (!vp8)
|
|
||||||
return NULL;
|
|
||||||
vp8->sequence_ok = 1;
|
vp8->sequence_ok = 1;
|
||||||
return vp8;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vp8_free_context(PayloadContext *vp8)
|
static void vp8_free_context(PayloadContext *vp8)
|
||||||
@ -293,7 +290,8 @@ RTPDynamicProtocolHandler ff_vp8_dynamic_handler = {
|
|||||||
.enc_name = "VP8",
|
.enc_name = "VP8",
|
||||||
.codec_type = AVMEDIA_TYPE_VIDEO,
|
.codec_type = AVMEDIA_TYPE_VIDEO,
|
||||||
.codec_id = AV_CODEC_ID_VP8,
|
.codec_id = AV_CODEC_ID_VP8,
|
||||||
.alloc = vp8_new_context,
|
.priv_data_size = sizeof(PayloadContext),
|
||||||
|
.init = vp8_init,
|
||||||
.free = vp8_free_context,
|
.free = vp8_free_context,
|
||||||
.parse_packet = vp8_handle_packet,
|
.parse_packet = vp8_handle_packet,
|
||||||
.need_keyframe = vp8_need_keyframe,
|
.need_keyframe = vp8_need_keyframe,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user