srs_xcode工程调试

1》左边是可运行的,右是是原工程,把st-1.9 utest research文件夹删除引用

srs_xcode工程调试_第1张图片
image

2》先执行./configure --osx && make

编译出libhttp_parser.a libssl.a libcrypto.a,不知道为什么libst.a没编译出来

自己下载 git clone https://github.com/ossrs/state-threads.git; make darwin-optimized

编译出来的libst.a 映射到工程里去,如图

srs_xcode工程调试_第2张图片
image

3》#include报错找不到

srs_xcode工程调试_第3张图片
image

4》变量重命名


diff --git a/trunk/src/main/srs_main_ingest_hls.cpp b/trunk/src/main/srs_main_ingest_hls.cpp

index 3321e29c..0fae5f25 100644

--- a/trunk/src/main/srs_main_ingest_hls.cpp

+++ b/trunk/src/main/srs_main_ingest_hls.cpp

@@ -55,18 +55,18 @@ int proxy_hls2rtmp(std::string hls, std::string rtmp);

 // never subscribe handler in constructor,

 // instead, subscribe handler in initialize method.

 // kernel module.

-ISrsLog* _srs_log = new SrsFastLog();

-ISrsThreadContext* _srs_context = new ISrsThreadContext();

+ISrsLog* m_srs_log = new SrsFastLog();

+ISrsThreadContext* m_srs_context = new ISrsThreadContext();

 // app module.

-SrsConfig* _srs_config = NULL;

-SrsServer* _srs_server = NULL;

+SrsConfig* m_srs_config = NULL;

+SrsServer* m_srs_server = NULL;

 #if defined(SRS_AUTO_HTTP_CORE)

 /**

 * main entrance.

 */

-int main(int argc, char** argv) 

+int m_main(int argc, char** argv)

 {

     // TODO: support both little and big endian.

     srs_assert(srs_is_little_endian());

@@ -83,7 +83,7 @@ int main(int argc, char** argv)

     exit(-1);

 #endif

-    srs_trace("srs_ingest_hls base on %s, to ingest hls live to srs", RTMP_SIG_SRS_SERVER);

+  srs_trace("srs_ingest_hls base on %s, to ingest hls live to srs", RTMP_SIG_SRS_SERVER);

     // parse user options.

     std::string in_hls_url, out_rtmp_url;

@@ -1301,7 +1301,7 @@ int SrsIngestSrsOutput::connect_app(string ep_server, string ep_port)

     data->set("srs_authors", SrsAmf0Any::str(RTMP_SIG_SRS_AUTHROS));

     // for edge to directly get the id of client.

     data->set("srs_pid", SrsAmf0Any::number(getpid()));

-    data->set("srs_id", SrsAmf0Any::number(_srs_context->get_id()));

+    data->set("srs_id", SrsAmf0Any::number(m_srs_context->get_id()));

     // local ip of edge

     std::vector ips = srs_get_local_ipv4_ips();

@@ -1412,7 +1412,7 @@ int proxy_hls2rtmp(string hls, string rtmp)

 #else

-int main(int argc, char** argv)

+int m_main(int argc, char** argv)

 {

 #ifndef SRS_AUTO_HTTP_CORE

     srs_error("ingest requires http-api or http-server");

5》给运行程序传参数,点srs_xcode->edit scheme


srs_xcode工程调试_第4张图片
F5F67369-E9ED-4016-83E5-36E573DF26C2.png

6》daemon off 要加上

diff --git a/trunk/conf/srs.conf b/trunk/conf/srs.conf
index da062849..c47fd11b 100644
--- a/trunk/conf/srs.conf
+++ b/trunk/conf/srs.conf
@@ -3,8 +3,8 @@
 
 listen              1935;
 max_connections     1000;
-srs_log_tank        file;
-srs_log_file        ./objs/srs.log;
+srs_log_tank        console;
+srs_log_file        /Users/wzw200/Downloads/srs/trunk/objs/srs.log;
 http_api {
     enabled         on;
     listen          1985;
@@ -20,3 +20,6 @@ stats {
 }
 vhost __defaultVhost__ {
 }
+
+pid                 /Users/wzw200/Downloads/srs/trunk/objs/srs.pid;
+daemon              off;

7>运行程序,然后执行命令
ffmpeg -framerate 30 -video_size 1280:720 -pixel_format yuyv422 -f avfoundation -i "0:0" -acodec aac -ar 48000 -b:a 96K -strict -2 -vcodec h264 -g 20 -r 20 -b:v 800k -s 1280:720 -f flv rtmp://127.0.0.1/live/livestream

ffplay rtmp://127.0.0.1/live/livestream

你可能感兴趣的:(srs_xcode工程调试)