MPEG-DASH Support

Please not this is a work in progress.  For testing, please set dash_cleanup off;.
You can use this player to test.  http://dashif.org/reference/players/javascript/1.0.0/index.html
If you have a specific player that you need changes to support, please file an issue on github
This commit is contained in:
Stephen Basile 2013-09-30 13:58:02 -04:00
parent 67443c28b4
commit a5a59aa50c
4 changed files with 2389 additions and 0 deletions

3
config
View file

@ -20,6 +20,7 @@ CORE_MODULES="$CORE_MODULES
ngx_rtmp_log_module \
ngx_rtmp_limit_module \
ngx_rtmp_hls_module \
ngx_rtmp_dash_module \
"
@ -43,6 +44,7 @@ NGX_ADDON_DEPS="$NGX_ADDON_DEPS \
$ngx_addon_dir/ngx_rtmp_relay_module.h \
$ngx_addon_dir/ngx_rtmp_streams.h \
$ngx_addon_dir/hls/ngx_rtmp_mpegts.h \
$ngx_addon_dir/hls/ngx_rtmp_mp4.h \
"
@ -78,6 +80,7 @@ NGX_ADDON_SRCS="$NGX_ADDON_SRCS \
$ngx_addon_dir/ngx_rtmp_limit_module.c \
$ngx_addon_dir/hls/ngx_rtmp_hls_module.c \
$ngx_addon_dir/hls/ngx_rtmp_mpegts.c \
$ngx_addon_dir/hls/ngx_rtmp_mp4.c \
"
CFLAGS="$CFLAGS -I$ngx_addon_dir"

1284
hls/ngx_rtmp_dash_module.c Normal file

File diff suppressed because it is too large Load diff

1064
hls/ngx_rtmp_mp4.c Normal file

File diff suppressed because it is too large Load diff

38
hls/ngx_rtmp_mp4.h Normal file
View file

@ -0,0 +1,38 @@
#ifndef _NGX_RTMP_MP4_H_INCLUDED_
#define _NGX_RTMP_MP4_H_INCLUDED_
#include <ngx_config.h>
#include <ngx_core.h>
#include <ngx_rtmp.h>
typedef struct {
ngx_uint_t width;
ngx_uint_t height;
ngx_uint_t audio;
ngx_uint_t video;
ngx_uint_t sample_rate;
ngx_uint_t frame_rate;
} ngx_rtmp_mp4_metadata_t;
enum {
NGX_RTMP_MP4_FILETYPE_INIT = 0,
NGX_RTMP_MP4_FILETYPE_SEG = 1
};
#define NGX_RTMP_MP4_TIMESCALE 1000 /* divide all times by this value. this is the same resolution as RTMP so it is convenient */
#define NGX_RTMP_MP4_PREFERRED_RATE 0x00010000 /* normal forward playback as defined by spec */
#define NGX_RTMP_MP4_PREFERRED_VOLUME 0x0100 /* full volume as defined by spec */
ngx_int_t ngx_rtmp_mp4_write_ftyp(ngx_buf_t *b, int type, ngx_rtmp_mp4_metadata_t metadata);
ngx_int_t ngx_rtmp_mp4_write_moov(ngx_rtmp_session_t *s, ngx_buf_t *b, ngx_rtmp_mp4_metadata_t metadata);
ngx_int_t ngx_rtmp_mp4_write_moof(ngx_buf_t *b, ngx_uint_t earliest_pres_time, uint32_t sample_count,
uint32_t sample_sizes[128], uint32_t index, ngx_uint_t sample_rate);
ngx_int_t ngx_rtmp_mp4_write_sidx(ngx_rtmp_session_t *s, ngx_buf_t *b, ngx_uint_t reference_size,
ngx_uint_t earliest_pres_time, ngx_uint_t latest_pres_time, ngx_uint_t sample_rate);
ngx_uint_t ngx_rtmp_mp4_write_mdat(ngx_buf_t *b, ngx_uint_t size);
uint32_t ngx_rtmp_mp4_write_data(ngx_rtmp_session_t *s, ngx_file_t *file, ngx_buf_t *b);
#endif /* _NGX_RTMP_MP4_H_INCLUDED_ */