1. 程式人生 > >webrtc 原始碼中如何新新增一個類

webrtc 原始碼中如何新新增一個類

webrtc 原始碼中如何新新增一個類

webrtc 原始碼使用gn做構建指令碼,使用.ninja作為編譯指令碼,gn就類似於cmakelist.txt,而.ninja就類似於makefile,webrtc中的BUILD.gn就是構建指令碼gn檔案,構建的時候會通過BUILD.gn檔案生成工程檔案(例如vs工程檔案)和.ninja檔案。
下面舉個例子:
本人在實現windows版的檔案插播和桌面共享是需要修改webrtc原始碼,下面是修改gn檔案,路徑是webrtc/src/media/BUILD.gn, 內容如下:

sources = [
    "engine/adm_helpers.cc"
, "engine/adm_helpers.h", "engine/apm_helpers.cc", "engine/apm_helpers.h", "engine/nullwebrtcvideoengine.h", "engine/payload_type_mapper.cc", "engine/payload_type_mapper.h", "engine/simulcast.cc", "engine/simulcast.h", "engine/webrtcmediaengine.cc", "engine/webrtcmediaengine.h"
, "engine/webrtcvideocapturer.cc", "engine/webrtcvideocapturer.h", "../custom_video_capturer/capture_module_interface.h", "../custom_video_capturer/custom_video_capture.h", "../custom_video_capturer/custom_video_capture.cc", "../custom_video_capturer/video_capture.h", "../custom_video_capturer/video_capture.cc"
, "engine/webrtcvideocapturerfactory.cc", "engine/webrtcvideocapturerfactory.h", "engine/webrtcvideodecoderfactory.cc", "engine/webrtcvideodecoderfactory.h", "engine/webrtcvideoencoderfactory.cc", "engine/webrtcvideoencoderfactory.h", "engine/webrtcvideoengine.cc", "engine/webrtcvideoengine.h", "engine/webrtcvoiceengine.cc", "engine/webrtcvoiceengine.h", ]

將自己的類加上之後,重新 gn gen out/Default –args=“target_os=\”win\” target_cpu=\”x86\” is_debug=false” –ide=vs2017 構建完成後,編譯就可以了。