mirror of
https://github.com/zotanmew/nginx-rtmp-module.git
synced 2024-05-09 22:11:08 +02:00
renamed AMF0 to AMF
This commit is contained in:
parent
bf7d0acad2
commit
38c7cf3137
2
config
2
config
|
@ -13,7 +13,7 @@ CORE_MODULES="$CORE_MODULES
|
|||
|
||||
NGX_ADDON_SRCS="$NGX_ADDON_SRCS \
|
||||
$ngx_addon_dir/ngx_rtmp.c \
|
||||
$ngx_addon_dir/ngx_rtmp_amf0.c \
|
||||
$ngx_addon_dir/ngx_rtmp_amf.c \
|
||||
$ngx_addon_dir/ngx_rtmp_send.c \
|
||||
$ngx_addon_dir/ngx_rtmp_shared.c \
|
||||
$ngx_addon_dir/ngx_rtmp_handler.c \
|
||||
|
|
44
ngx_rtmp.c
44
ngx_rtmp.c
|
@ -356,8 +356,8 @@ ngx_rtmp_init_events(ngx_conf_t *cf, ngx_rtmp_core_main_conf_t *cmcf)
|
|||
}
|
||||
}
|
||||
|
||||
if (ngx_array_init(&cmcf->amf0, cf->pool, 1,
|
||||
sizeof(ngx_rtmp_amf0_handler_t)) != NGX_OK)
|
||||
if (ngx_array_init(&cmcf->amf, cf->pool, 1,
|
||||
sizeof(ngx_rtmp_amf_handler_t)) != NGX_OK)
|
||||
{
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
@ -371,7 +371,7 @@ ngx_rtmp_init_event_handlers(ngx_conf_t *cf, ngx_rtmp_core_main_conf_t *cmcf)
|
|||
{
|
||||
ngx_hash_init_t calls_hash;
|
||||
ngx_rtmp_handler_pt *eh;
|
||||
ngx_rtmp_amf0_handler_t *h;
|
||||
ngx_rtmp_amf_handler_t *h;
|
||||
ngx_hash_key_t *ha;
|
||||
size_t n, m;
|
||||
|
||||
|
@ -383,10 +383,10 @@ ngx_rtmp_init_event_handlers(ngx_conf_t *cf, ngx_rtmp_core_main_conf_t *cmcf)
|
|||
NGX_RTMP_MSG_BANDWIDTH
|
||||
};
|
||||
|
||||
static size_t amf0_events[] = {
|
||||
NGX_RTMP_MSG_AMF0_META,
|
||||
NGX_RTMP_MSG_AMF0_SHARED,
|
||||
NGX_RTMP_MSG_AMF0_CMD
|
||||
static size_t amf_events[] = {
|
||||
NGX_RTMP_MSG_AMF_META,
|
||||
NGX_RTMP_MSG_AMF_SHARED,
|
||||
NGX_RTMP_MSG_AMF_CMD
|
||||
};
|
||||
|
||||
/* init standard protocol events */
|
||||
|
@ -395,31 +395,31 @@ ngx_rtmp_init_event_handlers(ngx_conf_t *cf, ngx_rtmp_core_main_conf_t *cmcf)
|
|||
*eh = ngx_rtmp_protocol_message_handler;
|
||||
}
|
||||
|
||||
/* init amf0 events */
|
||||
for(n = 0; n < sizeof(amf0_events) / sizeof(amf0_events[0]); ++n) {
|
||||
eh = ngx_array_push(&cmcf->events[amf0_events[n]]);
|
||||
*eh = ngx_rtmp_amf0_message_handler;
|
||||
/* init amf events */
|
||||
for(n = 0; n < sizeof(amf_events) / sizeof(amf_events[0]); ++n) {
|
||||
eh = ngx_array_push(&cmcf->events[amf_events[n]]);
|
||||
*eh = ngx_rtmp_amf_message_handler;
|
||||
}
|
||||
|
||||
/* init user protocol events */
|
||||
eh = ngx_array_push(&cmcf->events[NGX_RTMP_MSG_USER]);
|
||||
*eh = ngx_rtmp_user_message_handler;
|
||||
|
||||
/* init amf0 callbacks */
|
||||
ngx_array_init(&cmcf->amf0_arrays, cf->pool, 1, sizeof(ngx_hash_key_t));
|
||||
/* init amf callbacks */
|
||||
ngx_array_init(&cmcf->amf_arrays, cf->pool, 1, sizeof(ngx_hash_key_t));
|
||||
|
||||
h = cmcf->amf0.elts;
|
||||
for(n = 0; n < cmcf->amf0.nelts; ++n, ++h) {
|
||||
ha = cmcf->amf0_arrays.elts;
|
||||
for(m = 0; m < cmcf->amf0_arrays.nelts; ++m, ++ha) {
|
||||
h = cmcf->amf.elts;
|
||||
for(n = 0; n < cmcf->amf.nelts; ++n, ++h) {
|
||||
ha = cmcf->amf_arrays.elts;
|
||||
for(m = 0; m < cmcf->amf_arrays.nelts; ++m, ++ha) {
|
||||
if (h->name.len == ha->key.len
|
||||
&& !ngx_strncmp(h->name.data, ha->key.data, ha->key.len))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (m == cmcf->amf0_arrays.nelts) {
|
||||
ha = ngx_array_push(&cmcf->amf0_arrays);
|
||||
if (m == cmcf->amf_arrays.nelts) {
|
||||
ha = ngx_array_push(&cmcf->amf_arrays);
|
||||
ha->key = h->name;
|
||||
ha->key_hash = ngx_hash_key_lc(ha->key.data, ha->key.len);
|
||||
ha->value = ngx_array_create(cf->pool, 1,
|
||||
|
@ -433,15 +433,15 @@ ngx_rtmp_init_event_handlers(ngx_conf_t *cf, ngx_rtmp_core_main_conf_t *cmcf)
|
|||
*eh = h->handler;
|
||||
}
|
||||
|
||||
calls_hash.hash = &cmcf->amf0_hash;
|
||||
calls_hash.hash = &cmcf->amf_hash;
|
||||
calls_hash.key = ngx_hash_key_lc;
|
||||
calls_hash.max_size = 512;
|
||||
calls_hash.bucket_size = ngx_cacheline_size;
|
||||
calls_hash.name = "amf0_hash";
|
||||
calls_hash.name = "amf_hash";
|
||||
calls_hash.pool = cf->pool;
|
||||
calls_hash.temp_pool = NULL;
|
||||
|
||||
if (ngx_hash_init(&calls_hash, cmcf->amf0_arrays.elts, cmcf->amf0_arrays.nelts)
|
||||
if (ngx_hash_init(&calls_hash, cmcf->amf_arrays.elts, cmcf->amf_arrays.nelts)
|
||||
!= NGX_OK)
|
||||
{
|
||||
return NGX_ERROR;
|
||||
|
|
28
ngx_rtmp.h
28
ngx_rtmp.h
|
@ -12,7 +12,7 @@
|
|||
#include <ngx_event.h>
|
||||
#include <ngx_event_connect.h>
|
||||
|
||||
#include "ngx_rtmp_amf0.h"
|
||||
#include "ngx_rtmp_amf.h"
|
||||
|
||||
|
||||
typedef struct {
|
||||
|
@ -126,9 +126,9 @@ typedef struct {
|
|||
#define NGX_RTMP_MSG_AMF3_META 15
|
||||
#define NGX_RTMP_MSG_AMF3_SHARED 16
|
||||
#define NGX_RTMP_MSG_AMF3_CMD 17
|
||||
#define NGX_RTMP_MSG_AMF0_META 18
|
||||
#define NGX_RTMP_MSG_AMF0_SHARED 19
|
||||
#define NGX_RTMP_MSG_AMF0_CMD 20
|
||||
#define NGX_RTMP_MSG_AMF_META 18
|
||||
#define NGX_RTMP_MSG_AMF_SHARED 19
|
||||
#define NGX_RTMP_MSG_AMF_CMD 20
|
||||
#define NGX_RTMP_MSG_AGGREGATE 22
|
||||
#define NGX_RTMP_MSG_MAX 22
|
||||
|
||||
|
@ -229,7 +229,7 @@ typedef ngx_int_t (*ngx_rtmp_handler_pt)(ngx_rtmp_session_t *s,
|
|||
typedef struct {
|
||||
ngx_str_t name;
|
||||
ngx_rtmp_handler_pt handler;
|
||||
} ngx_rtmp_amf0_handler_t;
|
||||
} ngx_rtmp_amf_handler_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
|
@ -238,9 +238,9 @@ typedef struct {
|
|||
|
||||
ngx_array_t events[NGX_RTMP_MAX_EVENT];
|
||||
|
||||
ngx_hash_t amf0_hash;
|
||||
ngx_array_t amf0_arrays;
|
||||
ngx_array_t amf0;
|
||||
ngx_hash_t amf_hash;
|
||||
ngx_array_t amf_arrays;
|
||||
ngx_array_t amf;
|
||||
} ngx_rtmp_core_main_conf_t;
|
||||
|
||||
|
||||
|
@ -348,7 +348,7 @@ ngx_int_t ngx_rtmp_protocol_message_handler(ngx_rtmp_session_t *s,
|
|||
ngx_rtmp_header_t *h, ngx_chain_t *in);
|
||||
ngx_int_t ngx_rtmp_user_message_handler(ngx_rtmp_session_t *s,
|
||||
ngx_rtmp_header_t *h, ngx_chain_t *in);
|
||||
ngx_int_t ngx_rtmp_amf0_message_handler(ngx_rtmp_session_t *s,
|
||||
ngx_int_t ngx_rtmp_amf_message_handler(ngx_rtmp_session_t *s,
|
||||
ngx_rtmp_header_t *h, ngx_chain_t *in);
|
||||
|
||||
|
||||
|
@ -407,11 +407,11 @@ ngx_int_t ngx_rtmp_send_user_ping_response(ngx_rtmp_session_t *s,
|
|||
ngx_int_t ngx_rtmp_send_user_unknown(ngx_rtmp_session_t *s,
|
||||
uint32_t timestamp);
|
||||
|
||||
/* AMF0 sender/receiver */
|
||||
ngx_int_t ngx_rtmp_send_amf0(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
|
||||
ngx_rtmp_amf0_elt_t *elts, size_t nelts);
|
||||
ngx_int_t ngx_rtmp_receive_amf0(ngx_rtmp_session_t *s, ngx_chain_t *in,
|
||||
ngx_rtmp_amf0_elt_t *elts, size_t nelts);
|
||||
/* AMF sender/receiver */
|
||||
ngx_int_t ngx_rtmp_send_amf(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
|
||||
ngx_rtmp_amf_elt_t *elts, size_t nelts);
|
||||
ngx_int_t ngx_rtmp_receive_amf(ngx_rtmp_session_t *s, ngx_chain_t *in,
|
||||
ngx_rtmp_amf_elt_t *elts, size_t nelts);
|
||||
|
||||
|
||||
extern ngx_uint_t ngx_rtmp_max_module;
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
* Copyright (c) 2012 Roman Arutyunyan
|
||||
*/
|
||||
|
||||
#include "ngx_rtmp_amf0.h"
|
||||
#include "ngx_rtmp_amf.h"
|
||||
#include "ngx_rtmp.h"
|
||||
#include <string.h>
|
||||
|
||||
static inline void*
|
||||
ngx_rtmp_amf0_reverse_copy(void *dst, void* src, size_t len)
|
||||
ngx_rtmp_amf_reverse_copy(void *dst, void* src, size_t len)
|
||||
{
|
||||
size_t k;
|
||||
|
||||
|
@ -22,14 +22,14 @@ ngx_rtmp_amf0_reverse_copy(void *dst, void* src, size_t len)
|
|||
return dst;
|
||||
}
|
||||
|
||||
#define NGX_RTMP_AMF0_DEBUG_SIZE 16
|
||||
#define NGX_RTMP_AMF_DEBUG_SIZE 16
|
||||
|
||||
#ifdef NGX_DEBUG
|
||||
static void
|
||||
ngx_rtmp_amf0_debug(const char* op, ngx_log_t *log, u_char *p, size_t n)
|
||||
ngx_rtmp_amf_debug(const char* op, ngx_log_t *log, u_char *p, size_t n)
|
||||
{
|
||||
u_char hstr[3 * NGX_RTMP_AMF0_DEBUG_SIZE + 1];
|
||||
u_char str[NGX_RTMP_AMF0_DEBUG_SIZE + 1];
|
||||
u_char hstr[3 * NGX_RTMP_AMF_DEBUG_SIZE + 1];
|
||||
u_char str[NGX_RTMP_AMF_DEBUG_SIZE + 1];
|
||||
u_char *hp, *sp;
|
||||
static u_char hex[] = "0123456789ABCDEF";
|
||||
size_t i;
|
||||
|
@ -37,7 +37,7 @@ ngx_rtmp_amf0_debug(const char* op, ngx_log_t *log, u_char *p, size_t n)
|
|||
hp = hstr;
|
||||
sp = str;
|
||||
|
||||
for(i = 0; i < n && i < NGX_RTMP_AMF0_DEBUG_SIZE; ++i) {
|
||||
for(i = 0; i < n && i < NGX_RTMP_AMF_DEBUG_SIZE; ++i) {
|
||||
*hp++ = ' ';
|
||||
if (p) {
|
||||
*hp++ = hex[(*p & 0xf0) >> 4];
|
||||
|
@ -54,12 +54,12 @@ ngx_rtmp_amf0_debug(const char* op, ngx_log_t *log, u_char *p, size_t n)
|
|||
*hp = *sp = '\0';
|
||||
|
||||
ngx_log_debug4(NGX_LOG_DEBUG_RTMP, log, 0,
|
||||
"AMF0 %s (%d)%s '%s'", op, n, hstr, str);
|
||||
"AMF %s (%d)%s '%s'", op, n, hstr, str);
|
||||
}
|
||||
#endif
|
||||
|
||||
static ngx_int_t
|
||||
ngx_rtmp_amf0_get(ngx_rtmp_amf0_ctx_t *ctx, void *p, size_t n)
|
||||
ngx_rtmp_amf_get(ngx_rtmp_amf_ctx_t *ctx, void *p, size_t n)
|
||||
{
|
||||
ngx_buf_t *b;
|
||||
size_t size;
|
||||
|
@ -85,7 +85,7 @@ ngx_rtmp_amf0_get(ngx_rtmp_amf0_ctx_t *ctx, void *p, size_t n)
|
|||
ctx->link = l;
|
||||
|
||||
#ifdef NGX_DEBUG
|
||||
ngx_rtmp_amf0_debug("read", ctx->log, (u_char*)op, on);
|
||||
ngx_rtmp_amf_debug("read", ctx->log, (u_char*)op, on);
|
||||
#endif
|
||||
|
||||
return NGX_OK;
|
||||
|
@ -101,21 +101,21 @@ ngx_rtmp_amf0_get(ngx_rtmp_amf0_ctx_t *ctx, void *p, size_t n)
|
|||
}
|
||||
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_RTMP, ctx->log, 0,
|
||||
"AMF0 read eof (%d)", n);
|
||||
"AMF read eof (%d)", n);
|
||||
|
||||
return NGX_DONE;
|
||||
}
|
||||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_rtmp_amf0_put(ngx_rtmp_amf0_ctx_t *ctx, void *p, size_t n)
|
||||
ngx_rtmp_amf_put(ngx_rtmp_amf_ctx_t *ctx, void *p, size_t n)
|
||||
{
|
||||
ngx_buf_t *b;
|
||||
size_t size;
|
||||
ngx_chain_t *l, *ln;
|
||||
|
||||
#ifdef NGX_DEBUG
|
||||
ngx_rtmp_amf0_debug("write", ctx->log, (u_char*)p, n);
|
||||
ngx_rtmp_amf_debug("write", ctx->log, (u_char*)p, n);
|
||||
#endif
|
||||
|
||||
l = ctx->link;
|
||||
|
@ -159,7 +159,7 @@ ngx_rtmp_amf0_put(ngx_rtmp_amf0_ctx_t *ctx, void *p, size_t n)
|
|||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_rtmp_amf0_read_object(ngx_rtmp_amf0_ctx_t *ctx, ngx_rtmp_amf0_elt_t *elts,
|
||||
ngx_rtmp_amf_read_object(ngx_rtmp_amf_ctx_t *ctx, ngx_rtmp_amf_elt_t *elts,
|
||||
size_t nelts)
|
||||
{
|
||||
uint8_t type;
|
||||
|
@ -180,24 +180,24 @@ ngx_rtmp_amf0_read_object(ngx_rtmp_amf0_ctx_t *ctx, ngx_rtmp_amf0_elt_t *elts,
|
|||
char name[maxlen + 1];
|
||||
|
||||
/* read key */
|
||||
if (ngx_rtmp_amf0_get(ctx, buf, 2) != NGX_OK)
|
||||
if (ngx_rtmp_amf_get(ctx, buf, 2) != NGX_OK)
|
||||
return NGX_ERROR;
|
||||
|
||||
ngx_rtmp_amf0_reverse_copy(&len, buf, 2);
|
||||
ngx_rtmp_amf_reverse_copy(&len, buf, 2);
|
||||
|
||||
if (!len)
|
||||
break;
|
||||
|
||||
if (len <= maxlen) {
|
||||
rc = ngx_rtmp_amf0_get(ctx, name, len);
|
||||
rc = ngx_rtmp_amf_get(ctx, name, len);
|
||||
name[len] = 0;
|
||||
|
||||
} else {
|
||||
rc = ngx_rtmp_amf0_get(ctx, name, maxlen);
|
||||
rc = ngx_rtmp_amf_get(ctx, name, maxlen);
|
||||
if (rc != NGX_OK)
|
||||
return NGX_ERROR;
|
||||
name[maxlen] = 0;
|
||||
rc = ngx_rtmp_amf0_get(ctx, 0, len - maxlen);
|
||||
rc = ngx_rtmp_amf_get(ctx, 0, len - maxlen);
|
||||
}
|
||||
|
||||
if (rc != NGX_OK)
|
||||
|
@ -207,12 +207,12 @@ ngx_rtmp_amf0_read_object(ngx_rtmp_amf0_ctx_t *ctx, ngx_rtmp_amf0_elt_t *elts,
|
|||
* then we could be able to use binary search */
|
||||
for(n = 0; n < nelts && strcmp(name, elts[n].name); ++n);
|
||||
|
||||
if (ngx_rtmp_amf0_read(ctx, n < nelts ? &elts[n] : NULL, 1) != NGX_OK)
|
||||
if (ngx_rtmp_amf_read(ctx, n < nelts ? &elts[n] : NULL, 1) != NGX_OK)
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
if (ngx_rtmp_amf0_get(ctx, &type, 1) != NGX_OK
|
||||
|| type != NGX_RTMP_AMF0_END)
|
||||
if (ngx_rtmp_amf_get(ctx, &type, 1) != NGX_OK
|
||||
|| type != NGX_RTMP_AMF_END)
|
||||
{
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ ngx_rtmp_amf0_read_object(ngx_rtmp_amf0_ctx_t *ctx, ngx_rtmp_amf0_elt_t *elts,
|
|||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_rtmp_amf0_read_array(ngx_rtmp_amf0_ctx_t *ctx, ngx_rtmp_amf0_elt_t *elts,
|
||||
ngx_rtmp_amf_read_array(ngx_rtmp_amf_ctx_t *ctx, ngx_rtmp_amf_elt_t *elts,
|
||||
size_t nelts)
|
||||
{
|
||||
uint32_t len;
|
||||
|
@ -230,13 +230,13 @@ ngx_rtmp_amf0_read_array(ngx_rtmp_amf0_ctx_t *ctx, ngx_rtmp_amf0_elt_t *elts,
|
|||
u_char buf[4];
|
||||
|
||||
/* read length */
|
||||
if (ngx_rtmp_amf0_get(ctx, buf, 4) != NGX_OK)
|
||||
if (ngx_rtmp_amf_get(ctx, buf, 4) != NGX_OK)
|
||||
return NGX_ERROR;
|
||||
|
||||
ngx_rtmp_amf0_reverse_copy(&len, buf, 4);
|
||||
ngx_rtmp_amf_reverse_copy(&len, buf, 4);
|
||||
|
||||
for (n = 0; n < len; ++n) {
|
||||
if (ngx_rtmp_amf0_read(ctx, n < nelts ? &elts[n] : NULL, 1) != NGX_OK)
|
||||
if (ngx_rtmp_amf_read(ctx, n < nelts ? &elts[n] : NULL, 1) != NGX_OK)
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
|
@ -245,7 +245,7 @@ ngx_rtmp_amf0_read_array(ngx_rtmp_amf0_ctx_t *ctx, ngx_rtmp_amf0_elt_t *elts,
|
|||
|
||||
|
||||
ngx_int_t
|
||||
ngx_rtmp_amf0_read(ngx_rtmp_amf0_ctx_t *ctx, ngx_rtmp_amf0_elt_t *elts,
|
||||
ngx_rtmp_amf_read(ngx_rtmp_amf_ctx_t *ctx, ngx_rtmp_amf_elt_t *elts,
|
||||
size_t nelts)
|
||||
{
|
||||
void *data;
|
||||
|
@ -257,9 +257,9 @@ ngx_rtmp_amf0_read(ngx_rtmp_amf0_ctx_t *ctx, ngx_rtmp_amf0_elt_t *elts,
|
|||
|
||||
for(n = 0; n < nelts; ++n) {
|
||||
|
||||
switch (ngx_rtmp_amf0_get(ctx, &type, sizeof(type))) {
|
||||
switch (ngx_rtmp_amf_get(ctx, &type, sizeof(type))) {
|
||||
case NGX_DONE:
|
||||
if (elts->type & NGX_RTMP_AMF0_OPTIONAL) {
|
||||
if (elts->type & NGX_RTMP_AMF_OPTIONAL) {
|
||||
return NGX_OK;
|
||||
}
|
||||
case NGX_ERROR:
|
||||
|
@ -267,42 +267,42 @@ ngx_rtmp_amf0_read(ngx_rtmp_amf0_ctx_t *ctx, ngx_rtmp_amf0_elt_t *elts,
|
|||
}
|
||||
|
||||
data = (n >= nelts || elts == NULL
|
||||
|| (elts->type & ~NGX_RTMP_AMF0_OPTIONAL) != type)
|
||||
|| (elts->type & ~NGX_RTMP_AMF_OPTIONAL) != type)
|
||||
? NULL
|
||||
: elts->data;
|
||||
|
||||
switch (type) {
|
||||
case NGX_RTMP_AMF0_NUMBER:
|
||||
if (ngx_rtmp_amf0_get(ctx, buf, 8) != NGX_OK) {
|
||||
case NGX_RTMP_AMF_NUMBER:
|
||||
if (ngx_rtmp_amf_get(ctx, buf, 8) != NGX_OK) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
ngx_rtmp_amf0_reverse_copy(data, buf, 8);
|
||||
ngx_rtmp_amf_reverse_copy(data, buf, 8);
|
||||
break;
|
||||
|
||||
case NGX_RTMP_AMF0_BOOLEAN:
|
||||
if (ngx_rtmp_amf0_get(ctx, data, 1) != NGX_OK) {
|
||||
case NGX_RTMP_AMF_BOOLEAN:
|
||||
if (ngx_rtmp_amf_get(ctx, data, 1) != NGX_OK) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
break;
|
||||
|
||||
case NGX_RTMP_AMF0_STRING:
|
||||
if (ngx_rtmp_amf0_get(ctx, buf, 2) != NGX_OK) {
|
||||
case NGX_RTMP_AMF_STRING:
|
||||
if (ngx_rtmp_amf_get(ctx, buf, 2) != NGX_OK) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
ngx_rtmp_amf0_reverse_copy(&len, buf, 2);
|
||||
ngx_rtmp_amf_reverse_copy(&len, buf, 2);
|
||||
|
||||
if (data == NULL) {
|
||||
rc = ngx_rtmp_amf0_get(ctx, data, len);
|
||||
rc = ngx_rtmp_amf_get(ctx, data, len);
|
||||
|
||||
} else if (elts->len <= len) {
|
||||
rc = ngx_rtmp_amf0_get(ctx, data, elts->len - 1);
|
||||
rc = ngx_rtmp_amf_get(ctx, data, elts->len - 1);
|
||||
if (rc != NGX_OK)
|
||||
return NGX_ERROR;
|
||||
((char*)data)[elts->len - 1] = 0;
|
||||
rc = ngx_rtmp_amf0_get(ctx, NULL, len - elts->len + 1);
|
||||
rc = ngx_rtmp_amf_get(ctx, NULL, len - elts->len + 1);
|
||||
|
||||
} else {
|
||||
rc = ngx_rtmp_amf0_get(ctx, data, len);
|
||||
rc = ngx_rtmp_amf_get(ctx, data, len);
|
||||
((char*)data)[len] = 0;
|
||||
}
|
||||
|
||||
|
@ -312,28 +312,28 @@ ngx_rtmp_amf0_read(ngx_rtmp_amf0_ctx_t *ctx, ngx_rtmp_amf0_elt_t *elts,
|
|||
|
||||
break;
|
||||
|
||||
case NGX_RTMP_AMF0_NULL:
|
||||
case NGX_RTMP_AMF_NULL:
|
||||
break;
|
||||
|
||||
case NGX_RTMP_AMF0_OBJECT:
|
||||
if (ngx_rtmp_amf0_read_object(ctx, data,
|
||||
elts ? elts->len / sizeof(ngx_rtmp_amf0_elt_t) : 0
|
||||
case NGX_RTMP_AMF_OBJECT:
|
||||
if (ngx_rtmp_amf_read_object(ctx, data,
|
||||
elts ? elts->len / sizeof(ngx_rtmp_amf_elt_t) : 0
|
||||
) != NGX_OK)
|
||||
{
|
||||
return NGX_ERROR;
|
||||
}
|
||||
break;
|
||||
|
||||
case NGX_RTMP_AMF0_ARRAY:
|
||||
if (ngx_rtmp_amf0_read_array(ctx, data,
|
||||
elts ? elts->len / sizeof(ngx_rtmp_amf0_elt_t) : 0
|
||||
case NGX_RTMP_AMF_ARRAY:
|
||||
if (ngx_rtmp_amf_read_array(ctx, data,
|
||||
elts ? elts->len / sizeof(ngx_rtmp_amf_elt_t) : 0
|
||||
) != NGX_OK)
|
||||
{
|
||||
return NGX_ERROR;
|
||||
}
|
||||
break;
|
||||
|
||||
case NGX_RTMP_AMF0_END:
|
||||
case NGX_RTMP_AMF_END:
|
||||
return NGX_OK;
|
||||
|
||||
default:
|
||||
|
@ -350,8 +350,8 @@ ngx_rtmp_amf0_read(ngx_rtmp_amf0_ctx_t *ctx, ngx_rtmp_amf0_elt_t *elts,
|
|||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_rtmp_amf0_write_object(ngx_rtmp_amf0_ctx_t *ctx,
|
||||
ngx_rtmp_amf0_elt_t *elts, size_t nelts)
|
||||
ngx_rtmp_amf_write_object(ngx_rtmp_amf_ctx_t *ctx,
|
||||
ngx_rtmp_amf_elt_t *elts, size_t nelts)
|
||||
{
|
||||
uint16_t len, len_sb;
|
||||
size_t n;
|
||||
|
@ -363,25 +363,25 @@ ngx_rtmp_amf0_write_object(ngx_rtmp_amf0_ctx_t *ctx,
|
|||
name = elts[n].name;
|
||||
len_sb = len = strlen(name);
|
||||
|
||||
if (ngx_rtmp_amf0_put(ctx,
|
||||
ngx_rtmp_amf0_reverse_copy(buf,
|
||||
if (ngx_rtmp_amf_put(ctx,
|
||||
ngx_rtmp_amf_reverse_copy(buf,
|
||||
&len, 2), 2) != NGX_OK)
|
||||
{
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
if (ngx_rtmp_amf0_put(ctx, name, len) != NGX_OK) {
|
||||
if (ngx_rtmp_amf_put(ctx, name, len) != NGX_OK) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
if (ngx_rtmp_amf0_write(ctx, &elts[n], 1) != NGX_OK) {
|
||||
if (ngx_rtmp_amf_write(ctx, &elts[n], 1) != NGX_OK) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
len = 0;
|
||||
|
||||
if (ngx_rtmp_amf0_put(ctx, "\00\00", 2) != NGX_OK) {
|
||||
if (ngx_rtmp_amf_put(ctx, "\00\00", 2) != NGX_OK) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
|
@ -390,23 +390,23 @@ ngx_rtmp_amf0_write_object(ngx_rtmp_amf0_ctx_t *ctx,
|
|||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_rtmp_amf0_write_array(ngx_rtmp_amf0_ctx_t *ctx,
|
||||
ngx_rtmp_amf0_elt_t *elts, size_t nelts)
|
||||
ngx_rtmp_amf_write_array(ngx_rtmp_amf_ctx_t *ctx,
|
||||
ngx_rtmp_amf_elt_t *elts, size_t nelts)
|
||||
{
|
||||
uint32_t len;
|
||||
size_t n;
|
||||
u_char buf[4];
|
||||
|
||||
len = nelts;
|
||||
if (ngx_rtmp_amf0_put(ctx,
|
||||
ngx_rtmp_amf0_reverse_copy(buf,
|
||||
if (ngx_rtmp_amf_put(ctx,
|
||||
ngx_rtmp_amf_reverse_copy(buf,
|
||||
&len, 4), 4) != NGX_OK)
|
||||
{
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
for(n = 0; n < nelts; ++n) {
|
||||
if (ngx_rtmp_amf0_write(ctx, &elts[n], 1) != NGX_OK) {
|
||||
if (ngx_rtmp_amf_write(ctx, &elts[n], 1) != NGX_OK) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
}
|
||||
|
@ -416,8 +416,8 @@ ngx_rtmp_amf0_write_array(ngx_rtmp_amf0_ctx_t *ctx,
|
|||
|
||||
|
||||
ngx_int_t
|
||||
ngx_rtmp_amf0_write(ngx_rtmp_amf0_ctx_t *ctx,
|
||||
ngx_rtmp_amf0_elt_t *elts, size_t nelts)
|
||||
ngx_rtmp_amf_write(ngx_rtmp_amf_ctx_t *ctx,
|
||||
ngx_rtmp_amf_elt_t *elts, size_t nelts)
|
||||
{
|
||||
size_t n;
|
||||
uint8_t type;
|
||||
|
@ -431,59 +431,59 @@ ngx_rtmp_amf0_write(ngx_rtmp_amf0_ctx_t *ctx,
|
|||
data = elts[n].data;
|
||||
len = elts[n].len;
|
||||
|
||||
if (ngx_rtmp_amf0_put(ctx, &type, sizeof(type)) != NGX_OK)
|
||||
if (ngx_rtmp_amf_put(ctx, &type, sizeof(type)) != NGX_OK)
|
||||
return NGX_ERROR;
|
||||
|
||||
switch(type) {
|
||||
case NGX_RTMP_AMF0_NUMBER:
|
||||
if (ngx_rtmp_amf0_put(ctx,
|
||||
ngx_rtmp_amf0_reverse_copy(buf,
|
||||
case NGX_RTMP_AMF_NUMBER:
|
||||
if (ngx_rtmp_amf_put(ctx,
|
||||
ngx_rtmp_amf_reverse_copy(buf,
|
||||
data, 8), 8) != NGX_OK)
|
||||
{
|
||||
return NGX_ERROR;
|
||||
}
|
||||
break;
|
||||
|
||||
case NGX_RTMP_AMF0_BOOLEAN:
|
||||
if (ngx_rtmp_amf0_put(ctx, data, 1) != NGX_OK) {
|
||||
case NGX_RTMP_AMF_BOOLEAN:
|
||||
if (ngx_rtmp_amf_put(ctx, data, 1) != NGX_OK) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
break;
|
||||
|
||||
case NGX_RTMP_AMF0_STRING:
|
||||
case NGX_RTMP_AMF_STRING:
|
||||
if (len == 0 && data) {
|
||||
len = ngx_strlen((u_char*)data);
|
||||
}
|
||||
|
||||
if (ngx_rtmp_amf0_put(ctx,
|
||||
ngx_rtmp_amf0_reverse_copy(buf,
|
||||
if (ngx_rtmp_amf_put(ctx,
|
||||
ngx_rtmp_amf_reverse_copy(buf,
|
||||
&len, 2), 2) != NGX_OK)
|
||||
{
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
if (ngx_rtmp_amf0_put(ctx, data, len) != NGX_OK) {
|
||||
if (ngx_rtmp_amf_put(ctx, data, len) != NGX_OK) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
break;
|
||||
|
||||
case NGX_RTMP_AMF0_NULL:
|
||||
case NGX_RTMP_AMF_NULL:
|
||||
break;
|
||||
|
||||
case NGX_RTMP_AMF0_OBJECT:
|
||||
type = NGX_RTMP_AMF0_END;
|
||||
if (ngx_rtmp_amf0_write_object(ctx, data,
|
||||
elts[n].len / sizeof(ngx_rtmp_amf0_elt_t)) != NGX_OK
|
||||
|| ngx_rtmp_amf0_put(ctx, &type,
|
||||
case NGX_RTMP_AMF_OBJECT:
|
||||
type = NGX_RTMP_AMF_END;
|
||||
if (ngx_rtmp_amf_write_object(ctx, data,
|
||||
elts[n].len / sizeof(ngx_rtmp_amf_elt_t)) != NGX_OK
|
||||
|| ngx_rtmp_amf_put(ctx, &type,
|
||||
sizeof(type)) != NGX_OK)
|
||||
{
|
||||
return NGX_ERROR;
|
||||
}
|
||||
break;
|
||||
|
||||
case NGX_RTMP_AMF0_ARRAY:
|
||||
if (ngx_rtmp_amf0_write_array(ctx, data,
|
||||
elts[n].len / sizeof(ngx_rtmp_amf0_elt_t)) != NGX_OK)
|
||||
case NGX_RTMP_AMF_ARRAY:
|
||||
if (ngx_rtmp_amf_write_array(ctx, data,
|
||||
elts[n].len / sizeof(ngx_rtmp_amf_elt_t)) != NGX_OK)
|
||||
{
|
||||
return NGX_ERROR;
|
||||
}
|
104
ngx_rtmp_amf.h
Normal file
104
ngx_rtmp_amf.h
Normal file
|
@ -0,0 +1,104 @@
|
|||
/*
|
||||
* Copyright (c) 2012 Roman Arutyunyan
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _NGX_RTMP_AMF_H_INCLUDED_
|
||||
#define _NGX_RTMP_AMF_H_INCLUDED_
|
||||
|
||||
#define NGX_RTMP_AMF_NUMBER 0x00
|
||||
#define NGX_RTMP_AMF_BOOLEAN 0x01
|
||||
#define NGX_RTMP_AMF_STRING 0x02
|
||||
|
||||
#define NGX_RTMP_AMF_OBJECT 0x03
|
||||
#define NGX_RTMP_AMF_NULL 0x05
|
||||
#define NGX_RTMP_AMF_ARRAY_NULL 0x06
|
||||
#define NGX_RTMP_AMF_MIXED_ARRAY 0x08
|
||||
#define NGX_RTMP_AMF_END 0x09
|
||||
|
||||
#define NGX_RTMP_AMF_ARRAY 0x0a
|
||||
|
||||
#define NGX_RTMP_AMF_OPTIONAL 0x80
|
||||
|
||||
#include <ngx_config.h>
|
||||
#include <ngx_core.h>
|
||||
|
||||
|
||||
typedef struct {
|
||||
ngx_int_t type;
|
||||
char *name;
|
||||
void *data;
|
||||
size_t len;
|
||||
} ngx_rtmp_amf_elt_t;
|
||||
|
||||
|
||||
struct ngx_rtmp_core_srv_conf_s;
|
||||
|
||||
typedef ngx_chain_t * (*ngx_rtmp_amf_alloc_pt)(struct ngx_rtmp_core_srv_conf_s
|
||||
*cscf);
|
||||
|
||||
typedef struct {
|
||||
ngx_chain_t *link, *first;
|
||||
ngx_rtmp_amf_alloc_pt alloc;
|
||||
struct ngx_rtmp_core_srv_conf_s *cscf;
|
||||
ngx_log_t *log;
|
||||
} ngx_rtmp_amf_ctx_t;
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Examples:
|
||||
|
||||
struct {
|
||||
char name[32];
|
||||
double trans_id;
|
||||
char app[32];
|
||||
char flashver[32];
|
||||
char v1[8];
|
||||
int locked;
|
||||
} vals;
|
||||
|
||||
ngx_rtmp_amf_elt_t props[] = {
|
||||
{ NGX_RTMP_AMF_STRING, "app", vals.app, sizeof(vals.app) },
|
||||
{ NGX_RTMP_AMF_STRING, "flashver", vals.flashver, sizeof(vals.flashver) }
|
||||
};
|
||||
|
||||
ngx_rtmp_amf_elt_t list[] = {
|
||||
{ NGX_RTMP_AMF_STRING, 0, vals.v1, sizeof(vals.v1) },
|
||||
{ NGX_RTMP_AMF_BOOLEAN, 0, &vals.locked, sizeof(vals.locked) }
|
||||
};
|
||||
|
||||
ngx_rtmp_amf_elt elts[] = {
|
||||
{ NGX_RTMP_AMF_STRING, 0 vals.name, sizeof(vals.name) },
|
||||
{ NGX_RTMP_AMF_NUMBER, 0 &vals.trans_id, sizeof(vals.trans_id) },
|
||||
{ NGX_RTMP_AMF_OBJECT, 0, props, sizeof(props) },
|
||||
{ NGX_RTMP_AMF_ARRAY, 0, list, sizeof(list) },
|
||||
{ NGX_RTMP_AMF_NULL }
|
||||
};
|
||||
|
||||
|
||||
Reading:
|
||||
-------
|
||||
|
||||
memset(&vals, 0, sizeof(vals));
|
||||
ngx_rtmp_amf_read(l, elts, sizeof(elts));
|
||||
|
||||
|
||||
Writing:
|
||||
-------
|
||||
|
||||
ngx_rtmp_amf_write(l, free, elts, sizeof(elts));
|
||||
|
||||
*/
|
||||
|
||||
/* reading AMF */
|
||||
ngx_int_t ngx_rtmp_amf_read(ngx_rtmp_amf_ctx_t *ctx,
|
||||
ngx_rtmp_amf_elt_t *elts, size_t nelts);
|
||||
|
||||
/* writing AMF */
|
||||
ngx_int_t ngx_rtmp_amf_write(ngx_rtmp_amf_ctx_t *ctx,
|
||||
ngx_rtmp_amf_elt_t *elts, size_t nelts);
|
||||
|
||||
|
||||
#endif /* _NGX_RTMP_AMF_H_INCLUDED_ */
|
||||
|
104
ngx_rtmp_amf0.h
104
ngx_rtmp_amf0.h
|
@ -1,104 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2012 Roman Arutyunyan
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _NGX_RTMP_AMF0_H_INCLUDED_
|
||||
#define _NGX_RTMP_AMF0_H_INCLUDED_
|
||||
|
||||
#define NGX_RTMP_AMF0_NUMBER 0x00
|
||||
#define NGX_RTMP_AMF0_BOOLEAN 0x01
|
||||
#define NGX_RTMP_AMF0_STRING 0x02
|
||||
|
||||
#define NGX_RTMP_AMF0_OBJECT 0x03
|
||||
#define NGX_RTMP_AMF0_NULL 0x05
|
||||
#define NGX_RTMP_AMF0_ARRAY_NULL 0x06
|
||||
#define NGX_RTMP_AMF0_MIXED_ARRAY 0x08
|
||||
#define NGX_RTMP_AMF0_END 0x09
|
||||
|
||||
#define NGX_RTMP_AMF0_ARRAY 0x0a
|
||||
|
||||
#define NGX_RTMP_AMF0_OPTIONAL 0x80
|
||||
|
||||
#include <ngx_config.h>
|
||||
#include <ngx_core.h>
|
||||
|
||||
|
||||
typedef struct {
|
||||
ngx_int_t type;
|
||||
char *name;
|
||||
void *data;
|
||||
size_t len;
|
||||
} ngx_rtmp_amf0_elt_t;
|
||||
|
||||
|
||||
struct ngx_rtmp_core_srv_conf_s;
|
||||
|
||||
typedef ngx_chain_t * (*ngx_rtmp_amf0_alloc_pt)(struct ngx_rtmp_core_srv_conf_s
|
||||
*cscf);
|
||||
|
||||
typedef struct {
|
||||
ngx_chain_t *link, *first;
|
||||
ngx_rtmp_amf0_alloc_pt alloc;
|
||||
struct ngx_rtmp_core_srv_conf_s *cscf;
|
||||
ngx_log_t *log;
|
||||
} ngx_rtmp_amf0_ctx_t;
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Examples:
|
||||
|
||||
struct {
|
||||
char name[32];
|
||||
double trans_id;
|
||||
char app[32];
|
||||
char flashver[32];
|
||||
char v1[8];
|
||||
int locked;
|
||||
} vals;
|
||||
|
||||
ngx_rtmp_amf0_elt_t props[] = {
|
||||
{ NGX_RTMP_AMF0_STRING, "app", vals.app, sizeof(vals.app) },
|
||||
{ NGX_RTMP_AMF0_STRING, "flashver", vals.flashver, sizeof(vals.flashver) }
|
||||
};
|
||||
|
||||
ngx_rtmp_amf0_elt_t list[] = {
|
||||
{ NGX_RTMP_AMF0_STRING, 0, vals.v1, sizeof(vals.v1) },
|
||||
{ NGX_RTMP_AMF0_BOOLEAN, 0, &vals.locked, sizeof(vals.locked) }
|
||||
};
|
||||
|
||||
ngx_rtmp_amf0_elt elts[] = {
|
||||
{ NGX_RTMP_AMF0_STRING, 0 vals.name, sizeof(vals.name) },
|
||||
{ NGX_RTMP_AMF0_NUMBER, 0 &vals.trans_id, sizeof(vals.trans_id) },
|
||||
{ NGX_RTMP_AMF0_OBJECT, 0, props, sizeof(props) },
|
||||
{ NGX_RTMP_AMF0_ARRAY, 0, list, sizeof(list) },
|
||||
{ NGX_RTMP_AMF0_NULL }
|
||||
};
|
||||
|
||||
|
||||
Reading:
|
||||
-------
|
||||
|
||||
memset(&vals, 0, sizeof(vals));
|
||||
ngx_rtmp_amf0_read(l, elts, sizeof(elts));
|
||||
|
||||
|
||||
Writing:
|
||||
-------
|
||||
|
||||
ngx_rtmp_amf0_write(l, free, elts, sizeof(elts));
|
||||
|
||||
*/
|
||||
|
||||
/* reading AMF0 */
|
||||
ngx_int_t ngx_rtmp_amf0_read(ngx_rtmp_amf0_ctx_t *ctx,
|
||||
ngx_rtmp_amf0_elt_t *elts, size_t nelts);
|
||||
|
||||
/* writing AMF0 */
|
||||
ngx_int_t ngx_rtmp_amf0_write(ngx_rtmp_amf0_ctx_t *ctx,
|
||||
ngx_rtmp_amf0_elt_t *elts, size_t nelts);
|
||||
|
||||
|
||||
#endif /* _NGX_RTMP_AMF0_H_INCLUDED_ */
|
||||
|
|
@ -8,8 +8,8 @@
|
|||
#define NGX_RTMP_FMS_VERSION "FMS/3,0,1,123"
|
||||
#define NGX_RTMP_CAPABILITIES 31
|
||||
|
||||
#define NGX_RTMP_CMD_CSID_AMF0_INI 3
|
||||
#define NGX_RTMP_CMD_CSID_AMF0 5
|
||||
#define NGX_RTMP_CMD_CSID_AMF_INI 3
|
||||
#define NGX_RTMP_CMD_CSID_AMF 5
|
||||
#define NGX_RTMP_CMD_MSID 1
|
||||
|
||||
|
||||
|
@ -63,49 +63,49 @@ ngx_rtmp_cmd_connect_init(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
|
|||
{
|
||||
static ngx_rtmp_connect_t v;
|
||||
|
||||
static ngx_rtmp_amf0_elt_t in_cmd[] = {
|
||||
static ngx_rtmp_amf_elt_t in_cmd[] = {
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
"app",
|
||||
v.app, sizeof(v.app) },
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
"flashver",
|
||||
v.flashver, sizeof(v.flashver) },
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
"swfUrl",
|
||||
v.swf_url, sizeof(v.swf_url) },
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
"tcUrl",
|
||||
v.tc_url, sizeof(v.tc_url) },
|
||||
|
||||
{ NGX_RTMP_AMF0_NUMBER,
|
||||
{ NGX_RTMP_AMF_NUMBER,
|
||||
"audioCodecs",
|
||||
&v.acodecs, sizeof(v.acodecs) },
|
||||
|
||||
{ NGX_RTMP_AMF0_NUMBER,
|
||||
{ NGX_RTMP_AMF_NUMBER,
|
||||
"videoCodecs",
|
||||
&v.vcodecs, sizeof(v.vcodecs) },
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
"pageUrl",
|
||||
v.page_url, sizeof(v.page_url) },
|
||||
};
|
||||
|
||||
static ngx_rtmp_amf0_elt_t in_elts[] = {
|
||||
static ngx_rtmp_amf_elt_t in_elts[] = {
|
||||
|
||||
/* transaction in always 1 */
|
||||
{ NGX_RTMP_AMF0_NUMBER, NULL,
|
||||
{ NGX_RTMP_AMF_NUMBER, NULL,
|
||||
NULL, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_OBJECT, NULL,
|
||||
{ NGX_RTMP_AMF_OBJECT, NULL,
|
||||
in_cmd, sizeof(in_cmd) },
|
||||
};
|
||||
|
||||
ngx_memzero(&v, sizeof(v));
|
||||
if (ngx_rtmp_receive_amf0(s, in, in_elts,
|
||||
if (ngx_rtmp_receive_amf(s, in, in_elts,
|
||||
sizeof(in_elts) / sizeof(in_elts[0])))
|
||||
{
|
||||
return NGX_ERROR;
|
||||
|
@ -129,47 +129,47 @@ ngx_rtmp_cmd_connect(ngx_rtmp_session_t *s, ngx_rtmp_connect_t *v)
|
|||
static double trans = 1;
|
||||
static double capabilities = NGX_RTMP_CAPABILITIES;
|
||||
|
||||
static ngx_rtmp_amf0_elt_t out_obj[] = {
|
||||
static ngx_rtmp_amf_elt_t out_obj[] = {
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
"fmsVer",
|
||||
NGX_RTMP_FMS_VERSION, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_NUMBER,
|
||||
{ NGX_RTMP_AMF_NUMBER,
|
||||
"capabilities",
|
||||
&capabilities, 0 },
|
||||
};
|
||||
|
||||
static ngx_rtmp_amf0_elt_t out_inf[] = {
|
||||
static ngx_rtmp_amf_elt_t out_inf[] = {
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
"level",
|
||||
"status", 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
"code",
|
||||
"NetConnection.Connect.Success", 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
"description",
|
||||
"Connection succeeded.", 0 }
|
||||
};
|
||||
|
||||
static ngx_rtmp_amf0_elt_t out_elts[] = {
|
||||
static ngx_rtmp_amf_elt_t out_elts[] = {
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
NULL,
|
||||
"_result", 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_NUMBER,
|
||||
{ NGX_RTMP_AMF_NUMBER,
|
||||
NULL,
|
||||
&trans, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_OBJECT,
|
||||
{ NGX_RTMP_AMF_OBJECT,
|
||||
NULL,
|
||||
out_obj, sizeof(out_obj) },
|
||||
|
||||
{ NGX_RTMP_AMF0_OBJECT,
|
||||
{ NGX_RTMP_AMF_OBJECT,
|
||||
NULL,
|
||||
out_inf, sizeof(out_inf) },
|
||||
};
|
||||
|
@ -192,8 +192,8 @@ ngx_rtmp_cmd_connect(ngx_rtmp_session_t *s, ngx_rtmp_connect_t *v)
|
|||
s->connected = 1;
|
||||
|
||||
ngx_memzero(&h, sizeof(h));
|
||||
h.csid = NGX_RTMP_CMD_CSID_AMF0_INI;
|
||||
h.type = NGX_RTMP_MSG_AMF0_CMD;
|
||||
h.csid = NGX_RTMP_CMD_CSID_AMF_INI;
|
||||
h.type = NGX_RTMP_MSG_AMF_CMD;
|
||||
|
||||
|
||||
#define NGX_RTMP_SET_STRPAR(name) \
|
||||
|
@ -238,7 +238,7 @@ ngx_rtmp_cmd_connect(ngx_rtmp_session_t *s, ngx_rtmp_connect_t *v)
|
|||
NGX_RTMP_LIMIT_DYNAMIC) != NGX_OK
|
||||
|| ngx_rtmp_send_user_stream_begin(s, 0) != NGX_OK
|
||||
|| ngx_rtmp_send_chunk_size(s, cscf->chunk_size) != NGX_OK
|
||||
|| ngx_rtmp_send_amf0(s, &h, out_elts,
|
||||
|| ngx_rtmp_send_amf(s, &h, out_elts,
|
||||
sizeof(out_elts) / sizeof(out_elts[0])) != NGX_OK
|
||||
? NGX_ERROR
|
||||
: NGX_OK;
|
||||
|
@ -251,14 +251,14 @@ ngx_rtmp_cmd_create_stream_init(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
|
|||
{
|
||||
static ngx_rtmp_create_stream_t v;
|
||||
|
||||
static ngx_rtmp_amf0_elt_t in_elts[] = {
|
||||
static ngx_rtmp_amf_elt_t in_elts[] = {
|
||||
|
||||
{ NGX_RTMP_AMF0_NUMBER,
|
||||
{ NGX_RTMP_AMF_NUMBER,
|
||||
0,
|
||||
&v.trans, sizeof(v.trans) },
|
||||
};
|
||||
|
||||
if (ngx_rtmp_receive_amf0(s, in, in_elts,
|
||||
if (ngx_rtmp_receive_amf(s, in, in_elts,
|
||||
sizeof(in_elts) / sizeof(in_elts[0])))
|
||||
{
|
||||
return NGX_ERROR;
|
||||
|
@ -278,21 +278,21 @@ ngx_rtmp_cmd_create_stream(ngx_rtmp_session_t *s, ngx_rtmp_create_stream_t *v)
|
|||
static double trans;
|
||||
ngx_rtmp_header_t h;
|
||||
|
||||
static ngx_rtmp_amf0_elt_t out_elts[] = {
|
||||
static ngx_rtmp_amf_elt_t out_elts[] = {
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
NULL,
|
||||
"_result", 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_NUMBER,
|
||||
{ NGX_RTMP_AMF_NUMBER,
|
||||
NULL,
|
||||
&trans, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_NULL,
|
||||
{ NGX_RTMP_AMF_NULL,
|
||||
NULL,
|
||||
NULL, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_NUMBER,
|
||||
{ NGX_RTMP_AMF_NUMBER,
|
||||
NULL,
|
||||
&stream, sizeof(stream) },
|
||||
};
|
||||
|
@ -301,14 +301,14 @@ ngx_rtmp_cmd_create_stream(ngx_rtmp_session_t *s, ngx_rtmp_create_stream_t *v)
|
|||
stream = NGX_RTMP_CMD_MSID;
|
||||
|
||||
ngx_memzero(&h, sizeof(h));
|
||||
h.csid = NGX_RTMP_CMD_CSID_AMF0_INI;
|
||||
h.type = NGX_RTMP_MSG_AMF0_CMD;
|
||||
h.csid = NGX_RTMP_CMD_CSID_AMF_INI;
|
||||
h.type = NGX_RTMP_MSG_AMF_CMD;
|
||||
|
||||
ngx_log_debug0(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
|
||||
"createStream");
|
||||
|
||||
/* send result with standard stream */
|
||||
return ngx_rtmp_send_amf0(s, &h, out_elts,
|
||||
return ngx_rtmp_send_amf(s, &h, out_elts,
|
||||
sizeof(out_elts) / sizeof(out_elts[0])) == NGX_OK
|
||||
? NGX_DONE
|
||||
: NGX_ERROR;
|
||||
|
@ -321,22 +321,22 @@ ngx_rtmp_cmd_delete_stream_init(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
|
|||
{
|
||||
static ngx_rtmp_delete_stream_t v;
|
||||
|
||||
static ngx_rtmp_amf0_elt_t in_elts[] = {
|
||||
static ngx_rtmp_amf_elt_t in_elts[] = {
|
||||
|
||||
{ NGX_RTMP_AMF0_NUMBER,
|
||||
{ NGX_RTMP_AMF_NUMBER,
|
||||
0,
|
||||
NULL, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_NULL,
|
||||
{ NGX_RTMP_AMF_NULL,
|
||||
0,
|
||||
NULL, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_NUMBER,
|
||||
{ NGX_RTMP_AMF_NUMBER,
|
||||
0,
|
||||
&v.stream, 0 },
|
||||
};
|
||||
|
||||
if (ngx_rtmp_receive_amf0(s, in, in_elts,
|
||||
if (ngx_rtmp_receive_amf(s, in, in_elts,
|
||||
sizeof(in_elts) / sizeof(in_elts[0])))
|
||||
{
|
||||
return NGX_ERROR;
|
||||
|
@ -362,22 +362,22 @@ ngx_rtmp_cmd_publish_init(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
|
|||
{
|
||||
static ngx_rtmp_publish_t v;
|
||||
|
||||
static ngx_rtmp_amf0_elt_t in_elts[] = {
|
||||
static ngx_rtmp_amf_elt_t in_elts[] = {
|
||||
|
||||
/* transaction is always 0 */
|
||||
{ NGX_RTMP_AMF0_NUMBER,
|
||||
{ NGX_RTMP_AMF_NUMBER,
|
||||
0,
|
||||
NULL, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_NULL,
|
||||
{ NGX_RTMP_AMF_NULL,
|
||||
0,
|
||||
NULL, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
0,
|
||||
&v.name, sizeof(v.name) },
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
0,
|
||||
&v.type, sizeof(v.type) },
|
||||
};
|
||||
|
@ -385,7 +385,7 @@ ngx_rtmp_cmd_publish_init(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
|
|||
ngx_memzero(&v, sizeof(v));
|
||||
|
||||
/* parse input */
|
||||
if (ngx_rtmp_receive_amf0(s, in, in_elts,
|
||||
if (ngx_rtmp_receive_amf(s, in, in_elts,
|
||||
sizeof(in_elts) / sizeof(in_elts[0])))
|
||||
{
|
||||
return NGX_ERROR;
|
||||
|
@ -404,36 +404,36 @@ ngx_rtmp_cmd_publish(ngx_rtmp_session_t *s, ngx_rtmp_publish_t *v)
|
|||
|
||||
static double trans;
|
||||
|
||||
static ngx_rtmp_amf0_elt_t out_inf[] = {
|
||||
static ngx_rtmp_amf_elt_t out_inf[] = {
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
"code",
|
||||
"NetStream.Publish.Start", 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
"level",
|
||||
"status", 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
"description",
|
||||
"Publish succeeded.", 0 },
|
||||
};
|
||||
|
||||
static ngx_rtmp_amf0_elt_t out_elts[] = {
|
||||
static ngx_rtmp_amf_elt_t out_elts[] = {
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
NULL,
|
||||
"onStatus", 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_NUMBER,
|
||||
{ NGX_RTMP_AMF_NUMBER,
|
||||
NULL,
|
||||
&trans, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_NULL,
|
||||
{ NGX_RTMP_AMF_NULL,
|
||||
NULL,
|
||||
NULL, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_OBJECT,
|
||||
{ NGX_RTMP_AMF_OBJECT,
|
||||
NULL,
|
||||
out_inf, sizeof(out_inf) },
|
||||
};
|
||||
|
@ -449,11 +449,11 @@ ngx_rtmp_cmd_publish(ngx_rtmp_session_t *s, ngx_rtmp_publish_t *v)
|
|||
|
||||
/* send onStatus reply */
|
||||
memset(&h, 0, sizeof(h));
|
||||
h.type = NGX_RTMP_MSG_AMF0_CMD;
|
||||
h.csid = NGX_RTMP_CMD_CSID_AMF0;
|
||||
h.type = NGX_RTMP_MSG_AMF_CMD;
|
||||
h.csid = NGX_RTMP_CMD_CSID_AMF;
|
||||
h.msid = NGX_RTMP_CMD_MSID;
|
||||
|
||||
if (ngx_rtmp_send_amf0(s, &h, out_elts,
|
||||
if (ngx_rtmp_send_amf(s, &h, out_elts,
|
||||
sizeof(out_elts) / sizeof(out_elts[0])) != NGX_OK)
|
||||
{
|
||||
return NGX_ERROR;
|
||||
|
@ -469,14 +469,14 @@ ngx_rtmp_cmd_fcpublish_init(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
|
|||
{
|
||||
static ngx_rtmp_fcpublish_t v;
|
||||
|
||||
static ngx_rtmp_amf0_elt_t in_elts[] = {
|
||||
static ngx_rtmp_amf_elt_t in_elts[] = {
|
||||
|
||||
/* transaction is always 0 */
|
||||
{ NGX_RTMP_AMF0_NUMBER,
|
||||
{ NGX_RTMP_AMF_NUMBER,
|
||||
0,
|
||||
NULL, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
0,
|
||||
&v.name, sizeof(v.name) },
|
||||
};
|
||||
|
@ -484,7 +484,7 @@ ngx_rtmp_cmd_fcpublish_init(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
|
|||
ngx_memzero(&v, sizeof(v));
|
||||
|
||||
/* parse input */
|
||||
if (ngx_rtmp_receive_amf0(s, in, in_elts,
|
||||
if (ngx_rtmp_receive_amf(s, in, in_elts,
|
||||
sizeof(in_elts) / sizeof(in_elts[0])))
|
||||
{
|
||||
return NGX_ERROR;
|
||||
|
@ -503,36 +503,36 @@ ngx_rtmp_cmd_fcpublish(ngx_rtmp_session_t *s, ngx_rtmp_fcpublish_t *v)
|
|||
|
||||
static double trans;
|
||||
|
||||
static ngx_rtmp_amf0_elt_t out_inf[] = {
|
||||
static ngx_rtmp_amf_elt_t out_inf[] = {
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
"code",
|
||||
"NetStream.Publish.Start", 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
"level",
|
||||
"status", 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
"description",
|
||||
"FCPublish succeeded.", 0 },
|
||||
};
|
||||
|
||||
static ngx_rtmp_amf0_elt_t out_elts[] = {
|
||||
static ngx_rtmp_amf_elt_t out_elts[] = {
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
NULL,
|
||||
"onFCPublish", 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_NUMBER,
|
||||
{ NGX_RTMP_AMF_NUMBER,
|
||||
NULL,
|
||||
&trans, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_NULL,
|
||||
{ NGX_RTMP_AMF_NULL,
|
||||
NULL,
|
||||
NULL, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_OBJECT,
|
||||
{ NGX_RTMP_AMF_OBJECT,
|
||||
NULL,
|
||||
out_inf, sizeof(out_inf) },
|
||||
};
|
||||
|
@ -542,11 +542,11 @@ ngx_rtmp_cmd_fcpublish(ngx_rtmp_session_t *s, ngx_rtmp_fcpublish_t *v)
|
|||
|
||||
/* send onFCPublish reply */
|
||||
memset(&h, 0, sizeof(h));
|
||||
h.type = NGX_RTMP_MSG_AMF0_CMD;
|
||||
h.csid = NGX_RTMP_CMD_CSID_AMF0;
|
||||
h.type = NGX_RTMP_MSG_AMF_CMD;
|
||||
h.csid = NGX_RTMP_CMD_CSID_AMF;
|
||||
h.msid = NGX_RTMP_CMD_MSID;
|
||||
|
||||
if (ngx_rtmp_send_amf0(s, &h, out_elts,
|
||||
if (ngx_rtmp_send_amf(s, &h, out_elts,
|
||||
sizeof(out_elts) / sizeof(out_elts[0])) != NGX_OK)
|
||||
{
|
||||
return NGX_ERROR;
|
||||
|
@ -562,30 +562,30 @@ ngx_rtmp_cmd_play_init(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
|
|||
{
|
||||
static ngx_rtmp_play_t v;
|
||||
|
||||
static ngx_rtmp_amf0_elt_t in_elts[] = {
|
||||
static ngx_rtmp_amf_elt_t in_elts[] = {
|
||||
|
||||
/* transaction is always 0 */
|
||||
{ NGX_RTMP_AMF0_NUMBER,
|
||||
{ NGX_RTMP_AMF_NUMBER,
|
||||
0,
|
||||
NULL, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_NULL,
|
||||
{ NGX_RTMP_AMF_NULL,
|
||||
0,
|
||||
NULL, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
0,
|
||||
&v.name, sizeof(v.name) },
|
||||
|
||||
{ NGX_RTMP_AMF0_OPTIONAL | NGX_RTMP_AMF0_NUMBER,
|
||||
{ NGX_RTMP_AMF_OPTIONAL | NGX_RTMP_AMF_NUMBER,
|
||||
0,
|
||||
&v.start, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_OPTIONAL | NGX_RTMP_AMF0_NUMBER,
|
||||
{ NGX_RTMP_AMF_OPTIONAL | NGX_RTMP_AMF_NUMBER,
|
||||
0,
|
||||
&v.duration, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_OPTIONAL | NGX_RTMP_AMF0_BOOLEAN,
|
||||
{ NGX_RTMP_AMF_OPTIONAL | NGX_RTMP_AMF_BOOLEAN,
|
||||
0,
|
||||
&v.reset, 0 }
|
||||
};
|
||||
|
@ -593,7 +593,7 @@ ngx_rtmp_cmd_play_init(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
|
|||
ngx_memzero(&v, sizeof(v));
|
||||
|
||||
/* parse input */
|
||||
if (ngx_rtmp_receive_amf0(s, in, in_elts,
|
||||
if (ngx_rtmp_receive_amf(s, in, in_elts,
|
||||
sizeof(in_elts) / sizeof(in_elts[0])))
|
||||
{
|
||||
return NGX_ERROR;
|
||||
|
@ -613,104 +613,104 @@ ngx_rtmp_cmd_play(ngx_rtmp_session_t *s, ngx_rtmp_play_t *v)
|
|||
static double trans;
|
||||
static int bfalse;
|
||||
|
||||
static ngx_rtmp_amf0_elt_t out_inf[] = {
|
||||
static ngx_rtmp_amf_elt_t out_inf[] = {
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
"code",
|
||||
"NetStream.Play.Reset", 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
"level",
|
||||
"status", 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
"description",
|
||||
"Playing and resetting.", 0 },
|
||||
};
|
||||
|
||||
static ngx_rtmp_amf0_elt_t out_elts[] = {
|
||||
static ngx_rtmp_amf_elt_t out_elts[] = {
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
NULL,
|
||||
"onStatus", 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_NUMBER,
|
||||
{ NGX_RTMP_AMF_NUMBER,
|
||||
NULL,
|
||||
&trans, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_NULL,
|
||||
{ NGX_RTMP_AMF_NULL,
|
||||
NULL,
|
||||
NULL, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_OBJECT,
|
||||
{ NGX_RTMP_AMF_OBJECT,
|
||||
NULL,
|
||||
out_inf, sizeof(out_inf) },
|
||||
};
|
||||
|
||||
static ngx_rtmp_amf0_elt_t out2_inf[] = {
|
||||
static ngx_rtmp_amf_elt_t out2_inf[] = {
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
"code",
|
||||
"NetStream.Play.Start", 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
"level",
|
||||
"status", 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
"description",
|
||||
"Started playing.", 0 },
|
||||
};
|
||||
|
||||
static ngx_rtmp_amf0_elt_t out2_elts[] = {
|
||||
static ngx_rtmp_amf_elt_t out2_elts[] = {
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
NULL,
|
||||
"onStatus", 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_NUMBER,
|
||||
{ NGX_RTMP_AMF_NUMBER,
|
||||
NULL,
|
||||
&trans, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_NULL,
|
||||
{ NGX_RTMP_AMF_NULL,
|
||||
NULL,
|
||||
NULL, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_OBJECT,
|
||||
{ NGX_RTMP_AMF_OBJECT,
|
||||
NULL,
|
||||
out2_inf,
|
||||
sizeof(out2_inf) },
|
||||
};
|
||||
|
||||
static ngx_rtmp_amf0_elt_t out3_elts[] = {
|
||||
static ngx_rtmp_amf_elt_t out3_elts[] = {
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
NULL,
|
||||
"|RtmpSampleAccess", 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_BOOLEAN,
|
||||
{ NGX_RTMP_AMF_BOOLEAN,
|
||||
NULL,
|
||||
&bfalse, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_BOOLEAN,
|
||||
{ NGX_RTMP_AMF_BOOLEAN,
|
||||
NULL,
|
||||
&bfalse, 0 },
|
||||
};
|
||||
|
||||
static ngx_rtmp_amf0_elt_t out4_inf[] = {
|
||||
static ngx_rtmp_amf_elt_t out4_inf[] = {
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
"code",
|
||||
"NetStream.Data.Start", 0 },
|
||||
};
|
||||
|
||||
static ngx_rtmp_amf0_elt_t out4_elts[] = {
|
||||
static ngx_rtmp_amf_elt_t out4_elts[] = {
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
NULL,
|
||||
"onStatus", 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_OBJECT,
|
||||
{ NGX_RTMP_AMF_OBJECT,
|
||||
NULL,
|
||||
out4_inf, sizeof(out4_inf) },
|
||||
};
|
||||
|
@ -727,32 +727,32 @@ ngx_rtmp_cmd_play(ngx_rtmp_session_t *s, ngx_rtmp_play_t *v)
|
|||
|
||||
/* send onStatus reply */
|
||||
memset(&h, 0, sizeof(h));
|
||||
h.type = NGX_RTMP_MSG_AMF0_CMD;
|
||||
h.csid = NGX_RTMP_CMD_CSID_AMF0;
|
||||
h.type = NGX_RTMP_MSG_AMF_CMD;
|
||||
h.csid = NGX_RTMP_CMD_CSID_AMF;
|
||||
h.msid = NGX_RTMP_CMD_MSID;
|
||||
|
||||
if (ngx_rtmp_send_amf0(s, &h, out_elts,
|
||||
if (ngx_rtmp_send_amf(s, &h, out_elts,
|
||||
sizeof(out_elts) / sizeof(out_elts[0])) != NGX_OK)
|
||||
{
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
/* send sample access meta message FIXME */
|
||||
if (ngx_rtmp_send_amf0(s, &h, out2_elts,
|
||||
if (ngx_rtmp_send_amf(s, &h, out2_elts,
|
||||
sizeof(out2_elts) / sizeof(out2_elts[0])) != NGX_OK)
|
||||
{
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
/* send data start meta message */
|
||||
h.type = NGX_RTMP_MSG_AMF0_META;
|
||||
if (ngx_rtmp_send_amf0(s, &h, out3_elts,
|
||||
h.type = NGX_RTMP_MSG_AMF_META;
|
||||
if (ngx_rtmp_send_amf(s, &h, out3_elts,
|
||||
sizeof(out3_elts) / sizeof(out3_elts[0])) != NGX_OK)
|
||||
{
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
if (ngx_rtmp_send_amf0(s, &h, out4_elts,
|
||||
if (ngx_rtmp_send_amf(s, &h, out4_elts,
|
||||
sizeof(out4_elts) / sizeof(out4_elts[0])) != NGX_OK)
|
||||
{
|
||||
return NGX_ERROR;
|
||||
|
@ -768,14 +768,14 @@ ngx_rtmp_cmd_fcsubscribe_init(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
|
|||
{
|
||||
static ngx_rtmp_fcsubscribe_t v;
|
||||
|
||||
static ngx_rtmp_amf0_elt_t in_elts[] = {
|
||||
static ngx_rtmp_amf_elt_t in_elts[] = {
|
||||
|
||||
/* transaction is always 0 */
|
||||
{ NGX_RTMP_AMF0_NUMBER,
|
||||
{ NGX_RTMP_AMF_NUMBER,
|
||||
0,
|
||||
NULL, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
0,
|
||||
&v.name, sizeof(v.name) },
|
||||
|
||||
|
@ -784,7 +784,7 @@ ngx_rtmp_cmd_fcsubscribe_init(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
|
|||
ngx_memzero(&v, sizeof(v));
|
||||
|
||||
/* parse input */
|
||||
if (ngx_rtmp_receive_amf0(s, in, in_elts,
|
||||
if (ngx_rtmp_receive_amf(s, in, in_elts,
|
||||
sizeof(in_elts) / sizeof(in_elts[0])))
|
||||
{
|
||||
return NGX_ERROR;
|
||||
|
@ -803,36 +803,36 @@ ngx_rtmp_cmd_fcsubscribe(ngx_rtmp_session_t *s, ngx_rtmp_fcsubscribe_t *v)
|
|||
|
||||
static double trans;
|
||||
|
||||
static ngx_rtmp_amf0_elt_t out_inf[] = {
|
||||
static ngx_rtmp_amf_elt_t out_inf[] = {
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
"code",
|
||||
"NetStream.Play.Start", 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
"level",
|
||||
"status", 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
"description",
|
||||
"Started playing.", 0 },
|
||||
};
|
||||
|
||||
static ngx_rtmp_amf0_elt_t out_elts[] = {
|
||||
static ngx_rtmp_amf_elt_t out_elts[] = {
|
||||
|
||||
{ NGX_RTMP_AMF0_STRING,
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
NULL,
|
||||
"onFCSubscribe", 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_NUMBER,
|
||||
{ NGX_RTMP_AMF_NUMBER,
|
||||
NULL,
|
||||
&trans, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_NULL,
|
||||
{ NGX_RTMP_AMF_NULL,
|
||||
NULL,
|
||||
NULL, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF0_OBJECT,
|
||||
{ NGX_RTMP_AMF_OBJECT,
|
||||
NULL,
|
||||
out_inf,
|
||||
sizeof(out_inf) },
|
||||
|
@ -843,11 +843,11 @@ ngx_rtmp_cmd_fcsubscribe(ngx_rtmp_session_t *s, ngx_rtmp_fcsubscribe_t *v)
|
|||
|
||||
/* send onFCSubscribe reply */
|
||||
memset(&h, 0, sizeof(h));
|
||||
h.type = NGX_RTMP_MSG_AMF0_CMD;
|
||||
h.csid = NGX_RTMP_CMD_CSID_AMF0;
|
||||
h.type = NGX_RTMP_MSG_AMF_CMD;
|
||||
h.csid = NGX_RTMP_CMD_CSID_AMF;
|
||||
h.msid = NGX_RTMP_CMD_MSID;
|
||||
|
||||
if (ngx_rtmp_send_amf0(s, &h, out_elts,
|
||||
if (ngx_rtmp_send_amf(s, &h, out_elts,
|
||||
sizeof(out_elts) / sizeof(out_elts[0])) != NGX_OK)
|
||||
{
|
||||
return NGX_ERROR;
|
||||
|
@ -867,7 +867,7 @@ ngx_rtmp_cmd_disconnect(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
|
|||
}
|
||||
|
||||
|
||||
static ngx_rtmp_amf0_handler_t ngx_rtmp_cmd_map[] = {
|
||||
static ngx_rtmp_amf_handler_t ngx_rtmp_cmd_map[] = {
|
||||
|
||||
{ ngx_string("connect"), ngx_rtmp_cmd_connect_init },
|
||||
{ ngx_string("createStream"), ngx_rtmp_cmd_create_stream_init },
|
||||
|
@ -888,7 +888,7 @@ ngx_rtmp_cmd_postconfiguration(ngx_conf_t *cf)
|
|||
{
|
||||
ngx_rtmp_core_main_conf_t *cmcf;
|
||||
ngx_rtmp_handler_pt *h;
|
||||
ngx_rtmp_amf0_handler_t *ch, *bh;
|
||||
ngx_rtmp_amf_handler_t *ch, *bh;
|
||||
size_t n, ncalls;
|
||||
|
||||
cmcf = ngx_rtmp_conf_get_module_main_conf(cf, ngx_rtmp_core_module);
|
||||
|
@ -899,9 +899,9 @@ ngx_rtmp_cmd_postconfiguration(ngx_conf_t *cf)
|
|||
h = ngx_array_push(&cmcf->events[NGX_RTMP_DISCONNECT]);
|
||||
*h = ngx_rtmp_cmd_disconnect;
|
||||
|
||||
/* register AMF0 callbacks */
|
||||
/* register AMF callbacks */
|
||||
ncalls = sizeof(ngx_rtmp_cmd_map) / sizeof(ngx_rtmp_cmd_map[0]);
|
||||
ch = ngx_array_push_n(&cmcf->amf0, ncalls);
|
||||
ch = ngx_array_push_n(&cmcf->amf, ncalls);
|
||||
if (h == NULL) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <strings.h>
|
||||
|
||||
#include "ngx_rtmp.h"
|
||||
#include "ngx_rtmp_amf0.h"
|
||||
#include "ngx_rtmp_amf.h"
|
||||
|
||||
|
||||
static void ngx_rtmp_init_session(ngx_connection_t *c);
|
||||
|
|
|
@ -164,6 +164,7 @@ ngx_rtmp_notify_publish_create(ngx_rtmp_session_t *s, void *arg,
|
|||
|
||||
hl->next = cl;
|
||||
cl->next = pl;
|
||||
pl->next = NULL;
|
||||
|
||||
return hl;
|
||||
}
|
||||
|
@ -229,6 +230,7 @@ ngx_rtmp_notify_play_create(ngx_rtmp_session_t *s, void *arg,
|
|||
|
||||
hl->next = cl;
|
||||
cl->next = pl;
|
||||
pl->next = NULL;
|
||||
|
||||
return hl;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
|
||||
#include "ngx_rtmp.h"
|
||||
#include "ngx_rtmp_amf0.h"
|
||||
#include "ngx_rtmp_amf.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
|
@ -157,10 +157,10 @@ ngx_rtmp_user_message_handler(ngx_rtmp_session_t *s,
|
|||
|
||||
|
||||
ngx_int_t
|
||||
ngx_rtmp_amf0_message_handler(ngx_rtmp_session_t *s,
|
||||
ngx_rtmp_amf_message_handler(ngx_rtmp_session_t *s,
|
||||
ngx_rtmp_header_t *h, ngx_chain_t *in)
|
||||
{
|
||||
ngx_rtmp_amf0_ctx_t act;
|
||||
ngx_rtmp_amf_ctx_t act;
|
||||
ngx_connection_t *c;
|
||||
ngx_rtmp_core_main_conf_t *cmcf;
|
||||
ngx_array_t *ch;
|
||||
|
@ -169,36 +169,36 @@ ngx_rtmp_amf0_message_handler(ngx_rtmp_session_t *s,
|
|||
|
||||
static u_char func[128];
|
||||
|
||||
static ngx_rtmp_amf0_elt_t elts[] = {
|
||||
{ NGX_RTMP_AMF0_STRING, 0, func, sizeof(func) },
|
||||
static ngx_rtmp_amf_elt_t elts[] = {
|
||||
{ NGX_RTMP_AMF_STRING, 0, func, sizeof(func) },
|
||||
};
|
||||
|
||||
c = s->connection;
|
||||
cmcf = ngx_rtmp_get_module_main_conf(s, ngx_rtmp_core_module);
|
||||
|
||||
/* read AMF0 func name & transaction id */
|
||||
/* read AMF func name & transaction id */
|
||||
act.link = in;
|
||||
act.log = s->connection->log;
|
||||
memset(func, 0, sizeof(func));
|
||||
|
||||
if (ngx_rtmp_amf0_read(&act, elts,
|
||||
if (ngx_rtmp_amf_read(&act, elts,
|
||||
sizeof(elts) / sizeof(elts[0])) != NGX_OK)
|
||||
{
|
||||
ngx_log_debug0(NGX_LOG_DEBUG_RTMP, c->log, 0,
|
||||
"AMF0 cmd failed");
|
||||
"AMF cmd failed");
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
len = ngx_strlen(func);
|
||||
|
||||
ch = ngx_hash_find(&cmcf->amf0_hash,
|
||||
ch = ngx_hash_find(&cmcf->amf_hash,
|
||||
ngx_hash_strlow(func, func, len), func, len);
|
||||
|
||||
if (ch && ch->nelts) {
|
||||
ph = ch->elts;
|
||||
for (n = 0; n < ch->nelts; ++n, ++ph) {
|
||||
ngx_log_debug3(NGX_LOG_DEBUG_RTMP, c->log, 0,
|
||||
"AMF0 func '%s' passed to handler %d/%d",
|
||||
"AMF func '%s' passed to handler %d/%d",
|
||||
func, n, ch->nelts);
|
||||
switch ((*ph)(s, h, in)) {
|
||||
case NGX_ERROR:
|
||||
|
@ -209,7 +209,7 @@ ngx_rtmp_amf0_message_handler(ngx_rtmp_session_t *s,
|
|||
}
|
||||
} else {
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_RTMP, c->log, 0,
|
||||
"AMF0 cmd '%s' no handler", func);
|
||||
"AMF cmd '%s' no handler", func);
|
||||
}
|
||||
|
||||
return NGX_OK;
|
||||
|
@ -217,14 +217,14 @@ ngx_rtmp_amf0_message_handler(ngx_rtmp_session_t *s,
|
|||
|
||||
|
||||
ngx_int_t
|
||||
ngx_rtmp_receive_amf0(ngx_rtmp_session_t *s, ngx_chain_t *in,
|
||||
ngx_rtmp_amf0_elt_t *elts, size_t nelts)
|
||||
ngx_rtmp_receive_amf(ngx_rtmp_session_t *s, ngx_chain_t *in,
|
||||
ngx_rtmp_amf_elt_t *elts, size_t nelts)
|
||||
{
|
||||
ngx_rtmp_amf0_ctx_t act;
|
||||
ngx_rtmp_amf_ctx_t act;
|
||||
|
||||
act.link = in;
|
||||
act.log = s->connection->log;
|
||||
|
||||
return ngx_rtmp_amf0_read(&act, elts, nelts);
|
||||
return ngx_rtmp_amf_read(&act, elts, nelts);
|
||||
}
|
||||
|
||||
|
|
|
@ -287,6 +287,7 @@ ngx_rtmp_record_notify_create(ngx_rtmp_session_t *s, void *arg,
|
|||
|
||||
hl->next = cl;
|
||||
cl->next = pl;
|
||||
pl->next = NULL;
|
||||
|
||||
return hl;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
|
||||
#include "ngx_rtmp.h"
|
||||
#include "ngx_rtmp_amf0.h"
|
||||
#include "ngx_rtmp_amf.h"
|
||||
|
||||
|
||||
#define NGX_RTMP_USER_START(s, tp) \
|
||||
|
@ -19,9 +19,6 @@
|
|||
__h.type = tp; \
|
||||
__h.csid = 2; \
|
||||
__l = ngx_rtmp_alloc_shared_buf(__cscf); \
|
||||
if (__l->buf->in_file) { \
|
||||
ngx_log_debug0(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, "send in file buf!!"); \
|
||||
} \
|
||||
if (__l == NULL) { \
|
||||
return NGX_ERROR; \
|
||||
} \
|
||||
|
@ -202,12 +199,12 @@ ngx_rtmp_send_user_unknown(ngx_rtmp_session_t *s, uint32_t timestamp)
|
|||
}
|
||||
|
||||
|
||||
/* AMF0 sender */
|
||||
/* AMF sender */
|
||||
ngx_int_t
|
||||
ngx_rtmp_send_amf0(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
|
||||
ngx_rtmp_amf0_elt_t *elts, size_t nelts)
|
||||
ngx_rtmp_send_amf(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
|
||||
ngx_rtmp_amf_elt_t *elts, size_t nelts)
|
||||
{
|
||||
ngx_rtmp_amf0_ctx_t act;
|
||||
ngx_rtmp_amf_ctx_t act;
|
||||
ngx_rtmp_core_srv_conf_t *cscf;
|
||||
|
||||
cscf = ngx_rtmp_get_module_srv_conf(s, ngx_rtmp_core_module);
|
||||
|
@ -217,7 +214,7 @@ ngx_rtmp_send_amf0(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
|
|||
act.alloc = ngx_rtmp_alloc_shared_buf;
|
||||
act.log = s->connection->log;
|
||||
|
||||
if (ngx_rtmp_amf0_write(&act, elts, nelts) != NGX_OK) {
|
||||
if (ngx_rtmp_amf_write(&act, elts, nelts) != NGX_OK) {
|
||||
if (act.first) {
|
||||
ngx_rtmp_free_shared_bufs(cscf, act.first);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue