mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-08 08:31:13 +00:00
lottieplayer: handling error code.
Change-Id: I24c88fad24b821e18e7071e6bd82a828b8fd358e
This commit is contained in:
parent
ca6738b3da
commit
8bba2bc8d4
@ -1,5 +1,5 @@
|
|||||||
#ifndef _LOTCOMMON_H_
|
#ifndef _LOT_COMMON_H_
|
||||||
#define _LOTCOMMON_H_
|
#define _LOT_COMMON_H_
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#ifdef LOT_BUILD
|
#ifdef LOT_BUILD
|
||||||
@ -23,6 +23,22 @@
|
|||||||
#endif
|
#endif
|
||||||
#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 {
|
typedef struct LOTNode {
|
||||||
|
|
||||||
#define ChangeFlagNone 0x0000
|
#define ChangeFlagNone 0x0000
|
||||||
@ -83,4 +99,4 @@ typedef struct LOTBuffer {
|
|||||||
bool clear;
|
bool clear;
|
||||||
} lotbuf;
|
} lotbuf;
|
||||||
|
|
||||||
#endif // _LOTCOMMON_H_
|
#endif // _LOT_COMMON_H_
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef _LOTPLAYER_H_
|
#ifndef _LOT_PLAYER_H_
|
||||||
#define _LOTPLAYER_H_
|
#define _LOT_PLAYER_H_
|
||||||
|
|
||||||
#include <future>
|
#include <future>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
//TODO: Hide this.
|
//TODO: Hide this.
|
||||||
class LOTPlayerPrivate;
|
class LOTPlayerPrivate;
|
||||||
#define _LOTPLAYER_DECLARE_PRIVATE(A) \
|
#define _LOT_PLAYER_DECLARE_PRIVATE(A) \
|
||||||
class A##Private *d;
|
class A##Private *d;
|
||||||
|
|
||||||
namespace lottieplayer {
|
namespace lottieplayer {
|
||||||
@ -33,9 +33,9 @@ public:
|
|||||||
bool renderSync(float pos, LOTBuffer buffer, bool forceRender = false);
|
bool renderSync(float pos, LOTBuffer buffer, bool forceRender = false);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
_LOTPLAYER_DECLARE_PRIVATE(LOTPlayer);
|
_LOT_PLAYER_DECLARE_PRIVATE(LOTPlayer);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace lotplayer
|
} // namespace lotplayer
|
||||||
|
|
||||||
#endif // _LOTPLAYER_H_
|
#endif // _LOT_PLAYER_H_
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include <lotplayer.h>
|
#include <lotplayer.h>
|
||||||
|
#include "vdebug.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
@ -10,73 +11,83 @@ LOT_EXPORT lotplayer *lotplayer_create(void)
|
|||||||
{
|
{
|
||||||
lotplayer* p = new LOTPlayer();
|
lotplayer* p = new LOTPlayer();
|
||||||
if (!p) {
|
if (!p) {
|
||||||
//TODO: Print Error
|
vCritical << "Failed to initialize lotplayer";
|
||||||
}
|
}
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOT_EXPORT int lotplayer_destroy(lotplayer *player)
|
LOT_EXPORT int lotplayer_destroy(lotplayer *player)
|
||||||
{
|
{
|
||||||
if (!player) return -1;
|
if (!player) return LOT_PLAYER_ERROR_INVALID_PARAMETER;
|
||||||
delete(player);
|
delete(player);
|
||||||
|
|
||||||
return 0;
|
return LOT_PLAYER_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOT_EXPORT int lotplayer_set_file(lotplayer *player, const char *file)
|
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);
|
bool ret = player->setFilePath(file);
|
||||||
|
|
||||||
if (!ret) return -1;
|
if (!ret) return -1;
|
||||||
|
|
||||||
return 0;
|
return LOT_PLAYER_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOT_EXPORT int lotplayer_set_size(lotplayer *player, int w, int h)
|
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);
|
player->setSize(w, h);
|
||||||
|
|
||||||
return 0;
|
return LOT_PLAYER_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOT_EXPORT int lotplayer_get_size(const lotplayer *player, int* w, int* h)
|
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);
|
player->size(*w, *h);
|
||||||
|
|
||||||
return 0;
|
return LOT_PLAYER_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOT_EXPORT float lotplayer_get_pos(const lotplayer *player)
|
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();
|
return player->pos();
|
||||||
}
|
}
|
||||||
|
|
||||||
LOT_EXPORT size_t lotplayer_get_node_count(const lotplayer *player, float 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();
|
return player->renderList(pos).size();
|
||||||
}
|
}
|
||||||
|
|
||||||
LOT_EXPORT float lotplayer_get_playtime(const lotplayer *player)
|
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();
|
return player->playTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
LOT_EXPORT const lotnode* lotplayer_get_node(lotplayer *player, float pos, size_t idx)
|
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()) {
|
if (idx >= player->renderList(pos).size()) {
|
||||||
|
vWarning << "Invalid parameter idx? (0 ~ " << player->renderList(pos).size() << "), given idx = " << idx;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user