Working .wav live and VoD output, PCM A-law and MP3

This commit is contained in:
Thulinma 2017-04-17 17:41:38 +02:00
parent b7d1d38fb4
commit dda3a24805
5 changed files with 164 additions and 0 deletions

View file

@ -132,6 +132,18 @@ namespace RIFF{
}
}
}
std::string fmt::generate(uint16_t format, uint16_t channels, uint32_t hz, uint32_t bps, uint16_t blocksize, uint16_t size){
std::string ret("fmt \022\000\000\000", 8);
ret.append(std::string((size_t)18, '\000'));
Bit::htobs_le((char*)ret.data()+8, format);
Bit::htobs_le((char*)ret.data()+10, channels);
Bit::htobl_le((char*)ret.data()+12, hz);
Bit::htobl_le((char*)ret.data()+16, bps);
Bit::htobs_le((char*)ret.data()+20, blocksize);
Bit::htobs_le((char*)ret.data()+22, size);
Bit::htobs_le((char*)ret.data()+24, 0);
return ret;
}
uint32_t fact::getSamplesPerChannel() const{
if (!p){return 0;}
@ -143,6 +155,11 @@ namespace RIFF{
indent += 1;
o << std::string(indent, ' ') << "Samples per channel: " << getSamplesPerChannel() << std::endl;
}
std::string fact::generate(uint32_t samples){
std::string ret("fact\004\000\000\000\000\000\000\000", 12);
Bit::htobl_le((char*)ret.data()+8, samples);
return ret;
}
std::string ISFT::getSoftware() const{
if (!p){return 0;}

View file

@ -41,6 +41,7 @@ namespace RIFF{
/// WAVE "fmt " class.
class fmt : public Chunk{
public:
static std::string generate(uint16_t format, uint16_t channels, uint32_t hz, uint32_t bps, uint16_t blocksize, uint16_t size);
fmt(const void *_p = 0, uint32_t len = 0) : Chunk(_p, len){}
uint16_t getFormat() const;
std::string getCodec() const;
@ -59,6 +60,7 @@ namespace RIFF{
/// WAVE fact class.
class fact : public Chunk {
public:
static std::string generate(uint32_t samples);
fact(const void *_p = 0, uint32_t len = 0) : Chunk(_p, len){}
uint32_t getSamplesPerChannel() const;
virtual void toPrettyString(std::ostream &o, size_t indent = 0) const;