winlin

refine code

@@ -43,10 +43,13 @@ SrsThreadContext::~SrsThreadContext() @@ -43,10 +43,13 @@ SrsThreadContext::~SrsThreadContext()
43 { 43 {
44 } 44 }
45 45
46 -void SrsThreadContext::generate_id() 46 +int SrsThreadContext::generate_id()
47 { 47 {
48 static int id = 100; 48 static int id = 100;
49 - cache[st_thread_self()] = id++; 49 +
  50 + int gid = id++;
  51 + cache[st_thread_self()] = gid;
  52 + return gid;
50 } 53 }
51 54
52 int SrsThreadContext::get_id() 55 int SrsThreadContext::get_id()
@@ -51,7 +51,7 @@ public: @@ -51,7 +51,7 @@ public:
51 SrsThreadContext(); 51 SrsThreadContext();
52 virtual ~SrsThreadContext(); 52 virtual ~SrsThreadContext();
53 public: 53 public:
54 - virtual void generate_id(); 54 + virtual int generate_id();
55 virtual int get_id(); 55 virtual int get_id();
56 }; 56 };
57 57
@@ -607,7 +607,7 @@ int SrsServer::initialize_st() @@ -607,7 +607,7 @@ int SrsServer::initialize_st()
607 int ret = ERROR_SUCCESS; 607 int ret = ERROR_SUCCESS;
608 608
609 // init st 609 // init st
610 - if ((ret = srs_init_st()) != ERROR_SUCCESS) { 610 + if ((ret = srs_st_init()) != ERROR_SUCCESS) {
611 srs_error("init st failed. ret=%d", ret); 611 srs_error("init st failed. ret=%d", ret);
612 return ret; 612 return ret;
613 } 613 }
@@ -42,7 +42,7 @@ bool srs_st_epoll_is_supported(void) @@ -42,7 +42,7 @@ bool srs_st_epoll_is_supported(void)
42 } 42 }
43 #endif 43 #endif
44 44
45 -int srs_init_st() 45 +int srs_st_init()
46 { 46 {
47 int ret = ERROR_SUCCESS; 47 int ret = ERROR_SUCCESS;
48 48
@@ -33,7 +33,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -33,7 +33,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 #include <st.h> 33 #include <st.h>
34 34
35 // initialize st, requires epoll. 35 // initialize st, requires epoll.
36 -extern int srs_init_st(); 36 +extern int srs_st_init();
37 37
38 // close the netfd, and close the underlayer fd. 38 // close the netfd, and close the underlayer fd.
39 extern void srs_close_stfd(st_netfd_t& stfd); 39 extern void srs_close_stfd(st_netfd_t& stfd);
@@ -66,8 +66,9 @@ ISrsThreadContext::~ISrsThreadContext() @@ -66,8 +66,9 @@ ISrsThreadContext::~ISrsThreadContext()
66 { 66 {
67 } 67 }
68 68
69 -void ISrsThreadContext::generate_id() 69 +int ISrsThreadContext::generate_id()
70 { 70 {
  71 + return 0;
71 } 72 }
72 73
73 int ISrsThreadContext::get_id() 74 int ISrsThreadContext::get_id()
@@ -102,7 +102,7 @@ public: @@ -102,7 +102,7 @@ public:
102 ISrsThreadContext(); 102 ISrsThreadContext();
103 virtual ~ISrsThreadContext(); 103 virtual ~ISrsThreadContext();
104 public: 104 public:
105 - virtual void generate_id(); 105 + virtual int generate_id();
106 virtual int get_id(); 106 virtual int get_id();
107 }; 107 };
108 108
@@ -1378,7 +1378,7 @@ int proxy_hls2rtmp(string hls, string rtmp) @@ -1378,7 +1378,7 @@ int proxy_hls2rtmp(string hls, string rtmp)
1378 int ret = ERROR_SUCCESS; 1378 int ret = ERROR_SUCCESS;
1379 1379
1380 // init st. 1380 // init st.
1381 - if ((ret = srs_init_st()) != ERROR_SUCCESS) { 1381 + if ((ret = srs_st_init()) != ERROR_SUCCESS) {
1382 srs_error("init st failed. ret=%d", ret); 1382 srs_error("init st failed. ret=%d", ret);
1383 return ret; 1383 return ret;
1384 } 1384 }