FFmpegfs Fuse Multi Media Filesystem 2.16
Classes | Macros | Typedefs | Enumerations | Functions | Variables
ffmpegfs.h File Reference

Main include for FFmpegfs project. More...

#include <fuse.h>
#include <stdarg.h>
#include "ffmpeg_utils.h"
#include "fileio.h"
Include dependency graph for ffmpegfs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  FFMPEGFS_PARAMS
 Global program parameters. More...
 

Macros

#define FUSE_USE_VERSION   26
 Requested minimum FUSE version. More...
 

Typedefs

typedef std::multimap< AVCodecID, int > HWACCEL_BLOCKED_MAP
 Map command line option to AVCodecID. More...
 

Enumerations

enum class  HWACCELAPI { NONE , VAAPI , MMAL , OMX }
 Hardware acceleration types. More...
 

Functions

void init_fuse_ops ()
 Initialise FUSE operation structure. More...
 
void transcoder_cache_path (std::string *path)
 Get transcoder cache path. More...
 
bool transcoder_init ()
 Initialise transcoder, create cache. More...
 
void transcoder_free ()
 Free transcoder. More...
 
bool transcoder_cache_maintenance ()
 Run cache maintenance. More...
 
bool transcoder_cache_clear ()
 Clear transcoder cache. More...
 
LPVIRTUALFILE insert_file (VIRTUALTYPE type, const std::string &virtfile, const struct stat *stbuf, int flags=VIRTUALFLAG_NONE)
 Add new virtual file to internal list. More...
 
LPVIRTUALFILE insert_file (VIRTUALTYPE type, const std::string &virtfile, const std::string &origfile, const struct stat *stbuf, int flags=VIRTUALFLAG_NONE)
 Add new virtual file to internal list. If the file already exists, it will be updated. More...
 
LPVIRTUALFILE insert_dir (VIRTUALTYPE type, const std::string &virtdir, const struct stat *stbuf, int flags=VIRTUALFLAG_NONE)
 Add new virtual directory to the internal list. If the file already exists, it will be updated. More...
 
LPVIRTUALFILE find_file (const std::string &virtfile)
 Find file in cache. More...
 
LPVIRTUALFILE find_file_from_orig (const std::string &origfile)
 Look for the file in the cache. More...
 
bool check_path (const std::string &path)
 Check if the path has already been parsed. Only useful if for DVD, Blu-ray or VCD where it is guaranteed that all files have been parsed whenever the directory is in the hash. More...
 
int load_path (const std::string &path, const struct stat *statbuf, void *buf, fuse_fill_dir_t filler)
 Load a path with virtual files for FUSE. More...
 
LPVIRTUALFILE find_original (const std::string &origpath)
 Given the destination (post-transcode) file name, determine the parent of the file to be transcoded. More...
 
LPVIRTUALFILE find_original (std::string *filepath)
 Given the destination (post-transcode) file name, determine the name of the original file to be transcoded. More...
 
LPVIRTUALFILE find_parent (const std::string &origpath)
 Given the destination (post-transcode) file name, determine the parent of the file to be transcoded. More...
 
std::string get_sampleformat_text (SAMPLE_FMT sample_fmt)
 Convert SAMPLE_FMT enum to human readable text. More...
 
std::string get_audio_codec_text (AVCodecID audio_codec)
 Convert AVCodecID enum for audio codec to human readable text. More...
 
std::string get_video_codec_text (AVCodecID video_codec)
 Convert AVCodecID enum for video codec to human readable text. More...
 
std::string get_autocopy_text (AUTOCOPY autocopy)
 Convert AUTOCOPY enum to human readable text. More...
 
std::string get_recodesame_text (RECODESAME recode)
 Convert RECODESAME enum to human readable text. More...
 
std::string get_profile_text (PROFILE profile)
 Convert PROFILE enum to human readable text. More...
 
std::string get_level_text (PRORESLEVEL level)
 Convert PRORESLEVEL enum to human readable text. More...
 
std::string get_hwaccel_API_text (HWACCELAPI hwaccel_API)
 Get the selected hardware acceleration as text. More...
 
bool check_hwaccel_dec_blocked (AVCodecID codec_id, int profile)
 Check if codec_id and the optional profile are in the block list. More...
 
int add_fuse_entry (void *buf, fuse_fill_dir_t filler, const std::string &name, const struct stat *stbuf, off_t off)
 Wrapper to the Fuse filler function. More...
 
