Add method to generate short track description
This commit is contained in:
parent
267bd62879
commit
5aa5ccb6eb
|
@ -138,6 +138,58 @@ string AbstractTrack::label() const
|
|||
return ss.str();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Returns a short description about the track.
|
||||
*
|
||||
* The description contains the abbreviated format and further information depending on the media
|
||||
* type (eg. display size in case of video, language in case of audio/text). It is intended to be joined
|
||||
* with descriptions of other tracks to get a short technical description about the file.
|
||||
*
|
||||
* Examples (exact format might change in the future!):
|
||||
* - H.264-720p
|
||||
* - HE-AAC-6ch-eng
|
||||
*/
|
||||
string AbstractTrack::description() const
|
||||
{
|
||||
// use abbreviated format
|
||||
const char *format = m_format.shortAbbreviation();
|
||||
if(!format || !*format) {
|
||||
// fall back to media type name if no abbreviation available
|
||||
format = mediaTypeName();
|
||||
}
|
||||
|
||||
// find additional info
|
||||
const char *additionalInfo = nullptr;
|
||||
switch(m_mediaType) {
|
||||
case MediaType::Video:
|
||||
if(!displaySize().isNull()) {
|
||||
additionalInfo = displaySize().abbreviation();
|
||||
} else if(!pixelSize().isNull()) {
|
||||
additionalInfo = pixelSize().abbreviation();
|
||||
}
|
||||
break;
|
||||
case MediaType::Audio:
|
||||
case MediaType::Text:
|
||||
if(channelCount()) {
|
||||
if(!language().empty() && language() != "und") {
|
||||
return argsToString(format, '-', channelCount(), "ch-", language());
|
||||
} else {
|
||||
return argsToString(format, '-', channelCount(), 'c', 'h');
|
||||
}
|
||||
} else if(!language().empty() && language() != "und") {
|
||||
additionalInfo = language().data();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
||||
if(additionalInfo) {
|
||||
return argsToString(format, '-', additionalInfo);
|
||||
}
|
||||
return format;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Parses technical information about the track from the header.
|
||||
*
|
||||
|
|
|
@ -107,6 +107,7 @@ public:
|
|||
uint32 colorSpace() const;
|
||||
const Margin &cropping() const;
|
||||
std::string label() const;
|
||||
std::string description() const;
|
||||
|
||||
void parseHeader();
|
||||
bool isHeaderValid() const;
|
||||
|
|
Loading…
Reference in New Issue