fix #150, forward should forward the sequence header when retry. 0.9.208.
正在显示
4 个修改的文件
包含
39 行增加
和
1 行删除
| @@ -208,6 +208,7 @@ Supported operating systems and hardware: | @@ -208,6 +208,7 @@ Supported operating systems and hardware: | ||
| 208 | * 2013-10-17, Created.<br/> | 208 | * 2013-10-17, Created.<br/> |
| 209 | 209 | ||
| 210 | ## History | 210 | ## History |
| 211 | +* 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. | ||
| 211 | * 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. | 212 | * 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. |
| 212 | * 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. | 213 | * 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. |
| 213 | * 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. | 214 | * 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; | @@ -46,6 +46,7 @@ using namespace std; | ||
| 46 | #include <srs_protocol_msg_array.hpp> | 46 | #include <srs_protocol_msg_array.hpp> |
| 47 | #include <srs_app_utility.hpp> | 47 | #include <srs_app_utility.hpp> |
| 48 | #include <srs_protocol_amf0.hpp> | 48 | #include <srs_protocol_amf0.hpp> |
| 49 | +#include <srs_kernel_codec.hpp> | ||
| 49 | 50 | ||
| 50 | // when error, forwarder sleep for a while and retry. | 51 | // when error, forwarder sleep for a while and retry. |
| 51 | #define SRS_FORWARDER_SLEEP_US (int64_t)(3*1000*1000LL) | 52 | #define SRS_FORWARDER_SLEEP_US (int64_t)(3*1000*1000LL) |
| @@ -64,6 +65,8 @@ SrsForwarder::SrsForwarder(SrsSource* _source) | @@ -64,6 +65,8 @@ SrsForwarder::SrsForwarder(SrsSource* _source) | ||
| 64 | pthread = new SrsThread(this, SRS_FORWARDER_SLEEP_US, true); | 65 | pthread = new SrsThread(this, SRS_FORWARDER_SLEEP_US, true); |
| 65 | queue = new SrsMessageQueue(); | 66 | queue = new SrsMessageQueue(); |
| 66 | jitter = new SrsRtmpJitter(); | 67 | jitter = new SrsRtmpJitter(); |
| 68 | + | ||
| 69 | + sh_video = sh_audio = NULL; | ||
| 67 | } | 70 | } |
| 68 | 71 | ||
| 69 | SrsForwarder::~SrsForwarder() | 72 | SrsForwarder::~SrsForwarder() |
| @@ -74,6 +77,9 @@ SrsForwarder::~SrsForwarder() | @@ -74,6 +77,9 @@ SrsForwarder::~SrsForwarder() | ||
| 74 | srs_freep(queue); | 77 | srs_freep(queue); |
| 75 | srs_freep(jitter); | 78 | srs_freep(jitter); |
| 76 | srs_freep(kbps); | 79 | srs_freep(kbps); |
| 80 | + | ||
| 81 | + srs_freep(sh_video); | ||
| 82 | + srs_freep(sh_audio); | ||
| 77 | } | 83 | } |
| 78 | 84 | ||
| 79 | int SrsForwarder::initialize(SrsRequest* req, string ep_forward) | 85 | int SrsForwarder::initialize(SrsRequest* req, string ep_forward) |
| @@ -179,6 +185,11 @@ int SrsForwarder::on_audio(SrsSharedPtrMessage* msg) | @@ -179,6 +185,11 @@ int SrsForwarder::on_audio(SrsSharedPtrMessage* msg) | ||
| 179 | return ret; | 185 | return ret; |
| 180 | } | 186 | } |
| 181 | 187 | ||
| 188 | + if (SrsFlvCodec::audio_is_sequence_header(msg->payload, msg->size)) { | ||
| 189 | + srs_freep(sh_audio); | ||
| 190 | + sh_audio = msg->copy(); | ||
| 191 | + } | ||
| 192 | + | ||
| 182 | if ((ret = queue->enqueue(msg)) != ERROR_SUCCESS) { | 193 | if ((ret = queue->enqueue(msg)) != ERROR_SUCCESS) { |
| 183 | return ret; | 194 | return ret; |
| 184 | } | 195 | } |
| @@ -195,6 +206,11 @@ int SrsForwarder::on_video(SrsSharedPtrMessage* msg) | @@ -195,6 +206,11 @@ int SrsForwarder::on_video(SrsSharedPtrMessage* msg) | ||
| 195 | return ret; | 206 | return ret; |
| 196 | } | 207 | } |
| 197 | 208 | ||
| 209 | + if (SrsFlvCodec::video_is_sequence_header(msg->payload, msg->size)) { | ||
| 210 | + srs_freep(sh_video); | ||
| 211 | + sh_video = msg->copy(); | ||
| 212 | + } | ||
| 213 | + | ||
| 198 | if ((ret = queue->enqueue(msg)) != ERROR_SUCCESS) { | 214 | if ((ret = queue->enqueue(msg)) != ERROR_SUCCESS) { |
| 199 | return ret; | 215 | return ret; |
| 200 | } | 216 | } |
| @@ -371,6 +387,21 @@ int SrsForwarder::forward() | @@ -371,6 +387,21 @@ int SrsForwarder::forward() | ||
| 371 | 387 | ||
| 372 | SrsSharedPtrMessageArray msgs(SYS_MAX_FORWARD_SEND_MSGS); | 388 | SrsSharedPtrMessageArray msgs(SYS_MAX_FORWARD_SEND_MSGS); |
| 373 | 389 | ||
| 390 | + // update sequence header | ||
| 391 | + // TODO: FIXME: maybe need to zero the sequence header timestamp. | ||
| 392 | + if (sh_video) { | ||
| 393 | + if ((ret = client->send_and_free_message(sh_video->copy(), stream_id)) != ERROR_SUCCESS) { | ||
| 394 | + srs_error("forwarder send sh_video to server failed. ret=%d", ret); | ||
| 395 | + return ret; | ||
| 396 | + } | ||
| 397 | + } | ||
| 398 | + if (sh_audio) { | ||
| 399 | + if ((ret = client->send_and_free_message(sh_audio->copy(), stream_id)) != ERROR_SUCCESS) { | ||
| 400 | + srs_error("forwarder send sh_audio to server failed. ret=%d", ret); | ||
| 401 | + return ret; | ||
| 402 | + } | ||
| 403 | + } | ||
| 404 | + | ||
| 374 | while (pthread->can_loop()) { | 405 | while (pthread->can_loop()) { |
| 375 | // switch to other st-threads. | 406 | // switch to other st-threads. |
| 376 | st_usleep(0); | 407 | st_usleep(0); |
| @@ -65,6 +65,12 @@ private: | @@ -65,6 +65,12 @@ private: | ||
| 65 | SrsRtmpClient* client; | 65 | SrsRtmpClient* client; |
| 66 | SrsRtmpJitter* jitter; | 66 | SrsRtmpJitter* jitter; |
| 67 | SrsMessageQueue* queue; | 67 | SrsMessageQueue* queue; |
| 68 | + /** | ||
| 69 | + * cache the sequence header for retry when slave is failed. | ||
| 70 | + * @see https://github.com/winlinvip/simple-rtmp-server/issues/150 | ||
| 71 | + */ | ||
| 72 | + SrsSharedPtrMessage* sh_audio; | ||
| 73 | + SrsSharedPtrMessage* sh_video; | ||
| 68 | public: | 74 | public: |
| 69 | SrsForwarder(SrsSource* _source); | 75 | SrsForwarder(SrsSource* _source); |
| 70 | virtual ~SrsForwarder(); | 76 | virtual ~SrsForwarder(); |
| @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 31 | // current release version | 31 | // current release version |
| 32 | #define VERSION_MAJOR "0" | 32 | #define VERSION_MAJOR "0" |
| 33 | #define VERSION_MINOR "9" | 33 | #define VERSION_MINOR "9" |
| 34 | -#define VERSION_REVISION "207" | 34 | +#define VERSION_REVISION "208" |
| 35 | #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION | 35 | #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION |
| 36 | // server info. | 36 | // server info. |
| 37 | #define RTMP_SIG_SRS_KEY "SRS" | 37 | #define RTMP_SIG_SRS_KEY "SRS" |
-
请 注册 或 登录 后发表评论