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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
#include <config.h>
#include "mov_encoder_writer.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <pthread.h>
#include <semaphore.h>
#include <errno.h>
#include <string>
using namespace std;
#include "miav_config.h"
#include <time.h>
#include "multiplexer.h"
#include "multicast_configuration.h"
MovEncoderWriter::MovEncoderWriter(const char *clientip, const char* cpr,
ThreadSafeQueuePriority *video_q,
ThreadSafeQueuePriority *audio_q,
Info *i)
{
info = i;
info->info("MovEncoderWriter");
char fname[256];
string *server_root;
char birthmonth[3];
char date[32];
server_root = config->readString("server_movie_root");
strncpy(birthmonth, &cpr[2], 2);
birthmonth[2] = 0;
struct tm *ltime;
time_t t = time(NULL);
ltime = localtime(&t);
sprintf(date, "%.4d%.2d%.2d",
ltime->tm_year + 1900,
ltime->tm_mon + 1,
ltime->tm_mday);
sprintf(fname, "%s/%s/%s/%s-%s-", server_root->c_str(), birthmonth, cpr, cpr, date);
file = new File(fname, "mpg", info);
MulticastConfiguration mcconfig(info, ETC"/multicast.conf");
mcastconf_t mcclientconf = mcconfig.getConf((char*)clientip);
info->info("Client: %s - Enabled: %s - Addr: %s - Port: %d - WithAudio: %s",
mcclientconf.client.c_str(),
mcclientconf.enabled?"Yes\0":"No\0",
mcclientconf.addr.c_str(),
mcclientconf.port,
mcclientconf.with_audio?"Yes\0":"No\0");
multicast = NULL;
if(mcclientconf.enabled) multicast = new Multicast(info,
mcclientconf);
video_queue = video_q;
audio_queue = audio_q;
running = true;
}
MovEncoderWriter::~MovEncoderWriter()
{
info->info("~MovEncoderWriter");
delete file;
if(multicast) delete multicast;
}
void MovEncoderWriter::thread_main()
{
info->info("MovEncoderWriter::run");
Multiplexer multiplexer(file, multicast,
info, &running,
video_queue,
audio_queue);
multiplexer.multiplex();
info->info("MovEncoderWriter::stop");
}
void MovEncoderWriter::setSaveState(n_savestate savestate)
{
file->setSaveState(savestate);
}
|