-#ifndef _LOTCOMMON_H_
-#define _LOTCOMMON_H_
+#ifndef _LOT_COMMON_H_
+#define _LOT_COMMON_H_
#ifdef _WIN32
#ifdef LOT_BUILD
#endif
#endif
+
+/**
+ * @brief Enumeration for Lottie Player error code.
+ */
+typedef enum
+{
+ LOT_PLAYER_ERROR_NONE = 0,
+ LOT_PLAYER_ERROR_NOT_PERMITTED,
+ LOT_PLAYER_ERROR_OUT_OF_MEMORY,
+ LOT_PLAYER_ERROR_INVALID_PARAMETER,
+ LOT_PLAYER_ERROR_RESULT_OUT_OF_RANGE,
+ LOT_PLAYER_ERROR_ALREADY_IN_PROGRESS,
+ LOT_PLAYER_ERROR_UNKNOWN
+} lotplayer_error_e;
+
+
typedef struct LOTNode {
#define ChangeFlagNone 0x0000
bool clear;
} lotbuf;
-#endif // _LOTCOMMON_H_
+#endif // _LOT_COMMON_H_
-#ifndef _LOTPLAYER_H_
-#define _LOTPLAYER_H_
+#ifndef _LOT_PLAYER_H_
+#define _LOT_PLAYER_H_
#include <future>
#include <vector>
//TODO: Hide this.
class LOTPlayerPrivate;
-#define _LOTPLAYER_DECLARE_PRIVATE(A) \
+#define _LOT_PLAYER_DECLARE_PRIVATE(A) \
class A##Private *d;
namespace lottieplayer {
bool renderSync(float pos, LOTBuffer buffer, bool forceRender = false);
private:
- _LOTPLAYER_DECLARE_PRIVATE(LOTPlayer);
+ _LOT_PLAYER_DECLARE_PRIVATE(LOTPlayer);
};
} // namespace lotplayer
-#endif // _LOTPLAYER_H_
+#endif // _LOT_PLAYER_H_
#include <lotplayer.h>
+#include "vdebug.h"
extern "C" {
{
lotplayer* p = new LOTPlayer();
if (!p) {
- //TODO: Print Error
+ vCritical << "Failed to initialize lotplayer";
}
return p;
}
LOT_EXPORT int lotplayer_destroy(lotplayer *player)
{
- if (!player) return -1;
+ if (!player) return LOT_PLAYER_ERROR_INVALID_PARAMETER;
delete(player);
- return 0;
+ return LOT_PLAYER_ERROR_NONE;
}
LOT_EXPORT int lotplayer_set_file(lotplayer *player, const char *file)
{
- if (!player) return -1;
+ if (!player) return LOT_PLAYER_ERROR_INVALID_PARAMETER;
bool ret = player->setFilePath(file);
if (!ret) return -1;
- return 0;
+ return LOT_PLAYER_ERROR_NONE;
}
LOT_EXPORT int lotplayer_set_size(lotplayer *player, int w, int h)
{
- if (!player) return -1;
+ if (!player) return LOT_PLAYER_ERROR_INVALID_PARAMETER;
player->setSize(w, h);
- return 0;
+ return LOT_PLAYER_ERROR_NONE;
}
LOT_EXPORT int lotplayer_get_size(const lotplayer *player, int* w, int* h)
{
- if (!player) return -1;
+ if (!player) return LOT_PLAYER_ERROR_INVALID_PARAMETER;
player->size(*w, *h);
- return 0;
+ return LOT_PLAYER_ERROR_NONE;
}
LOT_EXPORT float lotplayer_get_pos(const lotplayer *player)
{
- if (!player) return -1.0f;
+ if (!player) {
+ vWarning << "Invalid parameter player = nullptr";
+ return -1.0f;
+ }
return player->pos();
}
LOT_EXPORT size_t lotplayer_get_node_count(const lotplayer *player, float pos)
{
- if (!player) return 0;
+ if (!player) return LOT_PLAYER_ERROR_NONE;
return player->renderList(pos).size();
}
LOT_EXPORT float lotplayer_get_playtime(const lotplayer *player)
{
- if (!player) return 0.0f;
+ if (!player) {
+ vWarning << "Invalid parameter player = nullptr";
+ return 0.0f;
+ }
return player->playTime();
}
LOT_EXPORT const lotnode* lotplayer_get_node(lotplayer *player, float pos, size_t idx)
{
- if (!player) return nullptr;
+ if (!player) {
+ vWarning << "Invalid parameter player = nullptr";
+ return nullptr;
+ }
if (idx >= player->renderList(pos).size()) {
+ vWarning << "Invalid parameter idx? (0 ~ " << player->renderList(pos).size() << "), given idx = " << idx;
return nullptr;
}