]> git.sesse.net Git - casparcg/commitdiff
2.0.0.2: Fixed SET MODE.
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sun, 27 Mar 2011 13:54:20 +0000 (13:54 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sun, 27 Mar 2011 13:54:20 +0000 (13:54 +0000)
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0.0.2@581 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

core/channel.cpp
core/consumer/frame_consumer_device.cpp
core/consumer/frame_consumer_device.h
modules/bluefish/consumer/bluefish_consumer.cpp
modules/ffmpeg/consumer/ffmpeg_consumer.cpp
modules/oal/consumer/oal_consumer.cpp
modules/ogl/consumer/ogl_consumer.cpp
shell/caspar.config

index e90510c86574be03357c8381dc8406a915657f1d..129edd52c1ce018cd198ff0581eaf864c9987714 100644 (file)
@@ -25,11 +25,11 @@ namespace caspar { namespace core {
 struct channel::implementation : boost::noncopyable\r
 {                                      \r
        const int index_;\r
-       const video_format_desc format_desc_;\r
+       video_format_desc format_desc_;\r
        \r
-       const std::shared_ptr<frame_mixer_device>        mixer_;\r
-       const std::shared_ptr<frame_consumer_device> consumer_;\r
-       const std::shared_ptr<frame_producer_device> producer_;\r
+       std::shared_ptr<frame_mixer_device>      mixer_;\r
+       std::shared_ptr<frame_consumer_device> consumer_;\r
+       std::shared_ptr<frame_producer_device> producer_;\r
 \r
        boost::signals2::scoped_connection mixer_connection_;\r
        boost::signals2::scoped_connection producer_connection_;\r
@@ -49,6 +49,20 @@ public:
        {\r
                return L"channel[" + boost::lexical_cast<std::wstring>(index_+1) + L"-" +  format_desc_.name + L"]";\r
        }\r
+\r
+       void set_video_format_desc(const video_format_desc& format_desc)\r
+       {\r
+               format_desc_ = format_desc;\r
+               producer_connection_.disconnect();\r
+               mixer_connection_.disconnect();\r
+\r
+               consumer_->set_video_format_desc(format_desc_);\r
+               mixer_.reset(new frame_mixer_device([=]{return print();}, format_desc_));\r
+               producer_.reset(new frame_producer_device([=]{return print();}, safe_ptr<frame_factory>(mixer_)));\r
+\r
+               mixer_connection_ = mixer_->connect([=](const safe_ptr<const read_frame>& frame){consumer_->send(frame);});\r
+               producer_connection_ = producer_->connect([=](const std::vector<safe_ptr<basic_frame>>& frames){mixer_->send(frames);});\r
+       }\r
 };\r
 \r
 channel::channel(int index, const video_format_desc& format_desc) : impl_(new implementation(index, format_desc)){}\r
@@ -57,7 +71,7 @@ frame_producer_device& channel::producer() { return *impl_->producer_;}
 frame_mixer_device& channel::mixer() { return *impl_->mixer_;} \r
 frame_consumer_device& channel::consumer() { return *impl_->consumer_;} \r
 const video_format_desc& channel::get_video_format_desc() const{return impl_->format_desc_;}\r
-void channel::set_video_format_desc(const video_format_desc& format_desc){impl_ = make_safe<implementation>(impl_->index_, format_desc);}\r
+void channel::set_video_format_desc(const video_format_desc& format_desc){impl_->set_video_format_desc(format_desc);}\r
 std::wstring channel::print() const { return impl_->print();}\r
 \r
 }}
\ No newline at end of file
index b45f499f22eefab950db95c8b7430936451bc1d5..20324b248ea27c731078aa770eb8f28939d0215f 100644 (file)
@@ -26,7 +26,7 @@ struct frame_consumer_device::implementation
 \r
        std::map<int, std::shared_ptr<frame_consumer>> consumers_; // Valid iterators after erase\r
        \r
-       const video_format_desc format_desc_;\r
+       video_format_desc format_desc_;\r
        \r
        executor executor_;     \r
 public:\r
@@ -51,7 +51,7 @@ public:
 \r
        void add(int index, safe_ptr<frame_consumer>&& consumer)\r
        {               \r
-               consumer->initialize(format_desc_, std::bind(&implementation::print, this));\r
+               consumer->initialize(format_desc_, [this]{return print();});\r
                executor_.invoke([&]\r
                {\r
                        if(buffer_.capacity() < consumer->buffer_depth())\r
@@ -104,10 +104,23 @@ public:
        {\r
                return (parent_printer_ ? parent_printer_() + L"/" : L"") + L"consumer";\r
        }\r
+       \r
+       void set_video_format_desc(const video_format_desc& format_desc)\r
+       {\r
+               auto p =  [this]{return print();};\r
+               executor_.invoke([&]\r
+               {\r
+                       format_desc_ = format_desc;\r
+                       buffer_.clear();\r
+                       BOOST_FOREACH(auto& consumer, consumers_)\r
+                               consumer.second->initialize(format_desc_, p);\r
+               });\r
+       }\r
 };\r
 \r
 frame_consumer_device::frame_consumer_device(const printer& parent_printer, const video_format_desc& format_desc) : impl_(new implementation(parent_printer, format_desc)){}\r
 void frame_consumer_device::add(int index, safe_ptr<frame_consumer>&& consumer){impl_->add(index, std::move(consumer));}\r
 void frame_consumer_device::remove(int index){impl_->remove(index);}\r
 void frame_consumer_device::send(const safe_ptr<const read_frame>& future_frame) { impl_->send(future_frame); }\r
+void frame_consumer_device::set_video_format_desc(const video_format_desc& format_desc){impl_->set_video_format_desc(format_desc);}\r
 }}
\ No newline at end of file
index dce523876fa2c18e38b8f6cd23ff6b0f0826b5d5..016757da246ca2af73c01ef2930f6e17120ea1ac 100644 (file)
@@ -23,6 +23,8 @@ public:
        void remove(int index);\r
 \r
        void send(const safe_ptr<const read_frame>& future_frame); // nothrow\r
+       \r
+       void set_video_format_desc(const video_format_desc& format_desc);\r
 private:\r
        struct implementation;\r
        safe_ptr<implementation> impl_;\r
index 8bbfafc4b9e5b5828b661a7874e0dc1fc0962473..b88a01168e9d0330ef3721702687e1c118c195cb 100644 (file)
@@ -347,9 +347,13 @@ public:
        }\r
 };\r
 \r
