forked from arut/nginx-rtmp-module
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemented avc sps parser & improved dash & stats
- Loading branch information
Showing
9 changed files
with
483 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
|
||
/* | ||
* Copyright (C) Roman Arutyunyan | ||
*/ | ||
|
||
|
||
#include <ngx_config.h> | ||
#include <ngx_core.h> | ||
#include "ngx_rtmp_bitop.h" | ||
|
||
|
||
void | ||
ngx_rtmp_bit_init_reader(ngx_rtmp_bit_reader_t *br, u_char *pos, u_char *last) | ||
{ | ||
ngx_memzero(br, sizeof(ngx_rtmp_bit_reader_t)); | ||
|
||
br->pos = pos; | ||
br->last = last; | ||
} | ||
|
||
|
||
uint64_t | ||
ngx_rtmp_bit_read(ngx_rtmp_bit_reader_t *br, ngx_uint_t n) | ||
{ | ||
uint64_t v; | ||
ngx_uint_t d; | ||
|
||
v = 0; | ||
|
||
while (n) { | ||
|
||
if (br->pos >= br->last) { | ||
br->err = 1; | ||
return 0; | ||
} | ||
|
||
d = (br->offs + n > 8 ? (ngx_uint_t) (8 - br->offs) : n); | ||
|
||
v <<= d; | ||
v += (*br->pos >> (8 - br->offs - d)) & ((u_char) 0xff >> (8 - d)); | ||
|
||
br->offs += d; | ||
n -= d; | ||
|
||
if (br->offs == 8) { | ||
br->pos++; | ||
br->offs = 0; | ||
} | ||
} | ||
|
||
return v; | ||
} | ||
|
||
|
||
uint64_t | ||
ngx_rtmp_bit_read_golomb(ngx_rtmp_bit_reader_t *br) | ||
{ | ||
ngx_uint_t n; | ||
|
||
for (n = 0; ngx_rtmp_bit_read(br, 1) == 0 && !br->err; n++); | ||
|
||
return ((uint64_t) 1 << n) + ngx_rtmp_bit_read(br, n) - 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
/* | ||
* Copyright (C) Roman Arutyunyan | ||
*/ | ||
|
||
|
||
#ifndef _NGX_RTMP_BITOP_H_INCLUDED_ | ||
#define _NGX_RTMP_BITOP_H_INCLUDED_ | ||
|
||
|
||
#include <ngx_config.h> | ||
#include <ngx_core.h> | ||
|
||
|
||
typedef struct { | ||
u_char *pos; | ||
u_char *last; | ||
ngx_uint_t offs; | ||
ngx_uint_t err; | ||
} ngx_rtmp_bit_reader_t; | ||
|
||
|
||
void ngx_rtmp_bit_init_reader(ngx_rtmp_bit_reader_t *br, u_char *pos, | ||
u_char *last); | ||
uint64_t ngx_rtmp_bit_read(ngx_rtmp_bit_reader_t *br, ngx_uint_t n); | ||
uint64_t ngx_rtmp_bit_read_golomb(ngx_rtmp_bit_reader_t *br); | ||
|
||
|
||
#define ngx_rtmp_bit_read_err(br) ((br)->err) | ||
|
||
#define ngx_rtmp_bit_read_eof(br) ((br)->pos == (br)->last) | ||
|
||
#define ngx_rtmp_bit_read_8(br) \ | ||
((uint8_t) ngx_rtmp_bit_read(br, 8)) | ||
|
||
#define ngx_rtmp_bit_read_16(br) \ | ||
((uint16_t) ngx_rtmp_bit_read(br, 16)) | ||
|
||
#define ngx_rtmp_bit_read_32(br) \ | ||
((uint32_t) ngx_rtmp_bit_read(br, 32)) | ||
|
||
#define ngx_rtmp_bit_read_64(br) \ | ||
((uint64_t) ngx_rtmp_read(br, 64)) | ||
|
||
|
||
#endif /* _NGX_RTMP_BITOP_H_INCLUDED_ */ |
Oops, something went wrong.