Add NamedChannel and use it to hide the never-used channels
[dcpomatic.git] / src / lib / audio_content.cc
index f3372011933c724985e2b172d8e37124ad908d91..22521c9e9b8be6ab6a263ef44b62b7ed22302e5f 100644 (file)
@@ -43,6 +43,7 @@ using boost::shared_ptr;
 using boost::dynamic_pointer_cast;
 using boost::optional;
 using dcp::raw_convert;
+using namespace dcpomatic;
 
 /** Something stream-related has changed */
 int const AudioContentProperty::STREAMS = 200;
@@ -196,10 +197,9 @@ AudioContent::mapping () const
 int
 AudioContent::resampled_frame_rate (shared_ptr<const Film> film) const
 {
-       /* Resample to a DCI-approved sample rate */
-       double t = has_rate_above_48k() ? 96000 : 48000;
+       double t = film->audio_frame_rate ();
 
-       FrameRateChange frc (_parent->active_video_frame_rate(film), film->video_frame_rate());
+       FrameRateChange frc (film, _parent);
 
        /* Compensate if the DCP is being run at a different frame rate
           to the source; that is, if the video is run such that it will
@@ -264,31 +264,19 @@ AudioContent::processing_description (shared_ptr<const Film> film) const
        return "";
 }
 
-/** @return true if any stream in this content has a sampling rate of more than 48kHz */
-bool
-AudioContent::has_rate_above_48k () const
-{
-       BOOST_FOREACH (AudioStreamPtr i, streams ()) {
-               if (i->frame_rate() > 48000) {
-                       return true;
-               }
-       }
-
-       return false;
-}
-
 /** @return User-visible names of each of our audio channels */
-vector<string>
+vector<NamedChannel>
 AudioContent::channel_names () const
 {
-       vector<string> n;
+       vector<NamedChannel> n;
 
-       int t = 1;
+       int index = 0;
+       int stream = 1;
        BOOST_FOREACH (AudioStreamPtr i, streams ()) {
                for (int j = 0; j < i->channels(); ++j) {
-                       n.push_back (String::compose ("%1:%2", t, j + 1));
+                       n.push_back (NamedChannel(String::compose ("%1:%2", stream, j + 1), index++));
                }
-               ++t;
+               ++stream;
        }
 
        return n;