-bluefish_consumer::bluefish_consumer(bluefish_consumer&& other) : impl_(std::move(other.impl_)){}\r
 bluefish_consumer::bluefish_consumer(unsigned int device_index, bool embed_audio) : impl_(new implementation(device_index, embed_audio)){}     \r
-void bluefish_consumer::initialize(const core::video_format_desc& format_desc, const printer& parent_printer){impl_->initialize(format_desc, parent_printer);}\r
+bluefish_consumer::bluefish_consumer(bluefish_consumer&& other) : impl_(std::move(other.impl_)){}\r
+void bluefish_consumer::initialize(const core::video_format_desc& format_desc, const printer& parent_printer)\r
+{\r
+       impl_.reset(new implementation(impl_->device_index_, impl_->embed_audio_));\r
+       impl_->initialize(format_desc, parent_printer);\r
+}\r
 void bluefish_consumer::send(const safe_ptr<const core::read_frame>& frame){impl_->send(frame);}\r
 size_t bluefish_consumer::buffer_depth() const{return impl_->buffer_depth();}\r
 std::wstring bluefish_consumer::print() const {return impl_->print();} \r
index 61a65d82169e496cd129d77d06f3422cf812170f..424e0d2a66ebe5a48dd82b4cc7af9fb39ff15c05 100644 (file)
@@ -401,7 +401,11 @@ ffmpeg_consumer::ffmpeg_consumer(const std::wstring& filename) : impl_(new imple
 ffmpeg_consumer::ffmpeg_consumer(ffmpeg_consumer&& other) : impl_(std::move(other.impl_)){}\r
 void ffmpeg_consumer::send(const safe_ptr<const core::read_frame>& frame){impl_->send(frame);}\r
 size_t ffmpeg_consumer::buffer_depth() const{return impl_->buffer_depth();}\r
-void ffmpeg_consumer::initialize(const core::video_format_desc& format_desc, const printer& parent_printer) {impl_->initialize(format_desc, parent_printer);}\r
+void ffmpeg_consumer::initialize(const core::video_format_desc& format_desc, const printer& parent_printer)\r
+{\r
+       impl_.reset(new implementation(impl_->filename_));\r
+       impl_->initialize(format_desc, parent_printer);\r
+}\r
 std::wstring ffmpeg_consumer::print() const {return impl_->print();}\r
 \r
 safe_ptr<core::frame_consumer> create_ffmpeg_consumer(const std::vector<std::wstring>& params)\r
index baa97e57813d7ead89a92ec44c8b1c2520f9d1fd..e2efa3ceaf4646befa33098fe6ec80f867a782ee 100644 (file)
@@ -48,14 +48,22 @@ struct oal_consumer::implementation : public sf::SoundStream, boost::noncopyable
 \r
        core::video_format_desc format_desc_;\r
 public:\r
-       implementation() \r
-               : graph_(diagnostics::create_graph(narrow(print())))\r
+       implementation(const core::video_format_desc& format_desc, const printer& parent_printer) \r
+               : parent_printer_(parent_printer)\r
+               , graph_(diagnostics::create_graph(narrow(print())))\r
                , container_(5)\r
+               , format_desc_(format_desc)\r
        {\r
                graph_->add_guide("tick-time", 0.5);\r
                graph_->set_color("tick-time", diagnostics::color(0.1f, 0.7f, 0.8f));\r
                is_running_ = true;\r
                input_.set_capacity(4);\r
+               for(size_t n = 0; n < buffer_depth(); ++n)\r
+                       input_.push(std::vector<short>(static_cast<size_t>(48000.0f/format_desc_.fps)*2, 0)); \r
+\r
+               sf::SoundStream::Initialize(2, 48000);\r
+               Play();         \r
+               CASPAR_LOG(info) << print() << " Sucessfully initialized.";\r
        }\r
 \r
        ~implementation()\r
@@ -66,18 +74,7 @@ public:
                Stop();\r
                CASPAR_LOG(info) << print() << L" Shutting down.";      \r
        }\r
