diff options
author | Samuel Pitoiset <samuel.pitoiset@gmail.com> | 2012-07-21 14:59:49 +0400 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2012-07-25 22:08:09 +0400 |
commit | 9b498148ca27fb59994522301da08afafb7d14fd (patch) | |
tree | 71f0252197bd602ae060da4ea9a07b09b3ee18a7 /libavformat/rtmpproto.c | |
parent | 758377a2b79a35386978b0af1196d36cbcfb8f64 (diff) |
rtmp: Factorize the code by adding handle_server_bw
Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat/rtmpproto.c')
-rw-r--r-- | libavformat/rtmpproto.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c index e20aacbc6c..87bed0ee99 100644 --- a/libavformat/rtmpproto.c +++ b/libavformat/rtmpproto.c @@ -880,6 +880,21 @@ static int rtmp_handshake(URLContext *s, RTMPContext *rt) return 0; } +static int handle_server_bw(URLContext *s, RTMPPacket *pkt) +{ + RTMPContext *rt = s->priv_data; + + rt->server_bw = AV_RB32(pkt->data); + if (rt->server_bw <= 0) { + av_log(s, AV_LOG_ERROR, "Incorrect server bandwidth %d\n", + rt->server_bw); + return AVERROR(EINVAL); + } + av_log(s, AV_LOG_DEBUG, "Server bandwidth = %d\n", rt->server_bw); + + return 0; +} + /** * Parse received packet and possibly perform some action depending on * the packet contents. @@ -931,12 +946,8 @@ static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt) rt->client_report_size = AV_RB32(pkt->data) >> 1; break; case RTMP_PT_SERVER_BW: - rt->server_bw = AV_RB32(pkt->data); - if (rt->server_bw <= 0) { - av_log(s, AV_LOG_ERROR, "Incorrect server bandwidth %d\n", rt->server_bw); - return AVERROR(EINVAL); - } - av_log(s, AV_LOG_DEBUG, "Server bandwidth = %d\n", rt->server_bw); + if ((ret = handle_server_bw(s, pkt)) < 0) + return ret; break; case RTMP_PT_INVOKE: //TODO: check for the messages sent for wrong state? |