int add_dotdot (void *buf, fuse_fill_dir_t filler, const struct stat *stbuf, off_t off)
 Make dot and double dot entries for a virtual directory. More...
 

Variables

FFMPEGFS_FORMAT_ARR ffmpeg_format
 Two FFmpegfs_Format infos, 0: video file, 1: audio file. More...
 
struct FFMPEGFS_PARAMS params
 Command line parameters.
 
bool docker_client
 True if running inside a Docker container. More...
 
fuse_operations ffmpegfs_ops
 Fuse operations struct. More...
 
std::unique_ptr< thread_pooltp
 Thread pool object. More...
 

Detailed Description

Main include for FFmpegfs project.

Author
Norbert Schlia (nschl.nosp@m.ia@o.nosp@m.blivi.nosp@m.on-s.nosp@m.oftwa.nosp@m.re.d.nosp@m.e)

Definition in file ffmpegfs.h.

Macro Definition Documentation

◆ FUSE_USE_VERSION

#define FUSE_USE_VERSION   26

Requested minimum FUSE version.

Definition at line 100 of file ffmpegfs.h.

Typedef Documentation

◆ HWACCEL_BLOCKED_MAP

typedef std::multimap<AVCodecID, int> HWACCEL_BLOCKED_MAP

Map command line option to AVCodecID.

Definition at line 158 of file ffmpegfs.h.

Enumeration Type Documentation

◆ HWACCELAPI

enum class HWACCELAPI
strong

Hardware acceleration types.

Enumerator
VAAPI 

Intel: VAAPI

MMAL 

Raspberry: MMAL

OMX 

Raspberry: OpenMAX

Definition at line 123 of file ffmpegfs.h.

Function Documentation

◆ add_dotdot()

int add_dotdot ( void *  buf,
fuse_fill_dir_t  filler,
const struct stat *  stbuf,
off_t  off 
)

Make dot and double dot entries for a virtual directory.

Parameters
[in,out]buf- The buffer passed to the readdir() operation. May be nullptr.
[in]filler- Function pointer to the Fuse update function. May be nullptr.
[in]stbuf- File attributes. May be nullptr.
[in]off- Offset of the next entry or zero.
Returns
Returns 1 if the buffer is full, zero otherwise. If buf or filler is nullptr, returns zero.

Definition at line 2416 of file fuseops.cc.

References add_fuse_entry(), and init_stat().

Referenced by check_bluray(), check_dvd(), check_vcd(), and ffmpegfs_readdir().

◆ add_fuse_entry()

int add_fuse_entry ( void *  buf,
fuse_fill_dir_t  filler,
const std::string &  name,
const struct stat *  stbuf,
off_t  off 
)

Wrapper to the Fuse filler function.

Parameters
[in,out]buf- The buffer passed to the readdir() operation. May be nullptr.
[in]filler- Function pointer to the Fuse update function. May be nullptr.
[in]name- The file name of the directory entry. Do not include the path!
[in]stbuf- File attributes, can be nullptr.
[in]off- Offset of the next entry or zero.
Returns
1 if buffer is full, zero otherwise or if buf or filler is nullptr.

Definition at line 2406 of file fuseops.cc.

Referenced by add_dotdot(), create_bluray_virtualfile(), create_dvd_virtualfile(), create_vcd_virtualfile(), ffmpegfs_readdir(), load_path(), and make_file().

◆ check_hwaccel_dec_blocked()

bool check_hwaccel_dec_blocked ( AVCodecID  codec_id,
int  profile 
)

Check if codec_id and the optional profile are in the block list.

Parameters
[in]codec_id- Codec ID to check
[in]profile- Profile to check. Set to FF_PROFILE_UNKOWN to ignore.
Returns
Returns true if codec is in block list, false if not.

Definition at line 1585 of file ffmpegfs.cc.

References FFMPEGFS_PARAMS::m_hwaccel_dec_blocked, and params.

Referenced by FFmpeg_Transcoder::open_decoder().

◆ check_path()

bool check_path ( const std::string &  path)

Check if the path has already been parsed. Only useful if for DVD, Blu-ray or VCD where it is guaranteed that all files have been parsed whenever the directory is in the hash.

Parameters
[in]path- Path to parse.
Returns
Returns true if path was found; false if not.

