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.
- Loading branch information
Showing
13 changed files
with
701 additions
and
54 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,23 @@ | ||
/* | ||
* Copyright (c) 2012 Roman Arutyunyan | ||
*/ | ||
|
||
|
||
#include "ngx_rtmp_bandwidth.h" | ||
|
||
|
||
void | ||
ngx_rtmp_update_bandwidth(ngx_rtmp_bandwidth_t *bw, uint32_t bytes) | ||
{ | ||
if (ngx_cached_time->sec > bw->intl_end) { | ||
bw->bandwidth = ngx_cached_time->sec > | ||
bw->intl_end + NGX_RTMP_BANDWIDTH_INTERVAL | ||
? 0 | ||
: bw->intl_bytes / NGX_RTMP_BANDWIDTH_INTERVAL; | ||
bw->intl_bytes = 0; | ||
bw->intl_end = ngx_cached_time->sec + NGX_RTMP_BANDWIDTH_INTERVAL; | ||
} | ||
|
||
bw->bytes += bytes; | ||
bw->intl_bytes += bytes; | ||
} |
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,30 @@ | ||
/* | ||
* Copyright (c) 2012 Roman Arutyunyan | ||
*/ | ||
|
||
|
||
#ifndef _NGX_RTMP_BANDWIDTH_H_INCLUDED_ | ||
#define _NGX_RTMP_BANDWIDTH_H_INCLUDED_ | ||
|
||
|
||
#include <ngx_core.h> | ||
|
||
|
||
/* Bandwidth update interval in seconds */ | ||
#define NGX_RTMP_BANDWIDTH_INTERVAL 60 | ||
|
||
|
||
typedef struct { | ||
uint64_t bytes; | ||
uint64_t bandwidth; /* bytes/sec */ | ||
|
||
time_t intl_end; | ||
uint64_t intl_bytes; | ||
} ngx_rtmp_bandwidth_t; | ||
|
||
|
||
void ngx_rtmp_update_bandwidth(ngx_rtmp_bandwidth_t *bw, uint32_t bytes); | ||
|
||
|
||
#endif /* _NGX_RTMP_BANDWIDTH_H_INCLUDED_ */ | ||
|
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
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,59 @@ | ||
/* | ||
* Copyright (c) 2012 Roman Arutyunyan | ||
*/ | ||
|
||
|
||
#ifndef _NGX_RTMP_LIVE_H_INCLUDED_ | ||
#define _NGX_RTMP_LIVE_H_INCLUDED_ | ||
|
||
|
||
#include "ngx_rtmp.h" | ||
#include "ngx_rtmp_bandwidth.h" | ||
|
||
|
||
/* session flags */ | ||
#define NGX_RTMP_LIVE_PUBLISHING 0x01 | ||
|
||
|
||
typedef struct ngx_rtmp_live_ctx_s ngx_rtmp_live_ctx_t; | ||
typedef struct ngx_rtmp_live_stream_s ngx_rtmp_live_stream_t; | ||
|
||
|
||
struct ngx_rtmp_live_ctx_s { | ||
ngx_rtmp_session_t *session; | ||
ngx_rtmp_live_stream_t *stream; | ||
ngx_rtmp_live_ctx_t *next; | ||
ngx_uint_t flags; | ||
ngx_uint_t msg_mask; | ||
ngx_uint_t dropped; | ||
uint32_t csid; | ||
uint32_t next_push; | ||
uint32_t last_audio; | ||
uint32_t last_video; | ||
}; | ||
|
||
|
||
struct ngx_rtmp_live_stream_s { | ||
u_char name[256]; | ||
ngx_rtmp_live_stream_t *next; | ||
ngx_rtmp_live_ctx_t *ctx; | ||
ngx_uint_t flags; | ||
ngx_rtmp_bandwidth_t bw_in; | ||
ngx_rtmp_bandwidth_t bw_out; | ||
}; | ||
|
||
|
||
typedef struct { | ||
ngx_int_t nbuckets; | ||
ngx_rtmp_live_stream_t **streams; | ||
ngx_flag_t live; | ||
ngx_msec_t buflen; | ||
ngx_pool_t *pool; | ||
ngx_rtmp_live_stream_t *free_streams; | ||
} ngx_rtmp_live_app_conf_t; | ||
|
||
|
||
extern ngx_module_t ngx_rtmp_live_module; | ||
|
||
|
||
#endif /* _NGX_RTMP_LIVE_H_INCLUDED_ */ |
Oops, something went wrong.