winlin

fix the export project bug. wakeup connection when dispose server.

@@ -80,7 +80,7 @@ function build_module_hpp() @@ -80,7 +80,7 @@ function build_module_hpp()
80 } 80 }
81 SRS_LIBRTMP_OBJS="${CORE_OBJS[@]}" && build_module_hpp 81 SRS_LIBRTMP_OBJS="${CORE_OBJS[@]}" && build_module_hpp
82 SRS_LIBRTMP_OBJS="${KERNEL_OBJS[@]}" && build_module_hpp 82 SRS_LIBRTMP_OBJS="${KERNEL_OBJS[@]}" && build_module_hpp
83 -SRS_LIBRTMP_OBJS="${RTMP_OBJS[@]}" && build_module_hpp 83 +SRS_LIBRTMP_OBJS="${PROTOCOL_OBJS[@]}" && build_module_hpp
84 SRS_LIBRTMP_OBJS="${LIBS_OBJS[@]}" && build_module_hpp 84 SRS_LIBRTMP_OBJS="${LIBS_OBJS[@]}" && build_module_hpp
85 # module to cpp files. 85 # module to cpp files.
86 function build_module_cpp() 86 function build_module_cpp()
@@ -99,7 +99,7 @@ function build_module_cpp() @@ -99,7 +99,7 @@ function build_module_cpp()
99 } 99 }
100 SRS_LIBRTMP_OBJS="${CORE_OBJS[@]}" && build_module_cpp 100 SRS_LIBRTMP_OBJS="${CORE_OBJS[@]}" && build_module_cpp
101 SRS_LIBRTMP_OBJS="${KERNEL_OBJS[@]}" && build_module_cpp 101 SRS_LIBRTMP_OBJS="${KERNEL_OBJS[@]}" && build_module_cpp
102 -SRS_LIBRTMP_OBJS="${RTMP_OBJS[@]}" && build_module_cpp 102 +SRS_LIBRTMP_OBJS="${PROTOCOL_OBJS[@]}" && build_module_cpp
103 SRS_LIBRTMP_OBJS="${LIBS_OBJS[@]}" && build_module_cpp 103 SRS_LIBRTMP_OBJS="${LIBS_OBJS[@]}" && build_module_cpp
104 104
105 # create example.cpp 105 # create example.cpp
@@ -88,6 +88,7 @@ SrsRtmpConn::SrsRtmpConn(SrsServer* svr, st_netfd_t c) @@ -88,6 +88,7 @@ SrsRtmpConn::SrsRtmpConn(SrsServer* svr, st_netfd_t c)
88 duration = 0; 88 duration = 0;
89 kbps = new SrsKbps(); 89 kbps = new SrsKbps();
90 kbps->set_io(skt, skt); 90 kbps->set_io(skt, skt);
  91 + wakable = NULL;
91 92
92 mw_sleep = SRS_PERF_MW_SLEEP; 93 mw_sleep = SRS_PERF_MW_SLEEP;
93 mw_enabled = false; 94 mw_enabled = false;
@@ -110,6 +111,16 @@ SrsRtmpConn::~SrsRtmpConn() @@ -110,6 +111,16 @@ SrsRtmpConn::~SrsRtmpConn()
110 srs_freep(kbps); 111 srs_freep(kbps);
111 } 112 }
112 113
  114 +void SrsRtmpConn::dispose()
  115 +{
  116 + SrsConnection::dispose();
  117 +
  118 + // wakeup the handler which need to notice.
  119 + if (wakable) {
  120 + wakable->wakeup();
  121 + }
  122 +}
  123 +
113 // TODO: return detail message when error for client. 124 // TODO: return detail message when error for client.
114 int SrsRtmpConn::do_cycle() 125 int SrsRtmpConn::do_cycle()
115 { 126 {
@@ -597,7 +608,9 @@ int SrsRtmpConn::playing(SrsSource* source) @@ -597,7 +608,9 @@ int SrsRtmpConn::playing(SrsSource* source)
597 } 608 }
598 609
599 // delivery messages for clients playing stream. 610 // delivery messages for clients playing stream.
  611 + wakable = consumer;
600 ret = do_playing(source, consumer, &trd); 612 ret = do_playing(source, consumer, &trd);
  613 + wakable = NULL;
601 614
602 // stop isolate recv thread 615 // stop isolate recv thread
603 trd.stop(); 616 trd.stop();
@@ -53,6 +53,7 @@ class SrsSharedPtrMessage; @@ -53,6 +53,7 @@ class SrsSharedPtrMessage;
53 class SrsQueueRecvThread; 53 class SrsQueueRecvThread;
54 class SrsPublishRecvThread; 54 class SrsPublishRecvThread;
55 class SrsSecurity; 55 class SrsSecurity;
  56 +class ISrsWakable;