Definition at line 1752 of file fuseops.cc.

References filenames, and find_prefix().

Referenced by check_bluray(), check_cuesheet(), check_dvd(), and check_vcd().

◆ find_file()

LPVIRTUALFILE find_file ( const std::string &  virtfile)

Find file in cache.

Parameters
[in]virtfile- Virtual filename and path of file to find.
Returns
If found, returns VIRTUALFILE object, if not found returns nullptr.

Definition at line 1734 of file fuseops.cc.

References filenames, and sanitise_filepath().

Referenced by check_cuesheet(), FFmpeg_Transcoder::encode_finish(), and find_original().

◆ find_file_from_orig()

LPVIRTUALFILE find_file_from_orig ( const std::string &  origfile)

Look for the file in the cache.

Parameters
[in]origfile- Filename and path of file to find.
Returns
If found, returns VIRTUALFILE object, if not found returns nullptr.

Definition at line 1743 of file fuseops.cc.

References rfilenames, and sanitise_filepath().

Referenced by check_cuesheet(), ffmpegfs_readdir(), and get_format().

◆ find_original() [1/2]

LPVIRTUALFILE find_original ( const std::string &  origpath)

Given the destination (post-transcode) file name, determine the parent of the file to be transcoded.

Parameters
[in]origpath- The original file
Returns
Returns contstant pointer to VIRTUALFILE object of file, nullptr if not found

Definition at line 1894 of file fuseops.cc.

References find_original().

Referenced by ffmpegfs_fgetattr(), ffmpegfs_getattr(), ffmpegfs_open(), ffmpegfs_read(), ffmpegfs_readdir(), ffmpegfs_readlink(), ffmpegfs_statfs(), find_original(), and find_parent().

◆ find_original() [2/2]

LPVIRTUALFILE find_original ( std::string *  filepath)

Given the destination (post-transcode) file name, determine the name of the original file to be transcoded.

Parameters
[in,out]filepath- Input the original file, output name of transcoded file.
Returns
Returns contstant pointer to VIRTUALFILE object of file, nullptr if not found

<*

Todo:
This probably won't work, need to redo "Fallback to old method"

Definition at line 1900 of file fuseops.cc.

References append_filename(), AUDIO, DISK, Logging::error(), ffmpeg_format, find_ext(), find_file(), insert_file(), VIRTUALFILE::m_origfile, params, remove_ext(), remove_filename(), remove_path(), sanitise_filepath(), scandir(), selector(), FFMPEGFS_PARAMS::smart_transcode(), strcasecmp(), VIDEO, and VIRTUALFLAG_PASSTHROUGH.

◆ find_parent()

LPVIRTUALFILE find_parent ( const std::string &  origpath)

Given the destination (post-transcode) file name, determine the parent of the file to be transcoded.

Parameters
[in]origpath- The original file
Returns
Returns contstant pointer to VIRTUALFILE object of file, nullptr if not found

Definition at line 1982 of file fuseops.cc.

References find_original(), remove_filename(), and remove_sep().

Referenced by ffmpegfs_getattr(), and ffmpegfs_open().

◆ get_audio_codec_text()

std::string get_audio_codec_text ( AVCodecID  audio_codec)

Convert AVCodecID enum for audio codec to human readable text.

Parameters
[in]audio_codec- AVCodecID enum value to convert.
Returns
AVCodecID as text or "INVALID" if not known.

Definition at line 1236 of file ffmpegfs.cc.

References audiocodec_map, and search_by_value().

Referenced by Format_Options::audio_codec_list().

◆ get_autocopy_text()

std::string get_autocopy_text ( AUTOCOPY  autocopy)

Convert AUTOCOPY enum to human readable text.

Parameters
[in]autocopy- AUTOCOPY enum value to convert.
Returns
AUTOCOPY enum as text or "INVALID" if not known.

Definition at line 1256 of file ffmpegfs.cc.

References autocopy_map, and search_by_value().

◆ get_hwaccel_API_text()

std::string get_hwaccel_API_text ( HWACCELAPI  hwaccel_API)

Get the selected hardware acceleration as text.

Parameters
[in]hwaccel_API- Hardware acceleration buffering API.
Returns
Hardware acceleration API as string.

Definition at line 1603 of file ffmpegfs.cc.

References hwaccel_map.

