1# Copyright (c) 2022-2022 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14IF (MSVC) 15 ADD_DEFINITIONS(-DMSVC_VMG_ENABLED /std:c++11) # /Z7) 16 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /vmg") 17ENDIF (MSVC) 18 19#IF(UNIX) 20#MESSAGE("UNIX") 21#ADD_DEFINITIONS( 22# -g -ggdb 23#) 24#ENDIF(UNIX) 25 26IF (UNIX AND NOT CYGWIN) 27 ADD_DEFINITIONS( 28 -fPIC -DPROFILE 29 ) 30 if (${OHOS_LITE}) 31 set(CMAKE_CXX_FLAGS "-g -ggdb3 -O0 -Wall -Wl,--disable-new-dtags") 32 else() 33 set(CMAKE_CXX_FLAGS "-g -ggdb3 -O0 -std=c++17 -Wall -Wl,--disable-new-dtags") 34 endif() 35 36ENDIF (UNIX AND NOT CYGWIN) 37 38ADD_DEFINITIONS( 39 -D__STDC_FORMAT_MACROS 40 -DHST_PLUGIN_PATH="./" 41) 42if (WIN32) 43add_definitions( -DHST_PLUGIN_FILE_TAIL=".dll" ) 44else() 45add_definitions( -DHST_PLUGIN_FILE_TAIL=".so" ) 46endif() 47 48IF (CMAKE_CL_64) 49 ADD_DEFINITIONS(-DWIN64) 50ENDIF (CMAKE_CL_64) 51 52###################################################### 53# include directories 54include_directories( 55 ${TOP_DIR}/engine 56 ${TOP_DIR}/engine/include 57 ${TOP_DIR}/engine/scene/player 58 ${TOP_DIR}/engine/scene/recorder 59 ${TOP_DIR}/engine/plugin 60) 61 62if (AVS3DA_ENABLE) 63 include_directories( 64 ${HISTREAMER_PLUGINS_DIR}/codec/avs3_audio_decoder/avs3_codec/libavs3_common 65 ${HISTREAMER_PLUGINS_DIR}/codec/avs3_audio_decoder/avs3_codec/avs3Decoder/include 66 ${HISTREAMER_PLUGINS_DIR}/codec/avs3_audio_decoder/avs3_render 67 ) 68endif () 69 70if (NOT ${OHOS_LITE}) 71 message(STATUS "media interface header included.") 72 include_directories( 73 ${TOP_DIR}/engine/scene/standard 74 ) 75endif () 76 77###################################################### 78 79file(GLOB_RECURSE HISTREAMER_BASE_SRCS 80 ${TOP_DIR}/engine/pipeline/*.cpp 81 ${TOP_DIR}/engine/plugin/common/*.cpp 82 ${TOP_DIR}/engine/plugin/convert/*.cpp 83 ${TOP_DIR}/engine/plugin/core/*.cpp 84 ${TOP_DIR}/engine/plugin/types/*.cpp 85 ${TOP_DIR}/engine/scene/player/internal/*.cpp 86 ${TOP_DIR}/engine/scene/recorder/internal/*.cpp 87 ${TOP_DIR}/engine/scene/common/*.cpp 88 ${TOP_DIR}/engine/foundation/*.cpp 89 ${TOP_DIR}/engine/foundation/utils/*.cpp 90 ) 91 92file(GLOB_RECURSE COMMON_PLUGIN_SRCS 93 ${TOP_DIR}/engine/plugin/plugins/codec_adapter/*.cpp 94 ${TOP_DIR}/engine/plugin/plugins/demuxer/wav_demuxer/*.cpp 95 ${TOP_DIR}/engine/plugin/plugins/demuxer/aac_demuxer/*.cpp 96 ${TOP_DIR}/engine/plugin/plugins/ffmpeg_adapter/*.cpp 97 ${TOP_DIR}/engine/plugin/plugins/sink/sdl/*.cpp 98 ${TOP_DIR}/engine/plugin/plugins/sink/file_sink/*.cpp 99 ${TOP_DIR}/engine/plugin/plugins/source/file_source/*.cpp 100 ${TOP_DIR}/engine/plugin/plugins/minimp3_adapter/*.cpp 101 ${TOP_DIR}/engine/plugin/plugins/minimp3_adapter/*.c 102 ${TOP_DIR}/engine/plugin/plugins/source/http_source/*.cpp 103 ${TOP_DIR}/engine/plugin/plugins/source/http_source_test/*.cpp 104 ${TOP_DIR}/engine/plugin/plugins/source/stream_source/*.cpp 105 ${TOP_DIR}/engine/plugin/plugins/source/std_stream_source/*.cpp 106) 107 108if (AVS3DA_ENABLE) 109 file(GLOB_RECURSE AVS3DA_PLUGIN_SRCS 110 ${HISTREAMER_PLUGINS_DIR}/codec/avs3_audio_decoder/avs3_codec/libavs3_common/*.c 111 ${HISTREAMER_PLUGINS_DIR}/codec/avs3_audio_decoder/avs3_codec/avs3Decoder/src/*.c 112 ${HISTREAMER_PLUGINS_DIR}/codec/avs3_audio_decoder/avs3_render/*.c 113 ${HISTREAMER_PLUGINS_DIR}/codec/avs3_audio_decoder/*.cpp 114 ) 115endif() 116 117if (OHOS_LITE) 118 message(STATUS "#1 player lite source") 119 file(GLOB_RECURSE PLAYER_SRCS 120 ${TOP_DIR}/engine/scene/lite/*.cpp 121 ${TOP_DIR}/engine/scene/player/lite/*.cpp 122 ) 123 message(STATUS "#1 recorder lite source") 124 file(GLOB_RECURSE RECORDER_SRCS 125 ${TOP_DIR}/engine/scene/lite/*.cpp 126 ${TOP_DIR}/engine/scene/recorder/lite/*.cpp 127 ) 128else () 129 message(STATUS "player standard source") 130 file(GLOB_RECURSE PLAYER_SRCS 131 ${TOP_DIR}/engine/scene/standard/*.cpp 132 ${TOP_DIR}/engine/scene/player/standard/*.cpp 133 ) 134 message(STATUS "recorder standard source") 135 file(GLOB_RECURSE RECORDER_SRCS 136 ${TOP_DIR}/engine/scene/standard/*.cpp 137 ${TOP_DIR}/engine/scene/recorder/standard/*.cpp 138 ) 139 file(GLOB_RECURSE PLAT_PLUGIN_SRCS 140 ${TOP_DIR}/engine/plugin/plugins/source/audio_capture/*.cpp 141 ${TOP_DIR}/engine/plugin/plugins/source/video_capture/*.cpp 142 ) 143endif () 144 145set(HISTREAMER_SRCS ${HISTREAMER_BASE_SRCS} ${PLAYER_SRCS} ${RECORDER_SRCS} ${COMMON_PLUGIN_SRCS} ${AVS3DA_PLUGIN_SRCS} ${PLAT_PLUGIN_SRCS}) 146 147file(GLOB_RECURSE PLUGINS_STATIC_BUILD_SRCS 148 ${TOP_DIR}/engine/plugin/plugins/source/file_source/*.cpp 149 ) 150 151INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/../include) 152 153link_directories( 154 ${ffmpeg_lib_path} 155 ${sdl_lib_path} 156 ${TOP_DIR}/../3rdparty/curl/lib/windows 157) 158 159if (WIN32) 160 link_libraries( 161 pthread 162 m 163 avcodec 164 avformat 165 avutil 166 avfilter 167 swresample 168 swscale 169 SDL2 170 curl 171 ) 172elseif (LINUX_DEMO) 173else () 174 link_libraries( 175 log 176 FFmpeg 177 SDL2 178 ) 179endif () 180 181set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin) 182set(CMAKE_SHARED_LIBRARY_PREFIX "libmedia_engine_") 183set(CMAKE_SHARED_LIBRARY_SUFFIX ".z.so") 184 185add_library(${PROJECT_NAME} SHARED ${HISTREAMER_SRCS} ${PLUGINS_STATIC_BUILD_SRCS} 186 ${3RDPARTY_SRCS}) 187