2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
9 #include "DVDStreamInfo.h"
11 #include "DVDDemuxers/DVDDemux.h"
12 #include "cores/VideoPlayer/Interface/DemuxCrypto.h"
16 CDVDStreamInfo::CDVDStreamInfo() : extradata
{}
20 CDVDStreamInfo::CDVDStreamInfo(const CDVDStreamInfo
& right
, bool withextradata
) : extradata
{}
23 Assign(right
, withextradata
);
25 CDVDStreamInfo::CDVDStreamInfo(const CDemuxStream
& right
, bool withextradata
) : extradata
{}
28 Assign(right
, withextradata
);
31 CDVDStreamInfo::~CDVDStreamInfo() = default;
33 void CDVDStreamInfo::Clear()
35 codec
= AV_CODEC_ID_NONE
;
38 source
= STREAM_SOURCE_NONE
;
47 cryptoSession
= nullptr;
48 externalInterfaces
= nullptr;
61 forced_aspect
= false;
63 hdrType
= StreamHdrType::HDR_TYPE_NONE
;
64 colorSpace
= AVCOL_SPC_UNSPECIFIED
;
65 colorRange
= AVCOL_RANGE_UNSPECIFIED
;
66 colorPrimaries
= AVCOL_PRI_UNSPECIFIED
;
67 colorTransferCharacteristic
= AVCOL_TRC_UNSPECIFIED
;
68 masteringMetadata
= nullptr;
69 contentLightMetadata
= nullptr;
84 bool CDVDStreamInfo::Equal(const CDVDStreamInfo
& right
, int compare
)
86 if (codec
!= right
.codec
|| type
!= right
.type
||
87 ((compare
& COMPARE_ID
) && uniqueId
!= right
.uniqueId
) ||
88 ((compare
& COMPARE_ID
) && demuxerId
!= right
.demuxerId
) || codec_tag
!= right
.codec_tag
||
92 if (compare
& COMPARE_EXTRADATA
&& extradata
!= right
.extradata
)
99 if (fpsscale
!= right
.fpsscale
100 || fpsrate
!= right
.fpsrate
101 || interlaced
!= right
.interlaced
102 || height
!= right
.height
103 || width
!= right
.width
104 || stills
!= right
.stills
105 || level
!= right
.level
106 || profile
!= right
.profile
107 || ptsinvalid
!= right
.ptsinvalid
108 || forced_aspect
!= right
.forced_aspect
109 || bitsperpixel
!= right
.bitsperpixel
110 || bitdepth
!= right
.bitdepth
112 || hdrType
!= right
.hdrType
113 || colorSpace
!= right
.colorSpace
114 || colorRange
!= right
.colorRange
115 || colorPrimaries
!= right
.colorPrimaries
116 || colorTransferCharacteristic
!= right
.colorTransferCharacteristic
117 || stereo_mode
!= right
.stereo_mode
)
121 if (masteringMetadata
&& right
.masteringMetadata
)
123 if (masteringMetadata
->has_luminance
!= right
.masteringMetadata
->has_luminance
124 || masteringMetadata
->has_primaries
!= right
.masteringMetadata
->has_primaries
)
127 if (masteringMetadata
->has_primaries
)
129 for (unsigned int i(0); i
< 3; ++i
)
130 for (unsigned int j(0); j
< 2; ++j
)
131 if (av_cmp_q(masteringMetadata
->display_primaries
[i
][j
], right
.masteringMetadata
->display_primaries
[i
][j
]))
133 for (unsigned int i(0); i
< 2; ++i
)
134 if (av_cmp_q(masteringMetadata
->white_point
[i
], right
.masteringMetadata
->white_point
[i
]))
138 if (masteringMetadata
->has_luminance
)
140 if (av_cmp_q(masteringMetadata
->min_luminance
, right
.masteringMetadata
->min_luminance
)
141 || av_cmp_q(masteringMetadata
->max_luminance
, right
.masteringMetadata
->max_luminance
))
145 else if (masteringMetadata
|| right
.masteringMetadata
)
148 if (contentLightMetadata
&& right
.contentLightMetadata
)
150 if (contentLightMetadata
->MaxCLL
!= right
.contentLightMetadata
->MaxCLL
151 || contentLightMetadata
->MaxFALL
!= right
.contentLightMetadata
->MaxFALL
)
154 else if (contentLightMetadata
|| right
.contentLightMetadata
)
157 if (0 != std::memcmp(&dovi
, &right
.dovi
, sizeof(AVDOVIDecoderConfigurationRecord
)))
161 if( channels
!= right
.channels
162 || samplerate
!= right
.samplerate
163 || blockalign
!= right
.blockalign
164 || bitrate
!= right
.bitrate
165 || bitspersample
!= right
.bitspersample
166 || channellayout
!= right
.channellayout
)
172 if ((cryptoSession
== nullptr) != (right
.cryptoSession
== nullptr))
175 if (cryptoSession
&& !(*cryptoSession
== *right
.cryptoSession
))
181 bool CDVDStreamInfo::Equal(const CDemuxStream
& right
, bool withextradata
)
184 info
.Assign(right
, withextradata
);
185 return Equal(info
, withextradata
? COMPARE_ALL
: COMPARE_ALL
& ~COMPARE_EXTRADATA
);
190 void CDVDStreamInfo::Assign(const CDVDStreamInfo
& right
, bool withextradata
)
194 uniqueId
= right
.uniqueId
;
195 demuxerId
= right
.demuxerId
;
196 source
= right
.source
;
197 codec_tag
= right
.codec_tag
;
199 filename
= right
.filename
;
202 if (withextradata
&& right
.extradata
)
204 extradata
= right
.extradata
;
211 cryptoSession
= right
.cryptoSession
;
212 externalInterfaces
= right
.externalInterfaces
;
215 fpsscale
= right
.fpsscale
;
216 fpsrate
= right
.fpsrate
;
217 interlaced
= right
.interlaced
;
218 height
= right
.height
;
220 aspect
= right
.aspect
;
221 stills
= right
.stills
;
223 profile
= right
.profile
;
224 ptsinvalid
= right
.ptsinvalid
;
225 forced_aspect
= right
.forced_aspect
;
226 orientation
= right
.orientation
;
227 bitsperpixel
= right
.bitsperpixel
;
228 bitdepth
= right
.bitdepth
;
230 codecOptions
= right
.codecOptions
;
231 hdrType
= right
.hdrType
;
232 colorSpace
= right
.colorSpace
;
233 colorRange
= right
.colorRange
;
234 colorPrimaries
= right
.colorPrimaries
;
235 colorTransferCharacteristic
= right
.colorTransferCharacteristic
;
236 masteringMetadata
= right
.masteringMetadata
;
237 contentLightMetadata
= right
.contentLightMetadata
;
238 stereo_mode
= right
.stereo_mode
;
242 channels
= right
.channels
;
243 samplerate
= right
.samplerate
;
244 blockalign
= right
.blockalign
;
245 bitrate
= right
.bitrate
;
246 bitspersample
= right
.bitspersample
;
247 channellayout
= right
.channellayout
;
252 void CDVDStreamInfo::Assign(const CDemuxStream
& right
, bool withextradata
)
258 uniqueId
= right
.uniqueId
;
259 demuxerId
= right
.demuxerId
;
260 source
= right
.source
;
261 codec_tag
= right
.codec_fourcc
;
262 profile
= right
.profile
;
266 if (withextradata
&& right
.extraData
)
268 extradata
= right
.extraData
;
271 cryptoSession
= right
.cryptoSession
;
272 externalInterfaces
= right
.externalInterfaces
;
274 if (right
.type
== STREAM_AUDIO
)
276 const CDemuxStreamAudio
*stream
= static_cast<const CDemuxStreamAudio
*>(&right
);
277 channels
= stream
->iChannels
;
278 samplerate
= stream
->iSampleRate
;
279 blockalign
= stream
->iBlockAlign
;
280 bitrate
= stream
->iBitRate
;
281 bitspersample
= stream
->iBitsPerSample
;
282 channellayout
= stream
->iChannelLayout
;
284 else if (right
.type
== STREAM_VIDEO
)
286 const CDemuxStreamVideo
*stream
= static_cast<const CDemuxStreamVideo
*>(&right
);
287 fpsscale
= stream
->iFpsScale
;
288 fpsrate
= stream
->iFpsRate
;
289 interlaced
= stream
->interlaced
;
290 height
= stream
->iHeight
;
291 width
= stream
->iWidth
;
292 aspect
= stream
->fAspect
;
294 ptsinvalid
= stream
->bPTSInvalid
;
295 forced_aspect
= stream
->bForcedAspect
;
296 orientation
= stream
->iOrientation
;
297 bitsperpixel
= stream
->iBitsPerPixel
;
298 bitdepth
= stream
->bitDepth
;
299 hdrType
= stream
->hdr_type
;
300 colorSpace
= stream
->colorSpace
;
301 colorRange
= stream
->colorRange
;
302 colorPrimaries
= stream
->colorPrimaries
;
303 colorTransferCharacteristic
= stream
->colorTransferCharacteristic
;
304 masteringMetadata
= stream
->masteringMetaData
;
305 contentLightMetadata
= stream
->contentLightMetaData
;
306 stereo_mode
= stream
->stereo_mode
;
309 else if (right
.type
== STREAM_SUBTITLE
)