mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-27 04:35:34 +08:00
Fix OBU total length error
This commit is contained in:
40
src/rtp/byte_buffer.h
Normal file
40
src/rtp/byte_buffer.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* @Author: DI JUNKUN
|
||||
* @Date: 2024-04-22
|
||||
* Copyright (c) 2024 by DI JUNKUN, All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _BYTE_BUFFER_H_
|
||||
#define _BYTE_BUFFER_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
class ByteBufferReader {
|
||||
public:
|
||||
ByteBufferReader(const char* bytes, size_t len);
|
||||
|
||||
ByteBufferReader(const ByteBufferReader&) = delete;
|
||||
ByteBufferReader& operator=(const ByteBufferReader&) = delete;
|
||||
|
||||
// Returns start of unprocessed data.
|
||||
const char* Data() const { return bytes_ + start_; }
|
||||
// Returns number of unprocessed bytes.
|
||||
size_t Length() const { return end_ - start_; }
|
||||
|
||||
bool ReadBytes(char* val, size_t len);
|
||||
bool ReadUInt8(uint8_t* val);
|
||||
bool ReadUVarint(uint64_t* val, size_t* len);
|
||||
|
||||
bool Consume(size_t size);
|
||||
|
||||
protected:
|
||||
void Construct(const char* bytes, size_t size);
|
||||
|
||||
const char* bytes_;
|
||||
size_t size_;
|
||||
size_t start_;
|
||||
size_t end_;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user