2021-05-31 05:42:20 +00:00
|
|
|
//
|
2024-01-01 02:51:24 +00:00
|
|
|
// Copyright (c) 2013-2024 The SRS Authors
|
2021-05-31 05:42:20 +00:00
|
|
|
//
|
2023-10-23 06:33:19 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2021-05-31 05:42:20 +00:00
|
|
|
//
|
2015-01-22 10:13:33 +00:00
|
|
|
|
2015-09-22 00:52:00 +00:00
|
|
|
#ifndef SRS_KERNEL_STREAM_HPP
|
|
|
|
#define SRS_KERNEL_STREAM_HPP
|
2015-01-22 10:13:33 +00:00
|
|
|
|
|
|
|
#include <srs_core.hpp>
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
/**
|
2017-03-25 09:21:39 +00:00
|
|
|
* the simple buffer use vector to append bytes,
|
|
|
|
* it's for hls and http, and need to be refined in future.
|
|
|
|
*/
|
2015-09-22 00:59:52 +00:00
|
|
|
class SrsSimpleStream
|
2015-01-22 10:13:33 +00:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
std::vector<char> data;
|
|
|
|
public:
|
2015-09-22 00:59:52 +00:00
|
|
|
SrsSimpleStream();
|
|
|
|
virtual ~SrsSimpleStream();
|
2015-01-22 10:13:33 +00:00
|
|
|
public:
|
|
|
|
/**
|
2017-03-25 09:21:39 +00:00
|
|
|
* get the length of buffer. empty if zero.
|
|
|
|
* @remark assert length() is not negative.
|
|
|
|
*/
|
2015-01-22 10:13:33 +00:00
|
|
|
virtual int length();
|
|
|
|
/**
|
2017-03-25 09:21:39 +00:00
|
|
|
* get the buffer bytes.
|
|
|
|
* @return the bytes, NULL if empty.
|
|
|
|
*/
|
2015-01-22 10:13:33 +00:00
|
|
|
virtual char* bytes();
|
|
|
|
/**
|
2017-03-25 09:21:39 +00:00
|
|
|
* erase size of bytes from begin.
|
|
|
|
* @param size to erase size of bytes.
|
|
|
|
* clear if size greater than or equals to length()
|
|
|
|
* @remark ignore size is not positive.
|
|
|
|
*/
|
2015-01-22 10:13:33 +00:00
|
|
|
virtual void erase(int size);
|
|
|
|
/**
|
2017-03-25 09:21:39 +00:00
|
|
|
* append specified bytes to buffer.
|
|
|
|
* @param size the size of bytes
|
|
|
|
* @remark assert size is positive.
|
|
|
|
*/
|
2015-01-22 10:13:33 +00:00
|
|
|
virtual void append(const char* bytes, int size);
|
2019-11-22 04:06:15 +00:00
|
|
|
virtual void append(SrsSimpleStream* src);
|
2015-01-22 10:13:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|