Improve:build ffmpeg.
This commit is contained in:
parent
7e6b8d4605
commit
0a7bf55c3e
32
README.md
32
README.md
|
@ -9,11 +9,33 @@
|
||||||
* SDK工程所有开发文档均使用markdown语法编写,需要使用markdown语法解析器进行解析,方便阅读,如:Typora;开发工程师建议使用vscode安装markdownlint插件进行阅读;
|
* SDK工程所有开发文档均使用markdown语法编写,需要使用markdown语法解析器进行解析,方便阅读,如:Typora;开发工程师建议使用vscode安装markdownlint插件进行阅读;
|
||||||
* SDK工程所有文档描述路径时,"//"双斜杠表示工程根目录;
|
* SDK工程所有文档描述路径时,"//"双斜杠表示工程根目录;
|
||||||
|
|
||||||
## 1.2. 编译
|
## 1.2. 开发环境准备
|
||||||
|
|
||||||
|
  工程的开发,需要预安装一些开发工具。例如:cmake的特定版本,llvm工具等。
|
||||||
|
|
||||||
|
### 1.2.1. cmake安装
|
||||||
|
|
||||||
|
  cmake是一个跨平台的安装(编译)工具,它是由Kitware公司开发的一个开源软件,可以用来配置、构建、编译一个工程。
|
||||||
|
|
||||||
|
```code
|
||||||
|
# 项目根目录执行:
|
||||||
|
$ make install-cmake
|
||||||
|
```
|
||||||
|
|
||||||
|
### 1.2.2. llvm工具安装
|
||||||
|
|
||||||
|
  LLVM是一个编译器工具链,包含clang编译器、llvm核心库等。此处只用了clang-tidy和clang-format工具,一个负责编码规范,一个负责代码格式化。
|
||||||
|
|
||||||
|
```code
|
||||||
|
# 项目根目录执行:
|
||||||
|
$ make compile_llvm
|
||||||
|
```
|
||||||
|
|
||||||
|
## 1.3. 编译
|
||||||
|
|
||||||
  架构设计上支持去平台编译和运行,本仓库源码可仿真运行在ubuntu系统。
|
  架构设计上支持去平台编译和运行,本仓库源码可仿真运行在ubuntu系统。
|
||||||
|
|
||||||
### 1.2.1. Ubuntu系统
|
### 1.3.1. Ubuntu系统
|
||||||
|
|
||||||
在项目根目录下执行命令:
|
在项目根目录下执行命令:
|
||||||
|
|
||||||
|
@ -24,7 +46,7 @@ cd cmake-shell/ // 在中间文件目录进行编译,把所有中间文件
|
||||||
make // 编译全部输出构建文件
|
make // 编译全部输出构建文件
|
||||||
```
|
```
|
||||||
|
|
||||||
### 1.2.2. 交叉编译
|
### 1.3.2. 交叉编译
|
||||||
|
|
||||||
参考:
|
参考:
|
||||||
|
|
||||||
|
@ -37,9 +59,9 @@ make // 编译全部输出构建文件
|
||||||
|
|
||||||
  交叉编译请参考基于IPC SDK作为子仓库的工程配置,此处忽略。
|
  交叉编译请参考基于IPC SDK作为子仓库的工程配置,此处忽略。
|
||||||
|
|
||||||
### 1.2.3. 小技巧
|
### 1.3.3. 小技巧
|
||||||
|
|
||||||
#### 1.2.3.1. 代码阅读辅助工具(基于vscode)
|
#### 1.3.3.1. 代码阅读辅助工具(基于vscode)
|
||||||
|
|
||||||
  为了方便代码跳转阅读,除了安装基本的c++插件外,结合cmake构建工具生成的compile_commands.json文件可实现代码之间的精准跳转。
|
  为了方便代码跳转阅读,除了安装基本的c++插件外,结合cmake构建工具生成的compile_commands.json文件可实现代码之间的精准跳转。
