Fleshed out interface wrappers for a bunch more SDK interface types.

This commit is contained in:
casey langen 2020-01-26 22:27:16 -08:00
parent 96250a0526
commit d52e3e89db
2 changed files with 306 additions and 51 deletions

View File

@ -44,19 +44,33 @@
#include <core/sdk/ITrackListEditor.h>
#include <core/sdk/IMetadataProxy.h>
#include <core/sdk/IPlaybackService.h>
#include <core/sdk/IPreferences.h>
#include <core/sdk/IDataStream.h>
#include <core/sdk/IBuffer.h>
#include <core/sdk/IDecoder.h>
#include <core/sdk/IEncoder.h>
#include <core/sdk/IBlockingEncoder.h>
#include <core/sdk/IStreamingEncoder.h>
using namespace musik::core::sdk;
#define R(x) reinterpret_cast<IResource*>(x)
#define V(x) reinterpret_cast<IValue*>(x)
#define M(x) reinterpret_cast<IMap*>(x)
#define VL(x) reinterpret_cast<IValueList*>(x)
#define ML(x) reinterpret_cast<IMapList*>(x)
#define RESOURCE(x) reinterpret_cast<IResource*>(x)
#define VALUE(x) reinterpret_cast<IValue*>(x)
#define MAP(x) reinterpret_cast<IMap*>(x)
#define VALUELIST(x) reinterpret_cast<IValueList*>(x)
#define MAPLIST(x) reinterpret_cast<IMapList*>(x)
#define TRACK(x) reinterpret_cast<ITrack*>(x)
#define TRACKLIST(x) reinterpret_cast<ITrackList*>(x)
#define TRACKLISTEDITOR(x) reinterpret_cast<ITrackListEditor*>(x)
#define METADATA(x) reinterpret_cast<IMetadataProxy*>(x)
#define PLAYBACK(x) reinterpret_cast<IPlaybackService*>(x)
#define PREFS(x) reinterpret_cast<IPreferences*>(x)
#define DATASTREAM(x) reinterpret_cast<IDataStream*>(x)
#define BUFFER(x) reinterpret_cast<IBuffer*>(x)
#define DECODER(x) reinterpret_cast<IDecoder*>(x)
#define ENCODER(x) reinterpret_cast<IEncoder*>(x)
#define STREAMINGENCODER(x) reinterpret_cast<IStreamingEncoder*>(x)
#define BLOCKINGENCODER(x) reinterpret_cast<IBlockingEncoder*>(x)
/*
*
@ -65,15 +79,15 @@ using namespace musik::core::sdk;
*/
mcsdk_export int64_t mcsdk_resource_get_id(mcsdk_resource r) {
return R(r)->GetId();
return RESOURCE(r)->GetId();
}
mcsdk_export mcsdk_resource_class mcsdk_resource_get_class(mcsdk_resource r) {
return (mcsdk_resource_class) R(r)->GetClass();
return (mcsdk_resource_class) RESOURCE(r)->GetClass();
}
mcsdk_export void mcsdk_resource_release(mcsdk_resource r) {
R(r)->Release();
RESOURCE(r)->Release();
}
/*
@ -83,11 +97,11 @@ mcsdk_export void mcsdk_resource_release(mcsdk_resource r) {
*/
mcsdk_export size_t mcsdk_value_get_value(mcsdk_value v, char* dst, size_t size) {
return V(v)->GetValue(dst, size);
return VALUE(v)->GetValue(dst, size);
}
mcsdk_export void mcsdk_value_release(mcsdk_value v) {
return V(v)->Release();
return VALUE(v)->Release();
}
/*
@ -97,15 +111,15 @@ mcsdk_export void mcsdk_value_release(mcsdk_value v) {
*/
mcsdk_export size_t mcsdk_value_list_count(mcsdk_value_list vl) {
return VL(vl)->Count();
return VALUELIST(vl)->Count();
}
mcsdk_export mcsdk_value mcsdk_value_list_get_at(mcsdk_value_list vl, size_t index) {
return (mcsdk_value) VL(vl)->GetAt(index);
return (mcsdk_value) VALUELIST(vl)->GetAt(index);
}
mcsdk_export void mcsdk_value_list_release(mcsdk_value_list vl) {
VL(vl)->Release();
VALUELIST(vl)->Release();
}
/*
@ -115,23 +129,23 @@ mcsdk_export void mcsdk_value_list_release(mcsdk_value_list vl) {
*/
mcsdk_export int mcsdk_map_get_string(mcsdk_map m, const char* key, char* dst, int size) {
return M(m)->GetString(key, dst, size);
return MAP(m)->GetString(key, dst, size);
}
mcsdk_export int64_t mcsdk_map_get_int64(mcsdk_map m, const char* key, int64_t default_value) {
return M(m)->GetInt64(key, default_value);
return MAP(m)->GetInt64(key, default_value);
}
mcsdk_export int32_t mcsdk_map_get_int32(mcsdk_map m, const char* key, int32_t default_value) {
return M(m)->GetInt32(key, default_value);
return MAP(m)->GetInt32(key, default_value);
}
mcsdk_export double mcsdk_map_get_double(mcsdk_map m, const char* key, double default_value) {
return M(m)->GetDouble(key, default_value);
return MAP(m)->GetDouble(key, default_value);
}
mcsdk_export void mcsdk_map_release(mcsdk_map m) {
M(m)->Release();
MAP(m)->Release();
}
/*
@ -141,15 +155,15 @@ mcsdk_export void mcsdk_map_release(mcsdk_map m) {
*/
mcsdk_export size_t mcsdk_map_list_get_count(mcsdk_map_list ml) {
return ML(ml)->Count();
return MAPLIST(ml)->Count();
}
mcsdk_export mcsdk_map_list mcsdk_map_list_get_at(mcsdk_map_list ml, size_t index) {
return (mcsdk_map_list) ML(ml)->GetAt(index);
return (mcsdk_map_list) MAPLIST(ml)->GetAt(index);
}
mcsdk_export void mcsdk_map_list_release(mcsdk_map_list ml) {
ML(ml)->Release();
MAPLIST(ml)->Release();
}
/*
@ -449,3 +463,253 @@ mcsdk_export void mcsdk_svc_playback_reload_output(mcsdk_svc_playback pb) {
mcsdk_export mcsdk_track_list mcsdk_svc_playback_clone(mcsdk_svc_playback pb) {
return (mcsdk_track_list) PLAYBACK(pb)->Clone();
}
/*
*
* IPreferences
*
*/
mcsdk_export bool mcsdk_prefs_get_bool(mcsdk_prefs p, const char* key, bool defaultValue) {
return PREFS(p)->GetBool(key, defaultValue);
}
mcsdk_export int mcsdk_prefs_get_int(mcsdk_prefs p, const char* key, int defaultValue) {
return PREFS(p)->GetInt(key, defaultValue);
}
mcsdk_export double mcsdk_prefs_get_double(mcsdk_prefs p, const char* key, double defaultValue) {
return PREFS(p)->GetDouble(key, defaultValue);
}
mcsdk_export int mcsdk_prefs_get_string(mcsdk_prefs p, const char* key, char* dst, size_t size, const char* defaultValue) {
return PREFS(p)->GetString(key, dst, size, defaultValue);
}
mcsdk_export void mcsdk_prefs_set_int(mcsdk_prefs p, const char* key, int value) {
PREFS(p)->SetInt(key, value);
}
mcsdk_export void mcsdk_prefs_set_double(mcsdk_prefs p, const char* key, double value) {
PREFS(p)->SetDouble(key, value);
}
mcsdk_export void mcsdk_prefs_set_string(mcsdk_prefs p, const char* key, const char* value) {
PREFS(p)->SetString(key, value);
}
mcsdk_export void mcsdk_prefs_save(mcsdk_prefs p) {
PREFS(p)->Save();
}
mcsdk_export void mcsdk_prefs_release(mcsdk_prefs p) {
PREFS(p)->Release();
}
/*
*
* IDataStream
*
*/
mcsdk_export bool mcsdk_data_stream_open(mcsdk_data_stream ds, const char *uri, mcsdk_stream_open_flags flags) {
return DATASTREAM(ds)->Open(uri, (OpenFlags) flags);
}
mcsdk_export bool mcsdk_data_stream_close(mcsdk_data_stream ds) {
return DATASTREAM(ds)->Close();
}
mcsdk_export void mcsdk_data_stream_interrupt(mcsdk_data_stream ds) {
DATASTREAM(ds)->Interrupt();
}
mcsdk_export bool mcsdk_data_stream_is_readable(mcsdk_data_stream ds) {
return DATASTREAM(ds)->Readable();
}
mcsdk_export bool mcsdk_data_stream_is_writable(mcsdk_data_stream ds) {
return DATASTREAM(ds)->Writable();
}
mcsdk_export long mcsdk_data_stream_read(mcsdk_data_stream ds, void* dst, long count) {
return DATASTREAM(ds)->Read(dst, count);
}
mcsdk_export long mcsdk_data_stream_write(mcsdk_data_stream ds, void* src, long count) {
return DATASTREAM(ds)->Write(src, count);
}
mcsdk_export bool mcsdk_data_stream_set_position(mcsdk_data_stream ds, long position) {
return DATASTREAM(ds)->SetPosition(position);
}
mcsdk_export long mcsdk_data_stream_get_position(mcsdk_data_stream ds) {
return DATASTREAM(ds)->Position();
}
mcsdk_export bool mcsdk_data_stream_is_seekable(mcsdk_data_stream ds) {
return DATASTREAM(ds)->Seekable();
}
mcsdk_export bool mcsdk_data_stream_is_eof(mcsdk_data_stream ds) {
return DATASTREAM(ds)->Eof();
}
mcsdk_export long mcsdk_data_stream_get_length(mcsdk_data_stream ds) {
return DATASTREAM(ds)->Length();
}
mcsdk_export const char* mcsdk_data_stream_get_type(mcsdk_data_stream ds) {
return DATASTREAM(ds)->Type();
}
mcsdk_export const char* mcsdk_data_stream_get_uri(mcsdk_data_stream ds) {
return DATASTREAM(ds)->Uri();
}
mcsdk_export bool mcsdk_data_stream_can_prefetch(mcsdk_data_stream ds) {
return DATASTREAM(ds)->CanPrefetch();
}
mcsdk_export void mcsdk_data_stream_release(mcsdk_data_stream ds) {
DATASTREAM(ds)->Release();
}
/*
*
* IAudioBuffer
*
*/
mcsdk_export long mcsdk_audio_buffer_get_sample_rate(mcsdk_audio_buffer ab) {
return BUFFER(ab)->SampleRate();
}
mcsdk_export void mcsdk_audio_buffer_set_sample_rate(mcsdk_audio_buffer ab, long sample_rate) {
BUFFER(ab)->SetSampleRate(sample_rate);
}
mcsdk_export int mcsdk_audio_buffer_get_channels(mcsdk_audio_buffer ab) {
return BUFFER(ab)->Channels();
}
mcsdk_export void mcsdk_audio_buffer_set_channels(mcsdk_audio_buffer ab, int channels) {
BUFFER(ab)->SetChannels(channels);
}
mcsdk_export float* mcsdk_audio_buffer_get_buffer_pointer(mcsdk_audio_buffer ab) {
return BUFFER(ab)->BufferPointer();
}
mcsdk_export long mcsdk_audio_buffer_get_sample_count(mcsdk_audio_buffer ab) {
return BUFFER(ab)->Samples();
}
mcsdk_export void mcsdk_audio_buffer_set_sample_count(mcsdk_audio_buffer ab, long samples) {
BUFFER(ab)->SetSamples(samples);
}
mcsdk_export long mcsdk_audio_buffer_get_byte_count(mcsdk_audio_buffer ab) {
return BUFFER(ab)->Bytes();
}
mcsdk_export void mcsdk_audio_buffer_release(mcsdk_audio_buffer ab) {
BUFFER(ab)->Release();
}
/*
*
* IDecoder
*
*/
mcsdk_export double mcsdk_decoder_set_position(mcsdk_decoder d, double seconds) {
return DECODER(d)->SetPosition(seconds);
}
mcsdk_export bool mcsdk_decoder_fill_buffer(mcsdk_decoder d, mcsdk_audio_buffer ab) {
return DECODER(d)->GetBuffer(BUFFER(ab));
}
mcsdk_export double mcsdk_decoder_get_duration(mcsdk_decoder d) {
return DECODER(d)->GetDuration();
}
mcsdk_export bool mcsdk_decoder_open(mcsdk_decoder d, mcsdk_data_stream ds) {
return DECODER(d)->Open(DATASTREAM(ds));
}
mcsdk_export bool mcsdk_decoder_is_eof(mcsdk_decoder d) {
return DECODER(d)->Exhausted();
}
mcsdk_export void mcsdk_decoder_release(mcsdk_decoder d) {
DECODER(d)->Release();
}
/*
*
* IEncoder
*
*/
mcsdk_export void mcsdk_encoder_release(mcsdk_encoder e) {
ENCODER(e)->Release();
}
mcsdk_export mcsdk_encoder_type mcsdk_encoder_get_type(mcsdk_encoder e) {
IEncoder* encoder = reinterpret_cast<IEncoder*>(e);
if (dynamic_cast<IBlockingEncoder*>(encoder) != nullptr) {
return mcsdk_encoder_type_blocking;
}
return mcsdk_encoder_type_streaming;
}
/*
*
* IBlockingEncoder
*
*/
mcsdk_export bool mcsdk_blocking_encoder_initialize(mcsdk_blocking_encoder be, mcsdk_data_stream out, size_t rate, size_t channels, size_t bitrate) {
return BLOCKINGENCODER(be)->Initialize(DATASTREAM(out), rate, channels, bitrate);
}
mcsdk_export bool mcsdk_blocking_encoder_encode(mcsdk_blocking_encoder be, mcsdk_audio_buffer ab) {
return BLOCKINGENCODER(be)->Encode(BUFFER(ab));
}
mcsdk_export void mcsdk_blocking_encoder_finalize(mcsdk_blocking_encoder be) {
BLOCKINGENCODER(be)->Finalize();
}
mcsdk_export void mcsdk_blocking_encoder_release(mcsdk_blocking_encoder be, mcsdk_encoder e) {
BLOCKINGENCODER(be)->Release();
}
/*
*
* IStreamingEncoder
*
*/
mcsdk_export bool mcsdk_streaming_encoder_initialize(mcsdk_streaming_encoder se, size_t rate, size_t channels, size_t bitrate) {
return STREAMINGENCODER(se)->Initialize(rate, channels, bitrate);
}
mcsdk_export int mcsdk_streaming_encoder_encode(mcsdk_streaming_encoder se, mcsdk_audio_buffer ab, char** data) {
return STREAMINGENCODER(se)->Encode(BUFFER(ab), data);
}
mcsdk_export int mcsdk_streaming_encoder_flush(mcsdk_streaming_encoder se, char** data) {
return STREAMINGENCODER(se)->Flush(data);
}
mcsdk_export void mcsdk_streaming_encoder_finalize(mcsdk_streaming_encoder se, const char* uri) {
STREAMINGENCODER(se)->Finalize(uri);
}
mcsdk_export void mcsdk_streaming_encoder_release(mcsdk_streaming_encoder se, mcsdk_encoder e) {
STREAMINGENCODER(se)->Release();
}

View File

@ -379,11 +379,10 @@ mcsdk_export mcsdk_track_list mcsdk_svc_playback_clone(mcsdk_svc_playback pb);
/*
*
* IPreferences (TODO)
* IPreferences
*
*/
mcsdk_export void mcsdk_prefs_release(mcsdk_prefs p);
mcsdk_export bool mcsdk_prefs_get_bool(mcsdk_prefs p, const char* key, bool defaultValue);
mcsdk_export int mcsdk_prefs_get_int(mcsdk_prefs p, const char* key, int defaultValue);
mcsdk_export double mcsdk_prefs_get_double(mcsdk_prefs p, const char* key, double defaultValue);
@ -392,10 +391,11 @@ mcsdk_export void mcsdk_prefs_set_int(mcsdk_prefs p, const char* key, int value)
mcsdk_export void mcsdk_prefs_set_double(mcsdk_prefs p, const char* key, double value);
mcsdk_export void mcsdk_prefs_set_string(mcsdk_prefs p, const char* key, const char* value);
mcsdk_export void mcsdk_prefs_save(mcsdk_prefs p);
mcsdk_export void mcsdk_prefs_release(mcsdk_prefs p);
/*
*
* IDataStream (TODO)
* IDataStream
*
*/
@ -418,7 +418,7 @@ mcsdk_export void mcsdk_data_stream_release(mcsdk_data_stream ds);
/*
*
* IAudioBuffer (TODO)
* IAudioBuffer
*
*/
@ -427,14 +427,14 @@ mcsdk_export void mcsdk_audio_buffer_set_sample_rate(mcsdk_audio_buffer ab, long
mcsdk_export int mcsdk_audio_buffer_get_channels(mcsdk_audio_buffer ab);
mcsdk_export void mcsdk_audio_buffer_set_channels(mcsdk_audio_buffer ab, int channels);
mcsdk_export float* mcsdk_audio_buffer_get_buffer_pointer(mcsdk_audio_buffer ab);
mcsdk_export long mcsdk_audio_buffer_get_samples(mcsdk_audio_buffer ab);
mcsdk_export void mcsdk_audio_buffer_set_samples(mcsdk_audio_buffer ab, long samples);
mcsdk_export long mcsdk_audio_buffer_get_sample_count(mcsdk_audio_buffer ab);
mcsdk_export void mcsdk_audio_buffer_set_sample_count(mcsdk_audio_buffer ab, long samples);
mcsdk_export long mcsdk_audio_buffer_get_byte_count(mcsdk_audio_buffer ab);
mcsdk_export void mcsdk_audio_buffer_release(mcsdk_audio_buffer ab);
/*
*
* IDecoder (TODO)
* IDecoder
*
*/
@ -442,48 +442,39 @@ mcsdk_export double mcsdk_decoder_set_position(mcsdk_decoder d, double seconds);
mcsdk_export bool mcsdk_decoder_get_buffer(mcsdk_decoder d, mcsdk_audio_buffer ab);
mcsdk_export double mcsdk_decoder_get_duration(mcsdk_decoder d);
mcsdk_export bool mcsdk_decoder_open(mcsdk_decoder d, mcsdk_data_stream ds);
mcsdk_export bool mcsdk_decoder_exhausted(mcsdk_decoder d);
mcsdk_export bool mcsdk_decoder_is_eof(mcsdk_decoder d);
mcsdk_export void mcsdk_decoder_release(mcsdk_decoder d);
/*
*
* IEncoder (TODO)
* IEncoder
*
*/
mcsdk_export bool mcsdk_encoder_release(mcsdk_encoder e);
mcsdk_export mcsdk_encoder_type mcsdk_encoder_get_type(mcsdk_encoder e);
mcsdk_export void mcsdk_encoder_release(mcsdk_encoder e);
/*
*
* IBlockingEncoder (TODO)
* IBlockingEncoder
*
*/
mcsdk_export bool mcsdk_blocking_encoder_initialize(mcsdk_data_stream out, size_t rate, size_t channels, size_t bitrate);
mcsdk_export bool mcsdk_blocking_encoder_encode(mcsdk_audio_buffer ab);
mcsdk_export void mcsdk_blocking_encoder_finalize();
mcsdk_export bool mcsdk_blocking_encoder_initialize(mcsdk_blocking_encoder be, mcsdk_data_stream out, size_t rate, size_t channels, size_t bitrate);
mcsdk_export bool mcsdk_blocking_encoder_encode(mcsdk_blocking_encoder be, mcsdk_audio_buffer ab);
mcsdk_export void mcsdk_blocking_encoder_finalize(mcsdk_blocking_encoder be);
mcsdk_export void mcsdk_blocking_encoder_release(mcsdk_blocking_encoder be, mcsdk_encoder e);
/*
*
* IStreamingEncoder (TODO)
* IStreamingEncoder
*
*/
mcsdk_export bool mcsdk_streaming_encoder_initialize(size_t rate, size_t channels, size_t bitrate);
mcsdk_export int mcsdk_streaming_encoder_encode(mcsdk_audio_buffer ab, char** data);
mcsdk_export int mcsdk_streaming_encoder_flush(char** data);
mcsdk_export void mcsdk_streaming_encoder_finalize(const char* uri);
/*
*
* IDebug (TODO)
*
*/
mcsdk_export void mcsdk_debug_verbose(const char* tag, const char* message);
mcsdk_export void mcsdk_debug_info(const char* tag, const char* message);
mcsdk_export void mcsdk_debug_warning(const char* tag, const char* message);
mcsdk_export void mcsdk_debug_error(const char* tag, const char* message);
mcsdk_export bool mcsdk_streaming_encoder_initialize(mcsdk_streaming_encoder se, size_t rate, size_t channels, size_t bitrate);
mcsdk_export int mcsdk_streaming_encoder_encode(mcsdk_streaming_encoder se, mcsdk_audio_buffer ab, char** data);
mcsdk_export int mcsdk_streaming_encoder_flush(mcsdk_streaming_encoder se, char** data);
mcsdk_export void mcsdk_streaming_encoder_finalize(mcsdk_streaming_encoder se, const char* uri);
mcsdk_export void mcsdk_streaming_encoder_release(mcsdk_streaming_encoder se, mcsdk_encoder e);
#endif