this version compiled on windows

This commit is contained in:
Roman Arutyunyan
2013-06-11 20:31:07 +04:00
parent 289ee42c53
commit 658f5ec639
28 changed files with 226 additions and 135 deletions

View File

@ -3,6 +3,8 @@
*/
#include <ngx_config.h>
#include <ngx_core.h>
#include <ngx_rtmp.h>
#include <ngx_rtmp_cmd_module.h>
#include <ngx_rtmp_codec_module.h>
@ -334,7 +336,7 @@ static ngx_int_t
ngx_rtmp_hls_write_playlist(ngx_rtmp_session_t *s)
{
static u_char buffer[1024];
int fd;
ngx_fd_t fd;
u_char *p;
ngx_rtmp_hls_ctx_t *ctx;
ssize_t n;
@ -375,7 +377,7 @@ retry:
for (i = 0; i < ctx->nfrags; i++) {
f = ngx_rtmp_hls_get_frag(s, i);
if (f->duration > max_frag) {
max_frag = f->duration + .5;
max_frag = (ngx_uint_t) (f->duration + .5);
}
}
@ -386,7 +388,7 @@ retry:
"#EXT-X-TARGETDURATION:%ui\n",
ctx->frag, max_frag);
n = write(fd, buffer, p - buffer);
n = ngx_write_fd(fd, buffer, p - buffer);
if (n < 0) {
ngx_log_error(NGX_LOG_ERR, s->connection->log, ngx_errno,
"hls: write failed: '%V'", &ctx->playlist_bak);
@ -411,7 +413,7 @@ retry:
"discont=%i",
ctx->frag, i + 1, ctx->nfrags, f->duration, f->discont);
n = write(fd, buffer, p - buffer);
n = ngx_write_fd(fd, buffer, p - buffer);
if (n < 0) {
ngx_log_error(NGX_LOG_ERR, s->connection->log, ngx_errno,
"hls: write failed '%V'", &ctx->playlist_bak);
@ -807,7 +809,8 @@ ngx_rtmp_hls_restore_stream(ngx_rtmp_session_t *s)
if (ngx_memcmp(p, NGX_RTMP_MSEQ, NGX_RTMP_MSEQ_LEN) == 0) {
ctx->frag = strtod((const char *) &p[NGX_RTMP_MSEQ_LEN], NULL);
ctx->frag = (uint64_t) strtod((const char *)
&p[NGX_RTMP_MSEQ_LEN], NULL);
ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
"hls: restore sequence frag=%uL", ctx->frag);
@ -1323,10 +1326,11 @@ ngx_rtmp_hls_audio(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
p[0] = 0xff;
p[1] = 0xf1;
p[2] = ((objtype - 1) << 6) | (srindex << 2) | ((chconf & 0x04) >> 2);
p[3] = ((chconf & 0x03) << 6) | ((size >> 11) & 0x03);
p[4] = (size >> 3);
p[5] = (size << 5) | 0x1f;
p[2] = (u_char) (((objtype - 1) << 6) | (srindex << 2) |
((chconf & 0x04) >> 2));
p[3] = (u_char) (((chconf & 0x03) << 6) | ((size >> 11) & 0x03));
p[4] = (u_char) (size >> 3);
p[5] = (u_char) (size << 5) | 0x1f;
p[6] = 0xfc;
if (p != b->start) {
@ -1810,17 +1814,17 @@ ngx_rtmp_hls_create_app_conf(ngx_conf_t *cf)
}
conf->hls = NGX_CONF_UNSET;
conf->fraglen = NGX_CONF_UNSET;
conf->max_fraglen = NGX_CONF_UNSET;
conf->muxdelay = NGX_CONF_UNSET;
conf->sync = NGX_CONF_UNSET;
conf->playlen = NGX_CONF_UNSET;
conf->fraglen = NGX_CONF_UNSET_MSEC;
conf->max_fraglen = NGX_CONF_UNSET_MSEC;
conf->muxdelay = NGX_CONF_UNSET_MSEC;
conf->sync = NGX_CONF_UNSET_MSEC;
conf->playlen = NGX_CONF_UNSET_MSEC;
conf->continuous = NGX_CONF_UNSET;
conf->nested = NGX_CONF_UNSET;
conf->naming = NGX_CONF_UNSET_UINT;
conf->slicing = NGX_CONF_UNSET_UINT;
conf->max_audio_delay = NGX_CONF_UNSET;
conf->audio_buffer_size = NGX_CONF_UNSET;
conf->max_audio_delay = NGX_CONF_UNSET_MSEC;
conf->audio_buffer_size = NGX_CONF_UNSET_SIZE;
conf->cleanup = NGX_CONF_UNSET;
return conf;

View File

@ -3,6 +3,8 @@
*/
#include <ngx_config.h>
#include <ngx_core.h>
#include "ngx_rtmp_mpegts.h"
@ -87,11 +89,11 @@ ngx_rtmp_mpegts_write_header(ngx_file_t *file)
static u_char *
ngx_rtmp_mpegts_write_pcr(u_char *p, uint64_t pcr)
{
*p++ = pcr >> 25;
*p++ = pcr >> 17;
*p++ = pcr >> 9;
*p++ = pcr >> 1;
*p++ = pcr << 7 | 0x7e;
*p++ = (u_char) (pcr >> 25);
*p++ = (u_char) (pcr >> 17);
*p++ = (u_char) (pcr >> 9);
*p++ = (u_char) (pcr >> 1);
*p++ = (u_char) (pcr << 7 | 0x7e);
*p++ = 0;
return p;
@ -104,15 +106,15 @@ ngx_rtmp_mpegts_write_pts(u_char *p, ngx_uint_t fb, uint64_t pts)
ngx_uint_t val;
val = fb << 4 | (((pts >> 30) & 0x07) << 1) | 1;
*p++ = val;
*p++ = (u_char) val;
val = (((pts >> 15) & 0x7fff) << 1) | 1;
*p++ = val >> 8;
*p++ = val;
*p++ = (u_char) (val >> 8);
*p++ = (u_char) val;
val = (((pts) & 0x7fff) << 1) | 1;
*p++ = val >> 8;
*p++ = val;
*p++ = (u_char) (val >> 8);
*p++ = (u_char) val;
return p;
}
@ -140,13 +142,13 @@ ngx_rtmp_mpegts_write_frame(ngx_file_t *file, ngx_rtmp_mpegts_frame_t *f,
f->cc++;
*p++ = 0x47;
*p++ = (f->pid >> 8);
*p++ = (u_char) (f->pid >> 8);
if (first) {
p[-1] |= 0x40;
}
*p++ = f->pid;
*p++ = (u_char) f->pid;
*p++ = 0x10 | (f->cc & 0x0f); /* payload */
if (first) {
@ -165,7 +167,7 @@ ngx_rtmp_mpegts_write_frame(ngx_file_t *file, ngx_rtmp_mpegts_frame_t *f,
*p++ = 0x00;
*p++ = 0x00;
*p++ = 0x01;
*p++ = f->sid;
*p++ = (u_char) f->sid;
header_size = 5;
flags = 0x80; /* PTS */
@ -180,11 +182,11 @@ ngx_rtmp_mpegts_write_frame(ngx_file_t *file, ngx_rtmp_mpegts_frame_t *f,
pes_size = 0;
}
*p++ = (pes_size >> 8);
*p++ = pes_size;
*p++ = (u_char) (pes_size >> 8);
*p++ = (u_char) pes_size;
*p++ = 0x80; /* H222 */
*p++ = flags;
*p++ = header_size;
*p++ = (u_char) flags;
*p++ = (u_char) header_size;
p = ngx_rtmp_mpegts_write_pts(p, flags >> 6, f->pts +
NGX_RTMP_HLS_DELAY);
@ -214,7 +216,7 @@ ngx_rtmp_mpegts_write_frame(ngx_file_t *file, ngx_rtmp_mpegts_frame_t *f,
base = &packet[5] + packet[4];
p = ngx_movemem(base + stuff_size, base, p - base);
ngx_memset(base, 0xff, stuff_size);
packet[4] += stuff_size;
packet[4] += (u_char) stuff_size;
} else {
@ -224,7 +226,7 @@ ngx_rtmp_mpegts_write_frame(ngx_file_t *file, ngx_rtmp_mpegts_frame_t *f,
p = ngx_movemem(&packet[4] + stuff_size, &packet[4],
p - &packet[4]);
packet[4] = stuff_size - 1;
packet[4] = (u_char) (stuff_size - 1);
if (stuff_size >= 2) {
packet[5] = 0;
ngx_memset(&packet[6], 0xff, stuff_size - 2);

View File

@ -16,6 +16,12 @@
#include "ngx_rtmp_bandwidth.h"
#if (NGX_WIN32)
typedef unsigned __int8 uint8_t;
typedef __int8 int8_t;
#endif
typedef struct {
void **main_conf;
void **srv_conf;
@ -241,7 +247,7 @@ typedef struct {
unsigned out_buffer:1;
size_t out_queue;
size_t out_cork;
ngx_chain_t *out[0];
ngx_chain_t *out[1];
} ngx_rtmp_session_t;
@ -391,24 +397,25 @@ void * ngx_rtmp_rmemcpy(void *dst, const void* src, size_t n);
(((u_char*)ngx_rtmp_rmemcpy(dst, src, n)) + (n))
static inline uint16_t
static ngx_inline uint16_t
ngx_rtmp_r16(uint16_t n)
{
return (n << 8) | (n >> 8);
}
static inline uint32_t
static ngx_inline uint32_t
ngx_rtmp_r32(uint32_t n)
{
return (n << 24) | ((n << 8) & 0xff0000) | ((n >> 8) & 0xff00) | (n >> 24);
}
static inline uint64_t
static ngx_inline uint64_t
ngx_rtmp_r64(uint64_t n)
{
return (uint64_t) ngx_rtmp_r32(n) << 32 | ngx_rtmp_r32(n >> 32);
return (uint64_t) ngx_rtmp_r32((uint32_t) n) << 32 |
ngx_rtmp_r32((uint32_t) (n >> 32));
}
@ -557,14 +564,14 @@ ngx_int_t ngx_rtmp_send_sample_access(ngx_rtmp_session_t *s);
#define NGX_RTMP_VIDEO_DISPOSABLE_FRAME 3
static inline ngx_int_t
static ngx_inline ngx_int_t
ngx_rtmp_get_video_frame_type(ngx_chain_t *in)
{
return (in->buf->pos[0] & 0xf0) >> 4;
}
static inline ngx_int_t
static ngx_inline ngx_int_t
ngx_rtmp_is_codec_header(ngx_chain_t *in)
{
return in->buf->pos + 1 < in->buf->last && in->buf->pos[1] == 0;

View File

@ -2,11 +2,14 @@
* Copyright (c) 2012 Roman Arutyunyan
*/
#include <ngx_config.h>
#include <ngx_core.h>
#include "ngx_rtmp_amf.h"
#include "ngx_rtmp.h"
#include <string.h>
static inline void*
static ngx_inline void*
ngx_rtmp_amf_reverse_copy(void *dst, void* src, size_t len)
{
size_t k;
@ -183,7 +186,8 @@ ngx_rtmp_amf_read_object(ngx_rtmp_amf_ctx_t *ctx, ngx_rtmp_amf_elt_t *elts,
for(;;) {
char name[maxlen];
/*FIXME!*/
char name[123/*maxlen*/];
/* read key */
if (ngx_rtmp_amf_get(ctx, buf, 2) != NGX_OK)
@ -318,7 +322,8 @@ ngx_rtmp_amf_read(ngx_rtmp_amf_ctx_t *ctx, ngx_rtmp_amf_elt_t *elts,
}
type = type8;
data = (elts &&
ngx_rtmp_amf_is_compatible_type(elts->type & 0xff, type))
ngx_rtmp_amf_is_compatible_type(elts->type & 0xff,
(uint8_t) type))
? elts->data
: NULL;
@ -453,7 +458,7 @@ ngx_rtmp_amf_write_object(ngx_rtmp_amf_ctx_t *ctx,
for(n = 0; n < nelts; ++n) {
len = elts[n].name.len;
len = (uint16_t) elts[n].name.len;
if (ngx_rtmp_amf_put(ctx,
ngx_rtmp_amf_reverse_copy(buf,
@ -521,7 +526,7 @@ ngx_rtmp_amf_write(ngx_rtmp_amf_ctx_t *ctx,
type = elts[n].type;
data = elts[n].data;
len = elts[n].len;
len = (uint16_t) elts[n].len;
if (type & NGX_RTMP_AMF_TYPELESS) {
type &= ~NGX_RTMP_AMF_TYPELESS;
@ -549,7 +554,7 @@ ngx_rtmp_amf_write(ngx_rtmp_amf_ctx_t *ctx,
case NGX_RTMP_AMF_STRING:
if (len == 0 && data) {
len = ngx_strlen((u_char*)data);
len = (uint16_t) ngx_strlen((u_char*)data);
}
if (ngx_rtmp_amf_put(ctx,

View File

@ -3,6 +3,8 @@
*/
#include <ngx_config.h>
#include <ngx_core.h>
#include "ngx_rtmp_cmd_module.h"
#include "ngx_rtmp_relay_module.h"
@ -269,7 +271,7 @@ ngx_rtmp_auto_push_create_conf(ngx_cycle_t *cycle)
}
apcf->auto_push = NGX_CONF_UNSET;
apcf->push_reconnect = NGX_CONF_UNSET;
apcf->push_reconnect = NGX_CONF_UNSET_MSEC;
return apcf;
}
@ -291,6 +293,7 @@ ngx_rtmp_auto_push_init_conf(ngx_cycle_t *cycle, void *conf)
}
#if !(NGX_WIN32)
static void
ngx_rtmp_auto_push_reconnect(ngx_event_t *ev)
{
@ -486,7 +489,6 @@ next:
return next_publish(s, v);
}
static ngx_int_t
ngx_rtmp_auto_push_delete_stream(ngx_rtmp_session_t *s,
ngx_rtmp_delete_stream_t *v)
@ -541,3 +543,4 @@ ngx_rtmp_auto_push_delete_stream(ngx_rtmp_session_t *s,
next:
return next_delete_stream(s, v);
}
#endif

View File

@ -3,6 +3,8 @@
*/
#include <ngx_config.h>
#include <ngx_core.h>
#include "ngx_rtmp_bandwidth.h"

View File

@ -2,6 +2,9 @@
* Copyright (c) 2012 Roman Arutyunyan
*/
#include <ngx_config.h>
#include <ngx_core.h>
#include "ngx_rtmp_cmd_module.h"
#include "ngx_rtmp_streams.h"
@ -285,8 +288,8 @@ ngx_rtmp_cmd_connect(ngx_rtmp_session_t *s, ngx_rtmp_connect_t *v)
s->app.len = (p - s->app.data);
}
s->acodecs = v->acodecs;
s->vcodecs = v->vcodecs;
s->acodecs = (uint32_t) v->acodecs;
s->vcodecs = (uint32_t) v->vcodecs;
/* find application & set app_conf */
cacfp = cscf->applications.elts;

View File

@ -3,6 +3,8 @@
*/
#include <ngx_config.h>
#include <ngx_core.h>
#include "ngx_rtmp_codec_module.h"
#include "ngx_rtmp_live_module.h"
#include "ngx_rtmp_cmd_module.h"
@ -530,16 +532,16 @@ ngx_rtmp_codec_meta_data(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
return NGX_OK;
}
ctx->width = v.width;
ctx->height = v.height;
ctx->duration = v.duration;
ctx->frame_rate = v.frame_rate;
ctx->video_data_rate = v.video_data_rate;
ctx->video_codec_id = v.video_codec_id_n;
ctx->audio_data_rate = v.audio_data_rate;
ctx->width = (ngx_uint_t) v.width;
ctx->height = (ngx_uint_t) v.height;
ctx->duration = (ngx_uint_t) v.duration;
ctx->frame_rate = (ngx_uint_t) v.frame_rate;
ctx->video_data_rate = (ngx_uint_t) v.video_data_rate;
ctx->video_codec_id = (ngx_uint_t) v.video_codec_id_n;
ctx->audio_data_rate = (ngx_uint_t) v.audio_data_rate;
ctx->audio_codec_id = (v.audio_codec_id_n == -1
? 0 : v.audio_codec_id_n == 0
? NGX_RTMP_AUDIO_UNCOMPRESSED : v.audio_codec_id_n);
? NGX_RTMP_AUDIO_UNCOMPRESSED : (ngx_uint_t) v.audio_codec_id_n);
ngx_memcpy(ctx->profile, v.profile, sizeof(v.profile));
ngx_memcpy(ctx->level, v.level, sizeof(v.level));

View File

@ -3,7 +3,8 @@
*/
#include <nginx.h>
#include <ngx_config.h>
#include <ngx_core.h>
#include <ngx_http.h>
#include "ngx_rtmp.h"

View File

@ -233,10 +233,10 @@ ngx_rtmp_core_create_srv_conf(ngx_conf_t *cf)
conf->so_keepalive = NGX_CONF_UNSET;
conf->max_streams = NGX_CONF_UNSET;
conf->chunk_size = NGX_CONF_UNSET;
conf->ack_window = NGX_CONF_UNSET;
conf->max_message = NGX_CONF_UNSET;
conf->out_queue = NGX_CONF_UNSET;
conf->out_cork = NGX_CONF_UNSET;
conf->ack_window = NGX_CONF_UNSET_UINT;
conf->max_message = NGX_CONF_UNSET_SIZE;
conf->out_queue = NGX_CONF_UNSET_SIZE;
conf->out_cork = NGX_CONF_UNSET_SIZE;
conf->play_time_fix = NGX_CONF_UNSET;
conf->publish_time_fix = NGX_CONF_UNSET;
conf->busy = NGX_CONF_UNSET;

View File

@ -3,6 +3,8 @@
*/
#include <ngx_config.h>
#include <ngx_core.h>
#include "ngx_rtmp_eval.h"
@ -103,7 +105,7 @@ ngx_int_t
ngx_rtmp_eval(ngx_rtmp_session_t *s, ngx_str_t *in, ngx_rtmp_eval_t **e,
ngx_str_t *out)
{
u_char c, *p;;
u_char c, *p;
ngx_str_t name;
ngx_buf_t b;
ngx_uint_t n;
@ -122,6 +124,8 @@ ngx_rtmp_eval(ngx_rtmp_session_t *s, ngx_str_t *in, ngx_rtmp_eval_t **e,
}
b.end = b.pos + NGX_RTMP_EVAL_BUFLEN;
name.data = NULL;
name.len = 0;
for (n = 0; n < in->len; ++n) {
p = &in->data[n];
@ -266,8 +270,11 @@ ngx_rtmp_eval_streams(ngx_str_t *in)
return NGX_OK;
}
#if !(NGX_WIN32)
/*FIXME*/
dup2(src, dst);
#endif
if (close_src) {
ngx_close_file(src);
}

View File

@ -3,6 +3,8 @@
*/
#include <ngx_config.h>
#include <ngx_core.h>
#include "ngx_rtmp_cmd_module.h"
#include "ngx_rtmp_eval.h"
#include <stdlib.h>
@ -225,9 +227,11 @@ ngx_rtmp_exec_init_main_conf(ngx_conf_t *cf, void *conf)
emcf->respawn_timeout = 5000;
}
#if !(NGX_WIN32)
if (emcf->kill_signal == NGX_CONF_UNSET) {
emcf->kill_signal = SIGKILL;
}
#endif
if (ngx_array_init(&emcf->execs, cf->pool, emcf->confs.nelts,
sizeof(ngx_rtmp_exec_t)) != NGX_OK)
@ -316,10 +320,11 @@ ngx_rtmp_exec_init_process(ngx_cycle_t *cycle)
}
/* execs are always started by the first worker */
if (ngx_process_slot) {
#if !(NGX_WIN32)
if (ngx_process_slot) {
return NGX_OK;
}
#endif
cscf = cmcf->servers.elts;
cctx = (*cscf)->ctx;
emcf = cctx->main_conf[ngx_rtmp_exec_module.ctx_index];
@ -354,6 +359,7 @@ ngx_rtmp_exec_respawn(ngx_event_t *ev)
}
#if !(NGX_WIN32)
static void
ngx_rtmp_exec_child_dead(ngx_event_t *ev)
{
@ -387,7 +393,7 @@ ngx_rtmp_exec_child_dead(ngx_event_t *ev)
ngx_add_timer(&e->respawn_evt, e->respawn_timeout);
}
#endif
static ngx_int_t
ngx_rtmp_exec_kill(ngx_rtmp_exec_t *e, ngx_int_t kill_signal)
@ -409,7 +415,9 @@ ngx_rtmp_exec_kill(ngx_rtmp_exec_t *e, ngx_int_t kill_signal)
(ngx_int_t) e->pid);
e->active = 0;
#if !(NGX_WIN32)
close(e->pipefd);
#endif
if (e->save_pid) {
*e->save_pid = NGX_INVALID_PID;
}
@ -417,7 +425,7 @@ ngx_rtmp_exec_kill(ngx_rtmp_exec_t *e, ngx_int_t kill_signal)
if (kill_signal == 0) {
return NGX_OK;
}
#if !(NGX_WIN32)
if (kill(e->pid, kill_signal) == -1) {
ngx_log_error(NGX_LOG_INFO, e->log, ngx_errno,
"exec: kill failed pid=%i", (ngx_int_t) e->pid);
@ -425,7 +433,7 @@ ngx_rtmp_exec_kill(ngx_rtmp_exec_t *e, ngx_int_t kill_signal)
ngx_log_debug1(NGX_LOG_DEBUG_RTMP, e->log, 0,
"exec: killed pid=%i", (ngx_int_t) e->pid);
}
#endif
return NGX_OK;
}
@ -765,6 +773,7 @@ ngx_rtmp_exec_kill_signal(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
return NGX_CONF_OK;
}
#if !(NGX_WIN32)
#define NGX_RMTP_EXEC_SIGNAL(name) \
if (value->len == sizeof(#name) - 1 && \
ngx_strncasecmp(value->data, (u_char *) #name, value->len) == 0) \
@ -797,6 +806,8 @@ ngx_rtmp_exec_kill_signal(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
#undef NGX_RMTP_EXEC_SIGNAL
#endif /* NGX_WIN32 */
return "unknown signal";
}

View File

@ -3,6 +3,8 @@
*/
#include <ngx_config.h>
#include <ngx_core.h>
#include "ngx_rtmp_play_module.h"
#include "ngx_rtmp_codec_module.h"
#include "ngx_rtmp_streams.h"
@ -289,7 +291,7 @@ ngx_rtmp_flv_timestamp_to_offset(ngx_rtmp_session_t *s, ngx_file_t *f,
goto rewind;
}
ret = ngx_rtmp_flv_index_value(ngx_rtmp_flv_buffer);
ret = (ngx_uint_t) ngx_rtmp_flv_index_value(ngx_rtmp_flv_buffer);
ngx_log_debug2(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
"flv: lookup index timestamp=%i offset=%ui",

View File

@ -3,6 +3,8 @@
*/
#include <ngx_config.h>
#include <ngx_core.h>
#include "ngx_rtmp.h"
#include "ngx_rtmp_amf.h"

View File

@ -2,7 +2,8 @@
* Copyright (c) 2012 Roman Arutyunyan
*/
#include <ngx_config.h>
#include <ngx_core.h>
#include "ngx_rtmp.h"
#include <openssl/hmac.h>
@ -182,7 +183,7 @@ static void
ngx_rtmp_fill_random_buffer(ngx_buf_t *b)
{
for (; b->last != b->end; ++b->last) {
*b->last = rand();
*b->last = (u_char) rand();
}
}

View File

@ -3,6 +3,8 @@
*/
#include <ngx_config.h>
#include <ngx_core.h>
#include "ngx_rtmp.h"

View File

@ -3,6 +3,8 @@
*/
#include <ngx_config.h>
#include <ngx_core.h>
#include "ngx_rtmp.h"

View File

@ -3,6 +3,8 @@
*/
#include <ngx_config.h>
#include <ngx_core.h>
#include "ngx_rtmp_live_module.h"
#include "ngx_rtmp_cmd_module.h"
#include "ngx_rtmp_codec_module.h"
@ -150,9 +152,9 @@ ngx_rtmp_live_create_app_conf(ngx_conf_t *cf)
lacf->live = NGX_CONF_UNSET;
lacf->meta = NGX_CONF_UNSET;
lacf->nbuckets = NGX_CONF_UNSET;
lacf->buflen = NGX_CONF_UNSET;
lacf->sync = NGX_CONF_UNSET;
lacf->idle_timeout = NGX_CONF_UNSET;
lacf->buflen = NGX_CONF_UNSET_MSEC;
lacf->sync = NGX_CONF_UNSET_MSEC;
lacf->idle_timeout = NGX_CONF_UNSET_MSEC;
lacf->interleave = NGX_CONF_UNSET;
lacf->wait_key = NGX_CONF_UNSET;
lacf->wait_video = NGX_CONF_UNSET;

View File

@ -3,6 +3,8 @@
*/
#include <ngx_config.h>
#include <ngx_core.h>
#include "ngx_rtmp_cmd_module.h"

View File

@ -3,6 +3,8 @@
*/
#include <ngx_config.h>
#include <ngx_core.h>
#include "ngx_rtmp_play_module.h"
#include "ngx_rtmp_codec_module.h"
#include "ngx_rtmp_streams.h"
@ -34,7 +36,7 @@ typedef struct {
typedef struct {
uint32_t version_flags;
uint32_t entry_count;
ngx_rtmp_mp4_chunk_entry_t entries[0];
ngx_rtmp_mp4_chunk_entry_t entries[1]; /*FIXME*/
} ngx_rtmp_mp4_chunks_t;
@ -47,7 +49,7 @@ typedef struct {
typedef struct {
uint32_t version_flags;
uint32_t entry_count;
ngx_rtmp_mp4_time_entry_t entries[0];
ngx_rtmp_mp4_time_entry_t entries[1]; /*FIXME*/
} ngx_rtmp_mp4_times_t;
@ -60,14 +62,14 @@ typedef struct {
typedef struct {
uint32_t version_flags;
uint32_t entry_count;
ngx_rtmp_mp4_delay_entry_t entries[0];
ngx_rtmp_mp4_delay_entry_t entries[1]; /*FIXME*/
} ngx_rtmp_mp4_delays_t;
typedef struct {
uint32_t version_flags;
uint32_t entry_count;
uint32_t entries[0];
uint32_t entries[1]; /*FIXME*/
} ngx_rtmp_mp4_keys_t;
@ -75,7 +77,7 @@ typedef struct {
uint32_t version_flags;
uint32_t sample_size;
uint32_t sample_count;
uint32_t entries[0];
uint32_t entries[1]; /*FIXME*/
} ngx_rtmp_mp4_sizes_t;
@ -83,21 +85,21 @@ typedef struct {
uint32_t version_flags;
uint32_t field_size;
uint32_t sample_count;
uint32_t entries[0];
uint32_t entries[1]; /*FIXME*/
} ngx_rtmp_mp4_sizes2_t;
typedef struct {
uint32_t version_flags;
uint32_t entry_count;
uint32_t entries[0];
uint32_t entries[1]; /*FIXME*/
} ngx_rtmp_mp4_offsets_t;
typedef struct {
uint32_t version_flags;
uint32_t entry_count;
uint64_t entries[0];
uint64_t entries[1]; /*FIXME*/
} ngx_rtmp_mp4_offsets64_t;
#pragma pack(pop)
@ -185,14 +187,14 @@ typedef struct {
((uint32_t)d << 24 | (uint32_t)c << 16 | (uint32_t)b << 8 | (uint32_t)a)
static inline uint32_t
ngx_rtmp_mp4_to_rtmp_timestamp(ngx_rtmp_mp4_track_t *t, uint32_t ts)
static ngx_inline uint32_t
ngx_rtmp_mp4_to_rtmp_timestamp(ngx_rtmp_mp4_track_t *t, uint64_t ts)
{
return (uint64_t) ts * 1000 / t->time_scale;
return (uint32_t) (ts * 1000 / t->time_scale);
}
static inline uint32_t
static ngx_inline uint32_t
ngx_rtmp_mp4_from_rtmp_timestamp(ngx_rtmp_mp4_track_t *t, uint32_t ts)
{
return (uint64_t) ts * t->time_scale / 1000;
@ -537,7 +539,7 @@ ngx_rtmp_mp4_parse_video(ngx_rtmp_session_t *s, u_char *pos, u_char *last,
return NGX_ERROR;
}
ctx->track->fhdr = ctx->track->codec;
ctx->track->fhdr = (u_char) ctx->track->codec;
return NGX_OK;
}
@ -1350,7 +1352,7 @@ ngx_rtmp_mp4_update_offset(ngx_rtmp_session_t *s, ngx_rtmp_mp4_track_t *t)
return NGX_ERROR;
}
cr->offset = ngx_rtmp_r32(t->offsets64->entries[chunk]);
cr->offset = ngx_rtmp_r64(t->offsets64->entries[chunk]);
cr->size = 0;
ngx_log_debug4(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
@ -2041,7 +2043,7 @@ ngx_rtmp_mp4_send(ngx_rtmp_session_t *s, ngx_file_t *f, ngx_uint_t *ts)
ngx_memzero(&h, sizeof(h));
h.msid = NGX_RTMP_MSID;
h.type = t->type;
h.type = (uint8_t) t->type;
h.csid = t->csid;
lh = h;
@ -2246,7 +2248,7 @@ ngx_rtmp_mp4_init(ngx_rtmp_session_t *s, ngx_file_t *f, ngx_int_t aindex,
return NGX_ERROR;
}
size = ngx_rtmp_r64(extended_size);
size = (size_t) ngx_rtmp_r64(extended_size);
shift += sizeof(extended_size);
} else if (size == 0) {
@ -2280,6 +2282,8 @@ ngx_rtmp_mp4_init(ngx_rtmp_session_t *s, ngx_file_t *f, ngx_int_t aindex,
page_offset = offset & (ngx_pagesize - 1);
ctx->mmaped_size = page_offset + size;
#if !(NGX_WIN32)
/*FIXME: ngx_create_file_mapping */
ctx->mmaped = mmap(NULL, ctx->mmaped_size, PROT_READ, MAP_SHARED,
f->fd, offset - page_offset);
@ -2290,6 +2294,7 @@ ngx_rtmp_mp4_init(ngx_rtmp_session_t *s, ngx_file_t *f, ngx_int_t aindex,
offset, size);
return NGX_ERROR;
}
#endif
return ngx_rtmp_mp4_parse(s, (u_char *) ctx->mmaped + page_offset,
(u_char *) ctx->mmaped + page_offset + size);
@ -2307,12 +2312,14 @@ ngx_rtmp_mp4_done(ngx_rtmp_session_t *s, ngx_file_t *f)
return NGX_OK;
}
#if !(NGX_WIN32)
/*FIXME: ngx_file_mapping */
if (munmap(ctx->mmaped, ctx->mmaped_size)) {
ngx_log_error(NGX_LOG_ERR, s->connection->log, ngx_errno,
"mp4: munmap failed");
return NGX_ERROR;
}
#endif
ctx->mmaped = NULL;
ctx->mmaped_size = 0;

View File

@ -237,8 +237,8 @@ ngx_rtmp_notify_create_app_conf(ngx_conf_t *cf)
nacf->url[n] = NGX_CONF_UNSET_PTR;
}
nacf->method = NGX_CONF_UNSET;
nacf->update_timeout = NGX_CONF_UNSET;
nacf->method = NGX_CONF_UNSET_UINT;
nacf->update_timeout = NGX_CONF_UNSET_MSEC;
nacf->update_strict = NGX_CONF_UNSET;
nacf->relay_redirect = NGX_CONF_UNSET;
@ -290,7 +290,7 @@ ngx_rtmp_notify_create_srv_conf(ngx_conf_t *cf)
nscf->url[n] = NGX_CONF_UNSET_PTR;
}
nscf->method = NGX_CONF_UNSET;
nscf->method = NGX_CONF_UNSET_UINT;
return nscf;
}

View File

@ -3,6 +3,8 @@
*/
#include <ngx_config.h>
#include <ngx_core.h>
#include "ngx_rtmp_play_module.h"
#include "ngx_rtmp_cmd_module.h"
#include "ngx_rtmp_netcall_module.h"
@ -576,7 +578,7 @@ ngx_rtmp_play_seek(ngx_rtmp_session_t *s, ngx_rtmp_seek_t *v)
}
if (!ctx->opened) {
ctx->post_seek = v->offset;
ctx->post_seek = (ngx_uint_t) v->offset;
ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
"play: post seek=%ui", ctx->post_seek);
goto next;
@ -586,7 +588,7 @@ ngx_rtmp_play_seek(ngx_rtmp_session_t *s, ngx_rtmp_seek_t *v)
return NGX_ERROR;
}
ngx_rtmp_play_do_seek(s, v->offset);
ngx_rtmp_play_do_seek(s, (ngx_uint_t) v->offset);
if (ngx_rtmp_send_status(s, "NetStream.Seek.Notify", "status", "Seeking")
!= NGX_OK)

View File

@ -3,6 +3,8 @@
*/
#include <ngx_config.h>
#include <ngx_core.h>
#include "ngx_rtmp.h"
#include "ngx_rtmp_amf.h"
#include "ngx_rtmp_cmd_module.h"
@ -208,8 +210,6 @@ ngx_rtmp_user_message_handler(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
return NGX_OK;
}
return NGX_OK;
}

View File

@ -188,9 +188,9 @@ ngx_rtmp_record_create_app_conf(ngx_conf_t *cf)
return NULL;
}
racf->max_size = NGX_CONF_UNSET;
racf->max_frames = NGX_CONF_UNSET;
racf->interval = NGX_CONF_UNSET;
racf->max_size = NGX_CONF_UNSET_SIZE;
racf->max_frames = NGX_CONF_UNSET_SIZE;
racf->interval = NGX_CONF_UNSET_MSEC;
racf->unique = NGX_CONF_UNSET;
racf->append = NGX_CONF_UNSET;
racf->lock_file = NGX_CONF_UNSET;
@ -371,7 +371,7 @@ ngx_rtmp_record_make_path(ngx_rtmp_session_t *s,
ngx_rtmp_record_ctx_t *ctx;
ngx_rtmp_record_app_conf_t *rracf;
u_char *p, *l;
ngx_tm_t tm;
struct tm tm;
static u_char buf[NGX_TIME_T_LEN + 1];
static u_char pbuf[NGX_MAX_PATH + 1];
@ -482,6 +482,7 @@ ngx_rtmp_record_node_open(ngx_rtmp_session_t *s,
return NGX_OK;
}
#if !(NGX_WIN32)
if (rracf->lock_file) {
err = ngx_lock_fd(rctx->file.fd);
if (err) {
@ -489,6 +490,7 @@ ngx_rtmp_record_node_open(ngx_rtmp_session_t *s,
"record: %V lock failed", &rracf->id);
}
}
#endif
ngx_log_debug2(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
"record: %V opened '%V'", &rracf->id, &path);
@ -503,7 +505,18 @@ ngx_rtmp_record_node_open(ngx_rtmp_session_t *s,
file_size = 0;
timestamp = 0;
#if (NGX_WIN32)
{
LONG lo, hi;
lo = 0;
hi = 0;
lo = SetFilePointer(rctx->file.fd, lo, &hi, FILE_END);
file_size = (lo == INVALID_SET_FILE_POINTER ?
(off_t) -1 : (off_t) hi << 32 | (off_t) lo);
}
#else
file_size = lseek(rctx->file.fd, 0, SEEK_END);
#endif
if (file_size == (off_t) -1) {
ngx_log_error(NGX_LOG_CRIT, s->connection->log, ngx_errno,
"record: %V seek failed", &rracf->id);

View File

@ -3,6 +3,8 @@
*/
#include <ngx_config.h>
#include <ngx_core.h>
#include "ngx_rtmp_relay_module.h"
#include "ngx_rtmp_cmd_module.h"
@ -184,10 +186,10 @@ ngx_rtmp_relay_create_app_conf(ngx_conf_t *cf)
racf->nbuckets = 1024;
racf->log = &cf->cycle->new_log;
racf->buflen = NGX_CONF_UNSET;
racf->buflen = NGX_CONF_UNSET_MSEC;
racf->session_relay = NGX_CONF_UNSET;
racf->push_reconnect = NGX_CONF_UNSET;
racf->pull_reconnect = NGX_CONF_UNSET;
racf->push_reconnect = NGX_CONF_UNSET_MSEC;
racf->pull_reconnect = NGX_CONF_UNSET_MSEC;
return racf;
}
@ -1610,9 +1612,11 @@ ngx_rtmp_relay_init_process(ngx_cycle_t *cycle)
/* only first worker does static pulling */
#if !(NGX_WIN32)
if (ngx_process_slot) {
return NGX_OK;
}
#endif
lst = cmcf->listen.elts;

View File

@ -3,6 +3,8 @@
*/
#include <ngx_config.h>
#include <ngx_core.h>
#include "ngx_rtmp.h"
#include "ngx_rtmp_amf.h"
#include "ngx_rtmp_streams.h"
@ -69,12 +71,12 @@ ngx_rtmp_send_shared_packet(ngx_rtmp_session_t *s, ngx_chain_t *cl)
ngx_chain_t *
ngx_rtmp_create_chunk_size(ngx_rtmp_session_t *s, uint32_t chunk_size)
{
NGX_RTMP_USER_START(s, NGX_RTMP_MSG_CHUNK_SIZE);
ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
"chunk_size=%uD", chunk_size);
NGX_RTMP_USER_START(s, NGX_RTMP_MSG_CHUNK_SIZE);
NGX_RTMP_USER_OUT4(chunk_size);
NGX_RTMP_USER_OUT4(chunk_size);
NGX_RTMP_USER_END(s);
}
@ -91,11 +93,11 @@ ngx_rtmp_send_chunk_size(ngx_rtmp_session_t *s, uint32_t chunk_size)
ngx_chain_t *
ngx_rtmp_create_abort(ngx_rtmp_session_t *s, uint32_t csid)
{
NGX_RTMP_USER_START(s, NGX_RTMP_MSG_CHUNK_SIZE);
ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
"create: abort csid=%uD", csid);
NGX_RTMP_USER_START(s, NGX_RTMP_MSG_CHUNK_SIZE);
NGX_RTMP_USER_OUT4(csid);
NGX_RTMP_USER_END(s);
@ -113,11 +115,11 @@ ngx_rtmp_send_abort(ngx_rtmp_session_t *s, uint32_t csid)
ngx_chain_t *
ngx_rtmp_create_ack(ngx_rtmp_session_t *s, uint32_t seq)
{
NGX_RTMP_USER_START(s, NGX_RTMP_MSG_ACK);
ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
"create: ack seq=%uD", seq);
NGX_RTMP_USER_START(s, NGX_RTMP_MSG_ACK);
NGX_RTMP_USER_OUT4(seq);
NGX_RTMP_USER_END(s);
@ -135,11 +137,11 @@ ngx_rtmp_send_ack(ngx_rtmp_session_t *s, uint32_t seq)
ngx_chain_t *
ngx_rtmp_create_ack_size(ngx_rtmp_session_t *s, uint32_t ack_size)
{
NGX_RTMP_USER_START(s, NGX_RTMP_MSG_ACK_SIZE);
ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
"create: ack_size=%uD", ack_size);
NGX_RTMP_USER_START(s, NGX_RTMP_MSG_ACK_SIZE);
NGX_RTMP_USER_OUT4(ack_size);
NGX_RTMP_USER_END(s);
@ -158,12 +160,12 @@ ngx_chain_t *
ngx_rtmp_create_bandwidth(ngx_rtmp_session_t *s, uint32_t ack_size,
uint8_t limit_type)
{
NGX_RTMP_USER_START(s, NGX_RTMP_MSG_BANDWIDTH);
ngx_log_debug2(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
"create: bandwidth ack_size=%uD limit=%d",
ack_size, (int)limit_type);
NGX_RTMP_USER_START(s, NGX_RTMP_MSG_BANDWIDTH);
NGX_RTMP_USER_OUT4(ack_size);
NGX_RTMP_USER_OUT1(limit_type);
@ -185,11 +187,11 @@ ngx_rtmp_send_bandwidth(ngx_rtmp_session_t *s, uint32_t ack_size,
ngx_chain_t *
ngx_rtmp_create_stream_begin(ngx_rtmp_session_t *s, uint32_t msid)
{
NGX_RTMP_UCTL_START(s, NGX_RTMP_MSG_USER, NGX_RTMP_USER_STREAM_BEGIN);
ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
"create: stream_begin msid=%uD", msid);
NGX_RTMP_UCTL_START(s, NGX_RTMP_MSG_USER, NGX_RTMP_USER_STREAM_BEGIN);
NGX_RTMP_USER_OUT4(msid);
NGX_RTMP_USER_END(s);
@ -207,10 +209,10 @@ ngx_rtmp_send_stream_begin(ngx_rtmp_session_t *s, uint32_t msid)
ngx_chain_t *
ngx_rtmp_create_stream_eof(ngx_rtmp_session_t *s, uint32_t msid)
{
NGX_RTMP_UCTL_START(s, NGX_RTMP_MSG_USER, NGX_RTMP_USER_STREAM_EOF);
ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
"create: stream_end msid=%uD", msid);
NGX_RTMP_UCTL_START(s, NGX_RTMP_MSG_USER, NGX_RTMP_USER_STREAM_EOF);
NGX_RTMP_USER_OUT4(msid);
@ -229,11 +231,11 @@ ngx_rtmp_send_stream_eof(ngx_rtmp_session_t *s, uint32_t msid)
ngx_chain_t *
ngx_rtmp_create_stream_dry(ngx_rtmp_session_t *s, uint32_t msid)
{
NGX_RTMP_UCTL_START(s, NGX_RTMP_MSG_USER, NGX_RTMP_USER_STREAM_DRY);
ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
"create: stream_dry msid=%uD", msid);
NGX_RTMP_UCTL_START(s, NGX_RTMP_MSG_USER, NGX_RTMP_USER_STREAM_DRY);
NGX_RTMP_USER_OUT4(msid);
NGX_RTMP_USER_END(s);
@ -252,12 +254,12 @@ ngx_chain_t *
ngx_rtmp_create_set_buflen(ngx_rtmp_session_t *s, uint32_t msid,
uint32_t buflen_msec)
{
NGX_RTMP_UCTL_START(s, NGX_RTMP_MSG_USER, NGX_RTMP_USER_SET_BUFLEN);
ngx_log_debug2(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
"create: set_buflen msid=%uD buflen=%uD",
msid, buflen_msec);
NGX_RTMP_UCTL_START(s, NGX_RTMP_MSG_USER, NGX_RTMP_USER_SET_BUFLEN);
NGX_RTMP_USER_OUT4(msid);
NGX_RTMP_USER_OUT4(buflen_msec);
@ -277,11 +279,11 @@ ngx_rtmp_send_set_buflen(ngx_rtmp_session_t *s, uint32_t msid,
ngx_chain_t *
ngx_rtmp_create_recorded(ngx_rtmp_session_t *s, uint32_t msid)
{
NGX_RTMP_UCTL_START(s, NGX_RTMP_MSG_USER, NGX_RTMP_USER_RECORDED);
ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
"create: recorded msid=%uD", msid);
NGX_RTMP_UCTL_START(s, NGX_RTMP_MSG_USER, NGX_RTMP_USER_RECORDED);
NGX_RTMP_USER_OUT4(msid);
NGX_RTMP_USER_END(s);
@ -299,11 +301,11 @@ ngx_rtmp_send_recorded(ngx_rtmp_session_t *s, uint32_t msid)
ngx_chain_t *
ngx_rtmp_create_ping_request(ngx_rtmp_session_t *s, uint32_t timestamp)
{
NGX_RTMP_UCTL_START(s, NGX_RTMP_MSG_USER, NGX_RTMP_USER_PING_REQUEST);
ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
"create: ping_request timestamp=%uD", timestamp);
NGX_RTMP_UCTL_START(s, NGX_RTMP_MSG_USER, NGX_RTMP_USER_PING_REQUEST);
NGX_RTMP_USER_OUT4(timestamp);
NGX_RTMP_USER_END(s);
@ -321,11 +323,11 @@ ngx_rtmp_send_ping_request(ngx_rtmp_session_t *s, uint32_t timestamp)
ngx_chain_t *
ngx_rtmp_create_ping_response(ngx_rtmp_session_t *s, uint32_t timestamp)
{
NGX_RTMP_UCTL_START(s, NGX_RTMP_MSG_USER, NGX_RTMP_USER_PING_RESPONSE);
ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
"create: ping_response timestamp=%uD", timestamp);
NGX_RTMP_UCTL_START(s, NGX_RTMP_MSG_USER, NGX_RTMP_USER_PING_RESPONSE);
NGX_RTMP_USER_OUT4(timestamp);
NGX_RTMP_USER_END(s);

View File

@ -3,6 +3,8 @@
*/
#include <ngx_config.h>
#include <ngx_core.h>
#include "ngx_rtmp.h"

View File

@ -3,7 +3,8 @@
*/
#include <nginx.h>
#include <ngx_config.h>
#include <ngx_core.h>
#include <ngx_http.h>
#include "ngx_rtmp.h"