ffmpeg coco2d-x lua test

Posted yzfhkms-x

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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;
}

 

}

以上是关于ffmpeg coco2d-x lua test的主要内容,如果未能解决你的问题,请参考以下文章

coco2d-x怎样创建project

coco2d-x open console

coco2d-x convertToWorldSpace介绍

lua: 截取字符串/home/root/test/123:输出结果为123 ,怎么弄呢?

FFMPEG ffmpeg + cocos2d video test

FFmpeg Fate(FFmpeg automated test environment)自动化测试