Skip to content

Commit

Permalink
Merge pull request #5 from mariotaku/lgncopenapi
Browse files Browse the repository at this point in the history
added lgncopenapi
  • Loading branch information
sundermann authored Jun 19, 2023
2 parents 4d2ccd6 + af5466f commit 011bc31
Show file tree
Hide file tree
Showing 12 changed files with 747 additions and 1 deletion.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ add_library(pf-1.0 SHARED src/dummy.c)
set_target_properties(pf-1.0 PROPERTIES VERSION 1.0.0 SOVERSION 1)
target_link_options(pf-1.0 PRIVATE ${CMAKE_SOURCE_DIR}/src/pf-1.0.lds)

install(TARGETS EGL GLESv1_CM GLESv2 NDL_directmedia playerAPIs wayland-egl AcbAPI helpers pf-1.0 DESTINATION lib)
add_library(lgncopenapi SHARED src/dummy.c)
set_target_properties(lgncopenapi PROPERTIES VERSION 2.4.0 SOVERSION 2)
target_link_options(lgncopenapi PRIVATE ${CMAKE_SOURCE_DIR}/src/lgncopenapi.lds)

install(TARGETS EGL GLESv1_CM GLESv2 NDL_directmedia playerAPIs wayland-egl AcbAPI helpers pf-1.0 lgncopenapi DESTINATION lib)

install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/
DESTINATION include
Expand Down
14 changes: 14 additions & 0 deletions include/lgncopenapi/lgnc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* @ingroup lgncopenapi
* @file lgnc.h
* @brief Includes all LG NetCast API headers
*/
#pragma once

#include "lgnc_system.h"
#include "lgnc_plugin.h"
#include "lgnc_egl.h"
#include "lgnc_dl.h"
#include "lgnc_gamepad.h"
#include "lgnc_directvideo.h"
#include "lgnc_directvideo.h"
91 changes: 91 additions & 0 deletions include/lgncopenapi/lgnc_directaudio.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

enum LGNC_ADEC_FMT_T
{
LGNC_ADEC_FMT_UNKNOWN = 0,
LGNC_ADEC_FMT_PCM = 1,
LGNC_ADEC_FMT_AC3 = 2,
LGNC_ADEC_FMT_AAC = 5,
LGNC_ADEC_FMT_MP3 = 8,
LGNC_ADEC_FMT_NONE = 10
};

typedef enum LGNC_ADEC_FMT_T LGNC_ADEC_FMT_T;

enum LGNC_ADEC_CH_INDEX_T
{
LGNC_ADEC_CH_INDEX_MAIN = 0,
LGNC_ADEC_CH_INDEX_BUF0 = 1
};

typedef enum LGNC_ADEC_CH_INDEX_T LGNC_ADEC_CH_INDEX_T;

enum LGNC_ADEC_SAMPLING_FREQ_T
{
LGNC_ADEC_SAMPLING_FREQ_4_KHZ = 4,
LGNC_ADEC_SAMPLING_FREQ_8_KHZ = 8,
LGNC_ADEC_SAMPLING_FREQ_11_025KHZ = 11,
LGNC_ADEC_SAMPLING_FREQ_12_KHZ = 12,
LGNC_ADEC_SAMPLING_FREQ_16_KHZ = 16,
LGNC_ADEC_SAMPLING_FREQ_22_05KHZ = 22,
LGNC_ADEC_SAMPLING_FREQ_24_KHZ = 24,
LGNC_ADEC_SAMPLING_FREQ_32_KHZ = 32,
LGNC_ADEC_SAMPLING_FREQ_44_1KHZ = 44,
LGNC_ADEC_SAMPLING_FREQ_48_KHZ = 48,
LGNC_ADEC_SAMPLING_FREQ_NONE = 0,
};

typedef enum LGNC_ADEC_SAMPLING_FREQ_T LGNC_ADEC_SAMPLING_FREQ_T;

static inline LGNC_ADEC_SAMPLING_FREQ_T LGNC_ADEC_SAMPLING_FREQ_OF(int hertz)
{
switch (hertz)
{
case 4000:
return LGNC_ADEC_SAMPLING_FREQ_4_KHZ;
case 8000:
return LGNC_ADEC_SAMPLING_FREQ_8_KHZ;
case 11025:
return LGNC_ADEC_SAMPLING_FREQ_11_025KHZ;
case 12000:
return LGNC_ADEC_SAMPLING_FREQ_12_KHZ;
case 16000:
return LGNC_ADEC_SAMPLING_FREQ_16_KHZ;
case 22050:
return LGNC_ADEC_SAMPLING_FREQ_22_05KHZ;
case 24000:
return LGNC_ADEC_SAMPLING_FREQ_24_KHZ;
case 32000:
return LGNC_ADEC_SAMPLING_FREQ_32_KHZ;
case 44100:
return LGNC_ADEC_SAMPLING_FREQ_44_1KHZ;
case 48000:
return LGNC_ADEC_SAMPLING_FREQ_48_KHZ;
default:
return LGNC_ADEC_SAMPLING_FREQ_NONE;
}
}

