Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
ffmpeg
Commits
50468f93
Commit
50468f93
authored
Aug 01, 2012
by
Jordi Ortiz
Committed by
Luca Barbato
Aug 02, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rtmp: add functions for reading AMF values
Signed-off-by:
Luca Barbato
<
lu_zero@gentoo.org
>
parent
cfb10918
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
0 deletions
+87
-0
rtmppkt.c
libavformat/rtmppkt.c
+45
-0
rtmppkt.h
libavformat/rtmppkt.h
+42
-0
No files found.
libavformat/rtmppkt.c
View file @
50468f93
...
...
@@ -71,6 +71,51 @@ void ff_amf_write_object_end(uint8_t **dst)
bytestream_put_be24
(
dst
,
AMF_DATA_TYPE_OBJECT_END
);
}
int
ff_amf_read_bool
(
GetByteContext
*
bc
,
int
*
val
)
{
if
(
bytestream2_get_byte
(
bc
)
!=
AMF_DATA_TYPE_BOOL
)
return
AVERROR_INVALIDDATA
;
*
val
=
bytestream2_get_byte
(
bc
);
return
0
;
}
int
ff_amf_read_number
(
GetByteContext
*
bc
,
double
*
val
)
{
uint64_t
read
;
if
(
bytestream2_get_byte
(
bc
)
!=
AMF_DATA_TYPE_NUMBER
)
return
AVERROR_INVALIDDATA
;
read
=
bytestream2_get_be64
(
bc
);
*
val
=
av_int2double
(
read
);
return
0
;
}
int
ff_amf_read_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
);
readsize
=
bytestream2_get_buffer
(
bc
,
str
,
stringlen
);
if
(
readsize
!=
stringlen
)
{
av_log
(
NULL
,
AV_LOG_WARNING
,
"Unable to read as many bytes as AMF string signaled
\n
"
);
}
str
[
readsize
]
=
'\0'
;
*
length
=
FFMIN
(
stringlen
,
readsize
);
return
0
;
}
int
ff_amf_read_null
(
GetByteContext
*
bc
)
{
if
(
bytestream2_get_byte
(
bc
)
!=
AMF_DATA_TYPE_NULL
)
return
AVERROR_INVALIDDATA
;
return
0
;
}
int
ff_rtmp_packet_read
(
URLContext
*
h
,
RTMPPacket
*
p
,
int
chunk_size
,
RTMPPacket
*
prev_pkt
)
{
...
...
libavformat/rtmppkt.h
View file @
50468f93
...
...
@@ -231,6 +231,48 @@ void ff_amf_write_field_name(uint8_t **dst, const char *str);
*/
void
ff_amf_write_object_end
(
uint8_t
**
dst
);
/**
* Read AMF boolean value.
*
*@param[in,out] gbc GetByteContext initialized with AMF-formatted data
*@param[out] val 0 or 1
*@return 0 on success or an AVERROR code on failure
*/
int
ff_amf_read_bool
(
GetByteContext
*
gbc
,
int
*
val
);
/**
* Read AMF number value.
*
*@param[in,out] gbc GetByteContext initialized with AMF-formatted data
*@param[out] val read value
*@return 0 on success or an AVERROR code on failure
*/
int
ff_amf_read_number
(
GetByteContext
*
gbc
,
double
*
val
);
/**
* Read AMF string value.
*
* Appends a trailing \0 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_read_string
(
GetByteContext
*
gbc
,
uint8_t
*
str
,
int
strsize
,
int
*
length
);
/**
* Read AMF NULL value.
*
*@param[in,out] gbc GetByteContext initialized with AMF-formatted data
*@return 0 on success or an AVERROR code on failure
*/
int
ff_amf_read_null
(
GetByteContext
*
gbc
);
/** @} */
// AMF funcs
#endif
/* AVFORMAT_RTMPPKT_H */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment