Commit cf9bde1c authored by Ghislain MARY's avatar Ghislain MARY

Use C++ to code the plugin.

parent 1e985d09
dnl Process this file with autoconf to produce a configure script.
AC_INIT([msopenh264],[0.1.0])
AM_INIT_AUTOMAKE([tar-ustar])
AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE([tar-ustar])
AC_MSG_CHECKING([warning make an error on compilation])
AC_ARG_ENABLE(strict,
[ --enable-strict Enable error on compilation warning [default=yes]],
......@@ -14,7 +14,7 @@ AC_ARG_ENABLE(strict,
dnl Checks for programs.
AC_PROG_CC
AC_PROG_CXX
AC_LIBTOOL_WIN32_DLL
AC_DISABLE_STATIC
......
......@@ -2,10 +2,10 @@ pluginsdir=$(PACKAGE_PLUGINS_DIR)
plugins_LTLIBRARIES=libmsopenh264.la
libmsopenh264_la_SOURCES=msopenh264.c
libmsopenh264_la_SOURCES=msopenh264.cpp msopenh264dec.cpp msopenh264enc.cpp
libmsopenh264_la_LIBADD=$(MEDIASTREAMER_LIBS) $(OPENH264_LIBS)
libmsopenh264_la_LDFLAGS=-module -no-undefined
AM_CFLAGS=$(MEDIASTREAMER_CFLAGS)
AM_CPPFLAGS=$(MEDIASTREAMER_CFLAGS)
......@@ -17,121 +17,45 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "mediastreamer2/msfilter.h"
#include "mediastreamer2/msinterfaces.h"
#include "mediastreamer2/msticker.h"
#include "mediastreamer2/msvideo.h"
#include "mediastreamer2/rfc3984.h"
#include "wels/codec_api.h"
#include "msopenh264dec.h"
#include "msopenh264enc.h"
#ifndef VERSION
#define VERSION "0.1.0"
#endif
/**
* The goal of this small object is to tell when to send I frames at startup: at 2 and 4 seconds
*/
typedef struct VideoStarter {
uint64_t next_time;
int i_frame_count;
} VideoStarter;
/**
* Definition of the private data structure of the decoder.
*/
typedef struct _MSV4L2H264DecData {
Rfc3984Context unpacker;
MSPicture outbuf;
MSVideoSize vsize;
uint64_t last_decoded_frame;
uint64_t last_error_reported_time;
mblk_t *yuv_msg;
mblk_t *sps;
mblk_t *pps;
uint8_t *bitstream;
int bitstream_size;
unsigned int packet_num;
bool_t first_image_decoded;
} MSV4L2H264DecData;
/**
* Definition of the private data structure of the encoder.
*/
typedef struct _MSOpenH264EncData {
VideoStarter starter;
MSVideoSize vsize;
MSPixFmt in_fmt;
uint64_t framenum;
Rfc3984Context *packer;
float fps;
int bitrate;
int mode;
bool_t generate_keyframe;
} MSOpenH264EncData;
/******************************************************************************
* Implementation of the video starter *
*****************************************************************************/
#if 0
static void video_starter_init(VideoStarter *vs) {
vs->next_time = 0;
vs->i_frame_count = 0;
}
static void video_starter_first_frame(VideoStarter *vs, uint64_t curtime) {
vs->next_time = curtime + 2000;
}
static bool_t video_starter_need_i_frame(VideoStarter *vs, uint64_t curtime) {
if (vs->next_time == 0) return FALSE;
if (curtime >= vs->next_time) {
vs->i_frame_count++;
if (vs->i_frame_count == 1) {
vs->next_time += 2000;
} else {
vs->next_time = 0;
}
return TRUE;
}
return FALSE;
}
#endif
/******************************************************************************
* Implementation of the decoder *
*****************************************************************************/
static void msopenh264_dec_init(MSFilter *f) {
MSV4L2H264DecData *d = (MSV4L2H264DecData *)ms_new(MSV4L2H264DecData, 1);
d->sps = NULL;
d->pps = NULL;
d->outbuf.w = 0;
d->outbuf.h = 0;
d->vsize.width = MS_VIDEO_SIZE_VGA_W;
d->vsize.height = MS_VIDEO_SIZE_VGA_H;
d->packet_num = 0;
d->last_decoded_frame = 0;
d->last_error_reported_time = 0;
MSOpenH264Decoder *d = new MSOpenH264Decoder();
f->data = d;
}
static void msopenh264_dec_preprocess(MSFilter *f) {
MSV4L2H264DecData *d = (MSV4L2H264DecData*)f->data;
d->first_image_decoded = FALSE;
MSOpenH264Decoder *d = static_cast<MSOpenH264Decoder *>(f->data);
d->initialize();
}
static void msopenh264_dec_process(MSFilter *f) {
//MSV4L2H264DecData *d = (MSV4L2H264DecData*)f->data;
// TODO
MSOpenH264Decoder *d = static_cast<MSOpenH264Decoder *>(f->data);
d->feed(f);
}
static void msopenh264_dec_postprocess(MSFilter *f) {
MSOpenH264Decoder *d = static_cast<MSOpenH264Decoder *>(f->data);
d->uninitialize();
}
static void msopenh264_dec_uninit(MSFilter *f) {
MSV4L2H264DecData *d = (MSV4L2H264DecData *)f->data;
ms_free(d);
MSOpenH264Decoder *d = static_cast<MSOpenH264Decoder *>(f->data);
delete d;
}
......@@ -140,8 +64,8 @@ static void msopenh264_dec_uninit(MSFilter *f) {
*****************************************************************************/
static int msopenh264_reset_first_image(MSFilter *f, void *data) {
MSV4L2H264DecData *d = (MSV4L2H264DecData *)f->data;
d->first_image_decoded = FALSE;
//MSOpenH264Decoder *d = static_cast<MSOpenH264Decoder *>(f->data);
//d->first_image_decoded = FALSE;
return 0;
}
......@@ -208,34 +132,28 @@ MSFilterDesc msopenh264_dec_desc = {
*****************************************************************************/
static void msopenh264_enc_init(MSFilter *f) {
MSOpenH264EncData *d = (MSOpenH264EncData *)ms_new(MSOpenH264EncData, 1);
d->bitrate = 384000;
d->fps = 30;
d->mode = 1;
d->packer = NULL;
d->framenum = 0;
d->generate_keyframe = FALSE;
f->data = d;
MSOpenH264Encoder *e = new MSOpenH264Encoder();
f->data = e;
}
static void msopenh264_enc_preprocess(MSFilter *f) {
//MSOpenH264EncData *d = (MSOpenH264EncData*)f->data;
// TODO
MSOpenH264Encoder *e = static_cast<MSOpenH264Encoder *>(f->data);
e->initialize();
}
static void msopenh264_enc_process(MSFilter *f) {
//MSOpenH264EncData *d = (MSOpenH264EncData*)f->data;
// TODO
MSOpenH264Encoder *e = static_cast<MSOpenH264Encoder *>(f->data);
e->feed(f);
}
static void msopenh264_enc_postprocess(MSFilter *f) {
//MSOpenH264EncData *d = (MSOpenH264EncData*)f->data;
// TODO
MSOpenH264Encoder *e = static_cast<MSOpenH264Encoder *>(f->data);
e->uninitialize();
}
static void msopenh264_enc_uninit(MSFilter *f) {
MSOpenH264EncData *d = (MSOpenH264EncData *)f->data;
ms_free(d);
MSOpenH264Encoder *e = static_cast<MSOpenH264Encoder *>(f->data);
delete e;
}
......@@ -244,117 +162,104 @@ static void msopenh264_enc_uninit(MSFilter *f) {
*****************************************************************************/
static int msopenh264_enc_set_fps(MSFilter *f, void *arg) {
MSOpenH264EncData *d = (MSOpenH264EncData *)f->data;
d->fps = *(float*)arg;
MSOpenH264Encoder *e = static_cast<MSOpenH264Encoder *>(f->data);
float *fps = static_cast<float *>(arg);
e->setFps(*fps);
return 0;
}
static int msopenh264_enc_get_fps(MSFilter *f, void *arg) {
MSOpenH264EncData *d = (MSOpenH264EncData *)f->data;
*(float*)arg = d->fps;
MSOpenH264Encoder *e = static_cast<MSOpenH264Encoder *>(f->data);
float *fps = static_cast<float *>(arg);
*fps = e->getFps();
return 0;
}
static int msopenh264_enc_set_bitrate(MSFilter *f, void *arg) {
MSOpenH264EncData *d = (MSOpenH264EncData *)f->data;
d->bitrate = *(int*)arg;
if (d->bitrate >= 1024000) {
d->vsize.width = MS_VIDEO_SIZE_SVGA_W;
d->vsize.height = MS_VIDEO_SIZE_SVGA_H;
d->fps = 25;
} else if (d->bitrate >= 512000) {
d->vsize.width = MS_VIDEO_SIZE_VGA_W;
d->vsize.height = MS_VIDEO_SIZE_VGA_H;
d->fps = 25;
} else if (d->bitrate >= 256000) {
d->vsize.width = MS_VIDEO_SIZE_VGA_W;
d->vsize.height = MS_VIDEO_SIZE_VGA_H;
d->fps = 15;
} else if (d->bitrate >= 170000) {
d->vsize.width = MS_VIDEO_SIZE_QVGA_W;
d->vsize.height = MS_VIDEO_SIZE_QVGA_H;
d->fps = 15;
} else if (d->bitrate >= 128000) {
d->vsize.width = MS_VIDEO_SIZE_QCIF_W;
d->vsize.height = MS_VIDEO_SIZE_QCIF_H;
d->fps = 10;
} else if (d->bitrate >= 64000) {
d->vsize.width = MS_VIDEO_SIZE_QCIF_W;
d->vsize.height = MS_VIDEO_SIZE_QCIF_H;
d->fps = 7;
} else {
d->vsize.width = MS_VIDEO_SIZE_QCIF_W;
d->vsize.height = MS_VIDEO_SIZE_QCIF_H;
d->fps = 5;
}
ms_message("bitrate requested: %d (%d x %d)", d->bitrate, d->vsize.width, d->vsize.height);
MSOpenH264Encoder *e = static_cast<MSOpenH264Encoder *>(f->data);
int *bitrate = static_cast<int *>(arg);
e->setBitrate(*bitrate);
return 0;
}
static int msopenh264_enc_get_bitrate(MSFilter *f, void*arg) {
MSOpenH264EncData *d = (MSOpenH264EncData *)f->data;
*(int*)arg = d->bitrate;
static int msopenh264_enc_get_bitrate(MSFilter *f, void *arg) {
MSOpenH264Encoder *e = static_cast<MSOpenH264Encoder *>(f->data);
int *bitrate = static_cast<int *>(arg);
*bitrate = e->getBitrate();
return 0;
}
static int msopenh264_enc_set_vsize(MSFilter *f, void *arg) {
MSOpenH264EncData *d = (MSOpenH264EncData *)f->data;
d->vsize = *(MSVideoSize*)arg;
MSOpenH264Encoder *e = static_cast<MSOpenH264Encoder *>(f->data);
MSVideoSize *vsize = static_cast<MSVideoSize *>(arg);
e->setSize(*vsize);
return 0;
}
static int msopenh264_enc_get_vsize(MSFilter *f, void *arg) {
MSOpenH264EncData *d = (MSOpenH264EncData *)f->data;
*(MSVideoSize*)arg = d->vsize;
MSOpenH264Encoder *e = static_cast<MSOpenH264Encoder *>(f->data);
MSVideoSize *vsize = static_cast<MSVideoSize *>(arg);
*vsize = e->getSize();
return 0;
}
static int msopenh264_enc_set_pix_fmt(MSFilter *f, void *arg) {
MSOpenH264EncData *d = (MSOpenH264EncData *)f->data;
MSPixFmt fmt = *(MSPixFmt *)arg;
d->in_fmt = fmt;
MSOpenH264Encoder *e = static_cast<MSOpenH264Encoder *>(f->data);
MSPixFmt *fmt = static_cast<MSPixFmt *>(arg);
e->setPixFormat(*fmt);
return 0;
}
static int msopenh264_enc_add_fmtp(MSFilter *f, void *arg) {
MSOpenH264EncData *d = (MSOpenH264EncData *)f->data;
const char *fmtp = (const char *)arg;
char value[12];
if (fmtp_get_value(fmtp, "packetization-mode", value, sizeof(value))) {
d->mode = atoi(value);
ms_message("packetization-mode set to %i", d->mode);
}
MSOpenH264Encoder *e = static_cast<MSOpenH264Encoder *>(f->data);
const char *fmtp = static_cast<const char *>(arg);
e->addFmtp(fmtp);
return 0;
}
static int msopenh264_enc_has_builtin_converter(MSFilter *f, void *arg) {
*((bool_t *)arg) = FALSE;
bool_t *conv = static_cast<bool_t *>(arg);
*conv = FALSE;
return 0;
}
static int msopenh264_enc_req_vfu(MSFilter *f, void *arg) {
MSOpenH264EncData *d = (MSOpenH264EncData *)f->data;
d->generate_keyframe = TRUE;
MSOpenH264Encoder *e = static_cast<MSOpenH264Encoder *>(f->data);
e->generateKeyframe();
return 0;
}
static int msopenh264_enc_get_configuration_list(MSFilter *f, void *arg) {
MSOpenH264Encoder *e = static_cast<MSOpenH264Encoder *>(f->data);
const MSVideoConfiguration **vconf_list = static_cast<const MSVideoConfiguration **>(arg);
*vconf_list = e->getConfigurationList();
return 0;
}
static int msopenh264_enc_set_configuration(MSFilter *f, void *arg) {
MSOpenH264Encoder *e = static_cast<MSOpenH264Encoder *>(f->data);
MSVideoConfiguration *vconf = static_cast<MSVideoConfiguration *>(arg);
e->setConfiguration(*vconf);
return 0;
}
static MSFilterMethod msopenh264_enc_methods[] = {
{ MS_FILTER_SET_FPS, msopenh264_enc_set_fps },
{ MS_FILTER_GET_FPS, msopenh264_enc_get_fps },
{ MS_FILTER_SET_BITRATE, msopenh264_enc_set_bitrate },
{ MS_FILTER_GET_BITRATE, msopenh264_enc_get_bitrate },
{ MS_FILTER_SET_VIDEO_SIZE, msopenh264_enc_set_vsize },
{ MS_FILTER_GET_VIDEO_SIZE, msopenh264_enc_get_vsize },
{ MS_FILTER_SET_PIX_FMT, msopenh264_enc_set_pix_fmt },
{ MS_FILTER_ADD_FMTP, msopenh264_enc_add_fmtp },
{ MS_VIDEO_ENCODER_HAS_BUILTIN_CONVERTER, msopenh264_enc_has_builtin_converter },
{ MS_FILTER_REQ_VFU, msopenh264_enc_req_vfu },
{ MS_FILTER_SET_FPS, msopenh264_enc_set_fps },
{ MS_FILTER_GET_FPS, msopenh264_enc_get_fps },
{ MS_FILTER_SET_BITRATE, msopenh264_enc_set_bitrate },
{ MS_FILTER_GET_BITRATE, msopenh264_enc_get_bitrate },
{ MS_FILTER_SET_VIDEO_SIZE, msopenh264_enc_set_vsize },
{ MS_FILTER_GET_VIDEO_SIZE, msopenh264_enc_get_vsize },
{ MS_FILTER_SET_PIX_FMT, msopenh264_enc_set_pix_fmt },
{ MS_FILTER_ADD_FMTP, msopenh264_enc_add_fmtp },
{ MS_VIDEO_ENCODER_HAS_BUILTIN_CONVERTER, msopenh264_enc_has_builtin_converter },
{ MS_FILTER_REQ_VFU, msopenh264_enc_req_vfu },
#ifdef MS_VIDEO_ENCODER_REQ_VFU
{ MS_VIDEO_ENCODER_REQ_VFU, msopenh264_enc_req_vfu },
{ MS_VIDEO_ENCODER_REQ_VFU, msopenh264_enc_req_vfu },
#endif
{ 0, NULL }
{ MS_VIDEO_ENCODER_GET_CONFIGURATION_LIST, msopenh264_enc_get_configuration_list },
{ MS_VIDEO_ENCODER_SET_CONFIGURATION, msopenh264_enc_set_configuration },
{ 0, NULL }
};
/******************************************************************************
......@@ -410,7 +315,13 @@ MSFilterDesc msopenh264_enc_desc = {
#endif
MS2_PUBLIC void libmsopenh264_init(void){
#ifdef _MSC_VER
#define MS_PLUGIN_DECLARE(type) extern "C" __declspec(dllexport) type
#else
#define MS_PLUGIN_DECLARE(type) extern "C" type
#endif
MS_PLUGIN_DECLARE(void) libmsopenh264_init(void){
ms_filter_register(&msopenh264_dec_desc);
ms_filter_register(&msopenh264_enc_desc);
ms_message("msopenh264-" VERSION " plugin registered.");
......
/*
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
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "msopenh264dec.h"
MSOpenH264Decoder::MSOpenH264Decoder()
: mDecoder(0), mInitialized(false), mFirstImageDecoded(false)
{
long ret = WelsCreateDecoder(&mDecoder);
if (ret != 0) {
ms_error("%s: Failed creating openh264 decoder: %d", __FUNCTION__, ret);
}
}
MSOpenH264Decoder::~MSOpenH264Decoder()
{
if (mDecoder != 0) {
WelsDestroyDecoder(mDecoder);
}
}
void MSOpenH264Decoder::initialize()
{
mFirstImageDecoded = false;
rfc3984_init(&mUnpacker);
if (mDecoder != 0) {
SDecodingParam params = { 0 };
params.iOutputColorFormat = videoFormatI420;
params.uiTargetDqLayer = (unsigned char) -1;
params.uiEcActiveFlag = 1;
params.sVideoProperty.size = sizeof(params.sVideoProperty);
params.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT;
long ret = mDecoder->Initialize(&params);
if (ret != 0) {
ms_error("%s: Failed to initialize openh264 decoder: %d", __FUNCTION__, ret);
} else {
mInitialized = true;
}
}
}
void MSOpenH264Decoder::feed(MSFilter *f)
{
if (!isInitialized()){
ms_queue_flush(f->inputs[0]);
return;
}
MSQueue nalus;
ms_queue_init(&nalus);
mblk_t *im;
while ((im = ms_queue_get(f->inputs[0])) != NULL) {
rfc3984_unpack(&mUnpacker, im, &nalus);
if (!ms_queue_empty(&nalus)) {
ms_message("nalus");
// void * pData[3] = { 0 };
// SBufferInfo sDstBufInfo = { 0 };
// mDecoder->DecodeFrame2 (pBuf + iBufPos, iSliceSize, pData, &sDstBufInfo);
// if (sDstBufInfo.iBufferStatus == 1) {
// uint8_t * pDst[3] = { 0 };
// pDst[0] = (uint8_t *)pData[0];
// pDst[1] = (uint8_t *)pData[1];
// pDst[2] = (uint8_t *)pData[2];
// }
}
}
}
void MSOpenH264Decoder::uninitialize()
{
if (mDecoder != 0) {
mDecoder->Uninitialize();
}
mInitialized = false;
}
/*
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
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "mediastreamer2/msfilter.h"
#include "mediastreamer2/rfc3984.h"
#include "wels/codec_api.h"
class MSOpenH264Decoder {
public:
MSOpenH264Decoder();
virtual ~MSOpenH264Decoder();
bool isInitialized() const { return mInitialized; }
void initialize();
void feed(MSFilter *f);
void uninitialize();
private:
SDecodingParam mDecoderParams;
ISVCDecoder *mDecoder;
Rfc3984Context mUnpacker;
bool mInitialized;
bool mFirstImageDecoded;
};
/*
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
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "msopenh264enc.h"
#define MS_OPENH264_CONF(required_bitrate, bitrate_limit, resolution, fps) \
{ required_bitrate, bitrate_limit, { MS_VIDEO_SIZE_ ## resolution ## _W, MS_VIDEO_SIZE_ ## resolution ## _H }, fps, NULL }
static const MSVideoConfiguration openh264_conf_list[] = {
#if defined(ANDROID) || (TARGET_OS_IPHONE == 1) || defined(__arm__)
MS_OPENH264_CONF(0, 512000, QVGA, 12)
#else
MS_OPENH264_CONF(1024000, 1536000, SVGA, 25),
MS_OPENH264_CONF( 512000, 1024000, VGA, 25),
MS_OPENH264_CONF( 256000, 512000, VGA, 15),
MS_OPENH264_CONF( 170000, 256000, QVGA, 15),
MS_OPENH264_CONF( 128000, 170000, QCIF, 10),
MS_OPENH264_CONF( 64000, 128000, QCIF, 7),
MS_OPENH264_CONF( 0, 64000, QCIF, 5)
#endif
};
static const MSVideoConfiguration multicore_openh264_conf_list[] = {
#if defined(ANDROID) || (TARGET_OS_IPHONE == 1) || defined(__arm__)
MS_OPENH264_CONF(2048000, 3072000, UXGA, 15),
MS_OPENH264_CONF(1024000, 1536000, SXGA_MINUS, 15),
MS_OPENH264_CONF( 750000, 1024000, XGA, 15),
MS_OPENH264_CONF( 500000, 750000, SVGA, 15),
MS_OPENH264_CONF( 300000, 500000, VGA, 12),
MS_OPENH264_CONF( 0, 300000, QVGA, 12)
#else
MS_OPENH264_CONF(1536000, 2560000, SXGA_MINUS, 15),
MS_OPENH264_CONF(1536000, 2560000, 720P, 15),
MS_OPENH264_CONF(1024000, 1536000, XGA, 15),
MS_OPENH264_CONF( 512000, 1024000, SVGA, 15),
MS_OPENH264_CONF( 256000, 512000, VGA, 15),
MS_OPENH264_CONF( 170000, 256000, QVGA, 15),
MS_OPENH264_CONF( 128000, 170000, QCIF, 10),
MS_OPENH264_CONF( 64000, 128000, QCIF, 7),
MS_OPENH264_CONF( 0, 64000, QCIF, 5)
#endif
};
MSOpenH264Encoder::MSOpenH264Encoder()
: mVConfList(openh264_conf_list), mInitialized(false)
{
if (ms_get_cpu_count() > 1) mVConfList = &multicore_openh264_conf_list[0];
mVConf = ms_video_find_best_configuration_for_bitrate(mVConfList, 384000);
long ret = WelsCreateSVCEncoder(&mEncoder);
if (ret != 0) {
ms_error("%s: Failed creating openh264 encoder: %d", __FUNCTION__, ret);
}
}
MSOpenH264Encoder::~MSOpenH264Encoder()
{
if (mEncoder != 0) {
WelsDestroySVCEncoder(mEncoder);
}
}
void MSOpenH264Encoder::initialize()
{
// TODO
}
void MSOpenH264Encoder::feed(MSFilter *f)
{
if (!isInitialized()){
ms_queue_flush(f->inputs[0]);
return;
}
}
void MSOpenH264Encoder::uninitialize()
{
// TODO
}
void MSOpenH264Encoder::setFps(float fps)
{
// TODO
}
void MSOpenH264Encoder::setBitrate(int bitrate)
{
// TODO
}
void MSOpenH264Encoder::setSize(MSVideoSize size)
{
// TODO
}
void MSOpenH264Encoder::setPixFormat(MSPixFmt format)
{
// TODO
}
void MSOpenH264Encoder::addFmtp(const char *fmtp)
{
// TODO
}
void MSOpenH264Encoder::generateKeyframe()
{
// TODO
}
void MSOpenH264Encoder::setConfiguration(MSVideoConfiguration conf)
{
// TODO
}
/*
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
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "mediastreamer2/msfilter.h"
#include "mediastreamer2/msvideo.h"
#include "wels/codec_api.h"
class MSOpenH264Encoder {
public:
MSOpenH264Encoder();
virtual ~MSOpenH264Encoder();
void initialize();
bool isInitialized() const { return mInitialized; }
void feed(MSFilter *f);
void uninitialize();
void setFps(float fps);
float getFps() const { return mVConf.fps; }
void setBitrate(int bitrate);
int getBitrate() const { return mVConf.required_bitrate; }
void setSize(MSVideoSize size);
MSVideoSize getSize() const { return mVConf.vsize; }
void setPixFormat(MSPixFmt format);
void addFmtp(const char *fmtp);
void generateKeyframe();
const MSVideoConfiguration *getConfigurationList() const { return mVConfList; }
void setConfiguration(MSVideoConfiguration conf);
private:
ISVCEncoder *mEncoder;
const MSVideoConfiguration *mVConfList;
MSVideoConfiguration mVConf;
bool mInitialized;
};