Add ffmpeg_remuxer
This commit is contained in:
42
opts/log.c
42
opts/log.c
@ -40,3 +40,45 @@ bool filter_log(const char *filename)
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int shrink_to_block(int size, int block)
|
||||
{
|
||||
return size / block * block;
|
||||
}
|
||||
|
||||
uint64_t get_time_us(clockid_t clock, struct timespec *ts, struct timeval *tv, int64_t delays_us)
|
||||
{
|
||||
struct timespec now;
|
||||
|
||||
if (clock != CLOCK_FROM_PARAMS) {
|
||||
clock_gettime(clock, &now);
|
||||
} else if (ts) {
|
||||
now = *ts;
|
||||
} else if (tv) {
|
||||
now.tv_sec = tv->tv_sec;
|
||||
now.tv_nsec = tv->tv_usec * 1000;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (delays_us > 0) {
|
||||
#define NS_IN_S (1000LL * 1000LL * 1000LL)
|
||||
int64_t nsec = now.tv_nsec + delays_us * 1000LL;
|
||||
now.tv_nsec = nsec % NS_IN_S;
|
||||
now.tv_sec += nsec / NS_IN_S;
|
||||
}
|
||||
|
||||
if (ts) {
|
||||
*ts = now;
|
||||
}
|
||||
if (tv) {
|
||||
tv->tv_sec = now.tv_sec;
|
||||
tv->tv_usec = now.tv_nsec / 1000;
|
||||
}
|
||||
return now.tv_sec * 1000000LL + now.tv_nsec / 1000;
|
||||
}
|
||||
|
||||
uint64_t get_monotonic_time_us(struct timespec *ts, struct timeval *tv)
|
||||
{
|
||||
return get_time_us(CLOCK_MONOTONIC, ts, tv, 0);
|
||||
}
|
||||
|
10
opts/log.h
10
opts/log.h
@ -2,6 +2,10 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#define __FILENAME__ __FILE__
|
||||
|
||||
@ -25,3 +29,9 @@ bool filter_log(const char *filename);
|
||||
#define E_LOG_INFO(dev, _msg, ...) do { fprintf(stderr, "%s: %s: " _msg "\n", __FILENAME__, dev_name(dev), ##__VA_ARGS__); } while(0)
|
||||
#define E_LOG_VERBOSE(dev, _msg, ...) do { if (log_options.debug || log_options.verbose || filter_log(__FILENAME__)) { fprintf(stderr, "%s: %s: " _msg "\n", __FILENAME__, dev_name(dev), ##__VA_ARGS__); } } while(0)
|
||||
#define E_LOG_DEBUG(dev, _msg, ...) do { if (log_options.debug || filter_log(__FILENAME__)) { fprintf(stderr, "%s: %s: " _msg "\n", __FILENAME__, dev_name(dev), ##__VA_ARGS__); } } while(0)
|
||||
|
||||
#define CLOCK_FROM_PARAMS -1
|
||||
|
||||
uint64_t get_monotonic_time_us(struct timespec *ts, struct timeval *tv);
|
||||
uint64_t get_time_us(clockid_t clock, struct timespec *ts, struct timeval *tv, int64_t delays_us);
|
||||
int shrink_to_block(int size, int block);
|
||||
|
Reference in New Issue
Block a user