diff options
author | Philip Gladstone <philipjsg@users.sourceforge.net> | 2002-09-12 02:26:58 +0000 |
---|---|---|
committer | Philip Gladstone <philipjsg@users.sourceforge.net> | 2002-09-12 02:26:58 +0000 |
commit | 75bdb984c7f422232d963facaf4f96887d40530a (patch) | |
tree | 019b1b1604ffdd7fd076d085e9a028a0b13f1ee6 /libav/aviobuf.c | |
parent | 208d3ddf961c745b20e19f1568dca3f631856d34 (diff) | |
download | ffmpeg-75bdb984c7f422232d963facaf4f96887d40530a.tar.gz |
Add the transfer of the new parameters from ffmpeg to ffserver and vice-versa
This adds functions to send and receive doubles and also null terminated strings.
Originally committed as revision 919 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libav/aviobuf.c')
-rw-r--r-- | libav/aviobuf.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/libav/aviobuf.c b/libav/aviobuf.c index 6c23088d91..3f0108361b 100644 --- a/libav/aviobuf.c +++ b/libav/aviobuf.c @@ -68,7 +68,7 @@ void put_byte(ByteIOContext *s, int b) flush_buffer(s); } -void put_buffer(ByteIOContext *s, unsigned char *buf, int size) +void put_buffer(ByteIOContext *s, const unsigned char *buf, int size) { int len; @@ -176,6 +176,19 @@ void put_be32(ByteIOContext *s, unsigned int val) put_byte(s, val); } +void put_native_double(ByteIOContext *s, double val) +{ + put_buffer(s, (const unsigned char *) &val, sizeof(val)); +} + +void put_native_string(ByteIOContext *s, const char *str) +{ + if (str) + put_buffer(s, (const unsigned char *) str, strlen(str) + 1); + else + put_byte(s, 0); +} + void put_le64(ByteIOContext *s, UINT64 val) { put_le32(s, (UINT32)(val & 0xffffffff)); @@ -326,6 +339,30 @@ unsigned int get_be32(ByteIOContext *s) return val; } +double get_native_double(ByteIOContext *s) +{ + double val; + + get_buffer(s, (unsigned char *) &val, sizeof(val)); + + return val; +} + +char *get_native_string(ByteIOContext *s, char *buf, int maxlen) +{ + int i = 0; + char c; + + while ((c = get_byte(s))) { + if (i < maxlen-1) + buf[i++] = c; + } + + buf[i] = 0; /* Ensure null terminated, but may be truncated */ + + return buf; +} + UINT64 get_be64(ByteIOContext *s) { UINT64 val; |