From c76daa89ab91ebbd9e29d289d207bf88213255ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Sun, 30 Dec 2012 18:53:35 +0200 Subject: [PATCH 1/2] rtmp: Return a proper error code in handle_invoke_error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- libavformat/rtmpproto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c index 8924fb3c19..4e059d6674 100644 --- a/libavformat/rtmpproto.c +++ b/libavformat/rtmpproto.c @@ -1533,7 +1533,7 @@ static int handle_invoke_error(URLContext *s, RTMPPacket *pkt) level = AV_LOG_WARNING; ret = 0; } else - ret = -1; + ret = AVERROR_UNKNOWN; av_log(s, level, "Server error: %s\n", tmpstr); } From 33f28a3be3092f642778253d9529dd66fe2a014a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Sun, 30 Dec 2012 22:38:23 +0200 Subject: [PATCH 2/2] rtmp: Add a function for writing AMF strings based on two substrings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This avoids having to concatenate them into one buffer before writing them as AMF. Signed-off-by: Martin Storsjö --- libavformat/rtmppkt.c | 13 +++++++++++++ libavformat/rtmppkt.h | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c index f69ce82c66..aed188dcc7 100644 --- a/libavformat/rtmppkt.c +++ b/libavformat/rtmppkt.c @@ -47,6 +47,19 @@ void ff_amf_write_string(uint8_t **dst, const char *str) bytestream_put_buffer(dst, str, strlen(str)); } +void ff_amf_write_string2(uint8_t **dst, const char *str1, const char *str2) +{ + int len1 = 0, len2 = 0; + if (str1) + len1 = strlen(str1); + if (str2) + len2 = strlen(str2); + bytestream_put_byte(dst, AMF_DATA_TYPE_STRING); + bytestream_put_be16(dst, len1 + len2); + bytestream_put_buffer(dst, str1, len1); + bytestream_put_buffer(dst, str2, len2); +} + void ff_amf_write_null(uint8_t **dst) { bytestream_put_byte(dst, AMF_DATA_TYPE_NULL); diff --git a/libavformat/rtmppkt.h b/libavformat/rtmppkt.h index a153ca6253..276c5608c0 100644 --- a/libavformat/rtmppkt.h +++ b/libavformat/rtmppkt.h @@ -203,6 +203,15 @@ void ff_amf_write_number(uint8_t **dst, double num); */ void ff_amf_write_string(uint8_t **dst, const char *str); +/** + * Write a string consisting of two parts in AMF format to a buffer. + * + * @param dst pointer to the input buffer (will be modified) + * @param str1 first string to write, may be null + * @param str2 second string to write, may be null + */ +void ff_amf_write_string2(uint8_t **dst, const char *str1, const char *str2); + /** * Write AMF NULL value to buffer. *