FFmpegfs Fuse Multi Media Filesystem 2.14
Classes | Typedefs | Functions
dvdparser.cc File Reference

dvdparser class implementation More...

#include "ffmpegfs.h"
#include "dvdparser.h"
#include "transcode.h"
#include "logging.h"
#include <dvdread/dvd_reader.h>
#include <dvdread/ifo_read.h>
#include <libavutil/rational.h>
Include dependency graph for dvdparser.cc:

Go to the source code of this file.

Classes

struct  AUDIO_SETTINGS
 Audio stream settings. More...
 
struct  VIDEO_SETTINGS
 Video stream settings. More...
 

Typedefs

typedef struct AUDIO_SETTINGS AUDIO_SETTINGS
 Audio stream settings.
 
typedef AUDIO_SETTINGS const * LPCAUDIO_SETTINGS
 Pointer to const version of AUDIO_SETTINGS. More...
 
typedef AUDIO_SETTINGSLPAUDIO_SETTINGS
 Pointer version of AUDIO_SETTINGS. More...
 
typedef struct VIDEO_SETTINGS VIDEO_SETTINGS
 Video stream settings.
 
typedef VIDEO_SETTINGS const * LPCVIDEO_SETTINGS
 Pointer to const version of VIDEO_SETTINGS. More...
 
typedef VIDEO_SETTINGSLPVIDEO_SETTINGS
 Pointer version of VIDEO_SETTINGS. More...
 

Functions

static int dvd_find_best_audio_stream (const vtsi_mat_t *vtsi_mat, int *best_channels, int *best_sample_frequency)
 Locate best matching audio stream. More...
 
static AVRational dvd_frame_rate (const uint8_t *ptr)
 Get the frame rate of the DVD. Can be 25 fps (PAL) or 29.97 (NTCS). More...
 
static int64_t BCDtime (const dvd_time_t *dvd_time)
 Convert a time in BCD format into AV_TIMEBASE fractional seconds. More...
 
static bool create_dvd_virtualfile (const ifo_handle_t *vts_file, const std::string &path, const struct stat *statbuf, void *buf, fuse_fill_dir_t filler, bool full_title, int title_idx, int chapter_idx, int angles, int ttnnum, int audio_stream, const AUDIO_SETTINGS &audio_settings, const VIDEO_SETTINGS &video_settings)
 Create a virtual file for a DVD. More...
 
static int parse_dvd (const std::string &path, const struct stat *statbuf, void *buf, fuse_fill_dir_t filler)
 Parse DVD directory and get all DVD titles and chapters as virtual files. More...
 
int check_dvd (const std::string &path, void *buf, fuse_fill_dir_t filler)
 Get number of titles on DVD. More...
 

Detailed Description

dvdparser class implementation

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 dvdparser.cc.

Typedef Documentation

◆ LPAUDIO_SETTINGS

Pointer version of AUDIO_SETTINGS.

Definition at line 53 of file dvdparser.cc.

◆ LPCAUDIO_SETTINGS

Pointer to const version of AUDIO_SETTINGS.

Definition at line 52 of file dvdparser.cc.

◆ LPCVIDEO_SETTINGS

Pointer to const version of VIDEO_SETTINGS.

Definition at line 61 of file dvdparser.cc.

◆ LPVIDEO_SETTINGS

Pointer version of VIDEO_SETTINGS.

Definition at line 62 of file dvdparser.cc.

Function Documentation

◆ BCDtime()

static int64_t BCDtime ( const dvd_time_t *  dvd_time)
static

Convert a time in BCD format into AV_TIMEBASE fractional seconds.

Parameters
[in]dvd_time- dvd_time_t object.
Returns
Time in AV_TIMEBASE fractional seconds.

Definition at line 202 of file dvdparser.cc.

References dvd_frame_rate().

Referenced by create_dvd_virtualfile().

◆ check_dvd()

int check_dvd ( const std::string &  path,
void *  buf = nullptr,
fuse_fill_dir_t  filler = nullptr 
)

Get number of titles on DVD.

