]> git.sesse.net Git - casparcg/commitdiff
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches...
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sat, 29 Oct 2011 15:55:43 +0000 (15:55 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sat, 29 Oct 2011 15:55:43 +0000 (15:55 +0000)
modules/ffmpeg/producer/ffmpeg_producer.cpp
modules/ffmpeg/producer/input/input.cpp

index 340f2a4e2ee48dc02a1c1064101bd878c574dc4d..3509c17d9413fb66d44ed9079b2df465e84da2c0 100644 (file)
@@ -64,6 +64,8 @@ struct ffmpeg_producer : public core::frame_producer
        const bool                                                                                                                              loop_;\r
        const size_t                                                                                                                    length_;\r
        \r
+       std::unique_ptr<input>                                                                                                  input_; \r
+\r
        unbounded_buffer<input::target_element_t>                                                               packets_;\r
        std::shared_ptr<unbounded_buffer<frame_muxer2::video_source_element_t>> video_;\r
        std::shared_ptr<unbounded_buffer<frame_muxer2::audio_source_element_t>> audio_;\r
@@ -71,7 +73,6 @@ struct ffmpeg_producer : public core::frame_producer
                \r
        const safe_ptr<diagnostics::graph>                                                                              graph_;\r
                                        \r
-       input                                                                                                                                   input_; \r
        std::unique_ptr<video_decoder>                                                                                  video_decoder_;\r
        std::unique_ptr<audio_decoder>                                                                                  audio_decoder_; \r
        std::unique_ptr<frame_muxer2>                                                                                   muxer_;\r
@@ -84,13 +85,14 @@ public:
                , start_(start)\r
                , loop_(loop)\r
                , length_(length)\r
-               , input_(packets_, graph_, filename_, loop, start, length)\r
                , last_frame_(core::basic_frame::empty())\r
        {               \r
+               input_.reset(new input(packets_, graph_, filename_, loop, start, length));\r
+\r
                try\r
                {\r
                        auto video = std::make_shared<unbounded_buffer<frame_muxer2::video_source_element_t>>();\r
-                       video_decoder_.reset(new video_decoder(packets_, *video, *input_.context()));\r
+                       video_decoder_.reset(new video_decoder(packets_, *video, *input_->context()));\r
                        video_ = video;\r
                }\r
                catch(averror_stream_not_found&)\r
@@ -106,7 +108,7 @@ public:
                try\r
                {\r
                        auto audio = std::make_shared<unbounded_buffer<frame_muxer2::audio_source_element_t>>();\r
-                       audio_decoder_.reset(new audio_decoder(packets_, *audio, *input_.context(), frame_factory->get_video_format_desc()));\r
+                       audio_decoder_.reset(new audio_decoder(packets_, *audio, *input_->context(), frame_factory->get_video_format_desc()));\r
                        audio_ = audio;\r
                }\r
                catch(averror_stream_not_found&)\r
@@ -131,7 +133,7 @@ public:
 \r
        ~ffmpeg_producer()\r
        {\r
-               input_.stop();  \r
+               input_->stop(); \r
        }\r
                                                \r
        virtual safe_ptr<core::basic_frame> receive(int hints)\r
@@ -165,8 +167,8 @@ public:
 \r
                // This function estimates nb_frames until input has read all packets for one loop, at which point the count should be accurate.\r
 \r
-               int64_t nb_frames = input_.nb_frames();\r
-               if(input_.nb_loops() < 1) // input still hasn't counted all frames\r
+               int64_t nb_frames = input_->nb_frames();\r
+               if(input_->nb_loops() < 1) // input still hasn't counted all frames\r
                {\r
                        int64_t video_nb_frames = video_decoder_->nb_frames();\r
                        int64_t audio_nb_frames = audio_decoder_->nb_frames();\r
@@ -186,7 +188,7 @@ public:
 \r
                if(boost::iequals(params.at(0), L"LOOP"))\r
                {\r
-                       input_.loop(boost::lexical_cast<bool>(params.at(1)));\r
+                       input_->loop(boost::lexical_cast<bool>(params.at(1)));\r
                        return true;\r
                }\r
                return false;\r
index f3a31de50dcab67e77527f7f24d43f1d8b617627..a7322d4b2db9468a0a175fde0147d5f8429492ef 100644 (file)
@@ -62,9 +62,7 @@ namespace caspar { namespace ffmpeg {
 static const size_t MAX_PACKETS_SIZE = 16 * 1000000;\r
 static const size_t MAX_PACKETS_COUNT = 50;\r
        \r
-struct input::implementation : public Concurrency::agent\r
-                                                        , public std::enable_shared_from_this<implementation>\r
-                                                        , boost::noncopyable\r
+struct input::implementation : public Concurrency::agent, boost::noncopyable\r
 {\r
        input::target_t&                                                target_;\r
        safe_ptr<diagnostics::graph>                    graph_;\r
@@ -209,8 +207,7 @@ public:
                graph_->update_value("buffer-size", (packets_size_+0.001)/MAX_PACKETS_SIZE);\r
                graph_->update_value("buffer-count", (packets_count_+0.001)/MAX_PACKETS_COUNT);\r
 \r
-               auto self = shared_from_this();\r
-               packet = safe_ptr<AVPacket>(packet.get(), [this, self, packet, size, data](AVPacket*)\r
+               packet = safe_ptr<AVPacket>(packet.get(), [this, packet, size, data](AVPacket*)\r
                {\r
                        packet->size = size;\r
                        packet->data = data;\r