msopenh264enc.h 2.06 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/*
H.264 encoder/decoder plugin for mediastreamer2 based on the openh264 library.
Copyright (C) 2006-2012 Belledonne Communications, Grenoble

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
17
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18 19 20 21 22
*/


#include "mediastreamer2/msfilter.h"
#include "mediastreamer2/msvideo.h"
Ghislain MARY's avatar
Ghislain MARY committed
23
#include "mediastreamer2/rfc3984.h"
24
#include "mediastreamer2/mscodecutils.h"
25
#include "wels/codec_api.h"
Ghislain MARY's avatar
Ghislain MARY committed
26
#include "msopenh264.h"
27 28 29 30


class MSOpenH264Encoder {
public:
Ghislain MARY's avatar
Ghislain MARY committed
31
	MSOpenH264Encoder(MSFilter *f);
32 33 34
	virtual ~MSOpenH264Encoder();
	void initialize();
	bool isInitialized() const { return mInitialized; }
Ghislain MARY's avatar
Ghislain MARY committed
35
	void feed();
36 37 38 39
	void uninitialize();
	void addFmtp(const char *fmtp);
	const MSVideoConfiguration *getConfigurationList() const { return mVConfList; }
	void setConfiguration(MSVideoConfiguration conf);
40
	MSVideoConfiguration getConfiguration() { return mVConf; }
41
	void requestVFU();
42 43 44
	void enableAVPF(bool enable) { mAVPFEnabled = enable; }
	void notifyPLI();
	void notifyFIR(uint8_t seqnr);
45 46

private:
47
	void generateKeyframe();
Ghislain MARY's avatar
Ghislain MARY committed
48 49 50 51 52 53 54
	void fillNalusQueue(SFrameBSInfo& sFbi, MSQueue* nalus);
	void calcBitrates(int &targetBitrate, int &maxBitrate) const;
	void applyBitrate();

	MSFilter *mFilter;
	Rfc3984Context *mPacker;
	int mPacketisationMode;
55 56 57
	ISVCEncoder *mEncoder;
	const MSVideoConfiguration *mVConfList;
	MSVideoConfiguration mVConf;
58
	MSVideoStarter mVideoStarter;
59
	MSIFrameRequestsLimiterCtx mIFrameLimiter;
60
	uint64_t mFrameCount;
61
	bool mInitialized;
62
	bool mPacketisationModeSet;
63
	bool mAVPFEnabled;
64
};