Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches
CStreamDetails Class Referencefinal

#include <StreamDetails.h>

Inheritance diagram for CStreamDetails:
IArchivable ISerializable

Classes

struct  AspectRatio
 A common aspect ratio, and the label Kodi reports for content closest to it. More...
 
struct  FlagName
 A stream flag, and the name Kodi reads and writes for it in an NFO. More...
 
struct  Resolution
 An upper bound on coded dimensions, and the label Kodi reports for content fitting within it. More...
 

Public Member Functions

 CStreamDetails ()
 
 CStreamDetails (const CStreamDetails &that)
 
CStreamDetailsoperator= (const CStreamDetails &that)
 
bool operator== (const CStreamDetails &that) const
 
bool operator!= (const CStreamDetails &that) const
 
bool HasItems (void) const
 
int GetStreamCount (CStreamDetail::StreamType type) const
 
int GetVideoStreamCount (void) const
 
int GetAudioStreamCount (void) const
 
int GetSubtitleStreamCount (void) const
 
const CStreamDetailGetNthStream (CStreamDetail::StreamType type, int idx) const
 
std::string GetVideoCodec (int idx=0) const
 
float GetVideoAspect (int idx=0) const
 
int GetVideoWidth (int idx=0) const
 
int GetVideoHeight (int idx=0) const
 
std::string GetVideoHdrType (int idx=0, bool alt=false) const
 
std::string GetVideoHdrDetail (int idx=0) const
 
int GetVideoDuration (int idx=0) const
 
void SetVideoDuration (int idx, const int duration)
 
std::string GetStereoMode (int idx=0) const
 
std::string GetVideoLanguage (int idx=0) const
 
std::string GetSubtitleLanguage (int idx=0) const
 
StreamFlags GetSubtitleFlags (int idx=0) const
 
int GetPreferredAudioStreamIndex (const StreamUtils::AudioPreferences &preferences) const
 Get the index of the audio stream playback is likely to start on.
 
int GetDefaultAudioStreamIndex () const
 Get the index of the audio stream the media nominates as its default.
 
std::string GetFirstAudioLanguage () const
 Get the language of the first audio stream in the order the source lists them.
 
std::string GetFirstAudioCodec () const
 Get the codec of the first audio stream in the order the source lists them.
 
int GetFirstAudioChannels () const
 Get the channel count of the first audio stream in the order the source lists them.
 
std::string GetFirstSubtitleLanguage () const
 Get the language of the first subtitle stream in the order the source lists them.
 
void AddStream (CStreamDetail *item)
 
void Reset (void)
 
void DetermineBestStreams (void)
 
void Archive (CArchive &ar) override
 
void Serialize (CVariant &value) const override
 
bool SetStreams (const VideoStreamInfo &videoInfo, int videoDuration, const AudioStreamInfo &audioInfo, const SubtitleStreamInfo &subtitleInfo, CStreamDetail::Source source)
 
CStreamDetail::Source GetSource (CStreamDetail::StreamType type, int idx) const
 
CStreamDetail::Source GetSources () const
 
void SetSources (CStreamDetail::Source source)
 
bool ShouldUpdateWithNewDetails (const CStreamDetails &newInfo) const
 
int GetVersion (CStreamDetail::StreamType type, int idx) const
 
Audio stream properties

An idx of 0 asks for the technically best stream, as judged by StreamUtils::CompareAudioQuality() (based on codec and channel count only).

Any other idx is a 1-based ordinal into the streams in the order the source presented them.

std::string GetAudioCodec (int idx=0) const
 
std::string GetAudioLanguage (int idx=0) const
 
int GetAudioChannels (int idx=0) const
 
StreamFlags GetAudioFlags (int idx=0) const
 
- Public Member Functions inherited from IArchivable
- Public Member Functions inherited from ISerializable

Static Public Member Functions

static std::string VideoDimsToResolutionDescription (int iWidth, int iHeight)
 
static std::string VideoAspectToAspectDescription (float fAspect)
 
static std::vector< std::string > StreamFlagsToNames (StreamFlags flags)
 Break a flag set out into its names, in alphabetical order.
 
static StreamFlags StreamFlagFromName (std::string_view name)
 Look a single flag up by name.
 