struct LGNC_ADEC_DATA_INFO_T
{
LGNC_ADEC_FMT_T codec;
LGNC_ADEC_CH_INDEX_T AChannel;
LGNC_ADEC_SAMPLING_FREQ_T samplingFreq;
unsigned int numberOfChannel;
unsigned int bitPerSample;
};

typedef struct LGNC_ADEC_DATA_INFO_T LGNC_ADEC_DATA_INFO_T;

int LGNC_DIRECTAUDIO_CheckBuffer(int *length);
int LGNC_DIRECTAUDIO_Close();
int LGNC_DIRECTAUDIO_Open(LGNC_ADEC_DATA_INFO_T *info);
int LGNC_DIRECTAUDIO_Play(const void *data, unsigned int size);

#ifdef __cplusplus
}
#endif
65 changes: 65 additions & 0 deletions include/lgncopenapi/lgnc_directvideo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

enum LGNC_VDEC_FMT_T
{
LGNC_VDEC_FMT_MAX = 10,
LGNC_VDEC_FMT_H264 = 2
};

enum LGNC_VDEC_3D_TYPE_T
{
LGNC_VDEC_3D_TYPE_LR_HALF = 2,
LGNC_VDEC_3D_TYPE_NONE = 0,
LGNC_VDEC_3D_TYPE_TB_HALF = 3,
LGNC_VDEC_3D_TYPE_2DTO3D = 1,
LGNC_VDEC_3D_TYPE_MAX = 4
};

typedef enum LGNC_VDEC_3D_TYPE_T LGNC_VDEC_3D_TYPE_T;

typedef struct LGNC_VDEC_DATA_INFO LGNC_VDEC_DATA_INFO_T;

typedef enum LGNC_VDEC_FMT_T LGNC_VDEC_FMT_T;

struct LGNC_VDEC_DATA_INFO
{
int width;
int height;
LGNC_VDEC_FMT_T vdecFmt;
LGNC_VDEC_3D_TYPE_T trid_type;
};

typedef struct LGNC_VDEC_DATA_INFO LGNC_VDEC_DATA_INFO_T;

int LGNC_DIRECTVIDEO_Close();

int LGNC_DIRECTVIDEO_Open(const LGNC_VDEC_DATA_INFO_T *info);

int LGNC_DIRECTVIDEO_Play(const void *data, unsigned int size);

/**
* @param x X position of the video
* @param y Y position of the video
* @param w Width of the video
* @param h Height of the video
* @return 0 If succeeded
*/
int _LGNC_DIRECTVIDEO_SetDisplayWindow(int x, int y, int w, int h);

/**
* @param x X position of the video
* @param y Y position of the video
* @param w Width of the video
* @param h Height of the video
* @return 0 If succeeded
* @since webOS 1.4.0
*/
int _LGNC_DIRECTVIDEO_SetCustomDisplayWindow(int x, int y, int w, int h);

#ifdef __cplusplus
}
#endif
15 changes: 15 additions & 0 deletions include/lgncopenapi/lgnc_dl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

int LGNC_DL_Initialize();

int LGNC_DL_IsInitialized();

void LGNC_DL_Finalize();

#ifdef __cplusplus
}
#endif
31 changes: 31 additions & 0 deletions include/lgncopenapi/lgnc_egl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#include <EGL/egl.h>

EGLDisplay LGNC_eglGetDisplay();
EGLBoolean LGNC_eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor);
EGLBoolean LGNC_eglTerminate(EGLDisplay dpy);

EGLBoolean LGNC_eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config);
EGLBoolean LGNC_eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
EGLBoolean LGNC_eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value);

EGLSurface LGNC_eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list);
EGLBoolean LGNC_eglDestroySurface(EGLDisplay dpy, EGLSurface surface);

/* EGL 1.1 swap control API */
EGLBoolean LGNC_eglSwapInterval(EGLDisplay dpy, EGLint interval);

EGLContext LGNC_eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint *attrib_list);
EGLBoolean LGNC_eglDestroyContext(EGLDisplay dpy, EGLContext ctx);
EGLBoolean LGNC_eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);

EGLBoolean LGNC_eglSwapBuffers(EGLDisplay dpy, EGLSurface draw);

#ifdef __cplusplus
}
#endif
24 changes: 24 additions & 0 deletions include/lgncopenapi/lgnc_gamepad.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once
#include "lgnc_system.h"

#ifdef __cplusplus
extern "C" {
#endif

struct LGNC_GAMEPAD_INFO_T
{
int id;
int type;
};

typedef struct LGNC_GAMEPAD_INFO_T LGNC_GAMEPAD_INFO;

typedef void(GamePadEventCallback)(LGNC_ADDITIONAL_INPUT_INFO_T *e);
typedef void(GamePadHotPlugCallback)(LGNC_GAMEPAD_INFO *gamepad, int count);

int LGNC_GAMEPAD_RegisterCallback(GamePadEventCallback *, GamePadHotPlugCallback *);
int LGNC_GAMEPAD_UnregisterCallback();

#ifdef __cplusplus
}
#endif
86 changes: 86 additions & 0 deletions include/lgncopenapi/lgnc_openapi_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#include <linux/input.h>

typedef enum LGNC_STATUS_T {
LGNC_OK = 0,
LGNC_HANDLED = 0,
LGNC_NOT_HANDLED = -1,
LGNC_ERROR = -1,
LGNC_BLOCKED = -2,
LGNC_INVALID_PARAMS = -3,
LGNC_NOT_ENOUGH_MEMORY = -4,
LGNC_TIMEOUT = -5,
LGNC_NOT_SUPPORTED = -6,
LGNC_BUFFER_FULL = -7,
LGNC_HOST_NOT_CONNECTED = -8,
LGNC_VERSION_MISMATCH = -9,
LGNC_ALREADY_REGISTERED = -10,
LGNC_LAST = -10,
LGNC_NOT_INITIALIZED = -11,
} LGNC_STATUS_T;

typedef enum LGNC_MSG_TYPE_T {
LGNC_MSG_NONE = 0,
LGNC_MSG_FOCUS_IN = 1,
LGNC_MSG_FOCUS_OUT = 2,
LGNC_MSG_TERMINATE = 3,
LGNC_MSG_HOST_EVENT = 4,
LGNC_MSG_PAUSE = 5,
LGNC_MSG_RESUME = 6,
LGNC_MSG_LAST = -1
} LGNC_MSG_TYPE_T;

typedef enum LGNC_KEY_COND_T {
LGNC_KEY_PRESS = 0,
LGNC_KEY_RELEASE = 1,
LGNC_KEY_REPEAT = 2,
LGNC_KEY_DRAG = 3,
LGNC_KEY_POWER = 4,
LGNC_KEY_GESTURE = 5,
LGNC_KEY_COND_LAST = 6,
} LGNC_KEY_COND_T;

typedef enum LGNC_INPUT_DEV_TYPE_T {
LGNC_INPUT_TYPE_NONE = 0,
LGNC_INPUT_TYPE_KEYBOARD = 1,
LGNC_INPUT_TYPE_MOUSE = 2,
LGNC_INPUT_TYPE_JOYSTICK = 4,
LGNC_INPUT_TYPE_REMOTE = 8,
LGNC_INPUT_TYPE_VIRTUAL = 16,
LGNC_INPUT_TYPE_KEY_RETURN = 32,
LGNC_INPUT_TYPE_CURSOR_RETURN = 64,
LGNC_INPUT_LGE = 128,
LGNC_INPUT_TYPE_NLP = 1024,
LGNC_INPUT_TYPE_SMARTREMOTE = 2048,
LGNC_INPUT_TYPE_XPAD = 4096,
LGNC_INPUT_TYPE_HIDPAD = 8192,
LGNC_INPUT_TYPE_WIDI = 16384,
LGNC_INPUT_TYPE_PS3 = 32768,
LGNC_INPUT_TYPE_ALL = 65023,
} LGNC_INPUT_DEV_TYPE_T;

typedef struct LGNC_ADDITIONAL_INPUT_INFO_T {
struct input_event event;
int deviceID;
LGNC_INPUT_DEV_TYPE_T deviceType;
} LGNC_ADDITIONAL_INPUT_INFO_T;

typedef struct LGNC_CALLBACKS_T {
LGNC_STATUS_T (*msgHandler)(LGNC_MSG_TYPE_T msg, unsigned int submsg, char *pData, unsigned short dataSize);

unsigned int (*keyEventCallback)(unsigned int key, LGNC_KEY_COND_T keyCond, LGNC_ADDITIONAL_INPUT_INFO_T *keyInput);

unsigned int (*mouseEventCallback)(int posX, int posY, unsigned int key, LGNC_KEY_COND_T keyCond,
LGNC_ADDITIONAL_INPUT_INFO_T *keyInput);

void (*joystickEventCallback)(LGNC_ADDITIONAL_INPUT_INFO_T *e);
} LGNC_CALLBACKS_T;

#ifdef __cplusplus
}
#endif
36 changes: 36 additions & 0 deletions include/lgncopenapi/lgnc_plugin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* @ingroup lgncopenapi
* @file lgnc_plugin.h
* @brief APIs for plugin-typed application
*/
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#include "lgnc_openapi_types.h"

/**
* @brief Initializes as plugin
* @param callbacks Event callbacks, must not be NULL.
* @return 0 if succeeded
*/
int LGNC_PLUGIN_Initialize(LGNC_CALLBACKS_T *callbacks);

/**
* @brief Set application ID
*
* Must be called AFTER LGNC_PLUGIN_Initialize.
*
* @param appId Application ID, e.g. "com.example.application"
* @return 0 if succeeded
*
*/
int LGNC_PLUGIN_SetAppId(const char *appId);

int LGNC_PLUGIN_Finalize();

#ifdef __cplusplus
}
#endif
Loading

0 comments on commit 011bc31

Please sign in to comment.