Skip to content

Commit

Permalink
[dev] support for onTextData and onCuePoint (#68).
Browse files Browse the repository at this point in the history
  • Loading branch information
ferreus authored and winshining committed Sep 4, 2018
1 parent 7410910 commit 4aad640
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions ngx_rtmp_live_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,7 @@ static ngx_int_t
ngx_rtmp_live_data(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
ngx_chain_t *in, ngx_rtmp_amf_elt_t *out_elts, ngx_uint_t out_elts_size)
{
ngx_rtmp_live_proc_handler_t *handler;
ngx_rtmp_live_ctx_t *ctx, *pctx;
ngx_chain_t *data, *rpkt;
ngx_rtmp_core_srv_conf_t *cscf;
Expand All @@ -1190,6 +1191,7 @@ ngx_rtmp_live_data(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
ngx_uint_t peers;
uint32_t delta;
ngx_rtmp_live_chunk_stream_t *cs;
ngx_http_request_t *http_request;
#ifdef NGX_DEBUG
u_char *msg_type;

Expand Down Expand Up @@ -1254,19 +1256,41 @@ ngx_rtmp_live_data(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
delta = ch.timestamp - cs->timestamp;

rpkt = ngx_rtmp_append_shared_bufs(cscf, data, in);
ngx_rtmp_prepare_message(s, &ch, NULL, rpkt);

for (pctx = ctx->stream->ctx; pctx; pctx = pctx->next) {
if (pctx == ctx || pctx->paused) {
continue;
}

ss = pctx->session;

if (ngx_rtmp_send_message(ss, rpkt, prio) != NGX_OK) {
++pctx->ndropped;
cs->dropped += delta;
continue;
handler = ngx_rtmp_live_proc_handlers[pctx->protocol];
if (pctx->protocol == NGX_RTMP_PROTOCOL_HTTP) {
http_request = ss->data;
if (http_request == NULL || (http_request->connection && http_request->connection->destroyed)) {
continue;
}
handler->meta = handler->append_message_pt(ss,&ch,NULL,rpkt);
if (handler->meta == NULL) {
continue;
}
if (handler->meta) {
if (handler->send_message_pt(ss,handler->meta,0) != NGX_OK) {
++pctx->ndropped;
cs->dropped += delta;
handler->free_message_pt(ss, handler->meta);
handler->meta = NULL;
continue;
}
handler->free_message_pt(ss, handler->meta);
handler->meta = NULL;
}
} else {
ngx_rtmp_prepare_message(s, &ch, NULL, rpkt);
if (ngx_rtmp_send_message(ss, rpkt, prio) != NGX_OK) {
++pctx->ndropped;
cs->dropped += delta;
continue;
}
}

cs->timestamp += delta;
Expand Down

0 comments on commit 4aad640

Please sign in to comment.