56 57
57 /** 58 /**
58 * the client provides the main logic control for RTMP clients. 59 * the client provides the main logic control for RTMP clients.
@@ -70,6 +71,8 @@ private: @@ -70,6 +71,8 @@ private:
70 SrsRefer* refer; 71 SrsRefer* refer;
71 SrsBandwidth* bandwidth; 72 SrsBandwidth* bandwidth;
72 SrsSecurity* security; 73 SrsSecurity* security;
  74 + // the wakable handler, maybe NULL.
  75 + ISrsWakable* wakable;
73 // elapse duration in ms 76 // elapse duration in ms
74 // for live play duration, for instance, rtmpdump to record. 77 // for live play duration, for instance, rtmpdump to record.
75 // @see https://github.com/simple-rtmp-server/srs/issues/47 78 // @see https://github.com/simple-rtmp-server/srs/issues/47
@@ -85,6 +88,8 @@ private: @@ -85,6 +88,8 @@ private:
85 public: 88 public:
86 SrsRtmpConn(SrsServer* svr, st_netfd_t c); 89 SrsRtmpConn(SrsServer* svr, st_netfd_t c);
87 virtual ~SrsRtmpConn(); 90 virtual ~SrsRtmpConn();
  91 +public:
  92 + virtual void dispose();
88 protected: 93 protected:
89 virtual int do_cycle(); 94 virtual int do_cycle();
90 // interface ISrsReloadHandler 95 // interface ISrsReloadHandler
@@ -423,6 +423,14 @@ void SrsMessageQueue::clear() @@ -423,6 +423,14 @@ void SrsMessageQueue::clear()
423 av_start_time = av_end_time = -1; 423 av_start_time = av_end_time = -1;
424 } 424 }
425 425
  426 +ISrsWakable::ISrsWakable()
  427 +{
  428 +}
  429 +
  430 +ISrsWakable::~ISrsWakable()
  431 +{
  432 +}
  433 +
426 SrsConsumer::SrsConsumer(SrsSource* _source) 434 SrsConsumer::SrsConsumer(SrsSource* _source)
427 { 435 {
428 source = _source; 436 source = _source;
@@ -551,14 +559,6 @@ void SrsConsumer::wait(int nb_msgs, int duration) @@ -551,14 +559,6 @@ void SrsConsumer::wait(int nb_msgs, int duration)
551 // use cond block wait for high performance mode. 559 // use cond block wait for high performance mode.
552 st_cond_wait(mw_wait); 560 st_cond_wait(mw_wait);
553 } 561 }
554 -  
555 -void SrsConsumer::wakeup()  
556 -{  
557 - if (mw_waiting) {  
558 - st_cond_signal(mw_wait);  
559 - mw_waiting = false;  
560 - }  
561 -}  
562 #endif 562 #endif
563 563
564 int SrsConsumer::on_play_client_pause(bool is_pause) 564 int SrsConsumer::on_play_client_pause(bool is_pause)
@@ -571,6 +571,16 @@ int SrsConsumer::on_play_client_pause(bool is_pause) @@ -571,6 +571,16 @@ int SrsConsumer::on_play_client_pause(bool is_pause)
571 return ret; 571 return ret;
572 } 572 }
573 573
  574 +void SrsConsumer::wakeup()
  575 +{
  576 +#ifdef SRS_PERF_QUEUE_COND_WAIT
  577 + if (mw_waiting) {
  578 + st_cond_signal(mw_wait);
  579 + mw_waiting = false;
  580 + }
  581 +#endif
  582 +}
  583 +
574 SrsGopCache::SrsGopCache() 584 SrsGopCache::SrsGopCache()
575 { 585 {
576 cached_video_count = 0; 586 cached_video_count = 0;
@@ -197,9 +197,27 @@ private: @@ -197,9 +197,27 @@ private:
197 }; 197 };
198 198
199 /** 199 /**
  200 + * the wakable used for some object
  201 + * which is waiting on cond.
  202 + */
  203 +class ISrsWakable
  204 +{
  205 +public:
  206 + ISrsWakable();
  207 + virtual ~ISrsWakable();
  208 +public:
  209 + /**
  210 + * when the consumer(for player) got msg from recv thread,
  211 + * it must be processed for maybe it's a close msg, so the cond
  212 + * wait must be wakeup.
  213 + */
  214 + virtual void wakeup() = 0;
  215 +};
  216 +
  217 +/**
200 * the consumer for SrsSource, that is a play client. 218 * the consumer for SrsSource, that is a play client.
201 */ 219 */
202 -class SrsConsumer 220 +class SrsConsumer : public ISrsWakable
203 { 221 {
204 private: 222 private:
205 SrsRtmpJitter* jitter; 223 SrsRtmpJitter* jitter;
@@ -257,17 +275,19 @@ public: @@ -257,17 +275,19 @@ public:
257 * @param duration the messgae duration to wait. 275 * @param duration the messgae duration to wait.
258 */ 276 */
259 virtual void wait(int nb_msgs, int duration); 277 virtual void wait(int nb_msgs, int duration);
260 - /**  
261 - * when the consumer(for player) got msg from recv thread,  
262 - * it must be processed for maybe it's a close msg, so the cond  
263 - * wait must be wakeup.  
264 - */  
265 - virtual void wakeup();  
266 #endif 278 #endif
267 /** 279 /**
268 * when client send the pause message. 280 * when client send the pause message.
269 */ 281 */
270 virtual int on_play_client_pause(bool is_pause); 282 virtual int on_play_client_pause(bool is_pause);
  283 +// ISrsWakable
  284 +public:
  285 + /**
  286 + * when the consumer(for player) got msg from recv thread,
  287 + * it must be processed for maybe it's a close msg, so the cond
  288 + * wait must be wakeup.
  289 + */
  290 + virtual void wakeup();
271 }; 291 };
272 292
273 /** 293 /**