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
152        ${CMAKE_CURRENT_SOURCE_DIR}/../include
153        ${HISTREAMER_BASE_SRCS} ${PLAYER_SRCS} ${RECORDER_SRCS} ${COMMON_PLUGIN_SRCS} ${AVS3DA_PLUGIN_SRCS} ${PLAT_PLUGIN_SRCS} ../../3rdparty/ohos/utils/native/base/include/
154)
155
156link_directories(
157        ${ffmpeg_lib_path}
158        ${sdl_lib_path}
159        ${TOP_DIR}/../3rdparty/curl/lib/windows
160)
161
162if (WIN32)
163    link_libraries(
164            pthread
165            m
166            avcodec
167            avformat
168            avutil
169            avfilter
170            swresample
171            swscale
172            SDL2
173            curl
174    )
175elseif (LINUX_DEMO)
176else ()
177    link_libraries(
178            log
179            FFmpeg
180            SDL2
181    )
182endif ()
183
184set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
185set(CMAKE_SHARED_LIBRARY_PREFIX "libmedia_engine_")
186set(CMAKE_SHARED_LIBRARY_SUFFIX ".z.so")
187
188add_library(${PROJECT_NAME} SHARED ${HISTREAMER_SRCS} ${PLUGINS_STATIC_BUILD_SRCS}
189        ${3RDPARTY_SRCS})
190