winlin

fix #87: add source id for full trackable log. 0.9.120

@@ -228,8 +228,9 @@ Supported operating systems and hardware: @@ -228,8 +228,9 @@ Supported operating systems and hardware:
228 * 2013-10-17, Created.<br/> 228 * 2013-10-17, Created.<br/>
229 229
230 ## History 230 ## History
231 -* v1.0, 2014-05-25, fix [#84](https://github.com/winlinvip/simple-rtmp-server/issues/84), unpublish when edge disconnect. 0.9.119  
232 -* v1.0, 2014-05-25, fix [#89](https://github.com/winlinvip/simple-rtmp-server/issues/89), config to /dev/null to disable ffmpeg log. 0.9.117 231 +* v1.0, 2014-05-27, fix [#87](https://github.com/winlinvip/simple-rtmp-server/issues/87), add source id for full trackable log. 0.9.120
  232 +* v1.0, 2014-05-27, fix [#84](https://github.com/winlinvip/simple-rtmp-server/issues/84), unpublish when edge disconnect. 0.9.119
  233 +* v1.0, 2014-05-27, fix [#89](https://github.com/winlinvip/simple-rtmp-server/issues/89), config to /dev/null to disable ffmpeg log. 0.9.117
233 * v1.0, 2014-05-25, fix [#76](https://github.com/winlinvip/simple-rtmp-server/issues/76), allow edge vhost to add or remove. 0.9.114 234 * v1.0, 2014-05-25, fix [#76](https://github.com/winlinvip/simple-rtmp-server/issues/76), allow edge vhost to add or remove. 0.9.114
234 * v1.0, 2014-05-24, Johnny contribute [ossrs.net](http://ossrs.net). karthikeyan start to translate wiki to English. 235 * v1.0, 2014-05-24, Johnny contribute [ossrs.net](http://ossrs.net). karthikeyan start to translate wiki to English.
235 * v1.0, 2014-05-22, fix [#78](https://github.com/winlinvip/simple-rtmp-server/issues/78), st joinable thread must be stop by other threads, 0.9.113 236 * v1.0, 2014-05-22, fix [#78](https://github.com/winlinvip/simple-rtmp-server/issues/78), st joinable thread must be stop by other threads, 0.9.113
@@ -571,7 +571,7 @@ int SrsRtmpConn::fmle_publish(SrsSource* source) @@ -571,7 +571,7 @@ int SrsRtmpConn::fmle_publish(SrsSource* source)
571 bool vhost_is_edge = _srs_config->get_vhost_is_edge(req->vhost); 571 bool vhost_is_edge = _srs_config->get_vhost_is_edge(req->vhost);
572 572
573 // when edge, ignore the publish event, directly proxy it. 573 // when edge, ignore the publish event, directly proxy it.
574 - if (vhost_is_edge) { 574 + if (!vhost_is_edge) {
575 // notify the hls to prepare when publish start. 575 // notify the hls to prepare when publish start.
576 if ((ret = source->on_publish()) != ERROR_SUCCESS) { 576 if ((ret = source->on_publish()) != ERROR_SUCCESS) {
577 srs_error("fmle hls on_publish failed. ret=%d", ret); 577 srs_error("fmle hls on_publish failed. ret=%d", ret);
@@ -650,7 +650,7 @@ int SrsRtmpConn::flash_publish(SrsSource* source) @@ -650,7 +650,7 @@ int SrsRtmpConn::flash_publish(SrsSource* source)
650 bool vhost_is_edge = _srs_config->get_vhost_is_edge(req->vhost); 650 bool vhost_is_edge = _srs_config->get_vhost_is_edge(req->vhost);
651 651
652 // when edge, ignore the publish event, directly proxy it. 652 // when edge, ignore the publish event, directly proxy it.
653 - if (vhost_is_edge) { 653 + if (!vhost_is_edge) {
654 // notify the hls to prepare when publish start. 654 // notify the hls to prepare when publish start.
655 if ((ret = source->on_publish()) != ERROR_SUCCESS) { 655 if ((ret = source->on_publish()) != ERROR_SUCCESS) {
656 srs_error("flash hls on_publish failed. ret=%d", ret); 656 srs_error("flash hls on_publish failed. ret=%d", ret);
@@ -176,7 +176,7 @@ int SrsListener::cycle() @@ -176,7 +176,7 @@ int SrsListener::cycle()
176 176
177 if(client_stfd == NULL){ 177 if(client_stfd == NULL){
178 // ignore error. 178 // ignore error.
179 - srs_warn("ignore accept thread stoppped for accept client error"); 179 + srs_error("ignore accept thread stoppped for accept client error");
180 return ret; 180 return ret;
181 } 181 }
182 srs_verbose("get a client. fd=%d", st_netfd_fileno(client_stfd)); 182 srs_verbose("get a client. fd=%d", st_netfd_fileno(client_stfd));
@@ -248,6 +248,7 @@ SrsConsumer::SrsConsumer(SrsSource* _source) @@ -248,6 +248,7 @@ SrsConsumer::SrsConsumer(SrsSource* _source)
248 paused = false; 248 paused = false;
249 jitter = new SrsRtmpJitter(); 249 jitter = new SrsRtmpJitter();
250 queue = new SrsMessageQueue(); 250 queue = new SrsMessageQueue();
  251 + should_update_source_id = false;
251 } 252 }
252 253
253 SrsConsumer::~SrsConsumer() 254 SrsConsumer::~SrsConsumer()
@@ -262,6 +263,11 @@ void SrsConsumer::set_queue_size(double queue_size) @@ -262,6 +263,11 @@ void SrsConsumer::set_queue_size(double queue_size)
262 queue->set_queue_size(queue_size); 263 queue->set_queue_size(queue_size);
263 } 264 }
264 265
  266 +void SrsConsumer::update_source_id()
  267 +{
  268 + should_update_source_id = true;
  269 +}
  270 +
265 int SrsConsumer::get_time() 271 int SrsConsumer::get_time()
266 { 272 {
267 return jitter->get_time(); 273 return jitter->get_time();
@@ -287,6 +293,11 @@ int SrsConsumer::enqueue(SrsSharedPtrMessage* msg, int tba, int tbv) @@ -287,6 +293,11 @@ int SrsConsumer::enqueue(SrsSharedPtrMessage* msg, int tba, int tbv)
287 293
288 int SrsConsumer::get_packets(int max_count, SrsSharedPtrMessage**& pmsgs, int& count) 294 int SrsConsumer::get_packets(int max_count, SrsSharedPtrMessage**& pmsgs, int& count)
289 { 295 {
  296 + if (should_update_source_id) {
  297 + srs_trace("update source_id=%d", source->source_id());
  298 + should_update_source_id = false;
  299 + }
  300 +
290 // paused, return nothing. 301 // paused, return nothing.
291 if (paused) { 302 if (paused) {
292 return ERROR_SUCCESS; 303 return ERROR_SUCCESS;
@@ -802,6 +813,13 @@ int SrsSource::on_source_id_changed(int id) @@ -802,6 +813,13 @@ int SrsSource::on_source_id_changed(int id)
802 813
803 _source_id = id; 814 _source_id = id;
804 815
  816 + // notice all consumer
  817 + std::vector<SrsConsumer*>::iterator it;
  818 + for (it = consumers.begin(); it != consumers.end(); ++it) {
  819 + SrsConsumer* consumer = *it;
  820 + consumer->update_source_id();
  821 + }
  822 +
805 return ret; 823 return ret;
806 } 824 }
807 825
@@ -134,11 +134,20 @@ private: @@ -134,11 +134,20 @@ private:
134 SrsSource* source; 134 SrsSource* source;
135 SrsMessageQueue* queue; 135 SrsMessageQueue* queue;
136 bool paused; 136 bool paused;
  137 + // when source id changed, notice all consumers
  138 + bool should_update_source_id;
137 public: 139 public:
138 SrsConsumer(SrsSource* _source); 140 SrsConsumer(SrsSource* _source);
139 virtual ~SrsConsumer(); 141 virtual ~SrsConsumer();
140 public: 142 public:
  143 + /**
  144 + * set the size of queue.
  145 + */
141 virtual void set_queue_size(double queue_size); 146 virtual void set_queue_size(double queue_size);
  147 + /**
  148 + * when source id changed, notice client to print.
  149 + */
  150 + virtual void update_source_id();
142 public: 151 public:
143 /** 152 /**
144 * get current client time, the last packet time. 153 * get current client time, the last packet time.
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 // current release version 31 // current release version
32 #define VERSION_MAJOR "0" 32 #define VERSION_MAJOR "0"
33 #define VERSION_MINOR "9" 33 #define VERSION_MINOR "9"
34 -#define VERSION_REVISION "119" 34 +#define VERSION_REVISION "120"
35 #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION 35 #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
36 // server info. 36 // server info.
37 #define RTMP_SIG_SRS_KEY "SRS" 37 #define RTMP_SIG_SRS_KEY "SRS"