FFmpegfs Fuse Multi Media Filesystem 2.16
Macros | Functions
cuesheetparser.cc File Reference

Cue sheet parser implementation. More...

#include "ffmpegfs.h"
#include "cuesheetparser.h"
#include "transcode.h"
#include "logging.h"
#include <libcue.h>
Include dependency graph for cuesheetparser.cc:

Go to the source code of this file.

Macros

#define FPS   (75)
 
#define VAL_OR_EMPTY(val)   ((val) != nullptr ? (val) : "")
 

Functions

static bool create_cuesheet_virtualfile (LPCVIRTUALFILE virtualfile, Track *track, int titleno, const std::string &path, const struct stat *statbuf, int trackcount, int trackno, const std::string &aperformer, const std::string &album, const std::string &genre, const std::string &date, int64_t *remainingduration, LPVIRTUALFILE *lastfile)
 Cuesheet structure Structure see https://en.wikipedia.org/wiki/Cue_sheet_(computing)

Real life example:

PERFORMER "Subway to Sally"
TITLE "Nord Nord Ost"
CATALOG 0727361134129
REM DATE 2005
REM DISCNUMBER 1
REM TOTALDISCS 1
FILE "Subway to Sally - Nord Nord Ost.flac" WAVE
TRACK 01 AUDIO
PERFORMER "Subway to Sally"
TITLE "Sarabande de noir"
INDEX 01 00:00:00
TRACK 02 AUDIO
PERFORMER "Subway to Sally"
TITLE "Schneekönigin"
INDEX 01 00:55:30
TRACK 03 AUDIO
PERFORMER "Subway to Sally"
TITLE "Feuerland"
INDEX 01 06:41:38
TRACK 04 AUDIO
PERFORMER "Subway to Sally"
TITLE "Sieben"
INDEX 01 10:48:42
TRACK 05 AUDIO
PERFORMER "Subway to Sally"
TITLE "Lacrimae '74"
INDEX 01 14:11:14
TRACK 06 AUDIO
PERFORMER "Subway to Sally"
TITLE "Feuerkind"
INDEX 01 15:57:07
TRACK 07 AUDIO
PERFORMER "Subway to Sally"
TITLE "Das Rätsel II"
INDEX 01 22:03:28
TRACK 08 AUDIO
PERFORMER "Subway to Sally"
TITLE "S.O.S."
INDEX 01 26:25:23
TRACK 09 AUDIO
PERFORMER "Subway to Sally"
TITLE "Eisblumen"
INDEX 01 32:21:42
TRACK 10 AUDIO
PERFORMER "Subway to Sally"
TITLE "Seemannslied"
INDEX 01 36:53:71
. More...
 
static int parse_cuesheet_file (LPCVIRTUALFILE virtualfile, const std::string &cuesheet, const struct stat *statbuf, void *buf, fuse_fill_dir_t filler)
 Parse a cue sheet file and build virtual set of files. More...
 
static int parse_cuesheet_text (LPCVIRTUALFILE virtualfile, void *buf, fuse_fill_dir_t filler)
 Parse a cue sheet and build virtual set of files. More...
 
static int parse_cuesheet (LPCVIRTUALFILE virtualfile, const std::string &cuesheet, Cd *cd, const struct stat *statbuf, void *buf, fuse_fill_dir_t filler)
 Parse a cue sheet and build virtual set of files. More...
 
int check_cuesheet (const std::string &filename, void *buf, fuse_fill_dir_t filler)
 Get number of titles in cue sheet. More...
 

Detailed Description

Cue sheet parser 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 cuesheetparser.cc.

Macro Definition Documentation

◆ FPS

#define FPS   (75)
  • On sector contains 75 frames per CD specs

Definition at line 39 of file cuesheetparser.cc.

◆ VAL_OR_EMPTY

#define VAL_OR_EMPTY (   val)    ((val) != nullptr ? (val) : "")
  • Return string or empty string if val is nullptr

Definition at line 40 of file cuesheetparser.cc.

Function Documentation

◆ check_cuesheet()

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

Get number of titles in cue sheet.

