2013-11-03 20:11:37 +01:00
|
|
|
|
2012-08-20 18:44:14 +02:00
|
|
|
/*
|
2013-11-03 20:11:37 +01:00
|
|
|
* Copyright (C) Roman Arutyunyan
|
2012-08-20 18:44:14 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _NGX_RTMP_RECORD_H_INCLUDED_
|
|
|
|
#define _NGX_RTMP_RECORD_H_INCLUDED_
|
|
|
|
|
|
|
|
|
2013-06-11 19:00:39 +02:00
|
|
|
#include <ngx_config.h>
|
|
|
|
#include <ngx_core.h>
|
2012-08-20 18:44:14 +02:00
|
|
|
#include "ngx_rtmp.h"
|
|
|
|
|
2012-08-30 16:20:13 +02:00
|
|
|
|
2012-09-04 18:36:25 +02:00
|
|
|
#define NGX_RTMP_RECORD_OFF 0x01
|
|
|
|
#define NGX_RTMP_RECORD_AUDIO 0x02
|
|
|
|
#define NGX_RTMP_RECORD_VIDEO 0x04
|
|
|
|
#define NGX_RTMP_RECORD_KEYFRAMES 0x08
|
2012-09-05 12:33:21 +02:00
|
|
|
#define NGX_RTMP_RECORD_MANUAL 0x10
|
2012-09-04 18:36:25 +02:00
|
|
|
|
|
|
|
|
2012-08-30 16:20:13 +02:00
|
|
|
typedef struct {
|
2012-09-04 18:36:25 +02:00
|
|
|
ngx_str_t id;
|
2012-08-30 16:20:13 +02:00
|
|
|
ngx_uint_t flags;
|
|
|
|
ngx_str_t path;
|
|
|
|
size_t max_size;
|
|
|
|
size_t max_frames;
|
|
|
|
ngx_msec_t interval;
|
|
|
|
ngx_str_t suffix;
|
|
|
|
ngx_flag_t unique;
|
2013-02-28 06:20:12 +01:00
|
|
|
ngx_flag_t append;
|
2013-01-15 18:59:29 +01:00
|
|
|
ngx_flag_t lock_file;
|
2012-10-05 13:46:57 +02:00
|
|
|
ngx_flag_t notify;
|
2012-08-30 16:20:13 +02:00
|
|
|
ngx_url_t *url;
|
2012-09-04 15:47:32 +02:00
|
|
|
|
2012-09-12 12:57:24 +02:00
|
|
|
void **rec_conf;
|
|
|
|
ngx_array_t rec; /* ngx_rtmp_record_app_conf_t * */
|
2012-09-04 18:36:25 +02:00
|
|
|
} ngx_rtmp_record_app_conf_t;
|
2012-09-04 15:47:32 +02:00
|
|
|
|
|
|
|
|
2012-09-04 18:36:25 +02:00
|
|
|
typedef struct {
|
2012-09-12 12:57:24 +02:00
|
|
|
ngx_rtmp_record_app_conf_t *conf;
|
2012-08-30 16:20:13 +02:00
|
|
|
ngx_file_t file;
|
|
|
|
ngx_uint_t nframes;
|
2013-03-01 16:10:11 +01:00
|
|
|
uint32_t epoch, time_shift;
|
2012-08-30 16:20:13 +02:00
|
|
|
ngx_time_t last;
|
|
|
|
time_t timestamp;
|
2012-11-26 17:04:01 +01:00
|
|
|
unsigned failed:1;
|
2013-03-01 16:10:11 +01:00
|
|
|
unsigned initialized:1;
|
2012-12-14 18:03:38 +01:00
|
|
|
unsigned aac_header_sent:1;
|
|
|
|
unsigned avc_header_sent:1;
|
|
|
|
unsigned video_key_sent:1;
|
2014-01-20 16:13:18 +01:00
|
|
|
unsigned audio:1;
|
|
|
|
unsigned video:1;
|
2012-09-12 12:57:24 +02:00
|
|
|
} ngx_rtmp_record_rec_ctx_t;
|
2012-09-04 15:47:32 +02:00
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
2012-09-12 12:57:24 +02:00
|
|
|
ngx_array_t rec; /* ngx_rtmp_record_rec_ctx_t */
|
2012-08-30 16:20:13 +02:00
|
|
|
u_char name[NGX_RTMP_MAX_NAME];
|
|
|
|
u_char args[NGX_RTMP_MAX_ARGS];
|
|
|
|
} ngx_rtmp_record_ctx_t;
|
|
|
|
|
2012-08-20 18:44:14 +02:00
|
|
|
|
2012-09-27 12:24:51 +02:00
|
|
|
ngx_uint_t ngx_rtmp_record_find(ngx_rtmp_record_app_conf_t *racf,
|
|
|
|
ngx_str_t *id);
|
|
|
|
|
|
|
|
|
2012-09-05 18:20:45 +02:00
|
|
|
/* Manual recording control,
|
|
|
|
* 'n' is record node index in config array.
|
2012-09-12 12:57:24 +02:00
|
|
|
* Note: these functions allocate path in static buffer */
|
2012-09-05 18:20:45 +02:00
|
|
|
|
2013-11-30 08:21:53 +01:00
|
|
|
ngx_int_t ngx_rtmp_record_open(ngx_rtmp_session_t *s, ngx_uint_t n,
|
2012-09-12 12:57:24 +02:00
|
|
|
ngx_str_t *path);
|
2012-09-05 18:20:45 +02:00
|
|
|
ngx_int_t ngx_rtmp_record_close(ngx_rtmp_session_t *s, ngx_uint_t n,
|
2012-09-12 12:57:24 +02:00
|
|
|
ngx_str_t *path);
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
ngx_str_t recorder;
|
|
|
|
ngx_str_t path;
|
|
|
|
} ngx_rtmp_record_done_t;
|
|
|
|
|
|
|
|
|
2013-11-30 08:21:53 +01:00
|
|
|
typedef ngx_int_t (*ngx_rtmp_record_done_pt)(ngx_rtmp_session_t *s,
|
2012-09-12 12:57:24 +02:00
|
|
|
ngx_rtmp_record_done_t *v);
|
|
|
|
|
|
|
|
|
|
|
|
extern ngx_rtmp_record_done_pt ngx_rtmp_record_done;
|
2012-08-20 18:44:14 +02:00
|
|
|
|
|
|
|
|
2012-08-30 16:20:13 +02:00
|
|
|
extern ngx_module_t ngx_rtmp_record_module;
|
|
|
|
|
|
|
|
|
2012-08-20 18:44:14 +02:00
|
|
|
#endif /* _NGX_RTMP_RECORD_H_INCLUDED_ */
|