载入中...
搜索中...
未找到
Decoder.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5#include <cstdint>
6#include <memory>
7#include <string>
8#include <vector>
9
10namespace medialoader {
11class Decoder;
12}
13
14namespace eve {
15namespace sound {
16
24public:
26#if !defined(__EMSCRIPTEN__)
27 Decoder(std::unique_ptr<medialoader::Decoder> impl, std::vector<char> ownedData);
28#endif
31
39 Decoder *clone() const;
40
42 int decode();
44 int getSize() const;
46 void *getBuffer() const;
48 bool seek(double seconds);
50 bool rewind();
52 bool isSeekable();
54 bool isFinished();
56 int getChannelCount() const;
58 int getBitDepth() const;
60 int getSampleRate() const;
62 double getDuration();
63
69 medialoader::Decoder *getImpl() {
70#if defined(__EMSCRIPTEN__)
71 return nullptr;
72#else
73 return impl.get();
74#endif
75 }
76
77private:
78#if defined(__EMSCRIPTEN__)
79 friend class Sound;
81 Decoder(std::shared_ptr<const std::vector<std::uint8_t>> pcm, int sampleRate, int channels, int bufferSize);
82#endif
83#if !defined(__EMSCRIPTEN__)
84 Decoder(std::unique_ptr<medialoader::Decoder> impl, std::shared_ptr<const std::vector<char>> ownedData);
85 // Providers borrow these bytes. Declare storage first so it outlives impl's
86 // destructor, including when this is the last clone.
87 std::shared_ptr<const std::vector<char>> ownedData;
88 std::unique_ptr<medialoader::Decoder> impl;
89#endif
90#if defined(__EMSCRIPTEN__)
91 std::shared_ptr<const std::vector<std::uint8_t>> browserPcm;
92 std::vector<std::uint8_t> browserBuffer;
93 std::size_t browserOffset = 0;
94 int browserSampleRate = 0;
95 int browserChannels = 0;
96 std::size_t browserChunkBytes = 0;
97#endif
98};
99
100} // namespace sound
101} // namespace eve
std::map< std::string, std::vector< Key >, std::less<> > channels
void * impl
#define EVENGINE_API_PLATFORM
Definition Export.h:107
Streaming audio decoder (medialoader-backed). Native builds own encoded bytes and decode incrementall...
Definition Decoder.h:23
medialoader::Decoder * getImpl()
Underlying medialoader decoder (advanced; null on browser builds). @ownership Borrowed from this Deco...
Definition Decoder.h:69
Sound module: decodes compressed audio and produces SoundData buffers. Script: sound <- eve....
Definition Sound.h:18
Build metadata (engine git commit, build time, third-party version).
Definition Build.cpp:16