static std::string HdrTypeToString (StreamHdrType hdrType)
 

Static Public Attributes

static constexpr auto COMMON_RESOLUTIONS
 The vocabulary of resolution labels Kodi reports, in ascending order.
 
static constexpr auto COMMON_ASPECT_RATIOS
 The vocabulary of aspect ratio labels Kodi reports, in ascending order.
 
static constexpr auto STREAM_FLAG_NAMES
 The vocabulary of stream flag names used in NFOs.
 

Additional Inherited Members

- Protected Member Functions inherited from IArchivable
virtual ~IArchivable ()=default
 
- Protected Member Functions inherited from ISerializable
 ~ISerializable ()=default
 

Constructor & Destructor Documentation

◆ CStreamDetails() [1/2]

CStreamDetails::CStreamDetails ( )
inline

◆ CStreamDetails() [2/2]

CStreamDetails::CStreamDetails ( const CStreamDetails & that)

Member Function Documentation

◆ AddStream()

void CStreamDetails::AddStream ( CStreamDetail * item)

◆ Archive()

void CStreamDetails::Archive ( CArchive & ar)
overridevirtual

Implements IArchivable.

◆ DetermineBestStreams()

void CStreamDetails::DetermineBestStreams ( void )

◆ GetAudioChannels()

int CStreamDetails::GetAudioChannels ( int idx = 0) const

◆ GetAudioCodec()

std::string CStreamDetails::GetAudioCodec ( int idx = 0) const

◆ GetAudioFlags()

StreamFlags CStreamDetails::GetAudioFlags ( int idx = 0) const

◆ GetAudioLanguage()

std::string CStreamDetails::GetAudioLanguage ( int idx = 0) const

◆ GetAudioStreamCount()

int CStreamDetails::GetAudioStreamCount ( void ) const

◆ GetDefaultAudioStreamIndex()

int CStreamDetails::GetDefaultAudioStreamIndex ( ) const

Get the index of the audio stream the media nominates as its default.

Returns
The 1-based index of the first stream flagged as default, or 0 (meaning the technically best stream, see GetAudioCodec()) when the media nominates none

◆ GetFirstAudioChannels()

int CStreamDetails::GetFirstAudioChannels ( ) const

Get the channel count of the first audio stream in the order the source lists them.

The counterpart of GetFirstAudioLanguage() for the channel count.

Returns
The channel count of the first audio stream, or -1 if there is none

◆ GetFirstAudioCodec()

std::string CStreamDetails::GetFirstAudioCodec ( ) const

Get the codec of the first audio stream in the order the source lists them.

The counterpart of GetFirstAudioLanguage() for the codec.

Returns
The codec of the first audio stream, or an empty string if there is none

◆ GetFirstAudioLanguage()

std::string CStreamDetails::GetFirstAudioLanguage ( ) const

Get the language of the first audio stream in the order the source lists them.

This is neither the technically best stream (GetAudioLanguage()) nor the one the user's preferences ask for (GetPreferredAudioStreamIndex()) - it is simply the stream listed first by whatever produced these details, which is one of:

  • a bluray playlist, whose streams are stored in stream number order, so the first is audio stream number 1 - the stream the disc expects a player to start with. This is the only case where the order is specified rather than conventional.
  • any other container, in the order its demuxer reports the streams.
  • an NFO, in the order its elements appear.

Note this does not say which stream playback will actually start on. That also depends on stream flags, a choice remembered from a previous watch and the audio layout at play time, none of which the library carries.

Note also that "first" is the order the details were stored, which is the order the source presented for freshly scanned or disc-browsed content. It is not currently guaranteed to survive a round trip through the video database, which stores no stream ordinal and reads the rows back without an ORDER BY.

Todo
Persist a stream ordinal and order by it, so this holds unconditionally.
Returns
The language of the first audio stream, or an empty string if there is none

◆ GetFirstSubtitleLanguage()

std::string CStreamDetails::GetFirstSubtitleLanguage ( ) const

Get the language of the first subtitle stream in the order the source lists them.

The counterpart of GetFirstAudioLanguage() for subtitles, ie. presentation graphic stream number 1 of a bluray playlist. Note that this says nothing about whether subtitles are displayed to begin with, which the locale.subtitlelanguage setting decides.

