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

Create interfaces for encoding/decoding filter implementations.

parent 52056ab7
/*
* Mediastreamer2 decoding-filter-impl.h
* Copyright (C) 2018 Belledonne Communications SARL
*
* 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 2
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#pragma once
#include "mediastreamer2/msvideo.h"
#include "filter-impl-base.h"
namespace mediastreamer {
class DecodingFilterImpl: public FilterImplBase {
public:
DecodingFilterImpl(MSFilter *f): FilterImplBase(f) {}
virtual MSVideoSize getVideoSize() const = 0;
virtual float getFps() const = 0;
virtual const MSFmtDescriptor *getOutFmt() const = 0;
virtual void addFmtp(const char *fmtp) = 0;
virtual void enableAvpf(bool enable) = 0;
virtual void enableFreezeOnError(bool enable) = 0;
virtual void resetFirstImage() = 0;
};
} // namespace mediastreamer
/*
* Mediastreamer2 encoding-filter-impl.h
* Copyright (C) 2018 Belledonne Communications SARL
*
* 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 2
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#pragma once
#include "mediastreamer2/msvideo.h"
#include "filter-impl-base.h"
namespace mediastreamer {
class EncodingFilterImpl: public FilterImplBase {
public:
EncodingFilterImpl(MSFilter *f): FilterImplBase(f) {}
virtual const MSVideoConfiguration *getVideoConfiguratons() const = 0;
virtual void setVideoConfigurations(const MSVideoConfiguration *vconfs) = 0;
virtual int setVideoConfiguration(const MSVideoConfiguration *vconf) = 0;
virtual int getBitrate() const = 0;
virtual void setBitrate(int br) = 0;
virtual float getFps() const = 0;
virtual void setFps(float fps) = 0;
virtual MSVideoSize getVideoSize() const = 0;
virtual void setVideoSize(const MSVideoSize &vsize) = 0;
virtual void enableAvpf(bool enable) = 0;
virtual void notifyPli() = 0;
virtual void notifyFir() = 0;
};
} // namespace mediastreamer
......@@ -248,7 +248,7 @@ bool MediaCodecDecoder::isKeyFrame(const MSQueue *frame) const {
}
MediaCodecDecoderFilterImpl::MediaCodecDecoderFilterImpl(MSFilter *f, const std::string &mime):
FilterImplBase(f),
DecodingFilterImpl(f),
_vsize({0, 0}),
_unpacker(H26xToolFactory::get(mime).createNalUnpacker()) {
......
......@@ -30,7 +30,7 @@
#include "mediastreamer2/msvideo.h"
#include "filter-impl-base.h"
#include "decoding-filter-impl.h"
#include "nal-unpacker.h"
namespace mediastreamer {
......@@ -77,7 +77,7 @@ protected:
static const unsigned int _timeoutUs = 0;
};
class MediaCodecDecoderFilterImpl: public FilterImplBase {
class MediaCodecDecoderFilterImpl: public DecodingFilterImpl {
public:
MediaCodecDecoderFilterImpl(MSFilter *f, const std::string &mime);
......@@ -85,14 +85,14 @@ public:
void process() override;
void postprocess() override;
MSVideoSize getVideoSize() const;
float getFps() const;
const MSFmtDescriptor *getOutFmt() const;
void addFmtp(const char *fmtp) {}
MSVideoSize getVideoSize() const override;
float getFps() const override;
const MSFmtDescriptor *getOutFmt() const override;
void addFmtp(const char *fmtp) override {}
void enableAvpf(bool enable);
void enableFreezeOnError(bool enable);
void resetFirstImage();
void enableAvpf(bool enable) override;
void enableFreezeOnError(bool enable) override;
void resetFirstImage() override;
protected:
MSVideoSize _vsize;
......
......@@ -277,7 +277,7 @@ std::ostringstream MediaCodecEncoder::getMediaForamtAsString() const {
// Public methods
MediaCodecEncoderFilterImpl::MediaCodecEncoderFilterImpl(MSFilter *f, MediaCodecEncoder *encoder, NalPacker *packer, const MSVideoConfiguration *defaultVConfList):
FilterImplBase(f), _encoder(encoder), _packer(packer), _defaultVConfList(defaultVConfList) {
EncodingFilterImpl(f), _encoder(encoder), _packer(packer), _defaultVConfList(defaultVConfList) {
setVideoConfigurations(nullptr);
_vconf = ms_video_find_best_configuration_for_size(_vconfList, MS_VIDEO_SIZE_CIF, ms_factory_get_cpu_count(f->factory));
......
......@@ -29,7 +29,7 @@
#include "mediastreamer2/msfilter.h"
#include "mediastreamer2/msvideo.h"
#include "filter-impl-base.h"
#include "encoding-filter-impl.h"
#include "h26x-utils.h"
#include "nal-packer.h"
......@@ -103,28 +103,29 @@ protected:
static const int32_t _priority = 0; // real-time priority
};
class MediaCodecEncoderFilterImpl: public FilterImplBase {
class MediaCodecEncoderFilterImpl: public EncodingFilterImpl {
public:
void preprocess() override;
void process() override;
void postprocess() override;
int getBitrate() const;
void setBitrate(int br);
const MSVideoConfiguration *getVideoConfiguratons() const override;
void setVideoConfigurations(const MSVideoConfiguration *vconfs) override;
int setVideoConfiguration(const MSVideoConfiguration *vconf) override;
const MSVideoConfiguration *getVideoConfiguratons() const;
void setVideoConfigurations(const MSVideoConfiguration *vconfs);
int setVideoConfiguration(const MSVideoConfiguration *vconf);
int getBitrate() const override;
void setBitrate(int br) override;
float getFps() const;
void setFps(float fps);
float getFps() const override;
void setFps(float fps) override;
MSVideoSize getVideoSize() const;
void setVideoSize(const MSVideoSize &vsize);
MSVideoSize getVideoSize() const override;
void setVideoSize(const MSVideoSize &vsize) override;
void enableAvpf(bool enable);
void notifyPli();
void notifyFir();
void enableAvpf(bool enable) override;
void notifyPli() override;
void notifyFir() override;
protected:
MediaCodecEncoderFilterImpl(MSFilter *f, MediaCodecEncoder *encoder, NalPacker *packer, const MSVideoConfiguration *defaultVConfList);
......
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