Allow UI to set up FFmpeg streams again.
authorCarl Hetherington <cth@carlh.net>
Wed, 3 Apr 2013 19:44:02 +0000 (20:44 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 3 Apr 2013 19:44:02 +0000 (20:44 +0100)
src/lib/film.cc
src/lib/film.h
src/lib/playlist.cc
src/lib/playlist.h
src/wx/film_editor.cc

index 091b35d47c7c74a8bbfbd07ef871a81c2196e80c..fd72aa1d5e373ffe78f1622d908caf0088ef8959 100644 (file)
@@ -1161,28 +1161,82 @@ Film::video_length () const
        return _playlist->video_length ();
 }
 
+/** Unfortunately this is needed as the GUI has FFmpeg-specific controls */
+shared_ptr<FFmpegContent>
+Film::ffmpeg () const
+{
+       boost::mutex::scoped_lock lm (_state_mutex);
+       
+       for (ContentList::const_iterator i = _content.begin (); i != _content.end(); ++i) {
+               shared_ptr<FFmpegContent> f = boost::dynamic_pointer_cast<FFmpegContent> (*i);
+               if (f) {
+                       return f;
+               }
+       }
+
+       return shared_ptr<FFmpegContent> ();
+}
+
 vector<FFmpegSubtitleStream>
 Film::ffmpeg_subtitle_streams () const
 {
-       return _playlist->ffmpeg_subtitle_streams ();
+       boost::shared_ptr<FFmpegContent> f = ffmpeg ();
+       if (f) {
+               return f->subtitle_streams ();
+       }
+
+       return vector<FFmpegSubtitleStream> ();
 }
 
 boost::optional<FFmpegSubtitleStream>
 Film::ffmpeg_subtitle_stream () const
 {
-       return _playlist->ffmpeg_subtitle_stream ();
+       boost::shared_ptr<FFmpegContent> f = ffmpeg ();
+       if (f) {
+               return f->subtitle_stream ();
+       }
+
+       return boost::none;
 }
 
 vector<FFmpegAudioStream>
 Film::ffmpeg_audio_streams () const
 {
-       return _playlist->ffmpeg_audio_streams ();
+       boost::shared_ptr<FFmpegContent> f = ffmpeg ();
+       if (f) {
+               return f->audio_streams ();
+       }
+
+       return vector<FFmpegAudioStream> ();
 }
 
 boost::optional<FFmpegAudioStream>
 Film::ffmpeg_audio_stream () const
 {
-       return _playlist->ffmpeg_audio_stream ();
+       boost::shared_ptr<FFmpegContent> f = ffmpeg ();
+       if (f) {
+               return f->audio_stream ();
+       }
+
+       return boost::none;
+}
+
+void
+Film::set_ffmpeg_subtitle_stream (FFmpegSubtitleStream s)
+{
+       boost::shared_ptr<FFmpegContent> f = ffmpeg ();
+       if (f) {
+               f->set_subtitle_stream (s);
+       }
+}
+
+void
+Film::set_ffmpeg_audio_stream (FFmpegAudioStream s)
+{
+       boost::shared_ptr<FFmpegContent> f = ffmpeg ();
+       if (f) {
+               f->set_audio_stream (s);
+       }
 }
 
 void
index e71fe2606aff21e2646cb91121e5bab465963311..a03fd5d9757dc658ac29f6a5c3cf4d64e5f60682 100644 (file)
@@ -119,6 +119,9 @@ public:
        boost::optional<FFmpegSubtitleStream> ffmpeg_subtitle_stream () const;
        std::vector<FFmpegAudioStream> ffmpeg_audio_streams () const;
        boost::optional<FFmpegAudioStream> ffmpeg_audio_stream () const;
+
+       void set_ffmpeg_subtitle_stream (FFmpegSubtitleStream);
+       void set_ffmpeg_audio_stream (FFmpegAudioStream);
        
        /** Identifiers for the parts of our state;
            used for signalling changes.
@@ -313,6 +316,7 @@ private:
        std::string video_state_identifier () const;
        void read_metadata ();
        void content_changed (int);
+       boost::shared_ptr<FFmpegContent> ffmpeg () const;
 
        /** Log to write to */
        boost::shared_ptr<Log> _log;
index 0c29650b6ce8fd24b846074f46e272df11b2a431..3da7f938bbce13af7a3b971787b810f20c16b1ce 100644 (file)
@@ -207,46 +207,6 @@ Playlist::has_audio () const
        return _audio_from != AUDIO_NONE;
 }
 