-\r
-       void initialize(const core::video_format_desc& format_desc, const printer& parent_printer)\r
-       {\r
-               format_desc_ = format_desc;\r
-               parent_printer_ = parent_printer;\r
-               for(size_t n = 0; n < buffer_depth(); ++n)\r
-                       input_.push(std::vector<short>(static_cast<size_t>(48000.0f/format_desc_.fps)*2, 0)); \r
-               sf::SoundStream::Initialize(2, 48000);\r
-               Play();         \r
-               CASPAR_LOG(info) << print() << " Sucessfully initialized.";\r
-       }\r
-\r
+       \r
        void send(const safe_ptr<const core::read_frame>& frame)\r
        {                               \r
                if(!frame->audio_data().empty())\r
@@ -109,11 +106,11 @@ public:
        }\r
 };\r
 \r
+oal_consumer::oal_consumer(){}\r
 oal_consumer::oal_consumer(oal_consumer&& other) : impl_(std::move(other.impl_)){}\r
-oal_consumer::oal_consumer() : impl_(new implementation()){}\r
 void oal_consumer::send(const safe_ptr<const core::read_frame>& frame){impl_->send(frame);}\r
 size_t oal_consumer::buffer_depth() const{return impl_->buffer_depth();}\r
-void oal_consumer::initialize(const core::video_format_desc& format_desc, const printer& parent_printer){impl_->initialize(format_desc, parent_printer);}\r
+void oal_consumer::initialize(const core::video_format_desc& format_desc, const printer& parent_printer){impl_.reset(new implementation(format_desc, parent_printer));}\r
 std::wstring oal_consumer::print() const { return impl_->print(); }\r
 \r
 safe_ptr<core::frame_consumer> create_oal_consumer(const std::vector<std::wstring>& params)\r
index de26bbdebf25ba233eb9a7cce295e7f5ec8a58b3..ddfd6b2e7e4f990eef20b80c7fbe96ddf7295411 100644 (file)
@@ -300,7 +300,11 @@ ogl_consumer::ogl_consumer(ogl_consumer&& other) : impl_(std::move(other.impl_))
 ogl_consumer::ogl_consumer(unsigned int screen_index, stretch stretch, bool windowed) : impl_(new implementation(screen_index, stretch, windowed)){}\r
 void ogl_consumer::send(const safe_ptr<const core::read_frame>& frame){impl_->send(frame);}\r
 size_t ogl_consumer::buffer_depth() const{return impl_->buffer_depth();}\r
-void ogl_consumer::initialize(const core::video_format_desc& format_desc, const printer& parent_printer){impl_->initialize(format_desc, parent_printer);}\r
+void ogl_consumer::initialize(const core::video_format_desc& format_desc, const printer& parent_printer)\r
+{\r
+       impl_.reset(new implementation(impl_->screen_index_, impl_->stretch_, impl_->windowed_));\r
+       impl_->initialize(format_desc, parent_printer);\r
+}\r
 std::wstring ogl_consumer::print() const {return impl_->print();}\r
 \r
 safe_ptr<core::frame_consumer> create_ogl_consumer(const std::vector<std::wstring>& params)\r
index 205558a1e3ebf3999289b951e6496c29fa8665db..3504bcbc55a64473f9f913bff0eb4d456a9fae0d 100644 (file)
     <channel>\r
       <videomode>PAL</videomode>\r
       <consumers>\r
-        <!--<ogl>\r
-          <device>0</device>\r
-          <stretch>uniform</stretch>\r
-          <windowed>true</windowed>\r
-        </ogl>\r
-        <audio/>\r
-        <decklink>\r
+        <!--<decklink>\r
           <device>1</device>\r
           <embedded-audio>true</embedded-audio>\r
           <internal-key>false</internal-key>\r
           <stretch>uniform</stretch>\r
           <windowed>true</windowed>\r
         </ogl>\r
-        <bluefish>\r
+        <audio/>\r
+        <!--<bluefish>\r
           <device>1</device>\r
           <embedded-audio>false</embedded-audio>\r
-        </bluefish>\r
-      </consumers>\r
-    </channel>\r
-    <channel>\r
-      <videomode>PAL</videomode>\r
-      <consumers>\r
-        <ogl>\r
-          <device>0</device>\r
-          <stretch>uniform</stretch>\r
-          <windowed>true</windowed>\r
-        </ogl>\r
-        <audio/>\r
+        </bluefish>-->\r
       </consumers>\r
     </channel>\r
 </channels>\r