Added IPlaybackService wrapper. Still not far enough along to test

anything.
This commit is contained in:
casey langen 2020-01-26 14:13:58 -08:00
parent adbff275bf
commit 79d3244799
4 changed files with 241 additions and 0 deletions

View File

@ -1,4 +1,5 @@
set(CORE_C_SOURCES
context.cpp
interface_wrappers.cpp
)

65
src/core_c/context.cpp Normal file
View File

@ -0,0 +1,65 @@
//////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2004-2019 musikcube team
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#include "musikcore_c.h"
// #include <core/sdk/IResource.h>
// #include <core/sdk/IValue.h>
// #include <core/sdk/IValueList.h>
// #include <core/sdk/IMap.h>
// #include <core/sdk/IMapList.h>
// #include <core/sdk/ITrack.h>
// #include <core/sdk/ITrackList.h>
// #include <core/sdk/ITrackListEditor.h>
// #include <core/sdk/IMetadataProxy.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 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)
mcsdk_export bool mcsdk_context_init(mcsdk_context* context) {
return false;
}
mcsdk_export bool mcsdk_context_release(mcsdk_context* context) {
return false;
}

View File

@ -43,6 +43,7 @@
#include <core/sdk/ITrackList.h>
#include <core/sdk/ITrackListEditor.h>
#include <core/sdk/IMetadataProxy.h>
#include <core/sdk/IPlaybackService.h>
using namespace musik::core::sdk;
@ -55,6 +56,7 @@ using namespace musik::core::sdk;
#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)
/*
*
@ -325,3 +327,125 @@ mcsdk_export size_t mcsdk_svc_metadata_remove_tracks_from_playlist(mcsdk_svc_met
mcsdk_export void mcsdk_svc_metadata_release(mcsdk_svc_metadata mp) {
METADATA(mp)->Release();
}
/*
*
* IPlaybackService
*
*/
mcsdk_export void mcsdk_svc_playback_play_at(mcsdk_svc_playback pb, size_t index) {
PLAYBACK(pb)->Play(index);
}
mcsdk_export bool mcsdk_svc_playback_next(mcsdk_svc_playback pb) {
return PLAYBACK(pb)->Next();
}
mcsdk_export bool mcsdk_svc_playback_previous(mcsdk_svc_playback pb) {
return PLAYBACK(pb)->Previous();
}
mcsdk_export void mcsdk_svc_playback_stop(mcsdk_svc_playback pb) {
PLAYBACK(pb)->Stop();
}
mcsdk_export mcsdk_repeat_mode mcsdk_svc_playback_get_repeat_mode(mcsdk_svc_playback pb) {
return (mcsdk_repeat_mode) PLAYBACK(pb)->GetRepeatMode();
}
mcsdk_export void mcsdk_svc_playback_set_repeat_mode(mcsdk_svc_playback pb, mcsdk_repeat_mode mode) {
PLAYBACK(pb)->SetRepeatMode((RepeatMode) mode);
}
mcsdk_export void mcsdk_svc_playback_toggle_repeat_mode(mcsdk_svc_playback pb) {
PLAYBACK(pb)->ToggleRepeatMode();
}
mcsdk_export mcsdk_playback_state mcsdk_svc_playback_get_playback_state(mcsdk_svc_playback pb) {
return (mcsdk_playback_state) PLAYBACK(pb)->GetPlaybackState();
}
mcsdk_export bool mcsdk_svc_playback_is_shuffled(mcsdk_svc_playback pb) {
return PLAYBACK(pb)->IsShuffled();
}
mcsdk_export void mcsdk_svc_playback_toggle_shuffle(mcsdk_svc_playback pb) {
PLAYBACK(pb)->ToggleShuffle();
}
mcsdk_export void mcsdk_svc_playback_pause_or_resume(mcsdk_svc_playback pb) {
PLAYBACK(pb)->PauseOrResume();
}
mcsdk_export double mcsdk_svc_playback_get_volume(mcsdk_svc_playback pb) {
return PLAYBACK(pb)->GetVolume();
}
mcsdk_export void mcsdk_svc_playback_set_volume(mcsdk_svc_playback pb, double volume) {
PLAYBACK(pb)->SetVolume(volume);
}
mcsdk_export double mcsdk_svc_playback_get_position(mcsdk_svc_playback pb) {
return PLAYBACK(pb)->GetPosition();
}
mcsdk_export void mcsdk_svc_playback_set_position(mcsdk_svc_playback pb, double seconds) {
PLAYBACK(pb)->SetPosition(seconds);
}
mcsdk_export double mcsdk_svc_playback_get_duration(mcsdk_svc_playback pb) {
return PLAYBACK(pb)->GetDuration();
}
mcsdk_export bool mcsdk_svc_playback_is_muted(mcsdk_svc_playback pb) {
return PLAYBACK(pb)->IsMuted();
}
mcsdk_export void mcsdk_svc_playback_toggle_mute(mcsdk_svc_playback pb) {
PLAYBACK(pb)->ToggleMute();
}
mcsdk_export size_t mcsdk_svc_playback_get_index(mcsdk_svc_playback pb) {
return PLAYBACK(pb)->GetIndex();
}
mcsdk_export size_t mcsdk_svc_playback_count(mcsdk_svc_playback pb) {
return PLAYBACK(pb)->Count();
}
mcsdk_export mcsdk_track mcsdk_svc_playback_get_track(mcsdk_svc_playback pb, size_t index) {
return (mcsdk_track) PLAYBACK(pb)->GetTrack(index);
}
mcsdk_export mcsdk_track mcsdk_svc_playback_get_playing_track(mcsdk_svc_playback pb) {
return (mcsdk_track) PLAYBACK(pb)->GetPlayingTrack();
}
mcsdk_export void mcsdk_svc_playback_copy_from(mcsdk_svc_playback pb, const mcsdk_track_list track_list) {
PLAYBACK(pb)->CopyFrom(TRACKLIST(track_list));
}
mcsdk_export void mcsdk_svc_playback_play(mcsdk_svc_playback pb, const mcsdk_track_list source, size_t index) {
PLAYBACK(pb)->Play(TRACKLIST(source), index);
}
mcsdk_export mcsdk_track_list_editor mcsdk_svc_playback_edit_playlist(mcsdk_svc_playback pb) {
return (mcsdk_track_list_editor) PLAYBACK(pb)->EditPlaylist();
}
mcsdk_export mcsdk_time_change_mode mcsdk_svc_playback_get_time_change_mode(mcsdk_svc_playback pb) {
return (mcsdk_time_change_mode) PLAYBACK(pb)->GetTimeChangeMode();
}
mcsdk_export void mcsdk_svc_playback_set_time_change_mode(mcsdk_svc_playback pb, mcsdk_time_change_mode mode) {
PLAYBACK(pb)->SetTimeChangeMode((TimeChangeMode) mode);
}
mcsdk_export void mcsdk_svc_playback_reload_output(mcsdk_svc_playback pb) {
PLAYBACK(pb)->ReloadOutput();
}
mcsdk_export mcsdk_track_list mcsdk_svc_playback_clone(mcsdk_svc_playback pb) {
return (mcsdk_track_list) PLAYBACK(pb)->Clone();
}

