zoukankan      html  css  js  c++  java
  • 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;
    }

    }

  • 相关阅读:
    C++ UI资源
    值得学习的C/C++开源框架(转)
    NT AUTHORITYIUSR登录失败解决方法
    C#改变LInqToSQL的引用地址,读取config的数据库字符串
    C#引用类库时出现黄色三角加感叹号的处理
    无法嵌入互操作类型“Microsoft.Office.Interop.Word.ApplicationClass”。请改用适用的接口。
    C#在线预览文档(word,excel,pdf,txt,png)
    WCF上传大文件处理方法
    C#一般处理程序 ashx.cs使用Session报错问题
    网页弹出框ClientScript,ScriptManager
  • 原文地址:https://www.cnblogs.com/YZFHKMS-X/p/13252103.html
Copyright © 2011-2022 走看看