FuJuntang
2022-07-06 e5cff5a3ef373a5090f45cd1dfb0b85d9c851d5d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#ifndef __SRV_AV_DEMUX_H__
#define __SRV_AV_DEMUX_H__
 
#include <semaphore.h>
#include <pthread.h>
 
#include "capabilities/capa.h"
 
#ifdef __cplusplus
extern "C" {
#endif
 
#define VIDEO_PUT_DIR "/home/Work/Log_repo/video_log"
#define VIDEO_CONF_DATA "/usr/bin/video_conv.sh"
#define FFMPEG_BIN_DIR "/home/Work/Sources_temp/ffmpeg_sources/host/bin/ffmpeg"
 
#define VIDEO_DURATION    (5 * 60) //sec
 
#define KB (1024.0)
#define MB (KB * 1024.0)
#define GB (MB * 1024.0)
#define DISK_FREE_THRES   (0.05)
 
/*the player work mode status*/
enum wr_mode {
  NORMAL,
  PAUSE,
};
 
/*playback mode set key*/
typedef struct _playback_key {
 
  /*format: 192.168.1.101*/
  char name[PTOTO_ADDRESS_ADD];
 
  /*format: 2022-6-28*/
  char date[PTOTO_ADDRESS_ADD];
 
  /*format: 21-32-19*/
  char time[PTOTO_ADDRESS_ADD];
 
} playback_key;
 
/*the operational handle*/
typedef struct _AVDevs {
 
  /*the devices capabilities*/
  struct tagCapabilities capa;
 
  /*the profies for each servies*/
  struct tagProfile *profiles;
 
  timer_t timer_id;
  int timer_sec;
 
  sem_t sem_cap;
 
  volatile char run_stat;
  volatile char slice_stat;
 
  char ip[PROTO_ADDRESS_SIZE];
 
  char uri[PROTO_ADDRESS_SIZE + PTOTO_ADDRESS_ADD];
  char uri_data[PROTO_ADDRESS_SIZE + PTOTO_ADDRESS_ADD];
 
  /*the device work stat*/
  char dev_stat;
 
  /*the process work stat*/
  char proc_stat;
 
  /*the stat record for pause work mode*/
  char pause_enable;
  char pause_prev_loc[MAX_BUF_SIZE];
  char pause_cur_loc[MAX_BUF_SIZE];
 
  enum wr_mode work_mode;
 
} AVDevs;
 
int proto_AVInit(void);
void proto_AVStart(AVDevs *DevData);
void proto_AVStop(AVDevs *DevData, enum wr_mode mode);
void proto_AVClose(void);
AVDevs *proto_AVGethandle(void);
void get_stream(AVDevs *DevData);
int playback_get_key(playback_key set, char *buf, int length);
 
static int get_dir_with_key(char *dir_path, char *name, char *key, char *buf, int length);
static int get_file_with_key(char *dir_path, char *key, char *buf, int length, int flag);
static int get_dir_oldest(char *dir_path, char *buf, int length);
 
static void cb_av_probe(char *DeviceXAddr);
static int video_file_create(char *buf, int len);
static int av_start_cap(AVDevs *DevData);
 
static void system_date_get(char *buf, int len);
 
#endif