Commit 215ceab7 authored by François Grisez's avatar François Grisez
Browse files

Use H26xToolFactory on encoder/decoder construction.

parent f94c3a95
......@@ -329,7 +329,7 @@ NalUnpacker *H264ToolFactory::createNalUnpacker() const {
return new H264NalUnpacker();
}
H26xParameterSetsInserter *H264ToolFactory::createParamterSetsInserter() const {
H26xParameterSetsInserter *H264ToolFactory::createParameterSetsInserter() const {
return new H264ParameterSetsInserter();
}
......
......@@ -196,7 +196,7 @@ public:
H26xNaluHeader *createNaluHeader() const override;
NalPacker *createNalPacker(MSFactory *factory) const override;
NalUnpacker *createNalUnpacker() const override;
H26xParameterSetsInserter *createParamterSetsInserter() const override;
H26xParameterSetsInserter *createParameterSetsInserter() const override;
H26xParameterSetsStore *createParameterSetsStore() const override;
};
......
......@@ -164,7 +164,7 @@ NalUnpacker *H265ToolFactory::createNalUnpacker() const {
return new H265NalUnpacker();
}
H26xParameterSetsInserter *H265ToolFactory::createParamterSetsInserter() const {
H26xParameterSetsInserter *H265ToolFactory::createParameterSetsInserter() const {
return new H265ParameterSetsInserter();
}
......
......@@ -125,7 +125,7 @@ public:
H26xNaluHeader *createNaluHeader() const override;
NalPacker *createNalPacker(MSFactory *factory) const override;
NalUnpacker *createNalUnpacker() const override;
H26xParameterSetsInserter *createParamterSetsInserter() const override;
H26xParameterSetsInserter *createParameterSetsInserter() const override;
H26xParameterSetsStore *createParameterSetsStore() const override;
};
......
......@@ -183,4 +183,6 @@ const H26xToolFactory &H26xToolFactory::get(const std::string &mime) {
return *instance;
}
std::unordered_map<std::string, std::unique_ptr<H26xToolFactory>> H26xToolFactory::_instances;
} // namespace mediastreamer
......@@ -122,7 +122,7 @@ public:
virtual H26xNaluHeader *createNaluHeader() const = 0;
virtual NalPacker *createNalPacker(MSFactory *factory) const = 0;
virtual NalUnpacker *createNalUnpacker() const = 0;
virtual H26xParameterSetsInserter *createParamterSetsInserter() const = 0;
virtual H26xParameterSetsInserter *createParameterSetsInserter() const = 0;
virtual H26xParameterSetsStore *createParameterSetsStore() const = 0;
private:
......
......@@ -240,8 +240,13 @@ const char *MediaCodecDecoder::toString(State state) {
}
}
MediaCodecDecoderFilterImpl::MediaCodecDecoderFilterImpl(MSFilter *f, const std::string &mimeType, NalUnpacker *unpacker, H26xParameterSetsStore *psStore, H26xNaluHeader *naluHeader):
_vsize({0, 0}),_f(f), _unpacker(unpacker), _psStore(psStore), _naluHeader(naluHeader), _codec(mimeType) {
MediaCodecDecoderFilterImpl::MediaCodecDecoderFilterImpl(MSFilter *f, const std::string &mime):
_vsize({0, 0}),
_f(f),
_unpacker(H26xToolFactory::get(mime).createNalUnpacker()),
_psStore(H26xToolFactory::get(mime).createParameterSetsStore()),
_naluHeader(H26xToolFactory::get(mime).createNaluHeader()),
_codec(mime) {
ms_message("MSMediaCodecH264Dec initialization");
ms_average_fps_init(&_fps, " H264 decoder: FPS: %f");
......
......@@ -81,7 +81,7 @@ private:
class MediaCodecDecoderFilterImpl {
public:
MediaCodecDecoderFilterImpl(MSFilter *f, const std::string &mimeType, NalUnpacker *unpacker, H26xParameterSetsStore *psStore, H26xNaluHeader *naluHeader);
MediaCodecDecoderFilterImpl(MSFilter *f, const std::string &mime);
virtual ~MediaCodecDecoderFilterImpl() = default;
void preprocess();
......
......@@ -37,8 +37,9 @@ using namespace std;
namespace mediastreamer {
MediaCodecEncoder::MediaCodecEncoder(const std::string &mime, H26xParameterSetsInserter *psInserter):
_mime(mime), _psInserter(psInserter) {
MediaCodecEncoder::MediaCodecEncoder(const std::string &mime):
_mime(mime),
_psInserter(H26xToolFactory::get(mime).createParameterSetsInserter()) {
try {
_vsize.width = 0;
......
......@@ -78,7 +78,7 @@ public:
bool fetch(MSQueue *encodedData) override;
protected:
MediaCodecEncoder(const std::string &mime, H26xParameterSetsInserter *psInserter);
MediaCodecEncoder(const std::string &mime);
void createImpl();
void configureImpl();
virtual AMediaFormat *createMediaFormat() const;
......
......@@ -29,7 +29,7 @@ namespace mediastreamer {
class MediaCodecH264DecoderFilterImpl: public MediaCodecDecoderFilterImpl {
public:
MediaCodecH264DecoderFilterImpl(MSFilter *f): MediaCodecDecoderFilterImpl(f, "video/avc", new H264NalUnpacker(), new H264ParameterSetsStore(), new H264NaluHeader()) {}
MediaCodecH264DecoderFilterImpl(MSFilter *f): MediaCodecDecoderFilterImpl(f, "video/avc") {}
~MediaCodecH264DecoderFilterImpl() {
if (_sps) freemsg(_sps);
if (_pps) freemsg(_pps);
......
......@@ -17,8 +17,6 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "h264-nal-packer.h"
#include "h264-utils.h"
#include "media-codec-encoder.h"
#define MS_MEDIACODECH265_CONF(required_bitrate, bitrate_limit, resolution, fps, ncpus) \
......@@ -41,7 +39,7 @@ namespace mediastreamer {
class MediaCodecH264Encoder: public MediaCodecEncoder {
public:
MediaCodecH264Encoder(): MediaCodecEncoder("video/avc", new H264ParameterSetsInserter()) {}
MediaCodecH264Encoder(): MediaCodecEncoder("video/avc") {}
private:
AMediaFormat *createMediaFormat() const override {
......
......@@ -25,7 +25,7 @@ namespace mediastreamer {
class MediaCodecH265DecoderFilterImpl: public MediaCodecDecoderFilterImpl {
public:
MediaCodecH265DecoderFilterImpl(MSFilter *f): MediaCodecDecoderFilterImpl(f, "video/hevc", new H265NalUnpacker(), new H265ParameterSetsStore(), new H265NaluHeader()) {}
MediaCodecH265DecoderFilterImpl(MSFilter *f): MediaCodecDecoderFilterImpl(f, "video/hevc") {}
static void onFilterInit(MSFilter *f) {
f->data = new MediaCodecH265DecoderFilterImpl(f);
......
......@@ -40,7 +40,7 @@ namespace mediastreamer {
class MediaCodecH265Encoder: public MediaCodecEncoder {
public:
MediaCodecH265Encoder(): MediaCodecEncoder("video/hevc", new H265ParameterSetsInserter()) {}
MediaCodecH265Encoder(): MediaCodecEncoder("video/hevc") {}
};
class MediaCodecH265EncoderFilterImpl: public MediaCodecEncoderFilterImpl {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment