HTTPD *global_httpd;
void load_existing_frames();
-int record_thread_func();
+void record_thread_func();
int main(int argc, char **argv)
{
string frame_dir = global_flags.working_directory + "/frames";
- struct stat st;
- if (stat(frame_dir.c_str(), &st) == -1) {
+ if (mkdir(frame_dir.c_str(), 0777) == 0) {
fprintf(stderr, "%s does not exist, creating it.\n", frame_dir.c_str());
- if (mkdir(frame_dir.c_str(), 0777) == -1) {
- perror(global_flags.working_directory.c_str());
- exit(1);
- }
+ } else if (errno != EEXIST) {
+ perror(global_flags.working_directory.c_str());
+ exit(1);
}
avformat_network_init();
{
QSurface *surface = create_surface();
QOpenGLContext *context = create_context(surface);
- make_current(context, surface);
+ if (!make_current(context, surface)) {
+ printf("oops\n");
+ exit(1);
+ }
CHECK(movit::init_movit(MOVIT_SHADER_DIR, movit::MOVIT_DEBUG_OFF));
delete_context(context);
// TODO: Delete the surface, too.
if (!all_frames.empty()) {
// We already had this cached in the database, so no need to look in the file.
for (const DB::FrameOnDiskAndStreamIdx &frame : all_frames) {
- if (frame.stream_idx >= 0 && frame.stream_idx < MAX_STREAMS) {
+ if (frame.stream_idx < MAX_STREAMS) {
frames[frame.stream_idx].push_back(frame.frame);
start_pts = max(start_pts, frame.frame.pts);
}
FrameOnDisk frame;
frame.pts = hdr.pts();
frame.offset = ftell(fp);
+ if (frame.offset == -1) {
+ fprintf(stderr, "WARNING: %s: ftell() failed (%s).\n", filename, strerror(errno));
+ break;
+ }
frame.filename_idx = filename_idx;
frame.size = hdr.file_size();
filename, skipped_bytes);
}
- size_t size = ftell(fp);
+ off_t size = ftell(fp);
fclose(fp);
+ if (size == -1) {
+ fprintf(stderr, "WARNING: %s: ftell() failed (%s).\n", filename, strerror(errno));
+ return;
+ }
+
db->store_frame_file(basename, size, all_frames);
}
db.clean_unused_frame_files(frame_basenames);
}
-int record_thread_func()
+void record_thread_func()
{
+ if (global_flags.stream_source.empty() || global_flags.stream_source == "/dev/null") {
+ // Save the user from some repetitive messages.
+ return;
+ }
+
pthread_setname_np(pthread_self(), "ReceiveFrames");
int64_t pts_offset;
start_pts = last_pts + TIMEBASE;
}
- return 0;
}