Distribution_Service/CC_SDK/Include/Multimedia/CCMiniMP3.h

58 lines
1.3 KiB
C
Raw Permalink Normal View History

2025-11-11 17:46:19 +08:00
#ifndef CC_MINI_MP3_H
#define CC_MINI_MP3_H
#include <cstdint>
#include <vector>
#include "cstddef"
2026-03-20 09:51:56 +08:00
#ifdef _WIN32
#include <windows.h>
#endif
2025-11-11 17:46:19 +08:00
namespace CTL {
class Frame {
public:
2026-03-20 09:51:56 +08:00
size_t length = {};
2025-11-11 17:46:19 +08:00
std::vector<uint8_t> frame{};
};
class PCM_Int16 {
public:
2026-03-20 09:51:56 +08:00
size_t length = {};
unsigned long frames = {};
2025-11-11 17:46:19 +08:00
std::vector<int16_t> frame{};
};
class MiniMP3Frames {
public:
2026-03-20 09:51:56 +08:00
size_t length = {};
2025-11-11 17:46:19 +08:00
std::vector<Frame> frames{};
std::vector<PCM_Int16> PCM{};
};
class MiniMP3 {
public:
int file_size = -1;
int frame_byte_size = -1;
int frame_count = -1;
int samples_per_frame = -1;
int channels = -1;
int sampling_rate = -1;
double frame_duration = -1;
long long total_duration = -1;
long long bit_rate = -1;
bool is_vbr = false;
bool has_cover = false;
private:
void* mp3d = nullptr;
std::vector<uint8_t> mp3Data;
int offsetof_t = 0;
public:
MiniMP3() = default;
explicit MiniMP3(const char* filename);
~MiniMP3();
void Init(const char* filename);
MiniMP3Frames GetFrames(bool DecodingPCM = false);
[[nodiscard]] PCM_Int16 GetPCM(size_t frame_index) const;
};
}
#endif