FFmpegfs Fuse Multi Media Filesystem 2.16
fileio.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 2017-2024 Norbert Schlia (nschlia@oblivion-software.de)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
17 *
18 * On Debian systems, the complete text of the GNU General Public License
19 * Version 3 can be found in `/usr/share/common-licenses/GPL-3'.
20 */
21
32#include "fileio.h"
33#include "ffmpegfs.h"
34#include "diskio.h"
35#ifdef USE_LIBVCD
36#include "vcdio.h"
37#endif // USE_LIBVCD
38#ifdef USE_LIBDVD
39#include "dvdio.h"
40#endif // USE_LIBDVD
41#ifdef USE_LIBBLURAY
42#include "blurayio.h"
43#endif // USE_LIBBLURAY
44
46{
48 {
49 return static_cast<uint32_t>((m_duration - 200000) / params.m_segment_duration) + 1;
50 }
51 else
52 {
53 return 0;
54 }
55}
56
58 : m_virtualfile(nullptr)
59{
60
61}
62
63std::shared_ptr<FileIO> FileIO::alloc(VIRTUALTYPE type)
64{
65 switch (type)
66 {
68 {
69 return std::make_shared<DiskIO>();
70 }
71#ifdef USE_LIBVCD
73 {
74 return std::make_shared<VcdIO>();
75 }
76#endif // USE_LIBVCD
77#ifdef USE_LIBDVD
79 {
80 return std::make_shared<DvdIO>();
81 }
82#endif // USE_LIBDVD
83#ifdef USE_LIBBLURAY
85 {
86 return std::make_shared<BlurayIO>();
87 }
88#endif // USE_LIBBLURAY
89 default:
90 {
91 return std::make_shared<DiskIO>();
92 }
93 }
94}
95
97{
99
100 if (virtualfile != nullptr)
101 {
102 // Store path to original file without file name for fast access
104
106 }
107 else
108 {
109 m_path.clear();
110 }
111}
112
114{
115 return m_virtualfile;
116}
117
118const std::string & FileIO::path() const
119{
120 return m_path;
121}
122
123const std::string & FileIO::filename() const
124{
125 if (m_virtualfile == nullptr)
126 {
127 static const std::string empty;
128 return empty;
129 }
130
132}
133
Blu-ray I/O.
const std::string & path() const
Path to source file (without file name)
Definition: fileio.cc:118
std::string m_path
Source path (directory without file name)
Definition: fileio.h:373
LPVIRTUALFILE virtualfile()
Get virtual file object.
Definition: fileio.cc:113
LPVIRTUALFILE m_virtualfile
Virtual file object of current file.
Definition: fileio.h:374
void set_virtualfile(LPVIRTUALFILE virtualfile)
Set the virtual file object.
Definition: fileio.cc:96
virtual VIRTUALTYPE type() const =0
Get type of the virtual file.
FileIO()
Create FileIO object.
Definition: fileio.cc:57
static std::shared_ptr< FileIO > alloc(VIRTUALTYPE type)
Allocate the correct object for type().
Definition: fileio.cc:63
const std::string & filename() const
Get source filename.
Definition: fileio.cc:123
Direct disk I/O.
DVD I/O.
const std::string & remove_filename(std::string *filepath)
Remove filename from path. Handy dirname alternative.
FFMPEGFS_PARAMS params
FFmpegfs command line parameters.
Definition: ffmpegfs.cc:74
Main include for FFmpegfs project.
FileIO class.
VIRTUALTYPE
Virtual file types enum.
Definition: fileio.h:92
@ DVD
DVD file.
@ DISK
Regular disk file to transcode.
@ BLURAY
Blu-ray disk file.
@ VCD
Video CD file.
int64_t m_segment_duration
Duration of one HLS segment file, in AV_TIME_BASE fractional seconds.
Definition: ffmpegfs.h:217
Virtual file definition.
Definition: fileio.h:123
std::string m_destfile
Name and path of destination file.
Definition: fileio.h:150
std::string m_origfile
Sanitised name and path of original file.
Definition: fileio.h:152
uint32_t get_segment_count() const
Number of HLS segments in set.
Definition: fileio.cc:45
int64_t m_duration
Track/chapter duration, in AV_TIME_BASE fractional seconds.
Definition: fileio.h:156
Video CD and Super Video CD I/O.