mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
fix #150, forward should forward the sequence header when retry. 0.9.208.
This commit is contained in:
parent
9b6187c3d5
commit
42a43c69cd
4 changed files with 39 additions and 1 deletions
|
@ -208,6 +208,7 @@ Supported operating systems and hardware:
|
||||||
* 2013-10-17, Created.<br/>
|
* 2013-10-17, Created.<br/>
|
||||||
|
|
||||||
## History
|
## History
|
||||||
|
* v1.0, 2014-08-24, fix [#150](https://github.com/winlinvip/simple-rtmp-server/issues/150), forward should forward the sequence header when retry. 0.9.208.
|
||||||
* v1.0, 2014-08-22, for [#165](https://github.com/winlinvip/simple-rtmp-server/issues/165), refine dh wrapper, ensure public key is 128bytes. 0.9.206.
|
* v1.0, 2014-08-22, for [#165](https://github.com/winlinvip/simple-rtmp-server/issues/165), refine dh wrapper, ensure public key is 128bytes. 0.9.206.
|
||||||
* v1.0, 2014-08-19, for [#160](https://github.com/winlinvip/simple-rtmp-server/issues/160), support forward/edge to flussonic, disable debug_srs_upnode to make flussonic happy. 0.9.201.
|
* v1.0, 2014-08-19, for [#160](https://github.com/winlinvip/simple-rtmp-server/issues/160), support forward/edge to flussonic, disable debug_srs_upnode to make flussonic happy. 0.9.201.
|
||||||
* v1.0, 2014-08-17, for [#155](https://github.com/winlinvip/simple-rtmp-server/issues/155), refine for osx, with ssl/http, disable statistics. 0.9.198.
|
* v1.0, 2014-08-17, for [#155](https://github.com/winlinvip/simple-rtmp-server/issues/155), refine for osx, with ssl/http, disable statistics. 0.9.198.
|
||||||
|
|
|
@ -46,6 +46,7 @@ using namespace std;
|
||||||
#include <srs_protocol_msg_array.hpp>
|
#include <srs_protocol_msg_array.hpp>
|
||||||
#include <srs_app_utility.hpp>
|
#include <srs_app_utility.hpp>
|
||||||
#include <srs_protocol_amf0.hpp>
|
#include <srs_protocol_amf0.hpp>
|
||||||
|
#include <srs_kernel_codec.hpp>
|
||||||
|
|
||||||
// when error, forwarder sleep for a while and retry.
|
// when error, forwarder sleep for a while and retry.
|
||||||
#define SRS_FORWARDER_SLEEP_US (int64_t)(3*1000*1000LL)
|
#define SRS_FORWARDER_SLEEP_US (int64_t)(3*1000*1000LL)
|
||||||
|
@ -64,6 +65,8 @@ SrsForwarder::SrsForwarder(SrsSource* _source)
|
||||||
pthread = new SrsThread(this, SRS_FORWARDER_SLEEP_US, true);
|
pthread = new SrsThread(this, SRS_FORWARDER_SLEEP_US, true);
|
||||||
queue = new SrsMessageQueue();
|
queue = new SrsMessageQueue();
|
||||||
jitter = new SrsRtmpJitter();
|
jitter = new SrsRtmpJitter();
|
||||||
|
|
||||||
|
sh_video = sh_audio = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsForwarder::~SrsForwarder()
|
SrsForwarder::~SrsForwarder()
|
||||||
|
@ -74,6 +77,9 @@ SrsForwarder::~SrsForwarder()
|
||||||
srs_freep(queue);
|
srs_freep(queue);
|
||||||
srs_freep(jitter);
|
srs_freep(jitter);
|
||||||
srs_freep(kbps);
|
srs_freep(kbps);
|
||||||
|
|
||||||
|
srs_freep(sh_video);
|
||||||
|
srs_freep(sh_audio);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SrsForwarder::initialize(SrsRequest* req, string ep_forward)
|
int SrsForwarder::initialize(SrsRequest* req, string ep_forward)
|
||||||
|
@ -179,6 +185,11 @@ int SrsForwarder::on_audio(SrsSharedPtrMessage* msg)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SrsFlvCodec::audio_is_sequence_header(msg->payload, msg->size)) {
|
||||||
|
srs_freep(sh_audio);
|
||||||
|
sh_audio = msg->copy();
|
||||||
|
}
|
||||||
|
|
||||||
if ((ret = queue->enqueue(msg)) != ERROR_SUCCESS) {
|
if ((ret = queue->enqueue(msg)) != ERROR_SUCCESS) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -195,6 +206,11 @@ int SrsForwarder::on_video(SrsSharedPtrMessage* msg)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SrsFlvCodec::video_is_sequence_header(msg->payload, msg->size)) {
|
||||||
|
srs_freep(sh_video);
|
||||||
|
sh_video = msg->copy();
|
||||||
|
}
|
||||||
|
|
||||||
if ((ret = queue->enqueue(msg)) != ERROR_SUCCESS) {
|
if ((ret = queue->enqueue(msg)) != ERROR_SUCCESS) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -371,6 +387,21 @@ int SrsForwarder::forward()
|
||||||
|
|
||||||
SrsSharedPtrMessageArray msgs(SYS_MAX_FORWARD_SEND_MSGS);
|
SrsSharedPtrMessageArray msgs(SYS_MAX_FORWARD_SEND_MSGS);
|
||||||
|
|
||||||
|
// update sequence header
|
||||||
|
// TODO: FIXME: maybe need to zero the sequence header timestamp.
|
||||||
|
if (sh_video) {
|
||||||
|
if ((ret = client->send_and_free_message(sh_video->copy(), stream_id)) != ERROR_SUCCESS) {
|
||||||
|
srs_error("forwarder send sh_video to server failed. ret=%d", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sh_audio) {
|
||||||
|
if ((ret = client->send_and_free_message(sh_audio->copy(), stream_id)) != ERROR_SUCCESS) {
|
||||||
|
srs_error("forwarder send sh_audio to server failed. ret=%d", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while (pthread->can_loop()) {
|
while (pthread->can_loop()) {
|
||||||
// switch to other st-threads.
|
// switch to other st-threads.
|
||||||
st_usleep(0);
|
st_usleep(0);
|
||||||
|
|
|
@ -65,6 +65,12 @@ private:
|
||||||
SrsRtmpClient* client;
|
SrsRtmpClient* client;
|
||||||
SrsRtmpJitter* jitter;
|
SrsRtmpJitter* jitter;
|
||||||
SrsMessageQueue* queue;
|
SrsMessageQueue* queue;
|
||||||
|
/**
|
||||||
|
* cache the sequence header for retry when slave is failed.
|
||||||
|
* @see https://github.com/winlinvip/simple-rtmp-server/issues/150
|
||||||
|
*/
|
||||||
|
SrsSharedPtrMessage* sh_audio;
|
||||||
|
SrsSharedPtrMessage* sh_video;
|
||||||
public:
|
public:
|
||||||
SrsForwarder(SrsSource* _source);
|
SrsForwarder(SrsSource* _source);
|
||||||
virtual ~SrsForwarder();
|
virtual ~SrsForwarder();
|
||||||
|
|
|
@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
// current release version
|
// current release version
|
||||||
#define VERSION_MAJOR "0"
|
#define VERSION_MAJOR "0"
|
||||||
#define VERSION_MINOR "9"
|
#define VERSION_MINOR "9"
|
||||||
#define VERSION_REVISION "207"
|
#define VERSION_REVISION "208"
|
||||||
#define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
|
#define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
|
||||||
// server info.
|
// server info.
|
||||||
#define RTMP_SIG_SRS_KEY "SRS"
|
#define RTMP_SIG_SRS_KEY "SRS"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue