From 3fb41195a584542ab0187d9f25b850e30acef393 Mon Sep 17 00:00:00 2001 From: Roman Arutyunyan Date: Tue, 22 May 2012 22:53:35 +0400 Subject: [PATCH] added publish/play silent mode to escape sending unrelated replies to when using relays --- ngx_rtmp_cmd_module.c | 20 ++++++++++++++------ ngx_rtmp_cmd_module.h | 2 ++ ngx_rtmp_relay_module.c | 2 ++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/ngx_rtmp_cmd_module.c b/ngx_rtmp_cmd_module.c index 6ff74ac..2046d82 100644 --- a/ngx_rtmp_cmd_module.c +++ b/ngx_rtmp_cmd_module.c @@ -445,9 +445,13 @@ ngx_rtmp_cmd_publish(ngx_rtmp_session_t *s, ngx_rtmp_publish_t *v) out_inf, sizeof(out_inf) }, }; - ngx_log_debug2(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "publish: name='%s' type=%s", - v->name, v->type); + ngx_log_debug3(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, + "publish: name='%s' type=%s silent=%d", + v->name, v->type, v->silent); + + if (v->silent) { + return NGX_OK; + } /* send onStatus reply */ memset(&h, 0, sizeof(h)); @@ -717,10 +721,14 @@ ngx_rtmp_cmd_play(ngx_rtmp_session_t *s, ngx_rtmp_play_t *v) out4_inf, sizeof(out4_inf) }, }; - ngx_log_debug4(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "play: name='%s' start=%uD duration=%uD reset=%d", + ngx_log_debug5(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, + "play: name='%s' start=%uD duration=%uD reset=%d silent=%d", v->name, (uint32_t)v->start, - (uint32_t)v->duration, v->reset); + (uint32_t)v->duration, v->reset, v->silent); + + if (v->silent) { + return NGX_OK; + } /* send onStatus reply */ memset(&h, 0, sizeof(h)); diff --git a/ngx_rtmp_cmd_module.h b/ngx_rtmp_cmd_module.h index 6235f49..2f4f4e3 100644 --- a/ngx_rtmp_cmd_module.h +++ b/ngx_rtmp_cmd_module.h @@ -43,6 +43,7 @@ typedef struct { typedef struct { u_char name[256]; u_char type[16]; + int silent; } ngx_rtmp_publish_t; @@ -61,6 +62,7 @@ typedef struct { double start; double duration; int reset; + int silent; } ngx_rtmp_play_t; diff --git a/ngx_rtmp_relay_module.c b/ngx_rtmp_relay_module.c index 1e12ef7..e8a6787 100644 --- a/ngx_rtmp_relay_module.c +++ b/ngx_rtmp_relay_module.c @@ -514,6 +514,7 @@ ngx_rtmp_relay_play_local(ngx_rtmp_session_t *s) } ngx_memzero(&v, sizeof(ngx_rtmp_play_t)); + v.silent = 1; *(ngx_cpymem(v.name, ctx->name.data, ngx_min(sizeof(v.name) - 1, ctx->name.len))) = 0; @@ -533,6 +534,7 @@ ngx_rtmp_relay_publish_local(ngx_rtmp_session_t *s) } ngx_memzero(&v, sizeof(ngx_rtmp_publish_t)); + v.silent = 1; *(ngx_cpymem(v.name, ctx->name.data, ngx_min(sizeof(v.name) - 1, ctx->name.len))) = 0;