Skip to content

Commit

Permalink
For #1509, release coroutine when source is idle. 3.0.98
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Jan 15, 2020
1 parent 816aa91 commit 857c783
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 7 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ For previous versions, please read:

## V3 changes

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

[exo #828]: https://github.com/google/ExoPlayer/pull/828
Expand Down
25 changes: 24 additions & 1 deletion trunk/src/app/srs_app_dvr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,13 +609,25 @@ srs_error_t SrsDvrPlan::initialize(SrsOriginHub* h, SrsDvrSegmenter* s, SrsReque
return srs_error_wrap(err, "segmenter");
}

return err;
}

srs_error_t SrsDvrPlan::on_publish()
{
srs_error_t err = srs_success;

if ((err = async->start()) != srs_success) {
return srs_error_wrap(err, "async");
}

return err;
}

void SrsDvrPlan::on_unpublish()
{
async->stop();
}

srs_error_t SrsDvrPlan::on_meta_data(SrsSharedPtrMessage* shared_metadata)
{
srs_error_t err = srs_success;
Expand Down Expand Up @@ -699,6 +711,10 @@ SrsDvrSessionPlan::~SrsDvrSessionPlan()
srs_error_t SrsDvrSessionPlan::on_publish()
{
srs_error_t err = srs_success;

if ((err = SrsDvrPlan::on_publish()) != srs_success) {
return err;
}

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

void SrsDvrSessionPlan::on_unpublish()
{
SrsDvrPlan::on_unpublish();

// support multiple publish.
if (!dvr_enabled) {
return;
Expand Down Expand Up @@ -766,6 +784,10 @@ srs_error_t SrsDvrSegmentPlan::initialize(SrsOriginHub* h, SrsDvrSegmenter* s, S
srs_error_t SrsDvrSegmentPlan::on_publish()
{
srs_error_t err = srs_success;

if ((err = SrsDvrPlan::on_publish()) != srs_success) {
return err;
}

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

void SrsDvrSegmentPlan::on_unpublish()
{
SrsDvrPlan::on_unpublish();
}

srs_error_t SrsDvrSegmentPlan::on_audio(SrsSharedPtrMessage* shared_audio, SrsFormat* format)
Expand Down
4 changes: 2 additions & 2 deletions trunk/src/app/srs_app_dvr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ class SrsDvrPlan : public ISrsReloadHandler
virtual ~SrsDvrPlan();
public:
virtual srs_error_t initialize(SrsOriginHub* h, SrsDvrSegmenter* s, SrsRequest* r);
virtual srs_error_t on_publish() = 0;
virtual void on_unpublish() = 0;
virtual srs_error_t on_publish();
virtual void on_unpublish();
virtual srs_error_t on_meta_data(SrsSharedPtrMessage* shared_metadata);
virtual srs_error_t on_audio(SrsSharedPtrMessage* shared_audio, SrsFormat* format);
virtual srs_error_t on_video(SrsSharedPtrMessage* shared_video, SrsFormat* format);
Expand Down
24 changes: 21 additions & 3 deletions trunk/src/app/srs_app_hls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,16 +268,27 @@ int SrsHlsMuxer::deviation()
}

srs_error_t SrsHlsMuxer::initialize()
{
return srs_success;
}

srs_error_t SrsHlsMuxer::on_publish(SrsRequest* req)
{
srs_error_t err = srs_success;

if ((err = async->start()) != srs_success) {
return srs_error_wrap(err, "async start");
}

return err;
}

srs_error_t SrsHlsMuxer::on_unpublish()
{
async->stop();
return srs_success;
}

srs_error_t SrsHlsMuxer::update_config(SrsRequest* r, string entry_prefix,
string path, string m3u8_file, string ts_file, srs_utime_t fragment, srs_utime_t window,
bool ts_floor, double aof_ratio, bool cleanup, bool wait_keyframe, bool keys,
Expand Down Expand Up @@ -899,8 +910,11 @@ srs_error_t SrsHlsController::on_publish(SrsRequest* req)

// TODO: FIXME: support load exists m3u8, to continue publish stream.
// for the HLS donot requires the EXT-X-MEDIA-SEQUENCE be monotonically increase.

if ((err = muxer->on_publish(req)) != srs_success) {
return srs_error_wrap(err, "muxer publish");
}

// open muxer
if ((err = muxer->update_config(req, entry_prefix, path, m3u8_file, ts_file, hls_fragment,
hls_window, ts_floor, hls_aof_ratio, cleanup, wait_keyframe,hls_keys,hls_fragments_per_key,
hls_key_file, hls_key_file_path, hls_key_url)) != srs_success ) {
Expand All @@ -924,6 +938,10 @@ srs_error_t SrsHlsController::on_publish(SrsRequest* req)
srs_error_t SrsHlsController::on_unpublish()
{
srs_error_t err = srs_success;

if ((err = muxer->on_unpublish()) != srs_success) {
return srs_error_wrap(err, "muxer unpublish");
}

if ((err = muxer->flush_audio(tsmc)) != srs_success) {
return srs_error_wrap(err, "hls: flush audio");
Expand Down
3 changes: 3 additions & 0 deletions trunk/src/app/srs_app_hls.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ class SrsHlsMuxer
public:
// Initialize the hls muxer.
virtual srs_error_t initialize();
// When publish or unpublish stream.
virtual srs_error_t on_publish(SrsRequest* req);
virtual srs_error_t on_unpublish();
// When publish, update the config for muxer.
virtual srs_error_t update_config(SrsRequest* r, std::string entry_prefix,
std::string path, std::string m3u8_file, std::string ts_file,
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/core/srs_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
// The version config.
#define VERSION_MAJOR 3
#define VERSION_MINOR 0
#define VERSION_REVISION 97
#define VERSION_REVISION 98

// The macros generated by configure script.
#include <srs_auto_headers.hpp>
Expand Down

0 comments on commit 857c783

Please sign in to comment.