Skylicht Engine
Loading...
Searching...
No Matches
COnlineMemoryStream.h
1#ifndef _ONLINE_MEMORY_STREAM_H_
2#define _ONLINE_MEMORY_STREAM_H_
3
4#include "IStream.h"
5#include "Thread/IMutex.h"
6
7using namespace Skylicht::System;
8
9namespace Skylicht
10{
11 namespace Audio
12 {
14
20 class COnlineMemoryStreamCursor : public IStreamCursor
21 {
22 public:
23 int m_pos;
24 COnlineMemoryStream* m_stream;
25
26 public:
27 COnlineMemoryStreamCursor(COnlineMemoryStream* stream);
28 virtual ~COnlineMemoryStreamCursor();
29
30 virtual int seek(int pos, EOrigin origin);
31 virtual int tell();
32 virtual int read(unsigned char* buff, int len);
33 virtual bool endOfStream();
34 virtual int size();
35 virtual bool readyReadData(int len);
36
40 virtual void trim();
41 };
42
48 class COnlineMemoryStream : public IStream
49 {
50 protected:
51 unsigned char* m_buffer;
52 int m_size;
53 int m_allocSize;
54
55 IMutex* m_mutex;
56 bool m_fullDataStream;
57
58 bool m_stopStream;
59 public:
60 COnlineMemoryStream();
61 virtual ~COnlineMemoryStream();
62
68
74 unsigned char* getDataBuffer();
75
82
88 virtual void uploadData(unsigned char* buffer, int size);
89
94 inline IMutex* getMutex()
95 {
96 return m_mutex;
97 }
98
103 inline void setFullData(bool b)
104 {
105 m_fullDataStream = b;
106 }
107
112 inline bool isFullData()
113 {
114 return m_fullDataStream;
115 }
116
121 inline bool isStopStream()
122 {
123 return m_stopStream;
124 }
125
130 inline void setStopStream(bool b)
131 {
132 m_stopStream = b;
133 }
134
139 virtual void trim(int position);
140
144 virtual void stopStream();
145 };
146 }
147}
148
149#endif
virtual int seek(int pos, EOrigin origin)
Move the cursor position.
virtual void trim()
Remove all data before the current cursor position from the stream.
virtual bool endOfStream()
Check if the cursor is at the end of the stream.
virtual int tell()
Get current cursor position.
virtual int size()
Get total size of the stream.
virtual int read(unsigned char *buff, int len)
Read data from the stream.
virtual bool readyReadData(int len)
Check if a certain amount of data is ready to be read.
A thread-safe dynamic memory stream for online data (e.g. voice chat or network audio)....
Definition COnlineMemoryStream.h:49
unsigned char * getDataBuffer()
Get pointer to the underlying buffer.
void setStopStream(bool b)
Stop the stream.
Definition COnlineMemoryStream.h:130
virtual void trim(int position)
Remove data before the specified position.
IMutex * getMutex()
Get the internal synchronization mutex.
Definition COnlineMemoryStream.h:94
bool isFullData()
Check if the stream is marked as complete.
Definition COnlineMemoryStream.h:112
virtual void stopStream()
Stop the stream and clear all buffers.
int getDataBufferSize()
Get total size of available data.
bool isStopStream()
Check if the stream has been stopped.
Definition COnlineMemoryStream.h:121
void setFullData(bool b)
Mark the stream as finished (no more data will be uploaded).
Definition COnlineMemoryStream.h:103
virtual void uploadData(unsigned char *buffer, int size)
Append new data to the stream. Thread-safe.
virtual IStreamCursor * createCursor()
Create a new online cursor.
Interface for a stream cursor, providing seek and read operations on an audio stream.
Definition IStream.h:39
EOrigin
Origin for seek operations.
Definition IStream.h:45
Definition IMutex.h:34
Handles all core audio functionality.
Definition AudioDebugLog.h:31
The foundation for thread and process handling.
Definition CNullMutex.h:32
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition AudioDebugLog.h:29