Referenced by FFmpeg_Transcoder::add_stream(), FFmpeg_Transcoder::open_bestmatch_video(), and FFmpeg_Transcoder::open_decoder().

◆ get_level_text()

std::string get_level_text ( PRORESLEVEL  level)

Convert PRORESLEVEL enum to human readable text.

Parameters
[in]level- PRORESLEVEL enum value to convert.
Returns
PRORESLEVEL enum as text or "INVALID" if not known.

Definition at line 1396 of file ffmpegfs.cc.

References prores_level_map, and search_by_value().

◆ get_profile_text()

std::string get_profile_text ( PROFILE  profile)

Convert PROFILE enum to human readable text.

Parameters
[in]profile- PROFILE enum value to convert.
Returns
PROFILE enum as text or "INVALID" if not known.

Definition at line 1348 of file ffmpegfs.cc.

References profile_map, and search_by_value().

◆ get_recodesame_text()

std::string get_recodesame_text ( RECODESAME  recode)

Convert RECODESAME enum to human readable text.

Parameters
[in]recode- RECODESAME enum value to convert.
Returns
RECODESAME enum as text or "INVALID" if not known.

Definition at line 1302 of file ffmpegfs.cc.

References recode_map, and search_by_value().

◆ get_sampleformat_text()

std::string get_sampleformat_text ( SAMPLE_FMT  sample_fmt)

Convert SAMPLE_FMT enum to human readable text.

Returns
SAMPLE_FMT enum as text or "INVALID" if not known.

Definition at line 861 of file ffmpegfs.cc.

References sample_fmt_map, and search_by_value().

Referenced by Format_Options::sample_fmt_list().

◆ get_video_codec_text()

std::string get_video_codec_text ( AVCodecID  video_codec)

Convert AVCodecID enum for video codec to human readable text.

Parameters
[in]video_codec- AVCodecID enum value to convert.
Returns
AVCodecID as text or "INVALID" if not known.

Definition at line 1246 of file ffmpegfs.cc.

References search_by_value(), and videocodec_map.

Referenced by Format_Options::video_codec_list().

◆ init_fuse_ops()

void init_fuse_ops ( )

◆ insert_dir()

LPVIRTUALFILE insert_dir ( VIRTUALTYPE  type,
const std::string &  virtdir,
const struct stat *  stbuf,
int  flags = VIRTUALFLAG_NONE 
)

Add new virtual directory to the internal list. If the file already exists, it will be updated.

Parameters
[in]type- Type of virtual file.
[in]virtdir- Name of virtual directory.
[in]stbuf- stat buffer with file size, time etc.
[in]flags- One of the VIRTUALFLAG_* flags to control the detailed behaviour.
Returns
Returns constant pointer to VIRTUALFILE object of file, nullptr if not found

Definition at line 1717 of file fuseops.cc.

References append_sep(), flags_to_dir(), insert_file(), and stat_to_dir().

Referenced by create_bluray_virtualfile(), create_cuesheet_virtualfile(), create_dvd_virtualfile(), create_vcd_virtualfile(), and parse_cuesheet().

◆ insert_file() [1/2]

LPVIRTUALFILE insert_file ( VIRTUALTYPE  type,
const std::string &  virtfile,
const std::string &  origfile,
const struct stat *  stbuf,
int  flags = VIRTUALFLAG_NONE 
)

Add new virtual file to internal list. If the file already exists, it will be updated.

Parameters
[in]type- Type of virtual file.
[in]virtfile- Name of virtual file.
[in]origfile- Original file name.
[in]stbuf- stat buffer with file size, time etc.
[in]flags- One of the VIRTUALFLAG_* flags to control the detailed behaviour.
Returns
Returns constant pointer to VIRTUALFILE object of file, nullptr if not found

Definition at line 1643 of file fuseops.cc.

References filenames, guess_format_idx(), insert(), FFMPEGFS_PARAMS::m_basepath, VIRTUALFILE::m_destfile, VIRTUALFILE::m_flags, VIRTUALFILE::m_format_idx, FFMPEGFS_PARAMS::m_mountpath, VIRTUALFILE::m_origfile, VIRTUALFILE::m_st, VIRTUALFILE::m_type, VIRTUALFILE::m_virtfile, params, replace_start(), and sanitise_filepath().

◆ insert_file() [2/2]