-vector<FFmpegSubtitleStream>
-Playlist::ffmpeg_subtitle_streams () const
-{
-       if (_video_from != VIDEO_FFMPEG || !_ffmpeg) {
-               return vector<FFmpegSubtitleStream> ();
-       }
-
-       return _ffmpeg->subtitle_streams ();
-}
-
-boost::optional<FFmpegSubtitleStream>
-Playlist::ffmpeg_subtitle_stream () const
-{
-       if (_video_from != VIDEO_FFMPEG || !_ffmpeg) {
-               return boost::none;
-       }
-
-       return _ffmpeg->subtitle_stream ();
-}
-
-vector<FFmpegAudioStream>
-Playlist::ffmpeg_audio_streams () const
-{
-       if (_video_from != VIDEO_FFMPEG || !_ffmpeg) {
-               return vector<FFmpegAudioStream> ();
-       }
-
-       return _ffmpeg->audio_streams ();
-}
-
-boost::optional<FFmpegAudioStream>
-Playlist::ffmpeg_audio_stream () const
-{
-       if (_video_from != VIDEO_FFMPEG || !_ffmpeg) {
-               return boost::none;
-       }
-
-       return _ffmpeg->audio_stream ();
-}
-
 Player::Player (boost::shared_ptr<const Film> f, boost::shared_ptr<const Playlist> p)
        : _film (f)
        , _playlist (p)
index c461151d458f6759b8e4faa33b5beb8fc8cdccef..480f1b2edd01f715029762ec29556a7c95bc842f 100644 (file)
@@ -53,11 +53,6 @@ public:
        libdcp::Size video_size () const;
        ContentVideoFrame video_length () const;
 
-       std::vector<FFmpegSubtitleStream> ffmpeg_subtitle_streams () const;
-       boost::optional<FFmpegSubtitleStream> ffmpeg_subtitle_stream () const;
-       std::vector<FFmpegAudioStream> ffmpeg_audio_streams () const;
-       boost::optional<FFmpegAudioStream> ffmpeg_audio_stream () const;
-
        enum VideoFrom {
                VIDEO_NONE,
                VIDEO_FFMPEG,
index 33919d946bf153e4240f8e00a696dc90d9ac437a..d55104a95280c4298e31eb6ab87c30ebf86414cc 100644 (file)
@@ -1074,14 +1074,16 @@ FilmEditor::ffmpeg_audio_stream_changed (wxCommandEvent &)
                return;
        }
 
-#if 0  
-       _film->set_content_audio_stream (
-               audio_stream_factory (
-                       string_client_data (_audio_stream->GetClientObject (_audio_stream->GetSelection ())),
-                       Film::state_version
-                       )
-               );
-#endif 
+       vector<FFmpegAudioStream> a = _film->ffmpeg_audio_streams ();
+       vector<FFmpegAudioStream>::iterator i = a.begin ();
+       string const s = string_client_data (_ffmpeg_audio_stream->GetClientObject (_ffmpeg_audio_stream->GetSelection ()));
+       while (i != a.end() && i->id != s) {
+               ++i;
+       }
+
+       if (i != a.end ()) {
+               _film->set_ffmpeg_audio_stream (*i);
+       }
 }
 
 void
@@ -1091,33 +1093,33 @@ FilmEditor::ffmpeg_subtitle_stream_changed (wxCommandEvent &)
                return;
        }
 
-#if 0  
-       _film->set_subtitle_stream (
-               subtitle_stream_factory (
-                       string_client_data (_subtitle_stream->GetClientObject (_subtitle_stream->GetSelection ())),
-                       Film::state_version
-                       )
-               );
-#endif 
+       vector<FFmpegSubtitleStream> a = _film->ffmpeg_subtitle_streams ();
+       vector<FFmpegSubtitleStream>::iterator i = a.begin ();
+       string const s = string_client_data (_ffmpeg_subtitle_stream->GetClientObject (_ffmpeg_subtitle_stream->GetSelection ()));
+       while (i != a.end() && i->id != s) {
+               ++i;
+       }
+
+       if (i != a.end ()) {
+               _film->set_ffmpeg_subtitle_stream (*i);
+       }
 }
 
 void
 FilmEditor::setup_audio_details ()
 {
-#if 0  
-       if (!_film->content_audio_stream()) {
+       if (!_film->ffmpeg_audio_stream()) {
                _audio->SetLabel (wxT (""));
        } else {
                stringstream s;
-               if (_film->audio_stream()->channels() == 1) {
+               if (_film->audio_channels() == 1) {
                        s << wx_to_std (_("1 channel"));
                } else {
-                       s << _film->audio_stream()->channels () << " " << wx_to_std (_("channels"));
+                       s << _film->audio_channels() << " " << wx_to_std (_("channels"));
                }
-               s << ", " << _film->audio_stream()->sample_rate() << wx_to_std (_("Hz"));
+               s << ", " << _film->audio_channels() << wx_to_std (_("Hz"));
                _audio->SetLabel (std_to_wx (s.str ()));
        }
-#endif 
 }
 
 void