JS8Call-Improved master
Loading...
Searching...
No Matches
BWFFile.h
Go to the documentation of this file.
1
28
29#ifndef BWF_FILE_HPP__
30#define BWF_FILE_HPP__
31
32#include "JS8_Include/pimpl_h.h"
33
34#include <QByteArray>
35#include <QFile>
36#include <QMap>
37
38#include <array>
39
40class QObject;
41class QString;
42class QAudioFormat;
43
52class BWFFile : public QIODevice {
53 Q_OBJECT
54 public:
55 using FileHandleFlags = QFile::FileHandleFlags;
56 using Permissions = QFile::Permissions;
57 using FileError = QFile::FileError;
58 using MemoryMapFlags = QFile::MemoryMapFlags;
59 using InfoDictionary = QMap<std::array<char, 4>, QByteArray>;
60 using UMID = std::array<quint8, 64>;
61
62 explicit BWFFile(QAudioFormat const &, QObject *parent = nullptr);
63 explicit BWFFile(QAudioFormat const &, QString const &name,
64 QObject *parent = nullptr);
65
66
67 explicit BWFFile(QAudioFormat const &, QString const &name,
68 InfoDictionary const &, QObject *parent = nullptr);
69
70 ~BWFFile();
71 QAudioFormat const &format() const;
72 InfoDictionary &list_info();
73
74 //
75 // Broadcast Audio Extension fields
76 //
77 // If any of these modifiers are called then a "bext" chunk will be
78 // written to the file if the file is writeable and the sample data
79 // is modified.
80 //
81 enum class BextVersion : quint16 { v_0, v_1, v_2 };
82 BextVersion bext_version() const;
83 void bext_version(BextVersion = BextVersion::v_2);
84
85 QByteArray bext_description() const;
86 void bext_description(QByteArray const &); // max 256 bytes
87
88 QByteArray bext_originator() const;
89 void bext_originator(QByteArray const &); // max 32 bytes
90
91 QByteArray bext_originator_reference() const;
92 void bext_originator_reference(QByteArray const &); // max 32 bytes
93
94 QDateTime bext_origination_date_time() const;
95 void bext_origination_date_time(QDateTime const &); // 1s resolution
96
97 quint64 bext_time_reference() const;
98 void bext_time_reference(quint64); // samples since midnight at start
99
100 UMID bext_umid() const; // bext version >= 1 only
101 void bext_umid(UMID const &);
102
103 quint16 bext_loudness_value() const;
104 void bext_loudness_value(quint16); // bext version >= 2 only
105
106 quint16 bext_loudness_range() const;
107 void bext_loudness_range(quint16); // bext version >= 2 only
108
109 quint16 bext_max_true_peak_level() const;
110 void bext_max_true_peak_level(quint16); // bext version >= 2 only
111
112 quint16 bext_max_momentary_loudness() const;
113 void bext_max_momentary_loudness(quint16); // bext version >= 2 only
114
115 quint16 bext_max_short_term_loudness() const;
116 void bext_max_short_term_loudness(quint16); // bext version >= 2 only
117
118 QByteArray bext_coding_history() const;
119 void bext_coding_history(QByteArray const &); // See EBU R 98
120
121 // Emulate QFile interface
122 bool open(OpenMode) override;
123 bool open(FILE *, OpenMode, FileHandleFlags = QFile::DontCloseHandle);
124 bool open(int fd, OpenMode, FileHandleFlags = QFile::DontCloseHandle);
125 bool copy(QString const &new_name);
126 bool exists() const;
127 bool link(QString const &link_name);
128 bool remove();
129 bool rename(QString const &new_name);
130 void setFileName(QString const &name);
131 QString symLinkTarget() const;
132 QString fileName() const;
133 Permissions permissions() const;
134
135 // Resize is of the sample data portion, header and trailer chunks
136 // are excess to the given size
137 bool resize(qint64 new_size);
138
139 bool setPermissions(Permissions permissions);
140 FileError error() const;
141 bool flush();
142 int handle() const;
143
144 // The mapping offset is relative to the start of the sample data
145 uchar *map(qint64 offset, qint64 size, MemoryMapFlags = QFile::NoOptions);
146 bool unmap(uchar *address);
147
148 void unsetError();
149
150 //
151 // QIODevice implementation
152 //
153
154 // The size returned is of the sample data only, header and trailer
155 // chunks are hidden and handled internally
156 qint64 size() const override;
157
158 bool isSequential() const override;
159
160 quint16 bitsPerSample() const;
161 quint16 blockAlign() const;
162
163 // The reset operation clears the 'bext' and LIST-INFO as if they
164 // were never supplied. If the file is writable the 'bext' and
165 // LIST-INFO chunks will not be written making the resulting file a
166 // lowest common denominator WAV file.
167 bool reset() override;
168
169 // Seek offsets are relative to the start of the sample data
170 bool seek(qint64) override;
171
172 // this can fail due to updating header issues, errors are ignored
173 void close() override;
174
175 protected:
176 qint64 readData(char *data, qint64 max_size) override;
177 qint64 writeData(char const *data, qint64 max_size) override;
178
179 private:
180 class impl;
181 pimpl<impl> m_;
182};
183
184#endif
Definition BWFFile.cpp:107
Opaque implementation manager utilizing perfect forwarding of constructors.
Definition pimpl_h.h:28
An implementation-hiding utility class template leveraging the Pimpl idiom.