LPVIRTUALFILE insert_file ( VIRTUALTYPE  type,
const std::string &  virtfile,
const struct stat *  stbuf,
int  flags = VIRTUALFLAG_NONE 
)

Add new virtual file to internal list.

For Blu-ray/DVD/VCD, actually, no physical input file exists, so virtual and origfile are the same.

The input file is handled by the BlurayIO or VcdIO classes.

For cue sheets, the original (huge) input file is used. Start positions are sought; end positions are reported as EOF.

Parameters
[in]type- Type of virtual file.
[in]virtfile- Name of virtual file.
[in]stbuf- stat buffer with file size, time etc.
[in]flags- One of the VIRTUALFLAG_* flags to control the detailed behaviour.
Returns
Returns constant pointer to VIRTUALFILE object of file, nullptr if not found

Definition at line 1638 of file fuseops.cc.

References insert_file().

Referenced by create_bluray_virtualfile(), create_cuesheet_virtualfile(), create_dvd_virtualfile(), create_vcd_virtualfile(), ffmpegfs_getattr(), ffmpegfs_readdir(), find_original(), insert_dir(), insert_file(), and make_file().

◆ load_path()

int load_path ( const std::string &  path,
const struct stat *  statbuf,
void *  buf,
fuse_fill_dir_t  filler 
)

Load a path with virtual files for FUSE.

Parameters
[in]path- Physical path to load.
[in]statbuf- stat buffer to load.
[in]buf- FUSE buffer to fill.
[in]filler- Filler function.
Returns
Returns number of files found.

Definition at line 1759 of file fuseops.cc.

References add_fuse_entry(), BLURAY, FFMPEGFS_PARAMS::current_format(), DVD, FFmpegfs_Format::fileext(), filenames, VIRTUALFILE::m_destfile, VIRTUALFILE::m_flags, VIRTUALFILE::m_st, VIRTUALFILE::m_type, Buffer::make_cachefile_name(), params, remove_filename(), remove_path(), remove_sep(), stat_set_size(), VCD, VIRTUALFLAG_CUESHEET, and VIRTUALFLAG_DIRECTORY.

Referenced by check_bluray(), check_dvd(), check_vcd(), and ffmpegfs_readdir().

◆ transcoder_cache_clear()

bool transcoder_cache_clear ( )

Clear transcoder cache.

Returns
Returns true on success; false on error. Check errno for details.

Definition at line 755 of file transcode.cc.

References cache.

◆ transcoder_cache_maintenance()

bool transcoder_cache_maintenance ( )

Run cache maintenance.

Returns
Returns true on success; false on error. Check errno for details.

Definition at line 743 of file transcode.cc.

References cache.

Referenced by main(), and maintenance_handler().

◆ transcoder_cache_path()

void transcoder_cache_path ( std::string *  path)

Get transcoder cache path.

Parameters
[out]path- Path to transcoder cache.

Definition at line 195 of file transcode.cc.

References append_sep(), expand_path(), FFMPEGFS_PARAMS::m_cachepath, and params.

Referenced by Cache::load_index(), Buffer::make_cachefile_name(), print_params(), and Logging::Logger::~Logger().

◆ transcoder_free()

void transcoder_free ( )

Free transcoder.

Definition at line 251 of file transcode.cc.

References cache, and Logging::debug().

Referenced by ffmpegfs_destroy().

◆ transcoder_init()

bool transcoder_init ( )

Initialise transcoder, create cache.

Returns
Returns true on success; false on error. Check errno for details.

Definition at line 229 of file transcode.cc.

References cache, Logging::debug(), and Logging::error().

Referenced by main().

Variable Documentation

◆ docker_client

bool docker_client
extern

True if running inside a Docker container.

Definition at line 98 of file fuseops.cc.

Referenced by ffmpegfs_init(), ffmpegfs_opt_proc(), and main().

◆ ffmpeg_format

FFMPEGFS_FORMAT_ARR ffmpeg_format
extern

◆ ffmpegfs_ops

fuse_operations ffmpegfs_ops
extern

Fuse operations struct.

Fuse operations struct.

Definition at line 100 of file fuseops.cc.

Referenced by init_fuse_ops().

◆ tp

std::unique_ptr<thread_pool> tp
extern

Thread pool object.

Definition at line 102 of file fuseops.cc.

Referenced by ffmpegfs_destroy(), ffmpegfs_init(), thread_pool::loop_function_starter(), and transcoder_new().