Skylicht Engine
Loading...
Searching...
No Matches
CMemoryStream.h
1/*
2!@
3MIT License
4
5Copyright (c) 2012 - 2019 Skylicht Technology CO., LTD
6
7Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
8(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
9merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
10subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
20This file is part of the "Skylicht Engine".
21https://github.com/skylicht-lab/skylicht-engine
22!#
23*/
24
25#ifndef _SKYLICHTAUDIO_MEMORYSTREAM_H_
26#define _SKYLICHTAUDIO_MEMORYSTREAM_H_
27
28#include "IStream.h"
29
30namespace Skylicht
31{
32 namespace Audio
33 {
38 class CMemoryStreamCursor : public IStreamCursor
39 {
40 public:
41 unsigned char *m_buffer;
42 int m_size;
43 int m_pos;
44
45 public:
46 CMemoryStreamCursor(unsigned char *buffer, int size);
47 virtual ~CMemoryStreamCursor();
48
49 virtual int seek(int pos, EOrigin origin);
50 virtual int tell();
51 virtual int read(unsigned char* buff, int len);
52 virtual bool endOfStream();
53 virtual int size();
54 virtual bool readyReadData(int len);
55 };
56
61 class CMemoryStream : public IStream
62 {
63 protected:
64 unsigned char *m_buffer;
65 int m_size;
66 bool m_takeOwnership;
67
68 public:
69 CMemoryStream(unsigned char *buffer, int size, bool takeOwnership = false);
70 virtual ~CMemoryStream();
71
77 };
78 }
79}
80
81#endif
virtual int read(unsigned char *buff, int len)
Read data from the stream.
virtual int seek(int pos, EOrigin origin)
Move the cursor position.
virtual bool readyReadData(int len)
Check if a certain amount of data is ready to be read.
virtual int size()
Get total size of the stream.
virtual int tell()
Get current cursor position.
virtual bool endOfStream()
Check if the cursor is at the end of the stream.
virtual IStreamCursor * createCursor()
Create a new memory 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
Handles all core audio functionality.
Definition AudioDebugLog.h:31
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition AudioDebugLog.h:29