diff --git a/core/Attribute.h b/core/Attribute.h new file mode 100644 index 00000000..4f20c1ae --- /dev/null +++ b/core/Attribute.h @@ -0,0 +1,66 @@ +/* + * + * Tiny Multimedia Framework + * Copyright (C) 2014 Arash Shafiei + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#ifndef ATTRIBUTE_H_ +#define ATTRIBUTE_H_ + +#include + +using namespace std; + +class Attribute { +private: + map props; /**< The map containing the message (key, value). */ + +public: + /*! + * Get the message value by passing the key + * + * \param key the key to retrieve the message value + */ + string getProp(const string & key) { + auto k = props.find(key); + + if (k == props.end()) + return ""; + + return props[key]; + } + + /*! + * Set the string message by key and value + * + * \param key the key of the message + * \param val the string value of the message + * + */ + template + void setProp(const string & key, const T& val) { + string valstr = to_string(val); + props.insert(std::make_pair(key, valstr)); + } + + void setProp(const string & key, const string& val) { + props.insert(std::make_pair(key, val)); + } + +}; + +#endif /* ATTRIBUTE_H_ */ diff --git a/core/Filter.cpp b/core/Filter.cpp index 8f035ad3..95a008ab 100644 --- a/core/Filter.cpp +++ b/core/Filter.cpp @@ -23,16 +23,18 @@ #include -Filter::Filter(const string &name) { +Filter::Filter(const string &name) : realtime(false) { this->name = name; - linked = 0; - inputFed = 0; - inMsg = 0; + inMsg = nullptr; outMsg = new Message(); } +void Filter::setRealTime(bool rt) { + realtime = rt; +} + void Filter::log(std::string msg) { io_lock->lock(); std::cout << name << ": " << msg << std::endl; @@ -63,15 +65,21 @@ void Filter::connectFilter(Filter * f) { } } -void Filter::setProp(const string & key, const string & val) { - props.emplace(this->name + "::" + key, val); -} +//void Filter::setProp(const string & key, const string & val) { +// props.emplace(this->name + "::" + key, val); +//} -string Filter::getProp(const string & key) { - return props[this->name + "::" + key]; +//string Filter::getProp(const string & key) { +// return props[this->name + "::" + key]; +//} + +FilterStatus Filter::initFilter() { + FilterStatus status = FILTER_SUCCESS; + status = init(); + return status; } -FilterStatus Filter::run() { +FilterStatus Filter::runFilter() { FilterStatus status = FILTER_SUCCESS; while(status != FILTER_FINISHED) { @@ -81,7 +89,7 @@ FilterStatus Filter::run() { //} //inputFed = 0; - status = process(); + status = realtime? runRT() : run(); } return status; } @@ -109,17 +117,14 @@ FilterStatus Filter::run() { * } */ -void Filter::increaseLinked() { - linked++; -} -int Filter::inputPortNum() { - return inputPorts.size(); -} +//int Filter::inputPortNum() { +// return inputPorts.size(); +//} -int Filter::outputPortNum() { - return outputPorts.size(); -} +//int Filter::outputPortNum() { +// return outputPorts.size(); +//} /* void Filter::processNextFilters(Port * p) { * vector * nextFilters = getNextFilters(p); @@ -169,17 +174,18 @@ int Filter::outputPortNum() { * * } */ - -void Filter::start() { - t = new thread(&Filter::run, this); +void Filter::startInit() { + t = new thread(&Filter::initFilter, this); } -void Filter::startRT() { - t = new thread(&Filter::run, this); +void Filter::startRun() { + t = new thread(&Filter::runFilter, this); } void Filter::wait() { t->join(); + + delete t; } void Filter::setIOLock(mutex * mux) { diff --git a/core/Filter.h b/core/Filter.h index d825e680..a5a8345d 100644 --- a/core/Filter.h +++ b/core/Filter.h @@ -21,6 +21,7 @@ #ifndef FITLER_H_ #define FITLER_H_ +#include "core/Attribute.h" #include "core/Message.h" #include "core/Port.h" #include @@ -41,7 +42,6 @@ enum FilterStatus { FILTER_SUCCESS, /**< Filter processed successfully. */ FILTER_ERROR, /**< An error occurred while processing. */ FILTER_FINISHED, /**< Filter is done generating more data. Used in data sources. */ - FILTER_WAIT_FOR_INPUT /**< Filter is waiting for input. */ }; /*! @@ -53,13 +53,14 @@ enum FilterStatus { class Filter { private: + + thread * t; mutex * io_lock; + string name; /**< The name f the filter */ - int linked; /**< The number of filters which are connected to this filter */ - int inputFed; /**< The number of data which are already fed to the filter */ - map props; /**< A map containing the message keys and values transfered to filter from a pipeline */ - thread * t; - //map*> nextFilters; /**< A map containing the next filters based on one port. */ + Attribute attr; /**< A map containing the message keys and values transfered to filter from a pipeline */ + + bool realtime; protected: Message * inMsg; /**< Input message of the filter */ @@ -82,25 +83,19 @@ class Filter { * Virtual function, to be implemented in the subclass filters. * Read data from input filter, process the data, and write the result to the output port. */ - virtual FilterStatus process() = 0; - virtual FilterStatus processRT() { - return process(); + virtual FilterStatus init() { + return FILTER_SUCCESS; + } + virtual FilterStatus run() = 0; + virtual FilterStatus runRT() { + return run(); } - //void initNextFilters(Port *p, Message * msg); - //void addNextFilter(Port * p, Filter *f); +public: - //vector * getNextFilters(Port *); -public: - /*! - * Perform initialization of the filter. - * To be overridden in subclasses to allow initialization of specific filter values. - */ - virtual FilterStatus init() { - return FILTER_SUCCESS; - } + void setRealTime(bool rt); /*! * Set a property of the filter. @@ -110,15 +105,20 @@ class Filter { * \param val * The property value. */ - void setProp(const string & key, const string & val); - + template + void setProp(const string & key, const T& val) { + attr.setProp(key, val); + } /*! * Get the value of a filter property. * * \param key * The property name. */ - string getProp(const string & key); + + string&& getProp(const string & key) { + return move(attr.getProp(key)); + } /*! * Connect this filter to another filter in the pipeline. @@ -129,52 +129,39 @@ class Filter { */ void connectFilter(Filter * f); - /*! - * Execute the processing of this filter. - * The filters are connected by a link list and each filter calls executeFilter of the next filter. - * - * \return The new status of the filter. - */ - FilterStatus run(); - /*! * Execute the init of this filter. * The filters are connected by a link list and each filter calls initFilter of the next filter. * * \return The new status of the filter. */ - //FilterStatus initFilter(Message * msg); + FilterStatus initFilter(); /*! - * Increase the number of the linked filters. + * Execute the processing of this filter. + * The filters are connected by a link list and each filter calls executeFilter of the next filter. + * + * \return The new status of the filter. */ - void increaseLinked(); + FilterStatus runFilter(); /*! * Get the number of input ports. */ - int inputPortNum(); + //int inputPortNum(); /*! * Get the number of output port. */ int outputPortNum(); - void start(); + void startInit(); - void startRT(); + void startRun(); void wait(); - + void setIOLock(mutex * mux); - /*! - * - * TODO - * Process all filters which are connected to a port - * - * \param p The output port - */ - //void processNextFilters(Port * p); /*! * Destructor of the filter. diff --git a/core/MediaBuffer.h b/core/MediaBuffer.h index b432b9ec..23627ebc 100644 --- a/core/MediaBuffer.h +++ b/core/MediaBuffer.h @@ -35,7 +35,7 @@ const int TMF_BUFFER_SIZE = 4; template class MediaBuffer { protected: - MediaSample * samples; /**< The array containing the samples */ + MediaSample * samples[TMF_BUFFER_SIZE]; /**< The array containing the samples */ int size; /**< The size of the buffer */ public: @@ -47,13 +47,14 @@ class MediaBuffer { */ MediaBuffer(int s): size(s) { - samples = new MediaSample[TMF_BUFFER_SIZE](); - + for (int i=0; i(); + } } void addConsumer() { for (int i=0; iaddConsumer(); } } @@ -70,14 +71,16 @@ class MediaBuffer { * \param idx the number of the element * \return the element number idx */ - MediaSample& at(int idx) const { return samples[idx]; } + MediaSample* at(int idx) const { return samples[idx]; } /*! * Buffer destructor * */ ~MediaBuffer() { - delete samples; + for (int i=0; i - #include "core/SampleSynchronizer.h" - #include -#ifdef __cplusplus -extern "C" { -#endif -#include -#include -#ifdef __cplusplus -} -#endif - +enum class SampleStatus { + OK, + ERROR, + EOS +}; template class MediaSample : public SampleSynchronizer { - + private: int number; T * data; + SampleStatus status; public: - MediaSample(): number(0) { data = new T(); } + MediaSample(): number(0), status(SampleStatus::OK) { data = new T(); } T * get() { return data; } - + + void setStatus(SampleStatus st) {status = st;} + SampleStatus getStatus() {return status;} + ~MediaSample() { delete data; } diff --git a/core/Pipeline.cpp b/core/Pipeline.cpp index d059423b..55c22484 100644 --- a/core/Pipeline.cpp +++ b/core/Pipeline.cpp @@ -20,17 +20,15 @@ #include "Pipeline.h" -Pipeline::Pipeline(const string& name): name(name), start(0), status(PIPELINE_STOPPED), realtime(false) { +Pipeline::Pipeline(const string& name): name(name), status(PIPELINE_STOPPED) { } -Pipeline::~Pipeline() { - - for (auto f : filters) - delete f; - -} -void Pipeline::setRealTime(bool rt) { realtime = rt; } +void Pipeline::setRealTime(bool rt) { + for (auto f : filters) { + f->setRealTime(rt); + } +} void Pipeline::connectFilters(Filter * inf, Filter * outf) { @@ -40,55 +38,38 @@ void Pipeline::connectFilters(Filter * inf, Filter * outf) { filters.insert(inf); filters.insert(outf); - if (this->start == 0 && inf->inputPortNum() == 0) - this->start = inf; - - if (this->start == 0 && outf->inputPortNum() == 0) - this->start = outf; - inf->connectFilter(outf); } -//void Pipeline::setStarter(Filter *starter) { -// this->start = starter; -//} - - PipelineStatus Pipeline::init() { - FilterStatus ret; - if (start == NULL) { - cerr << "Pipeline does not have enough filters to run.\n"; - return PIPELINE_STOPPED; + for (auto f: filters) { + + f->startInit(); + /*if (ret == FILTER_ERROR) { + cerr << "Pipeline cannot initialize a filter.\n"; + return PIPELINE_STOPPED; + }*/ } - ret = start->init(); - - if (ret == FILTER_ERROR) { - cerr << "Pipeline cannot initialize a filter.\n"; - return PIPELINE_STOPPED; + for (auto f : filters) { + f->wait(); } - /*for (set::iterator it = filters.begin(); it != filters.end(); ++it) { - * - * ret = (*it)->initFilter(0); - * - * if (ret == FILTER_ERROR) { - * cerr << "Pipeline cannot initialize a filter.\n"; - * return PIPELINE_STOPPED; -} -} -*/ + return PIPELINE_RUNNING; } PipelineStatus Pipeline::run() { for (auto f : filters) { - - realtime? f->startRT() : f->start(); + f->startRun(); } - + + for (auto f : filters) { + f->wait(); + } + /* * FilterStatus status; * while(1) { @@ -108,16 +89,13 @@ PipelineStatus Pipeline::run() { } */ - return PIPELINE_STATE_UNKNOWN; + return PIPELINE_FINISHED; } -void Pipeline::wait() { - - for (auto f : filters) { - - f->wait(); - } +Pipeline::~Pipeline() { + for (auto f : filters) + delete f; } diff --git a/core/Pipeline.h b/core/Pipeline.h index 4099b0ab..e0de364c 100644 --- a/core/Pipeline.h +++ b/core/Pipeline.h @@ -48,8 +48,6 @@ class Pipeline { string name; /**< The name of the pipeline. */ PipelineStatus status; /**< The current status of the pipeline. */ set filters; /**< The set of all filters in the pipeline. */ - Filter* start; /**< The initial element of the pipeline. Must be a data source (0 inputs). */ - bool realtime; public: /*! * Pipeline constructor @@ -82,8 +80,6 @@ class Pipeline { * \return the current pipeline status. */ PipelineStatus run(); - - void wait(); /*! * Pipeline destructor diff --git a/core/Port.h b/core/Port.h index 47f3c582..abfd77ef 100644 --- a/core/Port.h +++ b/core/Port.h @@ -46,7 +46,7 @@ class Port { protected: - + PortCaps portCaps; //MediaBuffer * buf; //DataType type; @@ -67,7 +67,7 @@ class Port { * \param owner The owner of the filter */ Port(string name) : - name(name), linked(0) { + name(name), linked(0) { } @@ -102,7 +102,6 @@ class Port { linked++; } - virtual void connectPort(Port* n) {} /*! @@ -147,12 +146,12 @@ class Port { template class InputPort: public Port { - + private: + MediaBuffer * buf; int index; - public: /*! @@ -173,19 +172,25 @@ class InputPort: public Port { } void lock() { - buf->at(index).consumerLock(); + buf->at(index)->consumerLock(); } - + void unlock() { - buf->at(index).consumerUnlock(); + buf->at(index)->consumerUnlock(); index = (index+1) % TMF_BUFFER_SIZE; } T * get() { - return buf->at(index).get(); + return buf->at(index)->get(); } + void setStatus(SampleStatus st) { + buf->at(index)->setStatus(st); + } + SampleStatus getStatus() { + return buf->at(index)->getStatus(); + } /*! * InputPort destructor * @@ -228,23 +233,30 @@ class OutputPort: public Port { } void lock() { - buf->at(index).producerLock(); + buf->at(index)->producerLock(); } bool lockRT() { - return buf->at(index).producerRTLock(); + return buf->at(index)->producerRTLock(); } void unlock() { - buf->at(index).producerUnlock(); + buf->at(index)->producerUnlock(); index = (index+1) % TMF_BUFFER_SIZE; } T * get() { - return buf->at(index).get(); + return buf->at(index)->get(); } + void setStatus(SampleStatus st) { + buf->at(index)->setStatus(st); + } + SampleStatus getStatus() { + return buf->at(index)->getStatus(); + } + /*! * Add next port to this port * diff --git a/examples/example0.cpp b/examples/example0.cpp index a17a8e89..7ed3584d 100644 --- a/examples/example0.cpp +++ b/examples/example0.cpp @@ -30,6 +30,8 @@ int main(int argc, char** argv) { Filter* producer = tmf.createFilter(STRINGPRODUCER_FILTER, "producer"); Filter* consumer = tmf.createFilter(STRINGCONSUMER_FILTER, "consumer"); + + producer->setProp("limit", 10); pipe->connectFilters(producer, consumer); @@ -37,8 +39,6 @@ int main(int argc, char** argv) { pipe->run(); - pipe->wait(); - tmf.destroyPipeline(pipe); return 0; diff --git a/examples/example1.cpp b/examples/example1.cpp index 27a497d6..7c3ae2ce 100644 --- a/examples/example1.cpp +++ b/examples/example1.cpp @@ -48,8 +48,6 @@ int main(int argc, char** argv) { pipe->run(); - pipe->wait(); - tmf.destroyPipeline(pipe); return 0; diff --git a/examples/example2.cpp b/examples/example2.cpp index 7c0efff5..700139f8 100644 --- a/examples/example2.cpp +++ b/examples/example2.cpp @@ -48,8 +48,6 @@ int main(int argc, char** argv) { pipe->run(); - pipe->wait(); - tmf.destroyPipeline(pipe); return 0; diff --git a/examples/example3.cpp b/examples/example3.cpp index 67c813e7..c528d70c 100644 --- a/examples/example3.cpp +++ b/examples/example3.cpp @@ -56,7 +56,6 @@ int main(int argc, char** argv) { pipe->run(); - pipe->wait(); tmf.destroyPipeline(pipe); return 0; diff --git a/examples/example4.cpp b/examples/example4.cpp index bdce46da..1292698a 100644 --- a/examples/example4.cpp +++ b/examples/example4.cpp @@ -68,7 +68,6 @@ int main(int argc, char** argv) { pipe->run(); - pipe->wait(); tmf.destroyPipeline(pipe); return 0; diff --git a/examples/example5.cpp b/examples/example5.cpp index da74f7a6..e3b3fd7c 100644 --- a/examples/example5.cpp +++ b/examples/example5.cpp @@ -54,14 +54,13 @@ int main(int argc, char** argv) { imageScaler->setProp("width", width); imageScaler->setProp("height", height); - videoEncoder->setProp("bitrate", "1000000"); - videoEncoder->setProp("framerate", "25"); + videoEncoder->setProp("bitrate", 1000000); + videoEncoder->setProp("framerate", 25); videoEncoder->setProp("output_video", outputVideo); pipe->init(); pipe->run(); - pipe->wait(); tmf.destroyPipeline(pipe); return 0; diff --git a/examples/example6.cpp b/examples/example6.cpp index 09972d25..169d8a78 100644 --- a/examples/example6.cpp +++ b/examples/example6.cpp @@ -48,8 +48,6 @@ int main(int argc, char** argv) { pipe->run(); - pipe->wait(); - tmf.destroyPipeline(pipe); return 0; diff --git a/filters/Add2Filter.h b/filters/Add2Filter.h index a1a3ee71..cf189fc1 100644 --- a/filters/Add2Filter.h +++ b/filters/Add2Filter.h @@ -39,7 +39,7 @@ struct Add2Filter: public Filter { outputPorts.push_back(output); } - FilterStatus process() { + FilterStatus run() { input->lock(); diff --git a/filters/AdditionFilter.h b/filters/AdditionFilter.h index 4b47cd06..90213cae 100644 --- a/filters/AdditionFilter.h +++ b/filters/AdditionFilter.h @@ -46,7 +46,7 @@ struct AdditionFilter: public Filter { } - FilterStatus process() { + FilterStatus run() { int * inputData1 = input1->get(); diff --git a/filters/DuplicateFilter.h b/filters/DuplicateFilter.h index 04593def..2d721740 100644 --- a/filters/DuplicateFilter.h +++ b/filters/DuplicateFilter.h @@ -42,7 +42,7 @@ struct DuplicateFilter: public Filter { } - FilterStatus process() { + FilterStatus run() { input->lock(); diff --git a/filters/ImageScalerFilter.h b/filters/ImageScalerFilter.h index b6f300a3..09cb5f16 100644 --- a/filters/ImageScalerFilter.h +++ b/filters/ImageScalerFilter.h @@ -64,16 +64,16 @@ class ImageScalerFilter : public Filter { int srcWidth, srcHeight, srcFormatInt; err = inMsg->getPropInt("width", srcWidth); - if (err == MSG_NOT_FOUND) - return FILTER_WAIT_FOR_INPUT; + //if (err == MSG_NOT_FOUND) + // return FILTER_WAIT_FOR_INPUT; err = inMsg->getPropInt("height", srcHeight); - if (err == MSG_NOT_FOUND) - return FILTER_WAIT_FOR_INPUT; + //if (err == MSG_NOT_FOUND) + // return FILTER_WAIT_FOR_INPUT; err = inMsg->getPropInt("format", srcFormatInt); - if (err == MSG_NOT_FOUND) - return FILTER_WAIT_FOR_INPUT; + //if (err == MSG_NOT_FOUND) + // return FILTER_WAIT_FOR_INPUT; AVPixelFormat srcFormat = static_cast(srcFormatInt); @@ -95,7 +95,7 @@ class ImageScalerFilter : public Filter { } - FilterStatus process() { + FilterStatus run() { FilterStatus status = FILTER_SUCCESS; inputPortFrame->lock(); diff --git a/filters/ImageWriterFilter.h b/filters/ImageWriterFilter.h index 8a91b382..5df76721 100644 --- a/filters/ImageWriterFilter.h +++ b/filters/ImageWriterFilter.h @@ -52,16 +52,16 @@ class ImageWriterFilter: public Filter { err = inMsg->getPropInt("width", srcWidth); - if (err == MSG_NOT_FOUND) - return FILTER_WAIT_FOR_INPUT; + //if (err == MSG_NOT_FOUND) + // return FILTER_WAIT_FOR_INPUT; err = inMsg->getPropInt("height", srcHeight); - if (err == MSG_NOT_FOUND) - return FILTER_WAIT_FOR_INPUT; + //if (err == MSG_NOT_FOUND) + // return FILTER_WAIT_FOR_INPUT; err = inMsg->getPropInt("format", srcFormatInt); - if (err == MSG_NOT_FOUND) - return FILTER_WAIT_FOR_INPUT; + //if (err == MSG_NOT_FOUND) + // return FILTER_WAIT_FOR_INPUT; AVPixelFormat srcFormat = static_cast(srcFormatInt); @@ -71,7 +71,7 @@ class ImageWriterFilter: public Filter { return FILTER_SUCCESS; } - FilterStatus process() { + FilterStatus run() { inputFrame->lock(); RawFrame * pFrame = inputFrame->get(); diff --git a/filters/Multiply2Filter.h b/filters/Multiply2Filter.h index a6d770de..058417f4 100644 --- a/filters/Multiply2Filter.h +++ b/filters/Multiply2Filter.h @@ -40,7 +40,7 @@ class Multiply2Filter: public Filter { } - FilterStatus process() { + FilterStatus run() { input->lock(); diff --git a/filters/ProducerFilter.h b/filters/ProducerFilter.h index 791e736b..5a6aa3f3 100644 --- a/filters/ProducerFilter.h +++ b/filters/ProducerFilter.h @@ -50,7 +50,7 @@ class ProducerFilter: public Filter { } - FilterStatus process() { + FilterStatus run() { static int number = 1; outputInt->lock(); diff --git a/filters/StringConsumerFilter.h b/filters/StringConsumerFilter.h index 4cb68d80..3e37c5a1 100644 --- a/filters/StringConsumerFilter.h +++ b/filters/StringConsumerFilter.h @@ -21,6 +21,7 @@ #ifndef STRINGCONSUMERFILTER_H_ #define STRINGCONSUMERFILTER_H_ +#include "core/Port.h" #include "core/Filter.h" #include #include @@ -37,7 +38,9 @@ struct StringConsumerFilter: public Filter { inputPorts.push_back(input); } - FilterStatus process() { + FilterStatus run() { + + FilterStatus status = FILTER_SUCCESS; input->lock(); @@ -45,10 +48,13 @@ struct StringConsumerFilter: public Filter { log("consuming "+*inputData); sleep(500); + + if (input->getStatus() == SampleStatus::EOS) + status = FILTER_FINISHED; input->unlock(); - return FILTER_SUCCESS; + return status; } ~StringConsumerFilter() { diff --git a/filters/StringProducerFilter.h b/filters/StringProducerFilter.h index eade8414..3c52f895 100644 --- a/filters/StringProducerFilter.h +++ b/filters/StringProducerFilter.h @@ -33,8 +33,10 @@ using namespace std; class StringProducerFilter: public Filter { private: - + int number; + int limit; + OutputPort * outputString; public: @@ -47,7 +49,16 @@ class StringProducerFilter: public Filter { outputPorts.push_back(outputString); } - FilterStatus process() { + FilterStatus init() { + + limit = stoi(getProp("limit")); + + return FILTER_SUCCESS; + } + + FilterStatus run() { + + FilterStatus status = FILTER_SUCCESS; outputString->lock(); @@ -56,12 +67,17 @@ class StringProducerFilter: public Filter { log("producing "+*outStr); sleep(500); + + if(number == limit) { + outputString->setStatus(SampleStatus::EOS); + status = FILTER_FINISHED; + } outputString->unlock(); number++; - return FILTER_SUCCESS; + return status; } ~StringProducerFilter() { diff --git a/filters/VideoDecoderFilter.h b/filters/VideoDecoderFilter.h index 5e78c0b2..8af70b57 100644 --- a/filters/VideoDecoderFilter.h +++ b/filters/VideoDecoderFilter.h @@ -67,7 +67,7 @@ class VideoDecoderFilter: public Filter { return FILTER_SUCCESS; } - FilterStatus process() { + FilterStatus run() { diff --git a/filters/VideoDisplayFilter.cpp b/filters/VideoDisplayFilter.cpp index bf20576a..d8f434c7 100644 --- a/filters/VideoDisplayFilter.cpp +++ b/filters/VideoDisplayFilter.cpp @@ -25,16 +25,16 @@ FilterStatus VideoDisplayFilter::init() { int width, height, pixFmtInt; err = inMsg->getPropInt("width", width); - if (err == MSG_NOT_FOUND) - return FILTER_WAIT_FOR_INPUT; + //if (err == MSG_NOT_FOUND) + // return FILTER_WAIT_FOR_INPUT; err = inMsg->getPropInt("height", height); - if (err == MSG_NOT_FOUND) - return FILTER_WAIT_FOR_INPUT; + //if (err == MSG_NOT_FOUND) + // return FILTER_WAIT_FOR_INPUT; err = inMsg->getPropInt("format", pixFmtInt); - if (err == MSG_NOT_FOUND) - return FILTER_WAIT_FOR_INPUT; + //if (err == MSG_NOT_FOUND) + // return FILTER_WAIT_FOR_INPUT; AVPixelFormat pixFmt = static_cast(pixFmtInt); @@ -42,7 +42,7 @@ FilterStatus VideoDisplayFilter::init() { return FILTER_SUCCESS; } -FilterStatus VideoDisplayFilter::process() { +FilterStatus VideoDisplayFilter::run() { RawFrame * inFrame = (RawFrame *) inputPortRawFrame->get(); diff --git a/filters/VideoDisplayFilter.h b/filters/VideoDisplayFilter.h index 5660a609..da711adb 100644 --- a/filters/VideoDisplayFilter.h +++ b/filters/VideoDisplayFilter.h @@ -22,7 +22,7 @@ class VideoDisplayFilter : public Filter { public: VideoDisplayFilter(string name); FilterStatus init(); - FilterStatus process(); + FilterStatus run(); ~VideoDisplayFilter(); }; diff --git a/filters/VideoEncoderFilter.cpp b/filters/VideoEncoderFilter.cpp index 6ea46704..3eefc36e 100644 --- a/filters/VideoEncoderFilter.cpp +++ b/filters/VideoEncoderFilter.cpp @@ -48,12 +48,12 @@ FilterStatus VideoEncoderFilter::init() { framerate = std::stoi(getProp("framerate")); err = inMsg->getPropInt("width", width); - if (err == MSG_NOT_FOUND) - return FILTER_WAIT_FOR_INPUT; + //if (err == MSG_NOT_FOUND) + // return FILTER_WAIT_FOR_INPUT; err = inMsg->getPropInt("height", height); - if (err == MSG_NOT_FOUND) - return FILTER_WAIT_FOR_INPUT; + //if (err == MSG_NOT_FOUND) + // return FILTER_WAIT_FOR_INPUT; videoEncoder->init(output_video, width, height, bitrate, framerate); @@ -66,7 +66,7 @@ FilterStatus VideoEncoderFilter::init() { return FILTER_SUCCESS; } -FilterStatus VideoEncoderFilter::process() { +FilterStatus VideoEncoderFilter::run() { inputPortRawFrame->lock(); diff --git a/filters/VideoEncoderFilter.h b/filters/VideoEncoderFilter.h index cd04bc6c..8526c71b 100644 --- a/filters/VideoEncoderFilter.h +++ b/filters/VideoEncoderFilter.h @@ -37,7 +37,7 @@ class VideoEncoderFilter : public Filter { public: VideoEncoderFilter(string name); FilterStatus init(); - FilterStatus process(); + FilterStatus run(); ~VideoEncoderFilter(); }; diff --git a/filters/VideoMuxerFilter.cpp b/filters/VideoMuxerFilter.cpp index f02b5220..370600a4 100644 --- a/filters/VideoMuxerFilter.cpp +++ b/filters/VideoMuxerFilter.cpp @@ -38,31 +38,31 @@ FilterStatus VideoMuxerFilter::init() { int width, height, bitrate, framerate; err = inMsg->getPropString("output_video", output_video); - if (err == MSG_NOT_FOUND) - return FILTER_WAIT_FOR_INPUT; + //if (err == MSG_NOT_FOUND) + // return FILTER_WAIT_FOR_INPUT; err = inMsg->getPropInt("width", width); - if (err == MSG_NOT_FOUND) - return FILTER_WAIT_FOR_INPUT; + //if (err == MSG_NOT_FOUND) + // return FILTER_WAIT_FOR_INPUT; err = inMsg->getPropInt("height", height); - if (err == MSG_NOT_FOUND) - return FILTER_WAIT_FOR_INPUT; + //if (err == MSG_NOT_FOUND) + // return FILTER_WAIT_FOR_INPUT; err = inMsg->getPropInt("bitrate", bitrate); - if (err == MSG_NOT_FOUND) - return FILTER_WAIT_FOR_INPUT; + //if (err == MSG_NOT_FOUND) + // return FILTER_WAIT_FOR_INPUT; err = inMsg->getPropInt("framerate", framerate); - if (err == MSG_NOT_FOUND) - return FILTER_WAIT_FOR_INPUT; + //if (err == MSG_NOT_FOUND) + // return FILTER_WAIT_FOR_INPUT; videoMuxer->init(output_video, width, height, bitrate, framerate); return FILTER_SUCCESS; } -FilterStatus VideoMuxerFilter::process() { +FilterStatus VideoMuxerFilter::run() { inputPortEncodedFrame->lock(); diff --git a/filters/VideoMuxerFilter.h b/filters/VideoMuxerFilter.h index ddb58ec7..7207519a 100644 --- a/filters/VideoMuxerFilter.h +++ b/filters/VideoMuxerFilter.h @@ -34,7 +34,7 @@ class VideoMuxerFilter: public Filter { public: VideoMuxerFilter(string name); FilterStatus init(); - FilterStatus process(); + FilterStatus run(); ~VideoMuxerFilter(); }; diff --git a/filters/VideoWriterFilter.cpp b/filters/VideoWriterFilter.cpp index b772477a..bfe075dc 100644 --- a/filters/VideoWriterFilter.cpp +++ b/filters/VideoWriterFilter.cpp @@ -28,12 +28,12 @@ FilterStatus VideoWriterFilter::init() { string output_video = getProp("output_video"); err = inMsg->getPropInt("width", width); - if (err == MSG_NOT_FOUND) - return FILTER_WAIT_FOR_INPUT; + //if (err == MSG_NOT_FOUND) + // return FILTER_WAIT_FOR_INPUT; err = inMsg->getPropInt("height", height); - if (err == MSG_NOT_FOUND) - return FILTER_WAIT_FOR_INPUT; + //if (err == MSG_NOT_FOUND) + // return FILTER_WAIT_FOR_INPUT; //bitrate = 400000; @@ -41,7 +41,7 @@ FilterStatus VideoWriterFilter::init() { return FILTER_SUCCESS; } -FilterStatus VideoWriterFilter::process() { +FilterStatus VideoWriterFilter::run() { inputPortRawFrame->lock(); diff --git a/filters/VideoWriterFilter.h b/filters/VideoWriterFilter.h index dade19b0..f45281cf 100644 --- a/filters/VideoWriterFilter.h +++ b/filters/VideoWriterFilter.h @@ -21,7 +21,7 @@ class VideoWriterFilter : public Filter { public: VideoWriterFilter(string name); FilterStatus init(); - FilterStatus process(); + FilterStatus run(); ~VideoWriterFilter(); };