void OSGConverter::reportFailure(const SendRequest& req) { Event event(req); if (event.name.length() == 0) event.name = "convert"; event.name += ".failure"; returnEvent(event); }
void OSGConverter::reportSuccess(const SendRequest& req, const Data& content) { Event event(req); std::string format; Event::getParam(req.params, "format", format); event.data.compound["mimetype"] = Data(URL::getMimeType(format), Data::VERBATIM); if (event.name.length() == 0) event.name = "convert"; event.name += ".success"; if (content) event.data.compound["content"] = content; returnEvent(event); }
void FFMPEGInvoker::finish(EncodingContext* ctx, const SendRequest& req) { av_write_trailer(ctx->formatCtx); /* Close each codec. */ if (ctx->videoStream) closeVideo(ctx, ctx->formatCtx, ctx->videoStream); if (!(ctx->formatCtx->oformat->flags & AVFMT_NOFILE)) /* Close the output file. */ avio_close(ctx->formatCtx->pb); /* free the stream */ avformat_free_context(ctx->formatCtx); // read file std::ifstream movieFile(ctx->filename.c_str()); movieFile.seekg(0, std::ios::end); size_t length = movieFile.tellg(); movieFile.seekg(0, std::ios::beg); char* movieBuffer = (char*)malloc(length); movieFile.read(movieBuffer, length); // move to desktop for checking // int err = rename(ctx->filename.c_str(), "/Users/sradomski/Desktop/foo.mpg"); // if (err) { // printf("%s", strerror(errno)); // } std::string context; Event::getParam(req.params, "context", context); Event event; event.name = "render.done"; event.data.compound["context"] = Data(context, Data::INTERPRETED); event.data.compound["movie"] = Data(movieBuffer, length, "video/mpeg", true); event.data.compound["filename"] = Data(std::string("movie.") + ctx->extension, Data::VERBATIM); returnEvent(event); }
void DirMonInvoker::handleFileAction(FW::WatchID watchid, const FW::String& dir, const FW::String& filename, FW::Action action) { if (!boost::algorithm::ends_with(filename, _suffix)) return; struct stat fileStat; if (stat(filename.c_str(), &fileStat) != 0) { LOG(ERROR) << "Error with stat on directory entry " << filename << ": " << strerror(errno); return; } Event event; event.invokeid = _invokeId; switch (action) { case FW::Actions::Existing: event.name = "file.existing"; break; case FW::Actions::Add: event.name = "file.added"; break; case FW::Actions::Delete: event.name = "file.deleted"; break; case FW::Actions::Modified: event.name = "file.modified"; break; default: break; } event.compound["file"].compound["name"] = Data(filename, Data::VERBATIM); event.compound["file"].compound["dir"] = Data(dir, Data::VERBATIM); event.compound["file"].compound["mtime"] = toStr(fileStat.st_mtime); event.compound["file"].compound["ctime"] = toStr(fileStat.st_ctime); event.compound["file"].compound["atime"] = toStr(fileStat.st_atime); event.compound["file"].compound["size"] = toStr(fileStat.st_size); returnEvent(event); }
void EventHandlerImpl::returnErrorCommunication(const std::string& cause) { ERROR_COMMUNICATION(exc, cause); returnEvent(exc); }
void EventHandlerImpl::returnErrorExecution(const std::string& cause) { ERROR_EXECUTION(exc, cause); returnEvent(exc); }