]> git.sesse.net Git - casparcg/commitdiff
* Return error code when SEEK is out of range for ffmpeg producer.
authorHelge Norberg <helge.norberg@svt.se>
Mon, 12 Oct 2015 14:59:16 +0000 (16:59 +0200)
committerHelge Norberg <helge.norberg@svt.se>
Mon, 12 Oct 2015 14:59:16 +0000 (16:59 +0200)
common/except.h
core/producer/frame_producer.cpp
modules/ffmpeg/producer/ffmpeg_producer.cpp
protocol/amcp/AMCPCommandQueue.cpp

index b06b1cacf54a31856867cee90dba977e07a4d8c0..c4fe6a1a9ef2998a3c7c1bd137b04a604ca101a1 100644 (file)
@@ -86,6 +86,8 @@ struct timed_out                              : virtual caspar_exception {};
 struct not_supported                   : virtual caspar_exception {};
 struct not_implemented                 : virtual caspar_exception {};
 
+struct user_error                              : virtual caspar_exception {};
+
 #define CASPAR_THROW_EXCEPTION(e) BOOST_THROW_EXCEPTION(e << call_stack_info(caspar::get_call_stack()))
 
 }
index 7312937f3b15088882304253abf85041e6b23505..16528bb4cd8ee7c830974a39dc9b94500947c7c1 100644 (file)
@@ -316,6 +316,10 @@ spl::shared_ptr<core::frame_producer> do_create_producer(const frame_producer_de
                        {
                                producer = factory(dependencies, params);
                        }
+                       catch (user_error&)
+                       {
+                               throw;
+                       }
                        catch(...)
                        {
                                if(throw_on_fail)
index 89b213cdddf70a417b37ee368b2074d553c8d086..9e65e7562660cfb2851b66e5e11ec49448f88173 100644 (file)
@@ -63,6 +63,8 @@
 
 namespace caspar { namespace ffmpeg {
 
+struct seek_out_of_range : virtual user_error {};
+
 std::wstring get_relative_or_original(
                const std::wstring& filename,
                const boost::filesystem::path& relative_to)
@@ -175,6 +177,9 @@ public:
                        CASPAR_LOG(warning) << print() << " Failed to open audio-stream. Running without audio.";               
                }
 
+               if (start_ > file_nb_frames())
+                       CASPAR_THROW_EXCEPTION(seek_out_of_range() << msg_info("SEEK out of range"));
+
                muxer_.reset(new frame_muxer(fps_, frame_factory, format_desc_, channel_layout, filter));
                
                decode_next_frame();
@@ -378,7 +383,10 @@ public:
 
        void seek(uint32_t target)
        {               
-               seek_target_ = std::min(target, file_nb_frames());
+               if (target > file_nb_frames())
+                       CASPAR_THROW_EXCEPTION(seek_out_of_range() << msg_info("SEEK out of range"));
+
+               seek_target_ = target;
 
                input_.seek(*seek_target_);
                muxer_->clear();
index e372047e10450914061af8d64d669d7c1365cef3..24a3f8af0a3917e312fad8703f201e64519fb43a 100644 (file)
@@ -111,6 +111,11 @@ void AMCPCommandQueue::AddCommand(AMCPCommand::ptr_type pCurrentCommand)
                                CASPAR_LOG(error) << L"File not found. No match found for parameters. Check syntax.";
                                pCurrentCommand->SetReplyString(L"404 " + pCurrentCommand->print() + L" FAILED\r\n");
                        }
+                       catch (const user_error& e)
+                       {
+                               CASPAR_LOG(error) << *boost::get_error_info<msg_info_t>(e) << ". Check syntax.";
+                               pCurrentCommand->SetReplyString(L"403 " + pCurrentCommand->print() + L" FAILED\r\n");
+                       }
                        catch (std::out_of_range&)
                        {
                                CASPAR_LOG(error) << L"Missing parameter. Check syntax.";