1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

rtmp: Factorize the code by adding handle_invoke_error

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
This commit is contained in:
Samuel Pitoiset 2012-08-09 14:57:51 +02:00 committed by Luca Barbato
parent 71036a3a5e
commit 3eebc1e174

View File

@ -1021,6 +1021,20 @@ static int handle_server_bw(URLContext *s, RTMPPacket *pkt)
return 0;
}
static int handle_invoke_error(URLContext *s, RTMPPacket *pkt)
{
const uint8_t *data_end = pkt->data + pkt->data_size;
uint8_t tmpstr[256];
if (!ff_amf_get_field_value(pkt->data + 9, data_end,
"description", tmpstr, sizeof(tmpstr))) {
av_log(s, AV_LOG_ERROR, "Server error: %s\n", tmpstr);
return -1;
}
return 0;
}
static int handle_invoke_result(URLContext *s, RTMPPacket *pkt)
{
RTMPContext *rt = s->priv_data;
@ -1133,17 +1147,12 @@ static int handle_invoke_status(URLContext *s, RTMPPacket *pkt)
static int handle_invoke(URLContext *s, RTMPPacket *pkt)
{
RTMPContext *rt = s->priv_data;
const uint8_t *data_end = pkt->data + pkt->data_size;
int ret = 0;
//TODO: check for the messages sent for wrong state?
if (!memcmp(pkt->data, "\002\000\006_error", 9)) {
uint8_t tmpstr[256];
if (!ff_amf_get_field_value(pkt->data + 9, data_end,
"description", tmpstr, sizeof(tmpstr)))
av_log(s, AV_LOG_ERROR, "Server error: %s\n",tmpstr);
return -1;
if ((ret = handle_invoke_error(s, pkt)) < 0)
return ret;
} else if (!memcmp(pkt->data, "\002\000\007_result", 10)) {
if ((ret = handle_invoke_result(s, pkt)) < 0)
return ret;