From: Helge Norberg Date: Mon, 12 Oct 2015 14:59:16 +0000 (+0200) Subject: * Return error code when SEEK is out of range for ffmpeg producer. X-Git-Tag: 2.1.0_Beta1~266 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=d0dc5486e200387cb058a0004d38d86e663aafd4;p=casparcg * Return error code when SEEK is out of range for ffmpeg producer. --- diff --git a/common/except.h b/common/except.h index b06b1cacf..c4fe6a1a9 100644 --- a/common/except.h +++ b/common/except.h @@ -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())) } diff --git a/core/producer/frame_producer.cpp b/core/producer/frame_producer.cpp index 7312937f3..16528bb4c 100644 --- a/core/producer/frame_producer.cpp +++ b/core/producer/frame_producer.cpp @@ -316,6 +316,10 @@ spl::shared_ptr do_create_producer(const frame_producer_de { producer = factory(dependencies, params); } + catch (user_error&) + { + throw; + } catch(...) { if(throw_on_fail) diff --git a/modules/ffmpeg/producer/ffmpeg_producer.cpp b/modules/ffmpeg/producer/ffmpeg_producer.cpp index 89b213cdd..9e65e7562 100644 --- a/modules/ffmpeg/producer/ffmpeg_producer.cpp +++ b/modules/ffmpeg/producer/ffmpeg_producer.cpp @@ -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(); diff --git a/protocol/amcp/AMCPCommandQueue.cpp b/protocol/amcp/AMCPCommandQueue.cpp index e372047e1..24a3f8af0 100644 --- a/protocol/amcp/AMCPCommandQueue.cpp +++ b/protocol/amcp/AMCPCommandQueue.cpp @@ -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(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.";