mirror of
https://github.com/zotanmew/nginx-rtmp-module.git
synced 2024-06-28 16:09:00 +02:00
fixed opening fragments & improved style
This commit is contained in:
parent
3b680915a8
commit
2c7111cf10
|
@ -505,8 +505,9 @@ ngx_rtmp_dash_close_fragment(ngx_rtmp_session_t *s, ngx_rtmp_dash_track_t *t)
|
|||
return;
|
||||
}
|
||||
|
||||
ngx_log_debug2(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
|
||||
"dash: close fragment id=%ui, type=%c", t->id, t->type);
|
||||
ngx_log_debug3(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
|
||||
"dash: close fragment id=%ui, type=%c, pts=%uD",
|
||||
t->id, t->type, t->earliest_pres_time);
|
||||
|
||||
ctx = ngx_rtmp_get_module_ctx(s, ngx_rtmp_dash_module);
|
||||
|
||||
|
@ -519,9 +520,6 @@ ngx_rtmp_dash_close_fragment(ngx_rtmp_session_t *s, ngx_rtmp_dash_track_t *t)
|
|||
pos = b.last;
|
||||
b.last += 44; /* leave room for sidx */
|
||||
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
|
||||
"dash: fragment earliest pts: %uD", t->earliest_pres_time);
|
||||
|
||||
ngx_rtmp_mp4_write_moof(&b, t->earliest_pres_time, t->sample_count,
|
||||
t->samples, t->sample_mask, t->id);
|
||||
pos1 = b.last;
|
||||
|
@ -593,15 +591,14 @@ ngx_rtmp_dash_close_fragments(ngx_rtmp_session_t *s)
|
|||
{
|
||||
ngx_rtmp_dash_ctx_t *ctx;
|
||||
|
||||
ngx_log_debug0(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
|
||||
"dash: close fragments");
|
||||
|
||||
ctx = ngx_rtmp_get_module_ctx(s, ngx_rtmp_dash_module);
|
||||
|
||||
if (!ctx->opened) {
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
ngx_log_debug0(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
|
||||
"dash: close fragments");
|
||||
|
||||
ngx_rtmp_dash_close_fragment(s, &ctx->video);
|
||||
ngx_rtmp_dash_close_fragment(s, &ctx->audio);
|
||||
|
||||
|
@ -626,6 +623,9 @@ ngx_rtmp_dash_open_fragment(ngx_rtmp_session_t *s, ngx_rtmp_dash_track_t *t,
|
|||
return NGX_OK;
|
||||
}
|
||||
|
||||
ngx_log_debug2(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
|
||||
"dash: open fragment id=%ui, type='%c'", id, type);
|
||||
|
||||
ctx = ngx_rtmp_get_module_ctx(s, ngx_rtmp_dash_module);
|
||||
|
||||
*ngx_sprintf(ctx->stream.data + ctx->stream.len, "raw.m4%c", type) = 0;
|
||||
|
@ -675,15 +675,9 @@ ngx_rtmp_dash_open_fragments(ngx_rtmp_session_t *s)
|
|||
return NGX_OK;
|
||||
}
|
||||
|
||||
if (ctx->has_video) {
|
||||
ngx_rtmp_dash_open_fragment(s, &ctx->video, ctx->id, 'v');
|
||||
}
|
||||
ngx_rtmp_dash_open_fragment(s, &ctx->video, ctx->id, 'v');
|
||||
|
||||
if (ctx->has_audio) {
|
||||
ngx_rtmp_dash_open_fragment(s, &ctx->audio, ctx->id, 'a');
|
||||
}
|
||||
|
||||
//ctx->id++;
|
||||
ngx_rtmp_dash_open_fragment(s, &ctx->audio, ctx->id, 'a');
|
||||
|
||||
ctx->opened = 1;
|
||||
|
||||
|
|
|
@ -496,7 +496,7 @@ ngx_rtmp_mp4_write_avcc(ngx_rtmp_session_t *s, ngx_buf_t *b,
|
|||
|
||||
pos = ngx_rtmp_mp4_start_box(b, "avcC");
|
||||
|
||||
/* assume config fits ont chunk (highly probable) */
|
||||
/* assume config fits one chunk (highly probable) */
|
||||
|
||||
/* check for start code */
|
||||
for (p = in->buf->pos; p <= in->buf->last; p++) {
|
||||
|
|
|
@ -16,28 +16,28 @@
|
|||
|
||||
|
||||
typedef struct {
|
||||
uint32_t size;
|
||||
uint32_t duration;
|
||||
uint32_t delay;
|
||||
uint32_t timestamp;
|
||||
unsigned key:1;
|
||||
uint32_t size;
|
||||
uint32_t duration;
|
||||
uint32_t delay;
|
||||
uint32_t timestamp;
|
||||
unsigned key:1;
|
||||
} ngx_rtmp_mp4_sample_t;
|
||||
|
||||
|
||||
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_uint_t audio_codec;
|
||||
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_uint_t audio_codec;
|
||||
} ngx_rtmp_mp4_metadata_t;
|
||||
|
||||
|
||||
enum {
|
||||
NGX_RTMP_MP4_FILETYPE_INIT = 0,
|
||||
NGX_RTMP_MP4_FILETYPE_SEG = 1
|
||||
NGX_RTMP_MP4_FILETYPE_SEG
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue