• ffmpeg coco2d-x lua test


    .h

    {

    #ifndef __LUA_YFFMPEG_H__
    #define __LUA_YFFMPEG_H__
    #ifdef __cplusplus
    extern "C" {
    #endif
    #include "tolua++.h"
    #ifdef __cplusplus
    }
    #endif
    
    
    TOLUA_API  int lua_yffmpeg(lua_State* L);
    #endif

    }

    .cpp

    {

    #include "lua_yffmpeg.h"
    #include "yffmpeg.h"
    #include "scripting/lua-bindings/manual/LuaBasicConversions.h"
    #include "scripting/lua-bindings/manual/CCLuaEngine.h"
    
    
    
    int lua_yffmpeg_init(lua_State *tolua_S)
    {
        int argc = 0;
        bool ok = true;
    
    #if COCOS2D_DEBUG >= 1
        tolua_Error tolua_err;
    #endif
    
    #if COCOS2D_DEBUG >= 1
        if (!tolua_isusertable(tolua_S, 1, "Solution.yffmpeg", 0, &tolua_err)) goto tolua_lerror;
    #endif
    
        argc = lua_gettop(tolua_S) - 1;
    
        if (argc == 0)
        {
            yffmpeg *ret = new (std::nothrow) yffmpeg();
            if (ret != nullptr)
            {
                ret->setup();
            }
            object_to_luaval<yffmpeg>(tolua_S, "Solution.yffmpeg", (yffmpeg*)ret);
            return 1;
        }
        luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d
     ", "Solution.yffmpeg:init", argc, 0);
        return 0;
    #if COCOS2D_DEBUG >= 1
        tolua_lerror:
                    tolua_error(tolua_S, "#ferror in function 'lua_yffmpeg_init'.", &tolua_err);
    #endif
                    return 0;
    }
    int lua_yffmpeg_getconfigure(lua_State *tolua_S)
    {
        int argc = 0;
        yffmpeg* cobj = nullptr;
        bool ok = true;
    
    #if COCOS2D_DEBUG >= 1
        tolua_Error tolua_err;
    #endif
    
    
    #if COCOS2D_DEBUG >= 1
        if (!tolua_isusertype(tolua_S, 1, "Solution.yffmpeg", 0, &tolua_err)) goto tolua_lerror;
    #endif
    
        cobj = (yffmpeg*)tolua_tousertype(tolua_S, 1, 0);
    
    #if COCOS2D_DEBUG >= 1
        if (!cobj)
        {
            tolua_error(tolua_S, "invalid 'cobj' in function 'lua_yffmpeg_getconfigure'", nullptr);
            return 0;
        }
    #endif
    
        argc = lua_gettop(tolua_S) - 1;
    
        if (argc == 0)
        {
            if (cobj != nullptr)
            {
                auto ret = avdevice_configuration();
    
                lua_pushlstring(tolua_S, ret, strlen(ret));
                log("[C++PRINTF] push string to lua lv ffmpeg info
    ");
                return 1;
            }
            return 0;
        }
        luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d 
    ", "Solution.yffmpeg:getconfigure", argc, 0);
        return 0;
    
    #if COCOS2D_DEBUG >= 1
        tolua_lerror:
                    tolua_error(tolua_S, "#ferror in function 'lua_yffmpeg_getconfigure'.", &tolua_err);
    #endif
    
                    return 0;
    }
    
    
    int lua_register_yffmpeg(lua_State *tolua_S)
    {
        tolua_usertype(tolua_S, "Solution.yffmpeg");
        tolua_cclass(tolua_S, "yffmpeg", "Solution.yffmpeg", "", nullptr);
    
        tolua_beginmodule(tolua_S, "yffmpeg");
            tolua_function(tolua_S, "init", lua_yffmpeg_init);
            tolua_function(tolua_S, "getconfigure", lua_yffmpeg_getconfigure);
        tolua_endmodule(tolua_S);
        std::string typeName = typeid(yffmpeg).name();
        g_luaType[typeName] = "Solution.yffmpeg";
        g_typeCast["yffmpeg"] = "Solution.yffmpeg";
        return 1;
    }
    
    int register_yffmpeg(lua_State *tolua_S)
    {
        tolua_open(tolua_S);
    
        tolua_module(tolua_S, "Solution", 0);
        tolua_beginmodule(tolua_S, "Solution");
    
        lua_register_yffmpeg(tolua_S);
    
        tolua_endmodule(tolua_S);
        return 1;
    }
    
    
    
    int lua_yffmpeg(lua_State* L)
    {
        lua_getglobal(L, "_G");
        if (lua_istable(L, -1))
        {
            register_yffmpeg(L);
            if (L)
            {
                lua_pushstring(L, "Solution.yffmpeg");
                lua_rawget(L, LUA_REGISTRYINDEX);
                lua_pop(L, 1);
            }
        }
        lua_pop(L, 1);
        return 0;
    }

    }

  • 相关阅读:
    程序员离职躲山洞,2 年敲出 45 万行代码。网友:硅谷精神
    别再自己瞎写工具类了,Spring Boot 内置工具类应有尽有。。。
    使用秘钥登录Linux
    使用cosmos sdk开发公链
    reactnative基本知识点(4/4)
    企业在转型(数字化、变革)中的几个关键点
    yarn: 无法加载文件 C:UsersAdminAppDataRoaming pmyarn.ps1,因为在此系统因为在此系统上禁止运行脚本。
    关于储能技术的几点分析
    MQTT接收字符串(1/2)
    reactnative必备工具(3/4)
  • 原文地址:https://www.cnblogs.com/YZFHKMS-X/p/13252103.html
Copyright © 2020-2023  润新知