|
|
@ -151,7 +151,6 @@ int SrsClient::do_cycle()
|
|
|
|
// find a source to publish.
|
|
|
|
// find a source to publish.
|
|
|
|
SrsSource* source = SrsSource::find(req->get_stream_url());
|
|
|
|
SrsSource* source = SrsSource::find(req->get_stream_url());
|
|
|
|
srs_assert(source != NULL);
|
|
|
|
srs_assert(source != NULL);
|
|
|
|
SrsHLS* hls = source->get_hls();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool enabled_cache = true;
|
|
|
|
bool enabled_cache = true;
|
|
|
|
conf = config->get_gop_cache(req->vhost);
|
|
|
|
conf = config->get_gop_cache(req->vhost);
|
|
|
@ -182,7 +181,6 @@ int SrsClient::do_cycle()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
srs_info("start to publish stream %s success", req->stream.c_str());
|
|
|
|
srs_info("start to publish stream %s success", req->stream.c_str());
|
|
|
|
ret = publish(source, true);
|
|
|
|
ret = publish(source, true);
|
|
|
|
hls->on_unpublish();
|
|
|
|
|
|
|
|
source->on_unpublish();
|
|
|
|
source->on_unpublish();
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -195,7 +193,6 @@ int SrsClient::do_cycle()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
srs_info("flash start to publish stream %s success", req->stream.c_str());
|
|
|
|
srs_info("flash start to publish stream %s success", req->stream.c_str());
|
|
|
|
ret = publish(source, false);
|
|
|
|
ret = publish(source, false);
|
|
|
|
hls->on_unpublish();
|
|
|
|
|
|
|
|
source->on_unpublish();
|
|
|
|
source->on_unpublish();
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -333,10 +330,9 @@ int SrsClient::publish(SrsSource* source, bool is_fmle)
|
|
|
|
srs_verbose("check publish_refer success.");
|
|
|
|
srs_verbose("check publish_refer success.");
|
|
|
|
|
|
|
|
|
|
|
|
SrsPithyPrint pithy_print(SRS_STAGE_PUBLISH_USER);
|
|
|
|
SrsPithyPrint pithy_print(SRS_STAGE_PUBLISH_USER);
|
|
|
|
SrsHLS* hls = source->get_hls();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// notify the hls to prepare when publish start.
|
|
|
|
// notify the hls to prepare when publish start.
|
|
|
|
if ((ret = hls->on_publish(req->vhost)) != ERROR_SUCCESS) {
|
|
|
|
if ((ret = source->on_publish(req->vhost)) != ERROR_SUCCESS) {
|
|
|
|
srs_error("hls on_publish failed. ret=%d", ret);
|
|
|
|
srs_error("hls on_publish failed. ret=%d", ret);
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -362,7 +358,7 @@ int SrsClient::publish(SrsSource* source, bool is_fmle)
|
|
|
|
(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());
|
|
|
|
(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());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ((ret = process_publish_message(source, hls, msg, is_fmle)) != ERROR_SUCCESS) {
|
|
|
|
if ((ret = process_publish_message(source, msg, is_fmle)) != ERROR_SUCCESS) {
|
|
|
|
srs_error("process publish message failed. ret=%d", ret);
|
|
|
|
srs_error("process publish message failed. ret=%d", ret);
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -371,16 +367,12 @@ int SrsClient::publish(SrsSource* source, bool is_fmle)
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int SrsClient::process_publish_message(SrsSource* source, SrsHLS* hls, SrsCommonMessage* msg, bool is_fmle)
|
|
|
|
int SrsClient::process_publish_message(SrsSource* source, SrsCommonMessage* msg, bool is_fmle)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int ret = ERROR_SUCCESS;
|
|
|
|
int ret = ERROR_SUCCESS;
|
|
|
|
|
|
|
|
|
|
|
|
// process audio packet
|
|
|
|
// process audio packet
|
|
|
|
if (msg->header.is_audio()) {
|
|
|
|
if (msg->header.is_audio()) {
|
|
|
|
if ((ret = hls->on_audio(msg)) != ERROR_SUCCESS) {
|
|
|
|
|
|
|
|
srs_error("hls process audio message failed. ret=%d", ret);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((ret = source->on_audio(msg)) != ERROR_SUCCESS) {
|
|
|
|
if ((ret = source->on_audio(msg)) != ERROR_SUCCESS) {
|
|
|
|
srs_error("source process audio message failed. ret=%d", ret);
|
|
|
|
srs_error("source process audio message failed. ret=%d", ret);
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
@ -388,10 +380,6 @@ int SrsClient::process_publish_message(SrsSource* source, SrsHLS* hls, SrsCommon
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// process video packet
|
|
|
|
// process video packet
|
|
|
|
if (msg->header.is_video()) {
|
|
|
|
if (msg->header.is_video()) {
|
|
|
|
if ((ret = hls->on_video(msg)) != ERROR_SUCCESS) {
|
|
|
|
|
|
|
|
srs_error("hls process video message failed. ret=%d", ret);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((ret = source->on_video(msg)) != ERROR_SUCCESS) {
|
|
|
|
if ((ret = source->on_video(msg)) != ERROR_SUCCESS) {
|
|
|
|
srs_error("source process video message failed. ret=%d", ret);
|
|
|
|
srs_error("source process video message failed. ret=%d", ret);
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
@ -408,10 +396,6 @@ int SrsClient::process_publish_message(SrsSource* source, SrsHLS* hls, SrsCommon
|
|
|
|
SrsPacket* pkt = msg->get_packet();
|
|
|
|
SrsPacket* pkt = msg->get_packet();
|
|
|
|
if (dynamic_cast<SrsOnMetaDataPacket*>(pkt)) {
|
|
|
|
if (dynamic_cast<SrsOnMetaDataPacket*>(pkt)) {
|
|
|
|
SrsOnMetaDataPacket* metadata = dynamic_cast<SrsOnMetaDataPacket*>(pkt);
|
|
|
|
SrsOnMetaDataPacket* metadata = dynamic_cast<SrsOnMetaDataPacket*>(pkt);
|
|
|
|
if ((ret = hls->on_meta_data(metadata)) != ERROR_SUCCESS) {
|
|
|
|
|
|
|
|
srs_error("hls process onMetaData message failed. ret=%d", ret);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((ret = source->on_meta_data(msg, metadata)) != ERROR_SUCCESS) {
|
|
|
|
if ((ret = source->on_meta_data(msg, metadata)) != ERROR_SUCCESS) {
|
|
|
|
srs_error("source process onMetaData message failed. ret=%d", ret);
|
|
|
|
srs_error("source process onMetaData message failed. ret=%d", ret);
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|