jsmad/wrapper.cpp

50 lines
1.1 KiB
C++

#include "wrapper.h"
MadHeader * mad_header_create()
{
MadHeader* header = new MadHeader;
mad_header_init(header);
return header;
}
MadFrame * mad_frame_create()
{
MadFrame* frame = new MadFrame;
mad_frame_init(frame);
return frame;
}
emscripten::val MadFrame::getOverlap() const
{
unsigned char* ptr = (unsigned char(*))overlap;
return emscripten::val(typed_memory_view(sizeof *overlap, ptr));
}
emscripten::val MadFrame::getSbsample() const
{
unsigned char* ptr = (unsigned char(*))&sbsample;
return emscripten::val(typed_memory_view(sizeof sbsample, ptr));
}
MadStream* mad_stream_create() {
MadStream* stream = new MadStream;
mad_stream_init(stream);
return stream;
}
emscripten::val MadStream::mainData()
{
return emscripten::val(typed_memory_view(MAD_BUFFER_MDLEN, (unsigned char(*))main_data));
}
void MadStream::setBuffer(intptr_t bufferPtr, unsigned long length)
{
mad_stream_buffer(this, (const unsigned char(*))bufferPtr, length);
}
int MadFrame::decode(mad_stream* stream)
{
return mad_frame_decode(this, stream);
}