Parameters
[in]filename- 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 (see https://libfuse.github.io/doxygen/fuse_8h.html#a7dd132de66a5cc2add2a4eff5d435660)
Note
buf and filler can be nullptr. In that case the call will run faster, so these parameters should only be passed if to be filled in.
Returns
-errno or number or titles in cue sheet

Definition at line 368 of file cuesheetparser.cc.

References append_ext(), append_sep(), check_path(), Logging::error(), find_file(), find_file_from_orig(), parse_cuesheet_file(), parse_cuesheet_text(), remove_path(), replace_ext(), Logging::trace(), and TRACKDIR.

Referenced by ffmpegfs_getattr(), and ffmpegfs_readdir().

◆ create_cuesheet_virtualfile()

static bool create_cuesheet_virtualfile ( LPCVIRTUALFILE  virtualfile,
Track *  track,
int  titleno,
const std::string &  path,
const struct stat *  statbuf,
int  trackcount,
int  trackno,
const std::string &  aperformer,
const std::string &  album,
const std::string &  genre,
const std::string &  date,
int64_t *  remainingduration,
LPVIRTUALFILE lastfile 
)
static

Cuesheet structure Structure see https://en.wikipedia.org/wiki/Cue_sheet_(computing)

Real life example:

PERFORMER "Subway to Sally"
TITLE "Nord Nord Ost"
CATALOG 0727361134129
REM DATE 2005
REM DISCNUMBER 1
REM TOTALDISCS 1
FILE "Subway to Sally - Nord Nord Ost.flac" WAVE
TRACK 01 AUDIO
PERFORMER "Subway to Sally"
TITLE "Sarabande de noir"
INDEX 01 00:00:00
TRACK 02 AUDIO
PERFORMER "Subway to Sally"
TITLE "Schneekönigin"
INDEX 01 00:55:30
TRACK 03 AUDIO
PERFORMER "Subway to Sally"
TITLE "Feuerland"
INDEX 01 06:41:38
TRACK 04 AUDIO
PERFORMER "Subway to Sally"
TITLE "Sieben"
INDEX 01 10:48:42
TRACK 05 AUDIO
PERFORMER "Subway to Sally"
TITLE "Lacrimae '74"
INDEX 01 14:11:14
TRACK 06 AUDIO
PERFORMER "Subway to Sally"
TITLE "Feuerkind"
INDEX 01 15:57:07
TRACK 07 AUDIO
PERFORMER "Subway to Sally"
TITLE "Das Rätsel II"
INDEX 01 22:03:28
TRACK 08 AUDIO
PERFORMER "Subway to Sally"
TITLE "S.O.S."
INDEX 01 26:25:23
TRACK 09 AUDIO
PERFORMER "Subway to Sally"
TITLE "Eisblumen"
INDEX 01 32:21:42
TRACK 10 AUDIO
PERFORMER "Subway to Sally"
TITLE "Seemannslied"
INDEX 01 36:53:71
.

Create a virtual file entry of a cue sheet title.

Parameters
[in]virtualfile- VIRTUALFILE struct of a file.
[in]track- libcue2 track handle
[in]titleno- Title number.
[in]path- Path to check.
[in]statbuf- File status structure of original file.
[in]trackcount- Number of tracks in cue sheet.
[in]trackno- Track number.
[in]aperformer- Album performer.
[in]album- Name of album.
[in]genre- Album genre.
[in]date- Publishing date.
[in,out]remainingduration- Remaining duration of file in AV_TIME_BASE fractions.
[in]lastfile- Pointer to last virtual file. May be nullptr if none exists.
Returns
On error, returns false. On success, returns true.

<

Todo:
probe original file for info

Definition at line 119 of file cuesheetparser.cc.

References BITRATE, DISK, Logging::error(), ffmpeg_format, format_duration(), FPS, insert_dir(), insert_file(), VIRTUALFILE::CUESHEET_TRACK::m_album, VIRTUALFILE::CUESHEET_TRACK::m_artist, VIRTUALFILE::m_channels, VIRTUALFILE::m_cuesheet_track, VIRTUALFILE::CUESHEET_TRACK::m_date, VIRTUALFILE::m_duration, VIRTUALFILE::CUESHEET_TRACK::m_duration, VIRTUALFILE::m_format_idx, VIRTUALFILE::CUESHEET_TRACK::m_genre, VIRTUALFILE::m_predicted_size, VIRTUALFILE::m_st, VIRTUALFILE::CUESHEET_TRACK::m_start, VIRTUALFILE::CUESHEET_TRACK::m_title, VIRTUALFILE::CUESHEET_TRACK::m_trackno, VIRTUALFILE::CUESHEET_TRACK::m_tracktotal, replace_all(), stat_set_size(), strsprintf(), transcoder_cached_filesize(), transcoder_set_filesize(), VAL_OR_EMPTY, VIDEO, and VIRTUALFLAG_CUESHEET.

Referenced by parse_cuesheet().

◆ parse_cuesheet()

static int parse_cuesheet ( LPCVIRTUALFILE  virtualfile,
const std::string &  cuesheet,
Cd *  cd,
const struct stat *  statbuf,
void *  buf,
fuse_fill_dir_t  filler 
)
static

Parse a cue sheet and build virtual set of files.

Parameters
[in]virtualfile- VIRTUALFILE struct of a file.
[in]cuesheet- Name of cue sheet file
[in]cd- libcue2 cue sheet handle
[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 titles in cue sheet or 0 if not found. On error, returns -errno.

Definition at line 271 of file cuesheetparser.cc.

References append_ext(), append_sep(), create_cuesheet_virtualfile(), DISK, Logging::error(), insert_dir(), VIRTUALFILE::m_duration, VIRTUALFILE::m_st, remove_filename(), remove_path(), TRACKDIR, VAL_OR_EMPTY, and VIRTUALFLAG_CUESHEET.

Referenced by parse_cuesheet_file(), and parse_cuesheet_text().

◆ parse_cuesheet_file()

static int parse_cuesheet_file ( LPCVIRTUALFILE  virtualfile,
const std::string &  cuesheet,
const struct stat *  statbuf,
void *  buf,
fuse_fill_dir_t  filler 
)
static

Parse a cue sheet file and build virtual set of files.

Parameters
[in]virtualfile- VIRTUALFILE struct of a file.
[in]cuesheet- Name of cue sheet file
[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 titles in cue sheet. On error, returns -errno.

Definition at line 230 of file cuesheetparser.cc.

References parse_cuesheet(), read_file(), and Logging::trace().

Referenced by check_cuesheet().

◆ parse_cuesheet_text()

static int parse_cuesheet_text ( LPCVIRTUALFILE  virtualfile,
void *  buf,
fuse_fill_dir_t  filler 
)
static

Parse a cue sheet and build virtual set of files.

Parameters
[in]virtualfile- VIRTUALFILE struct of a 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 titles in cue sheet. On error, returns -errno.

Definition at line 253 of file cuesheetparser.cc.

References parse_cuesheet(), and Logging::trace().

Referenced by check_cuesheet().