Returns
The language of the first subtitle stream, or an empty string if there is none

◆ GetNthStream()

const CStreamDetail * CStreamDetails::GetNthStream ( CStreamDetail::StreamType type,
int idx ) const

◆ GetPreferredAudioStreamIndex()

int CStreamDetails::GetPreferredAudioStreamIndex ( const StreamUtils::AudioPreferences & preferences) const

Get the index of the audio stream playback is likely to start on.

Applies StreamUtils::CompareAudioPreference(), so the stream named here is the stream the player picks, save for the two tiers the library cannot see: a stream remembered from a previous watch, and a stereo audio layout.

Parameters
preferencesThe settings in force, see StreamUtils::AudioPreferences::Current()
Returns
The 1-based index of that stream, or 0 when there are no audio streams

◆ GetSource()

CStreamDetail::Source CStreamDetails::GetSource ( CStreamDetail::StreamType type,
int idx ) const

◆ GetSources()

CStreamDetail::Source CStreamDetails::GetSources ( ) const

◆ GetStereoMode()

std::string CStreamDetails::GetStereoMode ( int idx = 0) const

◆ GetStreamCount()

int CStreamDetails::GetStreamCount ( CStreamDetail::StreamType type) const

◆ GetSubtitleFlags()

StreamFlags CStreamDetails::GetSubtitleFlags ( int idx = 0) const

◆ GetSubtitleLanguage()

std::string CStreamDetails::GetSubtitleLanguage ( int idx = 0) const

◆ GetSubtitleStreamCount()

int CStreamDetails::GetSubtitleStreamCount ( void ) const

◆ GetVersion()

int CStreamDetails::GetVersion ( CStreamDetail::StreamType type,
int idx ) const

◆ GetVideoAspect()

float CStreamDetails::GetVideoAspect ( int idx = 0) const

◆ GetVideoCodec()

std::string CStreamDetails::GetVideoCodec ( int idx = 0) const

◆ GetVideoDuration()

int CStreamDetails::GetVideoDuration ( int idx = 0) const

◆ GetVideoHdrDetail()

std::string CStreamDetails::GetVideoHdrDetail ( int idx = 0) const

◆ GetVideoHdrType()

std::string CStreamDetails::GetVideoHdrType ( int idx = 0,
bool alt = false ) const

◆ GetVideoHeight()

int CStreamDetails::GetVideoHeight ( int idx = 0) const

◆ GetVideoLanguage()

std::string CStreamDetails::GetVideoLanguage ( int idx = 0) const

◆ GetVideoStreamCount()

int CStreamDetails::GetVideoStreamCount ( void ) const

◆ GetVideoWidth()

int CStreamDetails::GetVideoWidth ( int idx = 0) const

◆ HasItems()

bool CStreamDetails::HasItems ( void ) const
inline

◆ HdrTypeToString()

std::string CStreamDetails::HdrTypeToString ( StreamHdrType hdrType)
static

◆ operator!=()

bool CStreamDetails::operator!= ( const CStreamDetails & that) const

◆ operator=()

CStreamDetails & CStreamDetails::operator= ( const CStreamDetails & that)

◆ operator==()

bool CStreamDetails::operator== ( const CStreamDetails & that) const

◆ Reset()

void CStreamDetails::Reset ( void )

◆ Serialize()

void CStreamDetails::Serialize ( CVariant & value) const
overridevirtual

Implements ISerializable.

◆ SetSources()

void CStreamDetails::SetSources ( CStreamDetail::Source source)

◆ SetStreams()

bool CStreamDetails::SetStreams ( const VideoStreamInfo & videoInfo,
int videoDuration,
const AudioStreamInfo & audioInfo,
const SubtitleStreamInfo & subtitleInfo,
CStreamDetail::Source source )

◆ SetVideoDuration()

void CStreamDetails::SetVideoDuration ( int idx,
const int duration )

◆ ShouldUpdateWithNewDetails()

bool CStreamDetails::ShouldUpdateWithNewDetails ( const CStreamDetails & newInfo) const

◆ StreamFlagFromName()

StreamFlags CStreamDetails::StreamFlagFromName ( std::string_view name)
static

