Skylicht Engine
Loading...
Searching...
No Matches
IAudioDecoder.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_IAUDIODECODER_H_
26#define _SKYLICHTAUDIO_IAUDIODECODER_H_
27
28#include "Driver/ISoundSource.h"
29#include "Stream/IStream.h"
30
31#include "AudioDebugLog.h"
32
33namespace Skylicht
34{
35 namespace Audio
36 {
37 enum EStatus
38 {
39 Failed = 0,
40 Success,
41 WaitData,
42 EndStream,
43 };
44
45 class IAudioDecoder
46 {
47 public:
48 enum EDecoderType
49 {
50 Wav,
51 Mp3,
52 RawWav, // use for micro, video audio
53 Num
54 };
55
56 protected:
57 bool m_loop;
58
59 IStream* m_stream;
60
61 std::string m_name;
62
63 public:
64 IAudioDecoder(IStream* stream)
65 {
66 m_loop = false;
67 m_stream = stream;
68 m_name = "Unknown";
69 }
70
71 virtual ~IAudioDecoder()
72 {
73 }
74
75 virtual EStatus initDecode() = 0;
76
77 virtual EStatus decode(void* outputBuffer, int bufferSize) = 0;
78
79 virtual float getCurrentTime() = 0;
80
81 virtual int seek(int bufferSize) = 0;
82
83 virtual void setLoop(bool loop)
84 {
85 m_loop = loop;
86 }
87
88 virtual bool isLoop()
89 {
90 return m_loop;
91 }
92
93 virtual void getTrackParam(STrackParams* track) = 0;
94
95 virtual void stopStream()
96 {
97
98 }
99
100 inline std::string getName()
101 {
102 return m_name;
103 }
104 };
105 }
106}
107
108#endif
Interface for an audio data stream (File, Memory, etc.).
Definition IStream.h:107
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
Definition ISoundSource.h:43