1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
|
/***************************************************************************
Compression.h - Wrapper for a compression
-------------------
begin : Fri Jan 25 2013
copyright : (C) 2013 by Thomas Eschenbacher
email : Thomas.Eschenbacher@gmx.de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef COMPRESSION_H
#define COMPRESSION_H
#include "config.h"
#include "libkwave_export.h"
#include <KLazyLocalizedString>
#include <QtGlobal>
#include <QList>
#include <QMap>
#include <QSharedData>
#include <QSharedDataPointer>
#include "libkwave/SampleFormat.h"
namespace Kwave
{
class LIBKWAVE_EXPORT Compression
{
public:
/**
* supported compression types
* @note for compatibility with older settings these values are
* the same as defined in audiofile.h.
*/
typedef enum {
INVALID = -1,
NONE = 0,
G722 = 501,
G711_ULAW = 502,
G711_ALAW = 503,
APPLE_ACE2 = 504,
APPLE_ACE8 = 505,
APPLE_MAC3 = 506,
APPLE_MAC6 = 507,
G726 = 517,
G728 = 518,
DVI_AUDIO = 519,
GSM = 520,
FS1016 = 521,
DV = 522,
MS_ADPCM = 523,
FLAC = 530,
ALAC = 540,
MPEG_LAYER_I = 600,
MPEG_LAYER_II,
MPEG_LAYER_III,
OGG_VORBIS,
OGG_OPUS
} Type;
/**
* default constructor
*/
Compression();
/**
* Constructor, from enum
* @param value the enum of an already known compression type
*/
explicit Compression(const Type value);
/**
* Copy constructor
* @param other another compression to copy from
*/
explicit Compression(const Kwave::Compression &other);
/** destructor */
virtual ~Compression() {}
/** assignment operator from sample_format_t */
inline void assign(Type t) { m_type = t; }
/**
* Returns the descriptive name of the compression, already localized
* @return localized name
*/
QString name() const;
/**
* Returns the preferred mime type or an empty string
*/
QString preferredMimeType() const;
/**
* Returns a list of supported sample formats
* @return list of sample formats, or empty list if none supported
*/
QList<Kwave::SampleFormat> sampleFormats() const;
/**
* Returns whether average bitrate mode is supported
* @return true if supported, false if not
*/
bool hasABR() const;
/**
* Returns whether variable bitrate mode is supported
* @return true if supported, false if not
*/
bool hasVBR() const;
/** conversion to int (e.g. for use in plugin parameters) */
inline int toInt() const { return static_cast<int>(m_type); }
/** conversion from int (e.g. for use in plugin parameters) */
static Kwave::Compression::Type fromInt(int i);
/** conversion to a numeric value from libaudiofile */
static int toAudiofile(Kwave::Compression::Type compression);
/** conversion from a numeric value from libaudiofile */
static Kwave::Compression::Type fromAudiofile(int af_compression);
private:
/** fills the map with known compression types (if empty) */
static void fillMap();
private:
/** internal storage of the compression type, see Type */
Type m_type;
private:
/** internal container class with meta data */
class Info
{
public:
/** default constructor */
Info();
/** copy constructor */
Info(const Info &other);
/**
* Constructor
*
* @param name descriptive name of the compression, non-localized
* @param mime_type preferred mime types (optional)
* @param sample_formats list of supported sample formats
* @param has_abr whether average bitrate mode is supported
* @param has_vbr whether variable bitrate mode is supported
*/
Info(const KLazyLocalizedString &name,
const QString &mime_type,
const QList<Kwave::SampleFormat> &sample_formats,
bool has_abr,
bool has_vbr
);
/** destructor */
virtual ~Info();
public:
/** non-localized descriptive name */
KLazyLocalizedString m_name;
/** preferred mime type (optional, not localized) */
QString m_mime_type;
/** list of supported sample formats */
QList<Kwave::SampleFormat> m_sample_formats;
/** true if ABR mode is supported */
bool m_has_abr;
/** true if VBR mode is supported */
bool m_has_vbr;
};
private:
/** map with all known compression types */
static QMap<int, Kwave::Compression::Info> m_map;
};
}
#endif /* COMPRESSION_H */
//***************************************************************************
//***************************************************************************
|