1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

Refactor code to keep sample function order

This commit is contained in:
winlin 2020-05-02 09:15:49 +08:00
parent 7b5fa0e391
commit 6f2b78f16a
10 changed files with 987 additions and 593 deletions

View file

@ -105,62 +105,62 @@ public:
// Create buffer with data b and size nn.
// @remark User must free the data b.
SrsBuffer(char* b, int nn);
virtual ~SrsBuffer();
~SrsBuffer();
public:
// Get the data and head of buffer.
// current-bytes = head() = data() + pos()
inline char* data() { return bytes; }
inline char* head() { return p; }
char* data();
char* head();
// Get the total size of buffer.
// left-bytes = size() - pos()
virtual int size();
void set_size(int v) { nb_bytes = v; }
int size();
void set_size(int v);
// Get the current buffer position.
virtual int pos();
int pos();
// Left bytes in buffer, total size() minus the current pos().
virtual int left();
int left();
// Whether buffer is empty.
virtual bool empty();
bool empty();
// Whether buffer is able to supply required size of bytes.
// @remark User should check buffer by require then do read/write.
// @remark Assert the required_size is not negative.
virtual bool require(int required_size);
bool require(int required_size);
public:
// Skip some size.
// @param size can be any value. positive to forward; nagetive to backward.
// @remark to skip(pos()) to reset buffer.
// @remark assert initialized, the data() not NULL.
virtual void skip(int size);
void skip(int size);
public:
// Read 1bytes char from buffer.
virtual int8_t read_1bytes();
int8_t read_1bytes();
// Read 2bytes int from buffer.
virtual int16_t read_2bytes();
int16_t read_2bytes();
// Read 3bytes int from buffer.
virtual int32_t read_3bytes();
int32_t read_3bytes();
// Read 4bytes int from buffer.
virtual int32_t read_4bytes();
int32_t read_4bytes();
// Read 8bytes int from buffer.
virtual int64_t read_8bytes();
int64_t read_8bytes();
// Read string from buffer, length specifies by param len.
virtual std::string read_string(int len);
std::string read_string(int len);
// Read bytes from buffer, length specifies by param len.
virtual void read_bytes(char* data, int size);
void read_bytes(char* data, int size);
public:
// Write 1bytes char to buffer.
virtual void write_1bytes(int8_t value);
void write_1bytes(int8_t value);
// Write 2bytes int to buffer.
virtual void write_2bytes(int16_t value);
void write_2bytes(int16_t value);
// Write 4bytes int to buffer.
virtual void write_4bytes(int32_t value);
void write_4bytes(int32_t value);
// Write 3bytes int to buffer.
virtual void write_3bytes(int32_t value);
void write_3bytes(int32_t value);
// Write 8bytes int to buffer.
virtual void write_8bytes(int64_t value);
void write_8bytes(int64_t value);
// Write string to buffer
virtual void write_string(std::string value);
void write_string(std::string value);
// Write bytes to buffer
virtual void write_bytes(char* data, int size);
void write_bytes(char* data, int size);
};
/**
@ -175,10 +175,10 @@ private:
SrsBuffer* stream;
public:
SrsBitBuffer(SrsBuffer* b);
virtual ~SrsBitBuffer();
~SrsBitBuffer();
public:
virtual bool empty();
virtual int8_t read_bit();
bool empty();
int8_t read_bit();
};
#endif