small adjustments
This commit is contained in:
parent
c70c2ffad0
commit
09fcb37442
|
@ -29,7 +29,7 @@ public:
|
|||
FieldMapBasedTag();
|
||||
virtual ~FieldMapBasedTag();
|
||||
|
||||
virtual const TagValue &value(KnownField value) const;
|
||||
virtual const TagValue &value(KnownField field) const;
|
||||
virtual const TagValue &value(const typename FieldType::identifierType &id) const;
|
||||
virtual std::list<const TagValue *> values(const typename FieldType::identifierType &id) const;
|
||||
virtual bool setValue(KnownField field, const TagValue &value);
|
||||
|
@ -82,9 +82,9 @@ FieldMapBasedTag<FieldType, Compare>::~FieldMapBasedTag()
|
|||
{}
|
||||
|
||||
template <class FieldType, class Compare>
|
||||
inline const TagValue &FieldMapBasedTag<FieldType, Compare>::value(KnownField value) const
|
||||
inline const TagValue &FieldMapBasedTag<FieldType, Compare>::value(KnownField field) const
|
||||
{
|
||||
return this->value(fieldId(value));
|
||||
return value(fieldId(field));
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -163,7 +163,7 @@ inline void FieldMapBasedTag<FieldType, Compare>::removeAllFields()
|
|||
*
|
||||
* This method provides direct access to the fields of the tag. It might
|
||||
* be usefull when the convenience methods value(), setValue(), hasField(), ...
|
||||
* to not offer the required functionality.
|
||||
* do not offer the required functionality.
|
||||
*/
|
||||
template <class FieldType, class Compare>
|
||||
inline const std::multimap<typename FieldType::identifierType, FieldType, Compare> &FieldMapBasedTag<FieldType, Compare>::fields() const
|
||||
|
@ -176,7 +176,7 @@ inline const std::multimap<typename FieldType::identifierType, FieldType, Compar
|
|||
*
|
||||
* This method provides direct access to the fields of the tag. It might
|
||||
* be usefull when the convenience methods value(), setValue(), hasField(), ...
|
||||
* to not offer the required functionality.
|
||||
* do not offer the required functionality.
|
||||
*/
|
||||
template <class FieldType, class Compare>
|
||||
inline std::multimap<typename FieldType::identifierType, FieldType, Compare> &FieldMapBasedTag<FieldType, Compare>::fields()
|
||||
|
|
|
@ -331,28 +331,37 @@ void Id3v2Tag::setVersion(byte majorVersion, byte revisionVersion)
|
|||
/*!
|
||||
* \brief Returns true if \a lhs goes before \a rhs; otherwise returns false.
|
||||
*/
|
||||
bool FrameComparer::operator ()(const uint32 &lhs, const uint32 &rhs) const
|
||||
bool FrameComparer::operator()(const uint32 &lhs, const uint32 &rhs) const
|
||||
{
|
||||
if(lhs == rhs)
|
||||
if(lhs == rhs) {
|
||||
return false;
|
||||
if(lhs == Id3v2FrameIds::lUniqueFileId || lhs == Id3v2FrameIds::sUniqueFileId)
|
||||
}
|
||||
if(lhs == Id3v2FrameIds::lUniqueFileId || lhs == Id3v2FrameIds::sUniqueFileId) {
|
||||
return true;
|
||||
if(rhs == Id3v2FrameIds::lUniqueFileId || rhs == Id3v2FrameIds::sUniqueFileId)
|
||||
}
|
||||
if(rhs == Id3v2FrameIds::lUniqueFileId || rhs == Id3v2FrameIds::sUniqueFileId) {
|
||||
return false;
|
||||
if(lhs == Id3v2FrameIds::lTitle || lhs == Id3v2FrameIds::sTitle)
|
||||
}
|
||||
if(lhs == Id3v2FrameIds::lTitle || lhs == Id3v2FrameIds::sTitle) {
|
||||
return true;
|
||||
if(rhs == Id3v2FrameIds::lTitle || rhs == Id3v2FrameIds::sTitle)
|
||||
}
|
||||
if(rhs == Id3v2FrameIds::lTitle || rhs == Id3v2FrameIds::sTitle) {
|
||||
return false;
|
||||
}
|
||||
bool lhstextfield = Id3v2FrameIds::isTextfield(lhs);
|
||||
bool rhstextfield = Id3v2FrameIds::isTextfield(rhs);
|
||||
if(lhstextfield && !rhstextfield)
|
||||
if(lhstextfield && !rhstextfield) {
|
||||
return true;
|
||||
if(!lhstextfield && rhstextfield)
|
||||
}
|
||||
if(!lhstextfield && rhstextfield) {
|
||||
return false;
|
||||
if(lhs == Id3v2FrameIds::lCover || lhs == Id3v2FrameIds::sCover)
|
||||
}
|
||||
if(lhs == Id3v2FrameIds::lCover || lhs == Id3v2FrameIds::sCover) {
|
||||
return false;
|
||||
if(rhs == Id3v2FrameIds::lCover || rhs == Id3v2FrameIds::sCover)
|
||||
}
|
||||
if(rhs == Id3v2FrameIds::lCover || rhs == Id3v2FrameIds::sCover) {
|
||||
return true;
|
||||
}
|
||||
return lhs < rhs;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Media
|
|||
|
||||
struct LIB_EXPORT FrameComparer
|
||||
{
|
||||
bool operator() (const uint32& lhs, const uint32& rhs) const;
|
||||
bool operator()(const uint32& lhs, const uint32& rhs) const;
|
||||
};
|
||||
|
||||
class LIB_EXPORT Id3v2Tag : public FieldMapBasedTag<Id3v2Frame, FrameComparer>
|
||||
|
|
|
@ -70,9 +70,7 @@ void EbmlElement::internalParse()
|
|||
}
|
||||
stream().seekg(startOffset());
|
||||
// read ID
|
||||
char buf[GenericFileElement<implementationType>::maximumIdLengthSupported() > GenericFileElement<implementationType>::maximumSizeLengthSupported()
|
||||
? GenericFileElement<implementationType>::maximumIdLengthSupported()
|
||||
: GenericFileElement<implementationType>::maximumSizeLengthSupported()] = {0};
|
||||
char buf[maximumIdLengthSupported() > maximumSizeLengthSupported() ? maximumIdLengthSupported() : maximumSizeLengthSupported()] = {0};
|
||||
byte beg, mask = 0x80;
|
||||
beg = stream().peek();
|
||||
m_idLength = 1;
|
||||
|
@ -107,7 +105,7 @@ void EbmlElement::internalParse()
|
|||
throw InvalidDataException();
|
||||
}
|
||||
// read size into buffer
|
||||
memset(buf, 0, sizeof(buf));
|
||||
*reinterpret_cast<dataSizeType *>(buf) = 0; // reset buffer
|
||||
reader().read(buf + (GenericFileElement<implementationType>::maximumSizeLengthSupported() - m_sizeLength), m_sizeLength);
|
||||
*(buf + (GenericFileElement<implementationType>::maximumSizeLengthSupported() - m_sizeLength)) ^= mask; // xor the first byte in buffer which has been read from the file with mask
|
||||
m_dataSize = ConversionUtilities::BE::toUInt64(buf);
|
||||
|
|
|
@ -77,7 +77,7 @@ void Mp4Atom::internalParse()
|
|||
}
|
||||
m_id = reader().readUInt32BE();
|
||||
m_idLength = 4;
|
||||
if(dataSize() == 1) { // mp4 atom denotes 64 bit size
|
||||
if(dataSize() == 1) { // atom denotes 64-bit size
|
||||
m_dataSize = reader().readUInt64BE();
|
||||
m_sizeLength = 12; // 4 bytes indicate long size denotation + 8 bytes for actual size denotation
|
||||
if(dataSize() < 16 && m_dataSize != 1) {
|
||||
|
|
|
@ -555,7 +555,7 @@ std::unique_ptr<Mpeg4ElementaryStreamInfo> Mp4Track::parseMpeg4ElementaryStreamI
|
|||
esInfo->videoSpecificConfig = parseVideoSpecificConfig(decCfgDescChild);
|
||||
break;
|
||||
default:
|
||||
; // TODO: covering more object types
|
||||
; // TODO: cover more object types
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -591,7 +591,6 @@ unique_ptr<Mpeg4AudioSpecificConfig> Mp4Track::parseAudioSpecificConfig(Mpeg4Des
|
|||
auto buff = make_unique<char []>(decSpecInfoDesc->dataSize());
|
||||
m_istream->read(buff.get(), decSpecInfoDesc->dataSize());
|
||||
BitReader bitReader(buff.get(), decSpecInfoDesc->dataSize());
|
||||
cout << "buff: " << reinterpret_cast<uint64>(buff.get()) << ", " << decSpecInfoDesc->dataSize() << endl;
|
||||
auto audioCfg = make_unique<Mpeg4AudioSpecificConfig>();
|
||||
try {
|
||||
// read audio object type
|
||||
|
@ -798,6 +797,8 @@ std::unique_ptr<Mpeg4VideoSpecificConfig> Mp4Track::parseVideoSpecificConfig(Mpe
|
|||
* - the ID of the atom holding these offsets is not "stco" or "co64"
|
||||
*
|
||||
* \throws Throws std::ios_base::failure when an IO error occurs.
|
||||
*
|
||||
* \remarks This method needs to be fixed.
|
||||
*/
|
||||
void Mp4Track::updateChunkOffsets(const vector<int64> &oldMdatOffsets, const vector<int64> &newMdatOffsets)
|
||||
{
|
||||
|
|
5
tag.h
5
tag.h
|
@ -69,7 +69,8 @@ enum class KnownField : unsigned int
|
|||
Cover, /**< cover */
|
||||
Composer, /**< composer */
|
||||
Rating, /**< rating */
|
||||
Description /**< description */
|
||||
Description, /**< description */
|
||||
Vendor /**< vendor */
|
||||
};
|
||||
|
||||
/*!
|
||||
|
@ -80,7 +81,7 @@ constexpr KnownField firstKnownField = KnownField::Title;
|
|||
/*!
|
||||
* \brief The last valid entry in the Media::KnownField enum.
|
||||
*/
|
||||
constexpr KnownField lastKnownField = KnownField::Description;
|
||||
constexpr KnownField lastKnownField = KnownField::Vendor;
|
||||
|
||||
/*!
|
||||
* \brief The number of valid entries in the Media::KnownField enum.
|
||||
|
|
43
tagvalue.cpp
43
tagvalue.cpp
|
@ -202,16 +202,15 @@ int32 TagValue::toInteger() const
|
|||
return ConversionUtilities::stringToNumber<int32>(string(m_ptr.get(), m_size));
|
||||
case TagDataType::Integer:
|
||||
case TagDataType::StandardGenreIndex:
|
||||
if(m_size == sizeof(int)) {
|
||||
char *test = m_ptr.get();
|
||||
int res = *reinterpret_cast<int *>(test);
|
||||
if(m_size == sizeof(int32)) {
|
||||
auto res = *reinterpret_cast<int32 *>(m_ptr.get());
|
||||
return res;
|
||||
} else {
|
||||
throw ConversionException("The assigned data is of unappropriate size.");
|
||||
throw ConversionException("Can not convert assigned data to integer because the data size is not appropriate.");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw ConversionException("It is not possible to convert assigned data to a number because of its incompatible type.");
|
||||
throw ConversionException("Can not convert binary data/picture/time span/date time to integer.");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -268,15 +267,16 @@ PositionInSet TagValue::toPositionIntSet() const
|
|||
return PositionInSet(string(m_ptr.get(), m_size));
|
||||
case TagDataType::Integer:
|
||||
case TagDataType::PositionInSet:
|
||||
if(m_size == sizeof(int32)) {
|
||||
switch(m_size) {
|
||||
case sizeof(int32):
|
||||
return PositionInSet(*(reinterpret_cast<int *>(m_ptr.get())));
|
||||
} else if(m_size == 2 * sizeof(int32)) {
|
||||
case 2 * sizeof(int32):
|
||||
return PositionInSet(*(reinterpret_cast<int32 *>(m_ptr.get())), *(reinterpret_cast<int32 *>(m_ptr.get() + sizeof(int32))));
|
||||
} else {
|
||||
throw ConversionException("The assigned data is of unappropriate size.");
|
||||
default:
|
||||
throw ConversionException("The size of the assigned data is not appropriate.");
|
||||
}
|
||||
default:
|
||||
throw ConversionException("It is not possible to convert assigned data to a number because of its incompatible type.");
|
||||
throw ConversionException("Can not convert binary data/genre index/picture to \"position in set\".");
|
||||
}
|
||||
}
|
||||
return PositionInSet();
|
||||
|
@ -295,15 +295,16 @@ TimeSpan TagValue::toTimeSpan() const
|
|||
return TimeSpan::fromSeconds(ConversionUtilities::stringToNumber<int64>(string(m_ptr.get(), m_size)));
|
||||
case TagDataType::Integer:
|
||||
case TagDataType::TimeSpan:
|
||||
if(m_size == sizeof(int32)) {
|
||||
switch(m_size) {
|
||||
case sizeof(int32):
|
||||
return TimeSpan(*(reinterpret_cast<int32 *>(m_ptr.get())));
|
||||
} else if(m_size == sizeof(int64)) {
|
||||
case sizeof(int64):
|
||||
return TimeSpan(*(reinterpret_cast<int64 *>(m_ptr.get())));
|
||||
} else {
|
||||
throw ConversionException("The assigned data is of unappropriate size.");
|
||||
default:
|
||||
throw ConversionException("The size of the assigned data is not appropriate.");
|
||||
}
|
||||
default:
|
||||
throw ConversionException("No conversion from assigned data to time span known.");
|
||||
throw ConversionException("Can not convert binary data/genre index/position in set/picture to time span.");
|
||||
}
|
||||
}
|
||||
return TimeSpan();
|
||||
|
@ -330,7 +331,7 @@ DateTime TagValue::toDateTime() const
|
|||
throw ConversionException("The assigned data is of unappropriate size.");
|
||||
}
|
||||
default:
|
||||
throw ConversionException("No conversion from assigned data to date known.");
|
||||
throw ConversionException("Can not convert binary data/genre index/position in set/picture to date time.");
|
||||
}
|
||||
}
|
||||
return DateTime();
|
||||
|
@ -351,14 +352,14 @@ string TagValue::toString() const
|
|||
/*!
|
||||
* \brief Converts the value of the current TagValue object to its equivalent
|
||||
* std::string representation.
|
||||
* \throws Throws ConversionException an failure.
|
||||
* \throws Throws ConversionException on failure.
|
||||
*/
|
||||
void TagValue::toString(string &result) const
|
||||
{
|
||||
if(!isEmpty()) {
|
||||
switch(m_type) {
|
||||
case TagDataType::Text:
|
||||
result = string(m_ptr.get(), m_size);
|
||||
result.assign(m_ptr.get(), m_size);
|
||||
return;
|
||||
case TagDataType::Integer:
|
||||
result = ConversionUtilities::numberToString(toInteger());
|
||||
|
@ -368,15 +369,17 @@ void TagValue::toString(string &result) const
|
|||
return;
|
||||
case TagDataType::StandardGenreIndex:
|
||||
if(const char *genreName = Id3Genres::stringFromIndex(toInteger())) {
|
||||
result = string(genreName);
|
||||
result.assign(genreName);
|
||||
return;
|
||||
} else {
|
||||
throw ConversionException("No string representation for the assigned standard genre index available.");
|
||||
}
|
||||
break;
|
||||
case TagDataType::TimeSpan:
|
||||
result = toTimeSpan().toString();
|
||||
return;
|
||||
default:
|
||||
throw ConversionException("It is not possible to convert assigned data to a number because of its incompatible type.");
|
||||
throw ConversionException("Can not convert binary data/picture to string.");
|
||||
}
|
||||
}
|
||||
result.clear();
|
||||
|
|
Loading…
Reference in New Issue