Parameters
[in]path- Path to check
[in,out]buf- The buffer passed to the readdir() operation.
[in,out]filler- Function to add an entry in a readdir() operation (see0
Returns
-errno or number or titles on DVD

Definition at line 550 of file dvdparser.cc.

References add_dotdot(), append_sep(), check_path(), load_path(), parse_dvd(), and Logging::trace().

Referenced by ffmpegfs_getattr(), and ffmpegfs_readdir().

◆ create_dvd_virtualfile()

static bool create_dvd_virtualfile ( const ifo_handle_t *  vts_file,
const std::string &  path,
const struct stat *  statbuf,
void *  buf,
fuse_fill_dir_t  filler,
bool  full_title,
int  title_idx,
int  chapter_idx,
int  angles,
int  ttnnum,
int  audio_stream,
const AUDIO_SETTINGS audio_settings,
const VIDEO_SETTINGS video_settings 
)
static

Create a virtual file for a DVD.

Parameters
[in]vts_file- Structure defines an IFO file
[in]path- Path to DVD files.
[in]statbuf- File status structure of original file.
[in,out]buf- The buffer passed to the readdir() operation.
[in,out]filler- Function to add an entry in a readdir() operation (see https://libfuse.github.io/doxygen/fuse_8h.html#a7dd132de66a5cc2add2a4eff5d435660)
[in]full_title- If true, create virtual file of all title. If false, include single chapter only.
[in]title_idx- Index of DVD title.
[in]chapter_idx- Index of DVD chapter.
[in]angles- Number of angles.
[in]ttnnum- DVD title number.
[in]audio_stream- Audio stream index.
[in]audio_settings- Audio stream settings.
[in]video_settings- Video stream settings.
Returns
Returns true if successful. Returns false on error.
Todo:
We actually calculate the overall DVD bitrate here, including all audio streams, not just the video bitrate. This should be the video bitrate alone. We should also calculate the audio bitrate for the selected stream.

Definition at line 242 of file dvdparser.cc.

References add_fuse_entry(), BCDtime(), BITRATE, Logging::debug(), dvd_frame_rate(), Logging::error(), ffmpeg_format, format_bitrate(), format_duration(), format_size(), insert_dir(), insert_file(), VIRTUALFILE::DVD_CHAPTER::m_angle_no, AUDIO_SETTINGS::m_audio_bit_rate, AUDIO_SETTINGS::m_channels, VIRTUALFILE::m_channels, VIRTUALFILE::DVD_CHAPTER::m_chapter_no, VIRTUALFILE::m_destfile, VIRTUALFILE::m_duration, VIRTUALFILE::m_dvd, VIRTUALFILE::m_format_idx, VIRTUALFILE::m_framerate, VIRTUALFILE::m_full_title, VIDEO_SETTINGS::m_height, VIRTUALFILE::m_height, FFMPEGFS_PARAMS::m_min_dvd_chapter_duration, VIRTUALFILE::m_predicted_size, AUDIO_SETTINGS::m_sample_rate, VIRTUALFILE::m_sample_rate, VIRTUALFILE::m_st, VIRTUALFILE::DVD_CHAPTER::m_title_no, VIDEO_SETTINGS::m_video_bit_rate, VIRTUALFILE::m_video_frame_count, VIDEO_SETTINGS::m_width, VIRTUALFILE::m_width, params, replace_all(), strsprintf(), Logging::trace(), transcoder_cached_filesize(), transcoder_set_filesize(), and VIRTUALTYPE_DVD.

Referenced by parse_dvd().

◆ dvd_find_best_audio_stream()

static int dvd_find_best_audio_stream ( const vtsi_mat_t *  vtsi_mat,
int *  best_channels,
int *  best_sample_frequency 
)
static

Locate best matching audio stream.

Parameters
[in]vtsi_mat- Video Title Set Information (VTSI)
[out]best_channels- Number of channels in best stream.
[out]best_sample_frequency- Sample frequency in best stream.
Returns
Returns number of best stream (0..8).

Definition at line 77 of file dvdparser.cc.

Referenced by parse_dvd().

◆ dvd_frame_rate()

static AVRational dvd_frame_rate ( const uint8_t *  ptr)
static

Get the frame rate of the DVD. Can be 25 fps (PAL) or 29.97 (NTCS).

Parameters
[in]ptr- Pointer to frame_u element in dvd_time_t structure.
Returns
On success, returns AVRational with frame rate. On error, returns frame rate { 0, 0 }.

Definition at line 167 of file dvdparser.cc.

Referenced by BCDtime(), and create_dvd_virtualfile().

◆ parse_dvd()

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

Parse DVD directory and get all DVD titles and chapters as virtual files.

Parameters
[in]path- Path to check.
[in]statbuf- File status structure of original file.
[in,out]buf- The buffer passed to the readdir() operation.
[in,out]filler- Function to add an entry in a readdir() operation (see https://libfuse.github.io/doxygen/fuse_8h.html#a7dd132de66a5cc2add2a4eff5d435660)
Returns
On success, returns number of chapters found. On error, returns -errno.

Definition at line 425 of file dvdparser.cc.

References create_dvd_virtualfile(), Logging::debug(), dvd_find_best_audio_stream(), Logging::error(), AUDIO_SETTINGS::m_audio_bit_rate, AUDIO_SETTINGS::m_channels, VIDEO_SETTINGS::m_height, AUDIO_SETTINGS::m_sample_rate, VIDEO_SETTINGS::m_video_bit_rate, VIDEO_SETTINGS::m_width, Logging::trace(), and Logging::warning().

Referenced by check_dvd().