View File

@ -187,6 +187,21 @@ mcsdk_export typedef mcsdk_handle mcsdk_map_list;
mcsdk_export typedef mcsdk_handle mcsdk_track_list;
mcsdk_export typedef mcsdk_handle mcsdk_track_list_editor;
mcsdk_export typedef mcsdk_handle mcsdk_svc_metadata;
mcsdk_export typedef mcsdk_handle mcsdk_svc_playback;
/*
*
* instance context
*
*/
struct mcsdk_context {
mcsdk_svc_metadata metadata;
mcsdk_svc_playback playback;
};
mcsdk_export bool mcsdk_context_init(mcsdk_context* context);
mcsdk_export bool mcsdk_context_release(mcsdk_context* context);
/*
*
@ -305,4 +320,40 @@ mcsdk_export bool mcsdk_svc_metadata_append_to_playlist_with_track_list(mcsdk_sv
mcsdk_export size_t mcsdk_svc_metadata_remove_tracks_from_playlist(mcsdk_svc_metadata mp, const int64_t playlist_id, const char** external_ids, const int* sort_orders, int count);
mcsdk_export void mcsdk_svc_metadata_release(mcsdk_svc_metadata mp);
/*
*
* IPlaybackService
*
*/
mcsdk_export void mcsdk_svc_playback_play_at(mcsdk_svc_playback pb, size_t index);
mcsdk_export bool mcsdk_svc_playback_next(mcsdk_svc_playback pb);
mcsdk_export bool mcsdk_svc_playback_previous(mcsdk_svc_playback pb);
mcsdk_export void mcsdk_svc_playback_stop(mcsdk_svc_playback pb);
mcsdk_export mcsdk_repeat_mode mcsdk_svc_playback_get_repeat_mode(mcsdk_svc_playback pb);
mcsdk_export void mcsdk_svc_playback_set_repeat_mode(mcsdk_svc_playback pb, mcsdk_repeat_mode mode);
mcsdk_export void mcsdk_svc_playback_toggle_repeat_mode(mcsdk_svc_playback pb);
mcsdk_export mcsdk_playback_state mcsdk_svc_playback_get_playback_state(mcsdk_svc_playback pb);
mcsdk_export bool mcsdk_svc_playback_is_shuffled(mcsdk_svc_playback pb);
mcsdk_export void mcsdk_svc_playback_toggle_shuffle(mcsdk_svc_playback pb);
mcsdk_export void mcsdk_svc_playback_pause_or_resume(mcsdk_svc_playback pb);
mcsdk_export double mcsdk_svc_playback_get_volume(mcsdk_svc_playback pb);
mcsdk_export void mcsdk_svc_playback_set_volume(mcsdk_svc_playback pb, double volume);
mcsdk_export double mcsdk_svc_playback_get_position(mcsdk_svc_playback pb);
mcsdk_export void mcsdk_svc_playback_set_position(mcsdk_svc_playback pb, double seconds);
mcsdk_export double mcsdk_svc_playback_get_duration(mcsdk_svc_playback pb);
mcsdk_export bool mcsdk_svc_playback_is_muted(mcsdk_svc_playback pb);
mcsdk_export void mcsdk_svc_playback_toggle_mute(mcsdk_svc_playback pb);
mcsdk_export size_t mcsdk_svc_playback_get_index(mcsdk_svc_playback pb);
mcsdk_export size_t mcsdk_svc_playback_count(mcsdk_svc_playback pb);
mcsdk_export mcsdk_track mcsdk_svc_playback_get_track(mcsdk_svc_playback pb, size_t index);
mcsdk_export mcsdk_track mcsdk_svc_playback_get_playing_track(mcsdk_svc_playback pb);
mcsdk_export void mcsdk_svc_playback_copy_from(mcsdk_svc_playback pb, const mcsdk_track_list track_list);
mcsdk_export void mcsdk_svc_playback_play(mcsdk_svc_playback pb, const mcsdk_track_list source, size_t index);
mcsdk_export mcsdk_track_list_editor mcsdk_svc_playback_edit_playlist(mcsdk_svc_playback pb);
mcsdk_export mcsdk_time_change_mode mcsdk_svc_playback_get_time_change_mode(mcsdk_svc_playback pb);
mcsdk_export void mcsdk_svc_playback_set_time_change_mode(mcsdk_svc_playback pb, mcsdk_time_change_mode mode);
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);
#endif