Skip to content

Commit

Permalink
refine code for consumer to refer the rtmp connection.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Dec 26, 2015
1 parent d3139c5 commit eca46c0
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
4 changes: 2 additions & 2 deletions trunk/src/app/srs_app_http_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ int SrsStreamCache::cycle()
// the stream cache will create consumer to cache stream,
// which will trigger to fetch stream from origin for edge.
SrsConsumer* consumer = NULL;
if ((ret = source->create_consumer(consumer, false, false, true)) != ERROR_SUCCESS) {
if ((ret = source->create_consumer(NULL, consumer, false, false, true)) != ERROR_SUCCESS) {
srs_error("http: create consumer failed. ret=%d", ret);
return ret;
}
Expand Down Expand Up @@ -483,7 +483,7 @@ int SrsLiveStream::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)

// create consumer of souce, ignore gop cache, use the audio gop cache.
SrsConsumer* consumer = NULL;
if ((ret = source->create_consumer(consumer, true, true, !enc->has_cache())) != ERROR_SUCCESS) {
if ((ret = source->create_consumer(NULL, consumer, true, true, !enc->has_cache())) != ERROR_SUCCESS) {
srs_error("http: create consumer failed. ret=%d", ret);
return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/app/srs_app_rtmp_conn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ int SrsRtmpConn::playing(SrsSource* source)

// create consumer of souce.
SrsConsumer* consumer = NULL;
if ((ret = source->create_consumer(consumer)) != ERROR_SUCCESS) {
if ((ret = source->create_consumer(this, consumer)) != ERROR_SUCCESS) {
srs_error("create consumer failed. ret=%d", ret);
return ret;
}
Expand Down
9 changes: 5 additions & 4 deletions trunk/src/app/srs_app_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,10 @@ ISrsWakable::~ISrsWakable()
{
}

SrsConsumer::SrsConsumer(SrsSource* _source)
SrsConsumer::SrsConsumer(SrsSource* s, SrsConnection* c)
{
source = _source;
source = s;
conn = c;
paused = false;
jitter = new SrsRtmpJitter();
queue = new SrsMessageQueue();
Expand Down Expand Up @@ -2143,11 +2144,11 @@ void SrsSource::on_unpublish()
handler->on_unpublish(this, _req);
}

int SrsSource::create_consumer(SrsConsumer*& consumer, bool ds, bool dm, bool dg)
int SrsSource::create_consumer(SrsConnection* conn, SrsConsumer*& consumer, bool ds, bool dm, bool dg)
{
int ret = ERROR_SUCCESS;

consumer = new SrsConsumer(this);
consumer = new SrsConsumer(this, conn);
consumers.push_back(consumer);

double queue_size = _srs_config->get_queue_length(_req->vhost);
Expand Down
7 changes: 5 additions & 2 deletions trunk/src/app/srs_app_source.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class SrsStSocket;
class SrsRtmpServer;
class SrsEdgeProxyContext;
class SrsMessageArray;
class SrsConnection;
#ifdef SRS_AUTO_HLS
class SrsHls;
#endif
Expand Down Expand Up @@ -224,6 +225,8 @@ class SrsConsumer : public ISrsWakable
SrsRtmpJitter* jitter;
SrsSource* source;
SrsMessageQueue* queue;
// the owner connection for debug, maybe NULL.
SrsConnection* conn;
bool paused;
// when source id changed, notice all consumers
bool should_update_source_id;
Expand All @@ -236,7 +239,7 @@ class SrsConsumer : public ISrsWakable
int mw_duration;
#endif
public:
SrsConsumer(SrsSource* _source);
SrsConsumer(SrsSource* s, SrsConnection* c);
virtual ~SrsConsumer();
public:
/**
Expand Down Expand Up @@ -571,7 +574,7 @@ class SrsSource : public ISrsReloadHandler
* @param dg, whether dumps the gop cache.
*/
virtual int create_consumer(
SrsConsumer*& consumer,
SrsConnection* conn, SrsConsumer*& consumer,
bool ds = true, bool dm = true, bool dg = true
);
virtual void on_consumer_destroy(SrsConsumer* consumer);
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 @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// current release version
#define VERSION_MAJOR 2
#define VERSION_MINOR 0
#define VERSION_REVISION 205
#define VERSION_REVISION 206

// server info.
#define RTMP_SIG_SRS_KEY "SRS"
Expand Down

0 comments on commit eca46c0

Please sign in to comment.