UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
thumbnailgen.cpp File Reference
#include <iostream>
#include <filesystem>
#include <string_view>
#include <memory>
#include <chrono>
#include <cassert>
#include <stdio.h>
#include <jpeglib.h>
#include "ipc_frame_unix.h"
Include dependency graph for thumbnailgen.cpp:

Go to the source code of this file.

Classes

struct  file_deleter
 
class  Img_writer
 

Typedefs

using File_uniq = std::unique_ptr<FILE, file_deleter>
 

Functions

int main (int argc, char **argv)
 

Typedef Documentation

◆ File_uniq

using File_uniq = std::unique_ptr<FILE, file_deleter>

Definition at line 12 of file thumbnailgen.cpp.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 59 of file thumbnailgen.cpp.

59 {
60 if(argc != 4){
61 fprintf(stderr, "Usage: %s <socket path> <output path> <fps>\n", argv[0]);
62 return 1;
63 }
64
66 Ipc_frame_uniq ipc_frame(ipc_frame_new());
67
68 Img_writer img_writer;
69
70 using clock = std::chrono::steady_clock;
71 auto frame_time = std::chrono::duration_cast<clock::duration>(std::chrono::duration<double>(1 / std::stod(argv[3])));
72 auto next_frame = clock::now();
73
74 while(true){
75 printf("Waiting for connection...\n");
77 printf("Connected...\n");
78 while(ipc_frame_reader_read(reader.get(), ipc_frame.get())){
79 auto now = clock::now();
80 if(now < next_frame)
81 continue;
82
83 std::string path = argv[2];
84 std::string tmp_path = path + ".swp";
85
86 img_writer.write_img(ipc_frame.get(), tmp_path);
87 std::filesystem::rename(tmp_path, path);
88
89 next_frame = std::max(next_frame + frame_time, now);
90 }
91 fprintf(stderr, "Failed to read frame\n");
92 }
93
94 return 0;
95}
bool write_img(Ipc_frame *f, const std::string &path)
Ipc_frame * ipc_frame_new()
Definition ipc_frame.cpp:48
std::unique_ptr< Ipc_frame, Ipc_frame_deleter > Ipc_frame_uniq
Definition ipc_frame.h:40
void ipc_frame_reader_wait_connect(struct Ipc_frame_reader *reader)
Ipc_frame_reader * ipc_frame_reader_new(const char *path)
bool ipc_frame_reader_read(Ipc_frame_reader *reader, Ipc_frame *dst)
std::unique_ptr< Ipc_frame_reader, Ipc_frame_reader_deleter > Ipc_frame_reader_uniq

References ipc_frame_new(), ipc_frame_reader_new(), ipc_frame_reader_read(), ipc_frame_reader_wait_connect(), and Img_writer::write_img().

Here is the call graph for this function: