diff options
author | Samuel Pitoiset <samuel.pitoiset@gmail.com> | 2012-08-09 16:57:51 +0400 |
---|---|---|
committer | Luca Barbato <lu_zero@gentoo.org> | 2012-08-10 00:44:30 +0400 |
commit | 3eebc1e1743c6e4855d29f73e9f4fbd1c9e1fa60 (patch) | |
tree | 97c2315c3761c85aba5a256bc57d1eb8790afe96 /libavformat/rtmpproto.c | |
parent | 71036a3a5eeda1c0a7eef6acf37aa0c33d488a36 (diff) |
rtmp: Factorize the code by adding handle_invoke_error
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
Diffstat (limited to 'libavformat/rtmpproto.c')
-rw-r--r-- | libavformat/rtmpproto.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c index a2d2529aa1..c85424e32c 100644 --- a/libavformat/rtmpproto.c +++ b/libavformat/rtmpproto.c @@ -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; |