Skip to content

Commit 857c783

Browse files
committed
For #1509, release coroutine when source is idle. 3.0.98
1 parent 816aa91 commit 857c783

File tree

6 files changed

+53
-7
lines changed

6 files changed

+53
-7
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ For previous versions, please read:
146146

147147
## V3 changes
148148

149+
* v3.0, 2020-01-15, For [#1509][bug #1509], release coroutine when source is idle. 3.0.98
149150
* <strong>v3.0, 2020-01-10, [3.0 alpha8(3.0.97)][r3.0a8] released. 121555 lines.</strong>
150151
* v3.0, 2020-01-09, For [#1042][bug #1042], improve test coverage for service. 3.0.97
151152
* v3.0, 2020-01-08, Merge [#1554][bug #1554], support logrotate copytruncate. 3.0.96
@@ -1592,6 +1593,7 @@ Winlin
15921593
[bug #1544]: https://github.com/ossrs/srs/issues/1544
15931594
[bug #1255]: https://github.com/ossrs/srs/issues/1255
15941595
[bug #1543]: https://github.com/ossrs/srs/issues/1543
1596+
[bug #1509]: https://github.com/ossrs/srs/issues/1509
15951597
[bug #xxxxxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxxxxx
15961598

15971599
[exo #828]: https://github.com/google/ExoPlayer/pull/828

trunk/src/app/srs_app_dvr.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,13 +609,25 @@ srs_error_t SrsDvrPlan::initialize(SrsOriginHub* h, SrsDvrSegmenter* s, SrsReque
609609
return srs_error_wrap(err, "segmenter");
610610
}
611611

612+
return err;
613+
}
614+
615+
srs_error_t SrsDvrPlan::on_publish()
616+
{
617+
srs_error_t err = srs_success;
618+
612619
if ((err = async->start()) != srs_success) {
613620
return srs_error_wrap(err, "async");
614621
}
615-
622+
616623
return err;
617624
}
618625

626+
void SrsDvrPlan::on_unpublish()
627+
{
628+
async->stop();
629+
}
630+
619631
srs_error_t SrsDvrPlan::on_meta_data(SrsSharedPtrMessage* shared_metadata)
620632
{
621633
srs_error_t err = srs_success;
@@ -699,6 +711,10 @@ SrsDvrSessionPlan::~SrsDvrSessionPlan()
699711
srs_error_t SrsDvrSessionPlan::on_publish()
700712
{
701713
srs_error_t err = srs_success;
714+
715+
if ((err = SrsDvrPlan::on_publish()) != srs_success) {
716+
return err;
717+
}
702718

703719
// support multiple publish.
704720
if (dvr_enabled) {
@@ -724,6 +740,8 @@ srs_error_t SrsDvrSessionPlan::on_publish()
724740

725741
void SrsDvrSessionPlan::on_unpublish()
726742
{
743+
SrsDvrPlan::on_unpublish();
744+
727745
// support multiple publish.
728746
if (!dvr_enabled) {
729747
return;
@@ -766,6 +784,10 @@ srs_error_t SrsDvrSegmentPlan::initialize(SrsOriginHub* h, SrsDvrSegmenter* s, S
766784
srs_error_t SrsDvrSegmentPlan::on_publish()
767785
{
768786
srs_error_t err = srs_success;
787+
788+
if ((err = SrsDvrPlan::on_publish()) != srs_success) {
789+
return err;
790+
}
769791

770792
// support multiple publish.
771793
if (dvr_enabled) {
@@ -791,6 +813,7 @@ srs_error_t SrsDvrSegmentPlan::on_publish()
791813

792814
void SrsDvrSegmentPlan::on_unpublish()
793815
{
816+
SrsDvrPlan::on_unpublish();
794817
}
795818

796819
srs_error_t SrsDvrSegmentPlan::on_audio(SrsSharedPtrMessage* shared_audio, SrsFormat* format)

trunk/src/app/srs_app_dvr.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ class SrsDvrPlan : public ISrsReloadHandler
185185
virtual ~SrsDvrPlan();
186186
public:
187187
virtual srs_error_t initialize(SrsOriginHub* h, SrsDvrSegmenter* s, SrsRequest* r);
188-
virtual srs_error_t on_publish() = 0;
189-
virtual void on_unpublish() = 0;
188+
virtual srs_error_t on_publish();
189+
virtual void on_unpublish();
190190
virtual srs_error_t on_meta_data(SrsSharedPtrMessage* shared_metadata);
191191
virtual srs_error_t on_audio(SrsSharedPtrMessage* shared_audio, SrsFormat* format);
192192
virtual srs_error_t on_video(SrsSharedPtrMessage* shared_video, SrsFormat* format);

trunk/src/app/srs_app_hls.cpp

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,16 +268,27 @@ int SrsHlsMuxer::deviation()
268268
}
269269

270270
srs_error_t SrsHlsMuxer::initialize()
271+
{
272+
return srs_success;
273+
}
274+
275+
srs_error_t SrsHlsMuxer::on_publish(SrsRequest* req)
271276
{
272277
srs_error_t err = srs_success;
273-
278+
274279
if ((err = async->start()) != srs_success) {
275280
return srs_error_wrap(err, "async start");
276281
}
277-
282+
278283
return err;
279284
}
280285

286+
srs_error_t SrsHlsMuxer::on_unpublish()
287+
{
288+
async->stop();
289+
return srs_success;
290+
}
291+
281292
srs_error_t SrsHlsMuxer::update_config(SrsRequest* r, string entry_prefix,
282293
string path, string m3u8_file, string ts_file, srs_utime_t fragment, srs_utime_t window,
283294
bool ts_floor, double aof_ratio, bool cleanup, bool wait_keyframe, bool keys,
@@ -899,8 +910,11 @@ srs_error_t SrsHlsController::on_publish(SrsRequest* req)
899910

900911
// TODO: FIXME: support load exists m3u8, to continue publish stream.
901912
// for the HLS donot requires the EXT-X-MEDIA-SEQUENCE be monotonically increase.
913+
914+
if ((err = muxer->on_publish(req)) != srs_success) {
915+
return srs_error_wrap(err, "muxer publish");
916+
}
902917

903-
// open muxer
904918
if ((err = muxer->update_config(req, entry_prefix, path, m3u8_file, ts_file, hls_fragment,
905919
hls_window, ts_floor, hls_aof_ratio, cleanup, wait_keyframe,hls_keys,hls_fragments_per_key,
906920
hls_key_file, hls_key_file_path, hls_key_url)) != srs_success ) {
@@ -924,6 +938,10 @@ srs_error_t SrsHlsController::on_publish(SrsRequest* req)
924938
srs_error_t SrsHlsController::on_unpublish()
925939
{
926940
srs_error_t err = srs_success;
941+
942+
if ((err = muxer->on_unpublish()) != srs_success) {
943+
return srs_error_wrap(err, "muxer unpublish");
944+
}
927945

928946
if ((err = muxer->flush_audio(tsmc)) != srs_success) {
929947
return srs_error_wrap(err, "hls: flush audio");

trunk/src/app/srs_app_hls.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ class SrsHlsMuxer
185185
public:
186186
// Initialize the hls muxer.
187187
virtual srs_error_t initialize();
188+
// When publish or unpublish stream.
189+
virtual srs_error_t on_publish(SrsRequest* req);
190+
virtual srs_error_t on_unpublish();
188191
// When publish, update the config for muxer.
189192
virtual srs_error_t update_config(SrsRequest* r, std::string entry_prefix,
190193
std::string path, std::string m3u8_file, std::string ts_file,

trunk/src/core/srs_core.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
// The version config.
2828
#define VERSION_MAJOR 3
2929
#define VERSION_MINOR 0
30-
#define VERSION_REVISION 97
30+
#define VERSION_REVISION 98
3131

3232
// The macros generated by configure script.
3333
#include <srs_auto_headers.hpp>

0 commit comments

Comments
 (0)