winlin

extract method to process publish message

@@ -352,6 +352,19 @@ int SrsClient::publish(SrsSource* source, bool is_fmle) @@ -352,6 +352,19 @@ int SrsClient::publish(SrsSource* source, bool is_fmle)
352 (int)(srs_get_system_time_ms()/1000), pithy_print.get_age(), rtmp->get_send_bytes(), rtmp->get_recv_bytes(), rtmp->get_send_kbps(), rtmp->get_recv_kbps()); 352 (int)(srs_get_system_time_ms()/1000), pithy_print.get_age(), rtmp->get_send_bytes(), rtmp->get_recv_bytes(), rtmp->get_send_kbps(), rtmp->get_recv_kbps());
353 } 353 }
354 354
  355 + if ((ret = process_publish_message(source, hls, msg, is_fmle)) != ERROR_SUCCESS) {
  356 + srs_error("process publish message failed. ret=%d", ret);
  357 + return ret;
  358 + }
  359 + }
  360 +
  361 + return ret;
  362 +}
  363 +
  364 +int SrsClient::process_publish_message(SrsSource* source, SrsHLS* hls, SrsCommonMessage* msg, bool is_fmle)
  365 +{
  366 + int ret = ERROR_SUCCESS;
  367 +
355 // process audio packet 368 // process audio packet
356 if (msg->header.is_audio() && ((ret = source->on_audio(msg)) != ERROR_SUCCESS)) { 369 if (msg->header.is_audio() && ((ret = source->on_audio(msg)) != ERROR_SUCCESS)) {
357 srs_error("process audio message failed. ret=%d", ret); 370 srs_error("process audio message failed. ret=%d", ret);
@@ -378,11 +391,11 @@ int SrsClient::publish(SrsSource* source, bool is_fmle) @@ -378,11 +391,11 @@ int SrsClient::publish(SrsSource* source, bool is_fmle)
378 return ret; 391 return ret;
379 } 392 }
380 srs_trace("process onMetaData message success."); 393 srs_trace("process onMetaData message success.");
381 - continue; 394 + return ret;
382 } 395 }
383 396
384 srs_trace("ignore AMF0/AMF3 data message."); 397 srs_trace("ignore AMF0/AMF3 data message.");
385 - continue; 398 + return ret;
386 } 399 }
387 400
388 // process UnPublish event. 401 // process UnPublish event.
@@ -405,8 +418,7 @@ int SrsClient::publish(SrsSource* source, bool is_fmle) @@ -405,8 +418,7 @@ int SrsClient::publish(SrsSource* source, bool is_fmle)
405 } 418 }
406 419
407 srs_trace("ignore AMF0/AMF3 command message."); 420 srs_trace("ignore AMF0/AMF3 command message.");
408 - continue;  
409 - } 421 + return ret;
410 } 422 }
411 423
412 return ret; 424 return ret;
@@ -39,6 +39,7 @@ class SrsSource; @@ -39,6 +39,7 @@ class SrsSource;
39 class SrsRefer; 39 class SrsRefer;
40 class SrsConsumer; 40 class SrsConsumer;
41 class SrsCommonMessage; 41 class SrsCommonMessage;
  42 +class SrsHLS;
42 43
43 /** 44 /**
44 * the client provides the main logic control for RTMP clients. 45 * the client provides the main logic control for RTMP clients.
@@ -60,6 +61,7 @@ private: @@ -60,6 +61,7 @@ private:
60 virtual int check_vhost(); 61 virtual int check_vhost();
61 virtual int playing(SrsSource* source); 62 virtual int playing(SrsSource* source);
62 virtual int publish(SrsSource* source, bool is_fmle); 63 virtual int publish(SrsSource* source, bool is_fmle);
  64 + virtual int process_publish_message(SrsSource* source, SrsHLS* hls, SrsCommonMessage* msg, bool is_fmle);
63 virtual int get_peer_ip(); 65 virtual int get_peer_ip();
64 virtual int process_play_control_msg(SrsConsumer* consumer, SrsCommonMessage* msg); 66 virtual int process_play_control_msg(SrsConsumer* consumer, SrsCommonMessage* msg);
65 }; 67 };