|
||||||
|
|
||||||
|
|
2
external/ffmpeg/CMakeLists.txt
vendored
2
external/ffmpeg/CMakeLists.txt
vendored
|
@ -7,6 +7,7 @@ add_custom_target(
|
||||||
# COMMAND cp ${EXTERNAL_SOURCE_PATH}/goahead-5.2.0/modify/http.c ${EXTERNAL_SOURCE_PATH}/goahead-5.2.0/GoAhead/src
|
# COMMAND cp ${EXTERNAL_SOURCE_PATH}/goahead-5.2.0/modify/http.c ${EXTERNAL_SOURCE_PATH}/goahead-5.2.0/GoAhead/src
|
||||||
# COMMAND touch ${EXTERNAL_SOURCE_PATH}/goahead-5.2.0/GoAhead/src/http.c
|
# COMMAND touch ${EXTERNAL_SOURCE_PATH}/goahead-5.2.0/GoAhead/src/http.c
|
||||||
COMMAND test -f ${EXTERNAL_SOURCE_PATH}/ffmpeg/Makefile || tar -xf ffmpeg_6.1.1.orig.tar.xz
|
COMMAND test -f ${EXTERNAL_SOURCE_PATH}/ffmpeg/Makefile || tar -xf ffmpeg_6.1.1.orig.tar.xz
|
||||||
|
COMMAND chmod 777 -R ffmpeg-6.1.1
|
||||||
COMMAND cd ffmpeg-6.1.1 && ./configure --enable-cross-compile --target-os=linux --arch=arm64
|
COMMAND cd ffmpeg-6.1.1 && ./configure --enable-cross-compile --target-os=linux --arch=arm64
|
||||||
--cc=${CMAKE_C_COMPILER}
|
--cc=${CMAKE_C_COMPILER}
|
||||||
--cxx=${CMAKE_CXX_COMPILER}
|
--cxx=${CMAKE_CXX_COMPILER}
|
||||||
|
@ -27,6 +28,7 @@ add_custom_target(
|
||||||
--disable-outdevs --disable-ffprobe --disable-ffmpeg --disable-ffplay --disable-debug
|
--disable-outdevs --disable-ffprobe --disable-ffmpeg --disable-ffplay --disable-debug
|
||||||
COMMAND cd ffmpeg-6.1.1 && make
|
COMMAND cd ffmpeg-6.1.1 && make
|
||||||
COMMAND cd ffmpeg-6.1.1 && make install
|
COMMAND cd ffmpeg-6.1.1 && make install
|
||||||
|
COMMAND cd ffmpeg-6.1.1 && make clean
|
||||||
WORKING_DIRECTORY ${EXTERNAL_SOURCE_PATH}/ffmpeg/
|
WORKING_DIRECTORY ${EXTERNAL_SOURCE_PATH}/ffmpeg/
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
1
test/support_test/audio.g711a
Executable file
1
test/support_test/audio.g711a
Executable file
File diff suppressed because one or more lines are too long
BIN
test/support_test/video.h264
Executable file
BIN
test/support_test/video.h264
Executable file
Binary file not shown.
|
@ -12,7 +12,7 @@ add_subdirectory(McuProtocol)
|
||||||
add_subdirectory(ModBusCRC16)
|
add_subdirectory(ModBusCRC16)
|
||||||
add_subdirectory(LedControl)
|
add_subdirectory(LedControl)
|
||||||
add_subdirectory(KeyControl)
|
add_subdirectory(KeyControl)
|
||||||
add_subdirectory(MediaAdapter)
|
add_subdirectory(MediaBase)
|
||||||
add_subdirectory(FxHttpServer)
|
add_subdirectory(FxHttpServer)
|
||||||
add_subdirectory(Servers)
|
add_subdirectory(Servers)
|
||||||
add_subdirectory(TcpModule)
|
add_subdirectory(TcpModule)
|
||||||
|
|
|
@ -58,17 +58,15 @@ endif()
|
||||||
|
|
||||||
# build libconfig before make libConfigBase.a
|
# build libconfig before make libConfigBase.a
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
# OUTPUT ${EXTERNAL_SOURCE_PATH}/libconfig/libconfig-1.7.3/lib/.libs/libconfig.a
|
|
||||||
OUTPUT ${EXTERNAL_LIBS_OUTPUT_PATH}/libconfig.a
|
OUTPUT ${EXTERNAL_LIBS_OUTPUT_PATH}/libconfig.a
|
||||||
COMMAND echo "Build libconfig-1.7.3. COMPILE_HOST = ${COMPILE_HOST}"
|
COMMAND echo "Build libconfig-1.7.3. COMPILE_HOST = ${COMPILE_HOST}"
|
||||||
# COMMAND tar zxvf libconfig-1.7.3.tar.gz
|
|
||||||
COMMAND sh build_libconfig.sh ${TARGET_PLATFORM} ${COMPILE_HOST}
|
COMMAND sh build_libconfig.sh ${TARGET_PLATFORM} ${COMPILE_HOST}
|
||||||
COMMAND mv ${EXTERNAL_SOURCE_PATH}/libconfig/libconfig-1.7.3/lib/.libs/libconfig.a ${EXTERNAL_LIBS_OUTPUT_PATH}/libconfig.a
|
COMMAND mv ${EXTERNAL_SOURCE_PATH}/libconfig/libconfig-1.7.3/lib/.libs/libconfig.a ${EXTERNAL_LIBS_OUTPUT_PATH}/libconfig.a
|
||||||
|
COMMAND cd libconfig-1.7.3; make clean;
|
||||||
WORKING_DIRECTORY ${EXTERNAL_SOURCE_PATH}/libconfig/
|
WORKING_DIRECTORY ${EXTERNAL_SOURCE_PATH}/libconfig/
|
||||||
)
|
)
|
||||||
add_custom_target(
|
add_custom_target(
|
||||||
libconfig.a
|
libconfig.a
|
||||||
# DEPENDS ${EXTERNAL_SOURCE_PATH}/libconfig/libconfig-1.7.3/lib/.libs/libconfig.a
|
|
||||||
DEPENDS ${EXTERNAL_LIBS_OUTPUT_PATH}/libconfig.a
|
DEPENDS ${EXTERNAL_LIBS_OUTPUT_PATH}/libconfig.a
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,6 @@ include_directories(
|
||||||
# ${EXTERNAL_SOURCE_PATH}/libconfig/libconfig-1.7.3/lib/.libs
|
# ${EXTERNAL_SOURCE_PATH}/libconfig/libconfig-1.7.3/lib/.libs
|
||||||
# )
|
# )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
aux_source_directory(./src SRC_FILES)
|
aux_source_directory(./src SRC_FILES)
|
||||||
|
|
||||||
set(TARGET_NAME MediaAdapter)
|
set(TARGET_NAME MediaAdapter)
|
||||||
|
|
68
utils/MediaBase/CMakeLists.txt
Normal file
68
utils/MediaBase/CMakeLists.txt
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
include(${CMAKE_SOURCE_DIR_IPCSDK}/build/global_config.cmake)
|
||||||
|
set(EXECUTABLE_OUTPUT_PATH ${EXEC_OUTPUT_PATH})
|
||||||
|
set(LIBRARY_OUTPUT_PATH ${LIBS_OUTPUT_PATH})
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
./src
|
||||||
|
./include
|
||||||
|
# ${UTILS_SOURCE_PATH}/LinuxApi/include
|
||||||
|
${UTILS_SOURCE_PATH}/StatusCode/include
|
||||||
|
${UTILS_SOURCE_PATH}/ModBusCRC16/include
|
||||||
|
${UTILS_SOURCE_PATH}/Log/include
|
||||||
|
)
|
||||||
|
# link_directories(
|
||||||
|
# ${EXTERNAL_SOURCE_PATH}/libconfig/libconfig-1.7.3/lib/.libs
|
||||||
|
# )
|
||||||
|
|
||||||
|
aux_source_directory(./src SRC_FILES)
|
||||||
|
|
||||||
|
set(TARGET_NAME MediaBase)
|
||||||
|
add_library(${TARGET_NAME} STATIC ${SRC_FILES})
|
||||||
|
target_link_libraries(${TARGET_NAME} StatusCode Log)
|
||||||
|
|
||||||
|
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
|
||||||
|
add_custom_target(
|
||||||
|
MediaBase_code_check
|
||||||
|
COMMAND ${CLANG_TIDY_EXE}
|
||||||
|
-checks='${CLANG_TIDY_CHECKS}'
|
||||||
|
--header-filter=.*
|
||||||
|
--system-headers=false
|
||||||
|
${SRC_FILES}
|
||||||
|
${CLANG_TIDY_CONFIG}
|
||||||
|
-p ${PLATFORM_PATH}/cmake-shell
|
||||||
|
WORKING_DIRECTORY ${UTILS_SOURCE_PATH}/MediaBase
|
||||||
|
)
|
||||||
|
file(GLOB_RECURSE HEADER_FILES *.h)
|
||||||
|
add_custom_target(
|
||||||
|
MediaBase_code_format
|
||||||
|
COMMAND ${CLANG_FORMAT_EXE}
|
||||||
|
-style=file
|
||||||
|
-i ${SRC_FILES} ${HEADER_FILES}
|
||||||
|
WORKING_DIRECTORY ${UTILS_SOURCE_PATH}/MediaBase
|
||||||
|
)
|
||||||
|
add_custom_command(
|
||||||
|
TARGET ${TARGET_NAME}
|
||||||
|
PRE_BUILD
|
||||||
|
COMMAND make MediaBase_code_check
|
||||||
|
COMMAND make MediaBase_code_format
|
||||||
|
WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# build ffmpeg before make libMediaBase.a
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${EXTERNAL_LIBS_OUTPUT_PATH}/ffmpeg/lib/libavcodec.a
|
||||||
|
COMMAND echo "Did not found ffmpeg libs in output_files, now compile ffmpeg."
|
||||||
|
COMMAND make ffmpeg
|
||||||
|
WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/
|
||||||
|
)
|
||||||
|
add_custom_target(
|
||||||
|
compile_ffmpeg
|
||||||
|
DEPENDS ${EXTERNAL_LIBS_OUTPUT_PATH}/ffmpeg/lib/libavcodec.a
|
||||||
|
)
|
||||||
|
add_dependencies(${TARGET_NAME} compile_ffmpeg)
|
||||||
|
|
||||||
|
define_file_name(${TARGET_NAME})
|
||||||
|
|
||||||
|
file(GLOB_RECURSE INSTALL_HEADER_FILES include/*.h)
|
||||||
|
install(FILES ${INSTALL_HEADER_FILES} DESTINATION include)
|
31
utils/MediaBase/include/MediaBase.h
Normal file
31
utils/MediaBase/include/MediaBase.h
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023 Fancy Code.
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
#ifndef MEDIA_BASE_H
|
||||||
|
#define MEDIA_BASE_H
|
||||||
|
#include "StatusCode.h"
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
enum MediaHandleType
|
||||||
|
{
|
||||||
|
MEDIA_HANDLE_TYPE_READ_H264 = 0,
|
||||||
|
MEDIA_HANDLE_TYPE_END
|
||||||
|
};
|
||||||
|
void *ICreateMediaBase(const MediaHandleType type);
|
||||||
|
void IMediaBaseFree(void *object);
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
32
utils/MediaBase/src/IMediaBase.cpp
Normal file
32
utils/MediaBase/src/IMediaBase.cpp
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023 Fancy Code.
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
#include "IMediaBase.h"
|
||||||
|
#include "ILog.h"
|
||||||
|
#include <string.h>
|
||||||
|
static const char *MEDIA_BASE_NAME = "media_adapter";
|
||||||
|
const char inline *GetMediaBaseModuleName(void)
|
||||||
|
{
|
||||||
|
return MEDIA_BASE_NAME;
|
||||||
|
}
|
||||||
|
std::shared_ptr<IMediaBase> *NewIMediaBase(const MediaHandleType &type)
|
||||||
|
{
|
||||||
|
LogInfo("Create the midia base object.\n");
|
||||||
|
MeidaAdapter *impl = (MeidaAdapter *)malloc(sizeof(MeidaAdapter));
|
||||||
|
MeidaAdapter tmp;
|
||||||
|
memcpy((void *)impl, (void *)&tmp, sizeof(MeidaAdapter));
|
||||||
|
impl->mHeader.mCheckName = MEDIA_BASE_NAME;
|
||||||
|
impl->mIMediaBase = std::make_shared<IMediaBase>();
|
||||||
|
return (std::shared_ptr<IMediaBase> *)(((char *)impl) + sizeof(MediaBaseHeader));
|
||||||
|
}
|
36
utils/MediaBase/src/IMediaBase.h
Normal file
36
utils/MediaBase/src/IMediaBase.h
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023 Fancy Code.
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
#ifndef I_MEDIA_BASE_H
|
||||||
|
#define I_MEDIA_BASE_H
|
||||||
|
#include "MediaBase.h"
|
||||||
|
#include <memory>
|
||||||
|
class IMediaBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
IMediaBase() = default;
|
||||||
|
virtual ~IMediaBase() = default;
|
||||||
|
};
|
||||||
|
typedef struct media_base_header
|
||||||
|
{
|
||||||
|
const char *mCheckName;
|
||||||
|
} MediaBaseHeader;
|
||||||
|
typedef struct media_adapter
|
||||||
|
{
|
||||||
|
MediaBaseHeader mHeader;
|
||||||
|
std::shared_ptr<IMediaBase> mIMediaBase;
|
||||||
|
} MeidaAdapter;
|
||||||
|
const char *GetMediaBaseModuleName(void);
|
||||||
|
std::shared_ptr<IMediaBase> *NewIMediaBase(const MediaHandleType &type);
|
||||||
|
#endif
|
40
utils/MediaBase/src/MediaBase.cpp
Normal file
40
utils/MediaBase/src/MediaBase.cpp
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023 Fancy Code.
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
#include "MediaBase.h"
|
||||||
|
#include "ILog.h"
|
||||||
|
#include "IMediaBase.h"
|
||||||
|
void *ICreateMediaBase(const MediaHandleType type)
|
||||||
|
{
|
||||||
|
return NewIMediaBase(type);
|
||||||
|
}
|
||||||
|
static bool ObjectCheck(void *object)
|
||||||
|
{
|
||||||
|
if (nullptr == object) {
|
||||||
|
LogError("nullptr object!\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (*((const char **)(((char *)object) - sizeof(IMediaBase))) != GetMediaBaseModuleName()) {
|
||||||
|
LogError("Illegal object!\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void IMediaBaseFree(void *object)
|
||||||
|
{
|
||||||
|
if (ObjectCheck(object) == true) {
|
||||||
|
(*(std::shared_ptr<IMediaBase> *)object).reset();
|
||||||
|
free(((char *)object) - sizeof(MediaBaseHeader));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user