Look a single flag up by name.

Parameters
nameThe name to look up. Leading and trailing space is ignored, as is case.
Returns
The matching flag, or FLAG_NONE if the name isn't known.

◆ StreamFlagsToNames()

std::vector< std::string > CStreamDetails::StreamFlagsToNames ( StreamFlags flags)
static

Break a flag set out into its names, in alphabetical order.

Parameters
flagsThe flags to name.
Returns
One entry per set bit that has a name; empty for FLAG_NONE.

◆ VideoAspectToAspectDescription()

std::string CStreamDetails::VideoAspectToAspectDescription ( float fAspect)
static

◆ VideoDimsToResolutionDescription()

std::string CStreamDetails::VideoDimsToResolutionDescription ( int iWidth,
int iHeight )
static

Member Data Documentation

◆ COMMON_ASPECT_RATIOS

auto CStreamDetails::COMMON_ASPECT_RATIOS
staticconstexpr
Initial value:
= std::to_array<AspectRatio>({
{1.00f, "1.00"},
{1.19f, "1.19"},
{1.33f, "1.33"},
{1.37f, "1.37"},
{1.43f, "1.43"},
{1.50f, "1.50"},
{1.66f, "1.66"},
{1.78f, "1.78"},
{1.85f, "1.85"},
{1.90f, "1.90"},
{2.00f, "2.00"},
{2.20f, "2.20"},
{2.35f, "2.35"},
{2.40f, "2.40"},
{2.55f, "2.55"},
{2.76f, "2.76"},
})

The vocabulary of aspect ratio labels Kodi reports, in ascending order.

Content is classified as the closest entry in log space, which means the cutoff between two adjacent entries is their geometric mean. See VideoAspectToAspectDescription().

This is the single source of truth for the aspect labels skins display. Anything else needing the same vocabulary - a selection list, a reported label, a plausibility check - must use this table rather than defining a parallel list, or the two will drift.

Note
The table classifies but never rejects. Any value wider than the last entry is reported as that entry, so this cannot be used as a validity check on its own.

◆ COMMON_RESOLUTIONS

auto CStreamDetails::COMMON_RESOLUTIONS
staticconstexpr
Initial value:
= std::to_array<Resolution>({
{854, 480, "480"},
{960, 544, "540"},
{1024, 576, "576"},
{1280, 962, "720"},
{1920, 1440, "1080"},
{4096, 3072, "4K"},
{8192, 6144, "8K"},
})

The vocabulary of resolution labels Kodi reports, in ascending order.

Content is described by the first entry it fits within on both axes. See VideoDimsToResolutionDescription().

Note
Bounding both axes means portrait content is described by whichever entry is tall enough to hold it, so 1080x1920 is "4K". Content larger than the last entry is not described at all rather than clamped to it.

◆ STREAM_FLAG_NAMES

auto CStreamDetails::STREAM_FLAG_NAMES
staticconstexpr
Initial value:
= std::to_array<FlagName>({
{StreamFlags::FLAG_HEARING_IMPAIRED, "hearingimpaired"},
{StreamFlags::FLAG_VISUAL_IMPAIRED, "visualimpaired"},
{StreamFlags::FLAG_WEBVTT_DATA_PACKETS, "webvttdatapackets"},
})
@ FLAG_WEBVTT_DATA_PACKETS
Definition StreamInfo.h:33
@ FLAG_KARAOKE
Definition StreamInfo.h:28
@ FLAG_VISUAL_IMPAIRED
Definition StreamInfo.h:31
@ FLAG_COMMENT
Definition StreamInfo.h:26
@ FLAG_DUB
Definition StreamInfo.h:24
@ FLAG_STILL_IMAGES
Definition StreamInfo.h:32
@ FLAG_ORIGINAL
Definition StreamInfo.h:25
@ FLAG_DEFAULT
Definition StreamInfo.h:23
@ FLAG_FORCED
Definition StreamInfo.h:29
@ FLAG_HEARING_IMPAIRED
Definition StreamInfo.h:30
@ FLAG_LYRICS
Definition StreamInfo.h:27

The vocabulary of stream flag names used in NFOs.

Written out in alphabetical order.


The documentation for this class was generated from the following files: