|
|
@ -20,14 +20,33 @@ void usage(std::ostream& o, const char* name, int exitcode){
|
|
|
|
exit(exitcode);
|
|
|
|
exit(exitcode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// frame count is in the ncplane's user pointer
|
|
|
|
constexpr auto NANOSECS_IN_SEC = 1000000000ll;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static inline uint64_t
|
|
|
|
|
|
|
|
timespec_to_ns(const struct timespec* ts){
|
|
|
|
|
|
|
|
return ts->tv_sec * NANOSECS_IN_SEC + ts->tv_nsec;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// frame count is in the curry. original time is in the ncplane's userptr.
|
|
|
|
int perframe(struct notcurses* nc, struct ncvisual* ncv, void* vframecount){
|
|
|
|
int perframe(struct notcurses* nc, struct ncvisual* ncv, void* vframecount){
|
|
|
|
|
|
|
|
const struct timespec* start = static_cast<struct timespec*>(ncplane_userptr(ncvisual_plane(ncv)));
|
|
|
|
struct ncplane* stdn = notcurses_stdplane(nc);
|
|
|
|
struct ncplane* stdn = notcurses_stdplane(nc);
|
|
|
|
int* framecount = static_cast<int*>(vframecount);
|
|
|
|
int* framecount = static_cast<int*>(vframecount);
|
|
|
|
++*framecount;
|
|
|
|
++*framecount;
|
|
|
|
ncplane_set_fg(stdn, 0x80c080);
|
|
|
|
ncplane_set_fg(stdn, 0x80c080);
|
|
|
|
ncplane_cursor_move_yx(stdn, 0, 0);
|
|
|
|
ncplane_cursor_move_yx(stdn, 0, 0);
|
|
|
|
|
|
|
|
struct timespec now;
|
|
|
|
|
|
|
|
clock_gettime(CLOCK_MONOTONIC, &now);
|
|
|
|
|
|
|
|
int64_t ns = timespec_to_ns(&now) - timespec_to_ns(start);
|
|
|
|
ncplane_printf(stdn, "Got frame %05d\u2026", *framecount);
|
|
|
|
ncplane_printf(stdn, "Got frame %05d\u2026", *framecount);
|
|
|
|
|
|
|
|
const int64_t h = ns / (60 * 60 * NANOSECS_IN_SEC);
|
|
|
|
|
|
|
|
ns -= h * (60 * 60 * NANOSECS_IN_SEC);
|
|
|
|
|
|
|
|
const int64_t m = ns / (60 * NANOSECS_IN_SEC);
|
|
|
|
|
|
|
|
ns -= m * (60 * NANOSECS_IN_SEC);
|
|
|
|
|
|
|
|
const int64_t s = ns / NANOSECS_IN_SEC;
|
|
|
|
|
|
|
|
ns -= s * NANOSECS_IN_SEC;
|
|
|
|
|
|
|
|
ncplane_printf_aligned(stdn, 0, NCALIGN_RIGHT, "%02ld:%02ld:%02ld.%04ld",
|
|
|
|
|
|
|
|
h, m, s, ns / 1000000);
|
|
|
|
if(ncvisual_render(ncv, 0, 0, 0, 0)){
|
|
|
|
if(ncvisual_render(ncv, 0, 0, 0, 0)){
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -49,7 +68,8 @@ int main(int argc, char** argv){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int dimy, dimx;
|
|
|
|
int dimy, dimx;
|
|
|
|
notcurses_term_dim_yx(nc, &dimy, &dimx);
|
|
|
|
notcurses_term_dim_yx(nc, &dimy, &dimx);
|
|
|
|
auto ncp = notcurses_newplane(nc, dimy - 1, dimx, 1, 0, nullptr);
|
|
|
|
struct timespec start;
|
|
|
|
|
|
|
|
auto ncp = notcurses_newplane(nc, dimy - 1, dimx, 1, 0, &start);
|
|
|
|
if(ncp == nullptr){
|
|
|
|
if(ncp == nullptr){
|
|
|
|
notcurses_stop(nc);
|
|
|
|
notcurses_stop(nc);
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
return EXIT_FAILURE;
|
|
|
@ -65,6 +85,7 @@ int main(int argc, char** argv){
|
|
|
|
std::cerr << "Error opening " << argv[i] << ": " << errbuf.data() << std::endl;
|
|
|
|
std::cerr << "Error opening " << argv[i] << ": " << errbuf.data() << std::endl;
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
clock_gettime(CLOCK_MONOTONIC, &start);
|
|
|
|
if(ncvisual_stream(nc, ncv, &averr, perframe, &frames)){
|
|
|
|
if(ncvisual_stream(nc, ncv, &averr, perframe, &frames)){
|
|
|
|
av_make_error_string(errbuf.data(), errbuf.size(), averr);
|
|
|
|
av_make_error_string(errbuf.data(), errbuf.size(), averr);
|
|
|
|
notcurses_stop(nc);
|
|
|
|
notcurses_stop(nc);
|
|
|
|