[FFmpeg-cvslog] rtmppkt: Add method to read an AMF string that is not prefixed by its type
Uwe L. Korn
git at videolan.org
Mon Jun 2 00:31:59 CEST 2014
ffmpeg | branch: master | Uwe L. Korn <uwelk at xhochy.com> | Sat May 31 20:37:25 2014 +0100| [3b18857ab301d2a0b3e86e9d85eed76f0798a29c] | committer: Martin Storsjö
rtmppkt: Add method to read an AMF string that is not prefixed by its type
Signed-off-by: Martin Storsjö <martin at martin.st>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3b18857ab301d2a0b3e86e9d85eed76f0798a29c
---
libavformat/rtmppkt.c | 14 ++++++++++----
libavformat/rtmppkt.h | 17 +++++++++++++++++
2 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c
index 306a243..37fbb5f 100644
--- a/libavformat/rtmppkt.c
+++ b/libavformat/rtmppkt.c
@@ -102,13 +102,11 @@ int ff_amf_read_number(GetByteContext *bc, double *val)
return 0;
}
-int ff_amf_read_string(GetByteContext *bc, uint8_t *str,
- int strsize, int *length)
+int ff_amf_get_string(GetByteContext *bc, uint8_t *str,
+ int strsize, int *length)
{
int stringlen = 0;
int readsize;
- if (bytestream2_get_byte(bc) != AMF_DATA_TYPE_STRING)
- return AVERROR_INVALIDDATA;
stringlen = bytestream2_get_be16(bc);
if (stringlen + 1 > strsize)
return AVERROR(EINVAL);
@@ -122,6 +120,14 @@ int ff_amf_read_string(GetByteContext *bc, uint8_t *str,
return 0;
}
+int ff_amf_read_string(GetByteContext *bc, uint8_t *str,
+ int strsize, int *length)
+{
+ if (bytestream2_get_byte(bc) != AMF_DATA_TYPE_STRING)
+ return AVERROR_INVALIDDATA;
+ return ff_amf_get_string(bc, str, strsize, length);
+}
+
int ff_amf_read_null(GetByteContext *bc)
{
if (bytestream2_get_byte(bc) != AMF_DATA_TYPE_NULL)
diff --git a/libavformat/rtmppkt.h b/libavformat/rtmppkt.h
index e973684..149c153 100644
--- a/libavformat/rtmppkt.h
+++ b/libavformat/rtmppkt.h
@@ -278,6 +278,23 @@ int ff_amf_read_bool(GetByteContext *gbc, int *val);
int ff_amf_read_number(GetByteContext *gbc, double *val);
/**
+ * Get AMF string value.
+ *
+ * This function behaves the same as ff_amf_read_string except that
+ * it does not expect the AMF type prepended to the actual data.
+ * Appends a trailing null byte to output string in order to
+ * ease later parsing.
+ *
+ *@param[in,out] gbc GetByteContext initialized with AMF-formatted data
+ *@param[out] str read string
+ *@param[in] strsize buffer size available to store the read string
+ *@param[out] length read string length
+ *@return 0 on success or an AVERROR code on failure
+*/
+int ff_amf_get_string(GetByteContext *bc, uint8_t *str,
+ int strsize, int *length);
+
+/**
* Read AMF string value.
*
* Appends a trailing null byte to output string in order to
More information about the ffmpeg-cvslog
mailing list