Add SoundAsset::active_channels(). v1.8.72
authorCarl Hetherington <cth@carlh.net>
Sun, 28 May 2023 21:01:32 +0000 (23:01 +0200)
committerCarl Hetherington <cth@carlh.net>
Sun, 28 May 2023 21:01:32 +0000 (23:01 +0200)
src/sound_asset.cc
src/sound_asset.h

index 7c94b54960416cac9c08f1ee220f9cfb2665cd22..ea952c35fc032420c7a62dfd239948e0bfdae078 100644 (file)
@@ -104,6 +104,16 @@ SoundAsset::SoundAsset (boost::filesystem::path file)
                }
        }
 
+       list<ASDCP::MXF::InterchangeObject*> channel_labels;
+       rr = reader.OP1aHeader().GetMDObjectsByType(
+               asdcp_smpte_dict->ul(ASDCP::MDD_AudioChannelLabelSubDescriptor),
+               channel_labels
+               );
+
+       if (KM_SUCCESS(rr)) {
+               _active_channels = channel_labels.size();
+       }
+
        _id = read_writer_info (info);
 }
 
@@ -266,3 +276,11 @@ SoundAsset::valid_mxf (boost::filesystem::path file)
        Kumu::Result_t r = reader.OpenRead (file.string().c_str());
        return !ASDCP_FAILURE (r);
 }
+
+
+int
+SoundAsset::active_channels() const
+{
+       return _active_channels.get_value_or(_channels);
+}
+
index 55669c2fee43ca489d872a926f86f0ebd865d8a5..70c3aee7cbe4913cfc0efe751462f9142429879c 100644 (file)
@@ -103,11 +103,14 @@ public:
                NoteHandler note
                ) const override;
 
-       /** @return number of channels */
+       /** @return number of channels in the MXF */
        int channels () const {
                return _channels;
        }
 
+       /** @return An estimate of the number of channels that are actually in use */
+       int active_channels() const;
+
        /** @return sampling rate in Hz */
        int sampling_rate () const {
                return _sampling_rate;
@@ -143,8 +146,9 @@ private:
         *  content presented may be less than this.
         */
        int64_t _intrinsic_duration = 0;
-       int _channels = 0;      ///< number of channels
-       int _sampling_rate = 0; ///< sampling rate in Hz
+       int _channels = 0;                     ///< number of channels in the MXF
+       boost::optional<int> _active_channels; ///< estimate of the number of active channels
+       int _sampling_rate = 0;                ///< sampling rate in Hz
        boost::optional<std::string> _language;
 };