Skip to content

Commit

Permalink
fix #425, refine the time jitter, correct (-inf,-250)+(250,+inf) to 1…
Browse files Browse the repository at this point in the history
…0ms. 2.0.175
  • Loading branch information
winlinvip committed Jun 10, 2015
1 parent 6941f2c commit 56938ef
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 106 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ Remark:

### SRS 2.0 history

* v2.0, 2015-06-10, fix [#425](https://github.com/simple-rtmp-server/srs/issues/425) refine the time jitter, correct (-inf,-250)+(250,+inf) to 10ms. 2.0.175
* v2.0, 2015-06-10, fix [#424](https://github.com/simple-rtmp-server/srs/issues/424) fix aggregate timestamp bug. 2.0.174
* v2.0, 2015-06-06, fix [#421](https://github.com/simple-rtmp-server/srs/issues/421) drop video for unkown RTMP header.
* v2.0, 2015-06-05, fix [#420](https://github.com/simple-rtmp-server/srs/issues/420) remove ts for hls ram mode.
Expand Down
6 changes: 3 additions & 3 deletions trunk/src/app/srs_app_dvr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ int SrsFlvSegment::write_audio(SrsSharedPtrMessage* shared_audio)
SrsSharedPtrMessage* audio = shared_audio->copy();
SrsAutoFree(SrsSharedPtrMessage, audio);

if ((jitter->correct(audio, 0, 0, jitter_algorithm)) != ERROR_SUCCESS) {
if ((jitter->correct(audio, jitter_algorithm)) != ERROR_SUCCESS) {
return ret;
}

Expand Down Expand Up @@ -324,7 +324,7 @@ int SrsFlvSegment::write_video(SrsSharedPtrMessage* shared_video)
}
}

if ((jitter->correct(video, 0, 0, jitter_algorithm)) != ERROR_SUCCESS) {
if ((jitter->correct(video, jitter_algorithm)) != ERROR_SUCCESS) {
return ret;
}

Expand All @@ -334,7 +334,7 @@ int SrsFlvSegment::write_video(SrsSharedPtrMessage* shared_video)
return ret;
}

int32_t timestamp = plan->filter_timestamp(video->timestamp);
int32_t timestamp = (int32_t)plan->filter_timestamp(video->timestamp);
if ((ret = enc->write_video(timestamp, payload, size)) != ERROR_SUCCESS) {
return ret;
}
Expand Down
11 changes: 7 additions & 4 deletions trunk/src/app/srs_app_forward.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ int SrsForwarder::on_meta_data(SrsSharedPtrMessage* shared_metadata)

SrsSharedPtrMessage* metadata = shared_metadata->copy();

if ((ret = jitter->correct(metadata, 0, 0, SrsRtmpJitterAlgorithmFULL)) != ERROR_SUCCESS) {
// TODO: FIXME: config the jitter of Forwarder.
if ((ret = jitter->correct(metadata, SrsRtmpJitterAlgorithmFULL)) != ERROR_SUCCESS) {
srs_freep(metadata);
return ret;
}
Expand All @@ -180,8 +181,9 @@ int SrsForwarder::on_audio(SrsSharedPtrMessage* shared_audio)
int ret = ERROR_SUCCESS;

SrsSharedPtrMessage* msg = shared_audio->copy();

if ((ret = jitter->correct(msg, 0, 0, SrsRtmpJitterAlgorithmFULL)) != ERROR_SUCCESS) {

// TODO: FIXME: config the jitter of Forwarder.
if ((ret = jitter->correct(msg, SrsRtmpJitterAlgorithmFULL)) != ERROR_SUCCESS) {
srs_freep(msg);
return ret;
}
Expand All @@ -204,7 +206,8 @@ int SrsForwarder::on_video(SrsSharedPtrMessage* shared_video)

SrsSharedPtrMessage* msg = shared_video->copy();

if ((ret = jitter->correct(msg, 0, 0, SrsRtmpJitterAlgorithmFULL)) != ERROR_SUCCESS) {
// TODO: FIXME: config the jitter of Forwarder.
if ((ret = jitter->correct(msg, SrsRtmpJitterAlgorithmFULL)) != ERROR_SUCCESS) {
srs_freep(msg);
return ret;
}
Expand Down
6 changes: 4 additions & 2 deletions trunk/src/app/srs_app_hls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,8 @@ int SrsHls::on_audio(SrsSharedPtrMessage* shared_audio)
return hls_cache->on_sequence_header(muxer);
}

if ((ret = jitter->correct(audio, 0, 0, SrsRtmpJitterAlgorithmFULL)) != ERROR_SUCCESS) {
// TODO: FIXME: config the jitter of HLS.
if ((ret = jitter->correct(audio, SrsRtmpJitterAlgorithmFULL)) != ERROR_SUCCESS) {
srs_error("rtmp jitter correct audio failed. ret=%d", ret);
return ret;
}
Expand Down Expand Up @@ -1394,7 +1395,8 @@ int SrsHls::on_video(SrsSharedPtrMessage* shared_video)
return hls_cache->on_sequence_header(muxer);
}

if ((ret = jitter->correct(video, 0, 0, SrsRtmpJitterAlgorithmFULL)) != ERROR_SUCCESS) {
// TODO: FIXME: config the jitter of HLS.
if ((ret = jitter->correct(video, SrsRtmpJitterAlgorithmFULL)) != ERROR_SUCCESS) {
srs_error("rtmp jitter correct video failed. ret=%d", ret);
return ret;
}
Expand Down
20 changes: 10 additions & 10 deletions trunk/src/app/srs_app_http_conn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,7 @@ int SrsStreamCache::start()
return pthread->start();
}

int SrsStreamCache::dump_cache(SrsConsumer* consumer)
int SrsStreamCache::dump_cache(SrsConsumer* consumer, SrsRtmpJitterAlgorithm jitter)
{
int ret = ERROR_SUCCESS;

Expand All @@ -1276,8 +1276,8 @@ int SrsStreamCache::dump_cache(SrsConsumer* consumer)
return ret;
}

// TODO: FIXME: config it.
if ((ret = queue->dump_packets(consumer, false, 0, 0, SrsRtmpJitterAlgorithmOFF)) != ERROR_SUCCESS) {
// the jitter is get from SrsSource, which means the time_jitter of vhost.
if ((ret = queue->dump_packets(consumer, false, jitter)) != ERROR_SUCCESS) {
return ret;
}

Expand Down Expand Up @@ -1398,7 +1398,7 @@ bool SrsTsStreamEncoder::has_cache()
return false;
}

int SrsTsStreamEncoder::dump_cache(SrsConsumer* /*consumer*/)
int SrsTsStreamEncoder::dump_cache(SrsConsumer* /*consumer*/, SrsRtmpJitterAlgorithm /*jitter*/)
{
// for ts stream, ignore cache.
return ERROR_SUCCESS;
Expand Down Expand Up @@ -1451,7 +1451,7 @@ bool SrsFlvStreamEncoder::has_cache()
return false;
}

int SrsFlvStreamEncoder::dump_cache(SrsConsumer* /*consumer*/)
int SrsFlvStreamEncoder::dump_cache(SrsConsumer* /*consumer*/, SrsRtmpJitterAlgorithm /*jitter*/)
{
// for flv stream, ignore cache.
return ERROR_SUCCESS;
Expand Down Expand Up @@ -1518,10 +1518,10 @@ bool SrsAacStreamEncoder::has_cache()
return true;
}

int SrsAacStreamEncoder::dump_cache(SrsConsumer* consumer)
int SrsAacStreamEncoder::dump_cache(SrsConsumer* consumer, SrsRtmpJitterAlgorithm jitter)
{
srs_assert(cache);
return cache->dump_cache(consumer);
return cache->dump_cache(consumer, jitter);
}

SrsMp3StreamEncoder::SrsMp3StreamEncoder()
Expand Down Expand Up @@ -1574,10 +1574,10 @@ bool SrsMp3StreamEncoder::has_cache()
return true;
}

int SrsMp3StreamEncoder::dump_cache(SrsConsumer* consumer)
int SrsMp3StreamEncoder::dump_cache(SrsConsumer* consumer, SrsRtmpJitterAlgorithm jitter)
{
srs_assert(cache);
return cache->dump_cache(consumer);
return cache->dump_cache(consumer, jitter);
}

SrsStreamWriter::SrsStreamWriter(ISrsHttpResponseWriter* w)
Expand Down Expand Up @@ -1686,7 +1686,7 @@ int SrsLiveStream::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)

// if gop cache enabled for encoder, dump to consumer.
if (enc->has_cache()) {
if ((ret = enc->dump_cache(consumer)) != ERROR_SUCCESS) {
if ((ret = enc->dump_cache(consumer, source->jitter())) != ERROR_SUCCESS) {
srs_error("http: dump cache to consumer failed. ret=%d", ret);
return ret;
}
Expand Down
13 changes: 7 additions & 6 deletions trunk/src/app/srs_app_http_conn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_kernel_file.hpp>
#include <srs_app_thread.hpp>
#include <srs_app_conn.hpp>
#include <srs_app_source.hpp>

class SrsServer;
class SrsSource;
Expand Down Expand Up @@ -407,7 +408,7 @@ class SrsStreamCache : public ISrsEndlessThreadHandler
virtual ~SrsStreamCache();
public:
virtual int start();
virtual int dump_cache(SrsConsumer* consumer);
virtual int dump_cache(SrsConsumer* consumer, SrsRtmpJitterAlgorithm jitter);
// interface ISrsEndlessThreadHandler.
public:
virtual int cycle();
Expand Down Expand Up @@ -444,7 +445,7 @@ class ISrsStreamEncoder
/**
* dumps the cache of encoder to consumer.
*/
virtual int dump_cache(SrsConsumer* consumer) = 0;
virtual int dump_cache(SrsConsumer* consumer, SrsRtmpJitterAlgorithm jitter) = 0;
};

/**
Expand All @@ -464,7 +465,7 @@ class SrsFlvStreamEncoder : public ISrsStreamEncoder
virtual int write_metadata(int64_t timestamp, char* data, int size);
public:
virtual bool has_cache();
virtual int dump_cache(SrsConsumer* consumer);
virtual int dump_cache(SrsConsumer* consumer, SrsRtmpJitterAlgorithm jitter);
};

#ifdef SRS_PERF_FAST_FLV_ENCODER
Expand Down Expand Up @@ -502,7 +503,7 @@ class SrsTsStreamEncoder : public ISrsStreamEncoder
virtual int write_metadata(int64_t timestamp, char* data, int size);
public:
virtual bool has_cache();
virtual int dump_cache(SrsConsumer* consumer);
virtual int dump_cache(SrsConsumer* consumer, SrsRtmpJitterAlgorithm jitter);
};

/**
Expand All @@ -523,7 +524,7 @@ class SrsAacStreamEncoder : public ISrsStreamEncoder
virtual int write_metadata(int64_t timestamp, char* data, int size);
public:
virtual bool has_cache();
virtual int dump_cache(SrsConsumer* consumer);
virtual int dump_cache(SrsConsumer* consumer, SrsRtmpJitterAlgorithm jitter);
};

/**
Expand All @@ -544,7 +545,7 @@ class SrsMp3StreamEncoder : public ISrsStreamEncoder
virtual int write_metadata(int64_t timestamp, char* data, int size);
public:
virtual bool has_cache();
virtual int dump_cache(SrsConsumer* consumer);
virtual int dump_cache(SrsConsumer* consumer, SrsRtmpJitterAlgorithm jitter);
};

/**
Expand Down
Loading

0 comments on commit 56938ef

Please sign in to comment.