mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-10-30 08:17:36 +08:00
提供Android编译支持
This commit is contained in:
parent
72a6d2db61
commit
e165849c35
@ -94,12 +94,12 @@ add_compile_options(-Wno-deprecated-declarations)
|
||||
add_compile_options(-Wno-predefined-identifier-outside-function)
|
||||
|
||||
#编译动态库
|
||||
if(NOT IOS)
|
||||
if(NOT IOS AND NOT ANDROID)
|
||||
add_library(${CMAKE_PROJECT_NAME}_shared SHARED ${SRC_LIST})
|
||||
set_target_properties(${CMAKE_PROJECT_NAME}_shared PROPERTIES OUTPUT_NAME "${CMAKE_PROJECT_NAME}")
|
||||
install(TARGETS ${CMAKE_PROJECT_NAME}_shared LIBRARY DESTINATION lib)
|
||||
target_link_libraries(${CMAKE_PROJECT_NAME}_shared ${LINK_LIB_LIST})
|
||||
endif(NOT IOS)
|
||||
endif()
|
||||
|
||||
#编译静态库
|
||||
add_library(${CMAKE_PROJECT_NAME}_static STATIC ${SRC_LIST})
|
||||
|
14
build_for_android.sh
Executable file
14
build_for_android.sh
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
path=`pwd`
|
||||
wget https://raw.githubusercontent.com/xiongziliang/ZLToolKit/master/build_for_android.sh -O toolkit_build.sh
|
||||
sudo chmod +x ./toolkit_build.sh
|
||||
./toolkit_build.sh
|
||||
cd $path
|
||||
cd ..
|
||||
git clone --depth=50 https://github.com/xiongziliang/ZLMediaKit.git
|
||||
cd ZLMediaKit
|
||||
mkdir -p build
|
||||
cd build
|
||||
cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/android.toolchain.cmake -DANDROID_NDK=$ANDROID_NDK_ROOT -DCMAKE_BUILD_TYPE=Release -DANDROID_ABI="armeabi" -DANDROID_NATIVE_API_LEVEL=android-9
|
||||
make -j4
|
||||
sudo make install
|
96
cmake/AndroidNdkGdb.cmake
Executable file
96
cmake/AndroidNdkGdb.cmake
Executable file
@ -0,0 +1,96 @@
|
||||
# Copyright (c) 2014, Pavel Rojtberg
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from this
|
||||
# software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Usage:
|
||||
# 1. place AndroidNdkGdb.cmake somewhere inside ${CMAKE_MODULE_PATH}
|
||||
# 2. inside your project add
|
||||
#
|
||||
# include(AndroidNdkGdb)
|
||||
# android_ndk_gdb_enable()
|
||||
# # for each target
|
||||
# add_library(MyLibrary ...)
|
||||
# android_ndk_gdb_debuggable(MyLibrary)
|
||||
|
||||
|
||||
# add gdbserver and general gdb configuration to project
|
||||
# also create a mininal NDK skeleton so ndk-gdb finds the paths
|
||||
#
|
||||
# the optional parameter defines the path to the android project.
|
||||
# uses PROJECT_SOURCE_DIR by default.
|
||||
macro(android_ndk_gdb_enable)
|
||||
if(ANDROID)
|
||||
# create custom target that depends on the real target so it gets executed afterwards
|
||||
add_custom_target(NDK_GDB ALL)
|
||||
|
||||
if(${ARGC})
|
||||
set(ANDROID_PROJECT_DIR ${ARGV0})
|
||||
else()
|
||||
set(ANDROID_PROJECT_DIR ${PROJECT_SOURCE_DIR})
|
||||
endif()
|
||||
|
||||
set(NDK_GDB_SOLIB_PATH ${ANDROID_PROJECT_DIR}/obj/local/${ANDROID_NDK_ABI_NAME}/)
|
||||
file(MAKE_DIRECTORY ${NDK_GDB_SOLIB_PATH})
|
||||
|
||||
# 1. generate essential Android Makefiles
|
||||
file(MAKE_DIRECTORY ${ANDROID_PROJECT_DIR}/jni)
|
||||
if(NOT EXISTS ${ANDROID_PROJECT_DIR}/jni/Android.mk)
|
||||
file(WRITE ${ANDROID_PROJECT_DIR}/jni/Android.mk "APP_ABI := ${ANDROID_NDK_ABI_NAME}\n")
|
||||
endif()
|
||||
if(NOT EXISTS ${ANDROID_PROJECT_DIR}/jni/Application.mk)
|
||||
file(WRITE ${ANDROID_PROJECT_DIR}/jni/Application.mk "APP_ABI := ${ANDROID_NDK_ABI_NAME}\n")
|
||||
endif()
|
||||
|
||||
# 2. generate gdb.setup
|
||||
get_directory_property(PROJECT_INCLUDES DIRECTORY ${PROJECT_SOURCE_DIR} INCLUDE_DIRECTORIES)
|
||||
string(REGEX REPLACE ";" " " PROJECT_INCLUDES "${PROJECT_INCLUDES}")
|
||||
file(WRITE ${LIBRARY_OUTPUT_PATH}/gdb.setup "set solib-search-path ${NDK_GDB_SOLIB_PATH}\n")
|
||||
file(APPEND ${LIBRARY_OUTPUT_PATH}/gdb.setup "directory ${PROJECT_INCLUDES}\n")
|
||||
|
||||
# 3. copy gdbserver executable
|
||||
file(COPY ${ANDROID_NDK}/prebuilt/android-${ANDROID_ARCH_NAME}/gdbserver/gdbserver DESTINATION ${LIBRARY_OUTPUT_PATH})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# register a target for remote debugging
|
||||
# copies the debug version to NDK_GDB_SOLIB_PATH then strips symbols of original
|
||||
macro(android_ndk_gdb_debuggable TARGET_NAME)
|
||||
if(ANDROID)
|
||||
get_property(TARGET_LOCATION TARGET ${TARGET_NAME} PROPERTY LOCATION)
|
||||
|
||||
# create custom target that depends on the real target so it gets executed afterwards
|
||||
add_dependencies(NDK_GDB ${TARGET_NAME})
|
||||
|
||||
# 4. copy lib to obj
|
||||
add_custom_command(TARGET NDK_GDB POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${TARGET_LOCATION} ${NDK_GDB_SOLIB_PATH})
|
||||
|
||||
# 5. strip symbols
|
||||
add_custom_command(TARGET NDK_GDB POST_BUILD COMMAND ${CMAKE_STRIP} ${TARGET_LOCATION})
|
||||
endif()
|
||||
endmacro()
|
58
cmake/AndroidNdkModules.cmake
Executable file
58
cmake/AndroidNdkModules.cmake
Executable file
@ -0,0 +1,58 @@
|
||||
# Copyright (c) 2014, Pavel Rojtberg
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from this
|
||||
# software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
macro(android_ndk_import_module_cpufeatures)
|
||||
if(ANDROID)
|
||||
include_directories(${ANDROID_NDK}/sources/android/cpufeatures)
|
||||
add_library(cpufeatures ${ANDROID_NDK}/sources/android/cpufeatures/cpu-features.c)
|
||||
target_link_libraries(cpufeatures dl)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(android_ndk_import_module_native_app_glue)
|
||||
if(ANDROID)
|
||||
include_directories(${ANDROID_NDK}/sources/android/native_app_glue)
|
||||
add_library(native_app_glue ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c)
|
||||
target_link_libraries(native_app_glue log)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(android_ndk_import_module_ndk_helper)
|
||||
if(ANDROID)
|
||||
android_ndk_import_module_cpufeatures()
|
||||
android_ndk_import_module_native_app_glue()
|
||||
|
||||
include_directories(${ANDROID_NDK}/sources/android/ndk_helper)
|
||||
file(GLOB _NDK_HELPER_SRCS ${ANDROID_NDK}/sources/android/ndk_helper/*.cpp ${ANDROID_NDK}/sources/android/ndk_helper/gl3stub.c)
|
||||
add_library(ndk_helper ${_NDK_HELPER_SRCS})
|
||||
target_link_libraries(ndk_helper log android EGL GLESv2 cpufeatures native_app_glue)
|
||||
|
||||
unset(_NDK_HELPER_SRCS)
|
||||
endif()
|
||||
endmacro()
|
1693
cmake/android.toolchain.cmake
Executable file
1693
cmake/android.toolchain.cmake
Executable file
File diff suppressed because it is too large
Load Diff
BIN
src/.DS_Store
vendored
BIN
src/.DS_Store
vendored
Binary file not shown.
@ -3,6 +3,10 @@
|
||||
#include "Util/onceToken.h"
|
||||
#include "Network/sockutil.h"
|
||||
|
||||
#ifndef UINT64_MAX
|
||||
#define UINT64_MAX 0xFFFFFFFFFFFFFFFF
|
||||
#endif//UINT64_MAX
|
||||
|
||||
using namespace ZL::Network;
|
||||
|
||||
namespace Config {
|
||||
|
@ -13,9 +13,11 @@
|
||||
#include <string>
|
||||
#include "h264_poc.h"
|
||||
#include "h264_parser.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#ifndef INT32_MAX
|
||||
#define INT32_MAX 0x7FFFFFFF
|
||||
#endif//INT32_MAX
|
||||
|
||||
class H264Parser{
|
||||
public:
|
||||
|
@ -36,7 +36,13 @@ STRING(REGEX REPLACE ".cpp" "" TEST_EXE_NAME ${TEST_SRC})
|
||||
STRING(REGEX REPLACE "./" "" TEST_EXE_NAME ${TEST_EXE_NAME})
|
||||
message(STATUS "add test program:${TEST_EXE_NAME}")
|
||||
add_executable(${TEST_EXE_NAME} ${TEST_SRC})
|
||||
|
||||
if(ANDROID)
|
||||
target_link_libraries(${TEST_EXE_NAME} ${CMAKE_PROJECT_NAME}_static ${LINK_LIB_LIST})
|
||||
else(ANDROID)
|
||||
target_link_libraries(${TEST_EXE_NAME} ${CMAKE_PROJECT_NAME}_shared ${LINK_LIB_LIST} pthread)
|
||||
endif(ANDROID)
|
||||
|
||||
endforeach(TEST_SRC ${TEST_SRC_LIST})
|
||||
|
||||
|
||||
|
@ -62,7 +62,7 @@ int main(int argc,char *argv[]){
|
||||
//http://127.0.0.1/record/live/0/2017-04-11/11-09-38.mp4
|
||||
//rtsp://127.0.0.1/record/live/0/2017-04-11/11-09-38.mp4
|
||||
//rtmp://127.0.0.1/record/live/0/2017-04-11/11-09-38.mp4
|
||||
PlayerProxy::Ptr player(new PlayerProxy("live",std::to_string(i++).data()));
|
||||
PlayerProxy::Ptr player(new PlayerProxy("live",to_string(i++).data()));
|
||||
player->play(url);
|
||||
proxyMap.emplace(string(url),player);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user