begin adding support for (real) arbitrary video size decoding (H.264)
This commit is contained in:
parent
304768e2ae
commit
ab372e958c
|
@ -222,4 +222,8 @@ bool MediaSessionMgr::defaultsSet100relEnabled(bool _100rel_enabled){
|
|||
|
||||
bool MediaSessionMgr::defaultsGet100relEnabled(){
|
||||
return tmedia_defaults_get_100rel_enabled() == 0;
|
||||
}
|
||||
|
||||
bool MediaSessionMgr::defaultsSetScreenSize(int32_t sx, int32_t sy){
|
||||
return tmedia_defaults_set_screen_size(sx, sy) == 0;
|
||||
}
|
|
@ -74,6 +74,7 @@ public:
|
|||
static int32_t defaultsGetNoiseSuppLevel();
|
||||
static bool defaultsSet100relEnabled(bool _100rel_enabled);
|
||||
static bool defaultsGet100relEnabled();
|
||||
static bool defaultsSetScreenSize(int32_t sx, int32_t sy);
|
||||
|
||||
|
||||
private:
|
||||
|
|
|
@ -384,11 +384,11 @@ int twrap_consumer_proxy_video_prepare(tmedia_consumer_t* self, const tmedia_cod
|
|||
if(codec && (manager = ProxyPluginMgr::getInstance())){
|
||||
const ProxyVideoConsumer* videoConsumer;
|
||||
if((videoConsumer = manager->findVideoConsumer(TWRAP_CONSUMER_PROXY_VIDEO(self)->id)) && videoConsumer->getCallback()){
|
||||
self->video.fps = TMEDIA_CODEC_VIDEO(codec)->fps;
|
||||
self->video.fps = TMEDIA_CODEC_VIDEO(codec)->in.fps;
|
||||
// in
|
||||
self->video.in.chroma = tmedia_yuv420p;
|
||||
self->video.in.width = TMEDIA_CODEC_VIDEO(codec)->width;
|
||||
self->video.in.height = TMEDIA_CODEC_VIDEO(codec)->height;
|
||||
self->video.in.width = TMEDIA_CODEC_VIDEO(codec)->in.width;
|
||||
self->video.in.height = TMEDIA_CODEC_VIDEO(codec)->in.height;
|
||||
// display (out)
|
||||
self->video.display.chroma = videoConsumer->getChroma();
|
||||
self->video.display.auto_resize = videoConsumer->getAutoResizeDisplay();
|
||||
|
@ -398,7 +398,7 @@ int twrap_consumer_proxy_video_prepare(tmedia_consumer_t* self, const tmedia_cod
|
|||
if(!self->video.display.height){
|
||||
self->video.display.height = self->video.in.height;
|
||||
}
|
||||
ret = videoConsumer->getCallback()->prepare(TMEDIA_CODEC_VIDEO(codec)->width, TMEDIA_CODEC_VIDEO(codec)->height, TMEDIA_CODEC_VIDEO(codec)->fps);
|
||||
ret = videoConsumer->getCallback()->prepare(TMEDIA_CODEC_VIDEO(codec)->in.width, TMEDIA_CODEC_VIDEO(codec)->in.height, TMEDIA_CODEC_VIDEO(codec)->in.fps);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -298,7 +298,7 @@ int twrap_producer_proxy_video_prepare(tmedia_producer_t* self, const tmedia_cod
|
|||
if((videoProducer = manager->findVideoProducer(TWRAP_PRODUCER_PROXY_VIDEO(self)->id)) && videoProducer->getCallback()){
|
||||
self->video.chroma = videoProducer->getChroma();
|
||||
self->video.rotation = videoProducer->getRotation();
|
||||
ret = videoProducer->getCallback()->prepare(TMEDIA_CODEC_VIDEO(codec)->width, TMEDIA_CODEC_VIDEO(codec)->height, TMEDIA_CODEC_VIDEO(codec)->fps);
|
||||
ret = videoProducer->getCallback()->prepare(TMEDIA_CODEC_VIDEO(codec)->out.width, TMEDIA_CODEC_VIDEO(codec)->out.height, TMEDIA_CODEC_VIDEO(codec)->out.fps);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -166,6 +166,11 @@ public class MediaSessionMgr : IDisposable {
|
|||
return ret;
|
||||
}
|
||||
|
||||
public static bool defaultsSetScreenSize(int sx, int sy) {
|
||||
bool ret = tinyWRAPPINVOKE.MediaSessionMgr_defaultsSetScreenSize(sx, sy);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -332,6 +332,9 @@ class tinyWRAPPINVOKE {
|
|||
[DllImport("tinyWRAP", EntryPoint="CSharp_MediaSessionMgr_defaultsGet100relEnabled")]
|
||||
public static extern bool MediaSessionMgr_defaultsGet100relEnabled();
|
||||
|
||||
[DllImport("tinyWRAP", EntryPoint="CSharp_MediaSessionMgr_defaultsSetScreenSize")]
|
||||
public static extern bool MediaSessionMgr_defaultsSetScreenSize(int jarg1, int jarg2);
|
||||
|
||||
[DllImport("tinyWRAP", EntryPoint="CSharp_delete_MediaContent")]
|
||||
public static extern void delete_MediaContent(HandleRef jarg1);
|
||||
|
||||
|
|
|
@ -1720,6 +1720,20 @@ SWIGEXPORT unsigned int SWIGSTDCALL CSharp_MediaSessionMgr_defaultsGet100relEnab
|
|||
}
|
||||
|
||||
|
||||
SWIGEXPORT unsigned int SWIGSTDCALL CSharp_MediaSessionMgr_defaultsSetScreenSize(int jarg1, int jarg2) {
|
||||
unsigned int jresult ;
|
||||
int32_t arg1 ;
|
||||
int32_t arg2 ;
|
||||
bool result;
|
||||
|
||||
arg1 = (int32_t)jarg1;
|
||||
arg2 = (int32_t)jarg2;
|
||||
result = (bool)MediaSessionMgr::defaultsSetScreenSize(arg1,arg2);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_delete_MediaContent(void * jarg1) {
|
||||
MediaContent *arg1 = (MediaContent *) 0 ;
|
||||
|
||||
|
|
|
@ -135,4 +135,8 @@ public class MediaSessionMgr {
|
|||
return tinyWRAPJNI.MediaSessionMgr_defaultsGet100relEnabled();
|
||||
}
|
||||
|
||||
public static boolean defaultsSetScreenSize(int sx, int sy) {
|
||||
return tinyWRAPJNI.MediaSessionMgr_defaultsSetScreenSize(sx, sy);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -135,4 +135,8 @@ public class MediaSessionMgr {
|
|||
return tinyWRAPJNI.MediaSessionMgr_defaultsGet100relEnabled();
|
||||
}
|
||||
|
||||
public static boolean defaultsSetScreenSize(int sx, int sy) {
|
||||
return tinyWRAPJNI.MediaSessionMgr_defaultsSetScreenSize(sx, sy);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -59,6 +59,7 @@ class tinyWRAPJNI {
|
|||
public final static native int MediaSessionMgr_defaultsGetNoiseSuppLevel();
|
||||
public final static native boolean MediaSessionMgr_defaultsSet100relEnabled(boolean jarg1);
|
||||
public final static native boolean MediaSessionMgr_defaultsGet100relEnabled();
|
||||
public final static native boolean MediaSessionMgr_defaultsSetScreenSize(int jarg1, int jarg2);
|
||||
public final static native void delete_MediaContent(long jarg1);
|
||||
public final static native String MediaContent_getType(long jarg1, MediaContent jarg1_);
|
||||
public final static native long MediaContent_getDataLength(long jarg1, MediaContent jarg1_);
|
||||
|
|
|
@ -2646,6 +2646,22 @@ SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_MediaSessionM
|
|||
}
|
||||
|
||||
|
||||
SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_MediaSessionMgr_1defaultsSetScreenSize(JNIEnv *jenv, jclass jcls, jint jarg1, jint jarg2) {
|
||||
jboolean jresult = 0 ;
|
||||
int32_t arg1 ;
|
||||
int32_t arg2 ;
|
||||
bool result;
|
||||
|
||||
(void)jenv;
|
||||
(void)jcls;
|
||||
arg1 = (int32_t)jarg1;
|
||||
arg2 = (int32_t)jarg2;
|
||||
result = (bool)MediaSessionMgr::defaultsSetScreenSize(arg1,arg2);
|
||||
jresult = (jboolean)result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_delete_1MediaContent(JNIEnv *jenv, jclass jcls, jlong jarg1) {
|
||||
MediaContent *arg1 = (MediaContent *) 0 ;
|
||||
|
||||
|
|
|
@ -59,6 +59,7 @@ class tinyWRAPJNI {
|
|||
public final static native int MediaSessionMgr_defaultsGetNoiseSuppLevel();
|
||||
public final static native boolean MediaSessionMgr_defaultsSet100relEnabled(boolean jarg1);
|
||||
public final static native boolean MediaSessionMgr_defaultsGet100relEnabled();
|
||||
public final static native boolean MediaSessionMgr_defaultsSetScreenSize(int jarg1, int jarg2);
|
||||
public final static native void delete_MediaContent(long jarg1);
|
||||
public final static native String MediaContent_getType(long jarg1, MediaContent jarg1_);
|
||||
public final static native long MediaContent_getDataLength(long jarg1, MediaContent jarg1_);
|
||||
|
|
|
@ -2646,6 +2646,22 @@ SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_MediaSessionM
|
|||
}
|
||||
|
||||
|
||||
SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_MediaSessionMgr_1defaultsSetScreenSize(JNIEnv *jenv, jclass jcls, jint jarg1, jint jarg2) {
|
||||
jboolean jresult = 0 ;
|
||||
int32_t arg1 ;
|
||||
int32_t arg2 ;
|
||||
bool result;
|
||||
|
||||
(void)jenv;
|
||||
(void)jcls;
|
||||
arg1 = (int32_t)jarg1;
|
||||
arg2 = (int32_t)jarg2;
|
||||
result = (bool)MediaSessionMgr::defaultsSetScreenSize(arg1,arg2);
|
||||
jresult = (jboolean)result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_delete_1MediaContent(JNIEnv *jenv, jclass jcls, jlong jarg1) {
|
||||
MediaContent *arg1 = (MediaContent *) 0 ;
|
||||
|
||||
|
|
|
@ -216,6 +216,7 @@ sub DESTROY {
|
|||
*defaultsGetNoiseSuppLevel = *tinyWRAPc::MediaSessionMgr_defaultsGetNoiseSuppLevel;
|
||||
*defaultsSet100relEnabled = *tinyWRAPc::MediaSessionMgr_defaultsSet100relEnabled;
|
||||
*defaultsGet100relEnabled = *tinyWRAPc::MediaSessionMgr_defaultsGet100relEnabled;
|
||||
*defaultsSetScreenSize = *tinyWRAPc::MediaSessionMgr_defaultsSetScreenSize;
|
||||
sub DISOWN {
|
||||
my $self = shift;
|
||||
my $ptr = tied(%$self);
|
||||
|
|
|
@ -3777,6 +3777,44 @@ XS(_wrap_MediaSessionMgr_defaultsGet100relEnabled) {
|
|||
}
|
||||
|
||||
|
||||
XS(_wrap_MediaSessionMgr_defaultsSetScreenSize) {
|
||||
{
|
||||
int32_t arg1 ;
|
||||
int32_t arg2 ;
|
||||
int val1 ;
|
||||
int ecode1 = 0 ;
|
||||
int val2 ;
|
||||
int ecode2 = 0 ;
|
||||
int argvi = 0;
|
||||
bool result;
|
||||
dXSARGS;
|
||||
|
||||
if ((items < 2) || (items > 2)) {
|
||||
SWIG_croak("Usage: MediaSessionMgr_defaultsSetScreenSize(sx,sy);");
|
||||
}
|
||||
ecode1 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(0), &val1);
|
||||
if (!SWIG_IsOK(ecode1)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "MediaSessionMgr_defaultsSetScreenSize" "', argument " "1"" of type '" "int32_t""'");
|
||||
}
|
||||
arg1 = static_cast< int32_t >(val1);
|
||||
ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2);
|
||||
if (!SWIG_IsOK(ecode2)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "MediaSessionMgr_defaultsSetScreenSize" "', argument " "2"" of type '" "int32_t""'");
|
||||
}
|
||||
arg2 = static_cast< int32_t >(val2);
|
||||
result = (bool)MediaSessionMgr::defaultsSetScreenSize(arg1,arg2);
|
||||
ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ;
|
||||
|
||||
|
||||
XSRETURN(argvi);
|
||||
fail:
|
||||
|
||||
|
||||
SWIG_croak_null();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
XS(_wrap_delete_MediaContent) {
|
||||
{
|
||||
MediaContent *arg1 = (MediaContent *) 0 ;
|
||||
|
@ -21196,6 +21234,7 @@ static swig_command_info swig_commands[] = {
|
|||
{"tinyWRAPc::MediaSessionMgr_defaultsGetNoiseSuppLevel", _wrap_MediaSessionMgr_defaultsGetNoiseSuppLevel},
|
||||
{"tinyWRAPc::MediaSessionMgr_defaultsSet100relEnabled", _wrap_MediaSessionMgr_defaultsSet100relEnabled},
|
||||
{"tinyWRAPc::MediaSessionMgr_defaultsGet100relEnabled", _wrap_MediaSessionMgr_defaultsGet100relEnabled},
|
||||
{"tinyWRAPc::MediaSessionMgr_defaultsSetScreenSize", _wrap_MediaSessionMgr_defaultsSetScreenSize},
|
||||
{"tinyWRAPc::delete_MediaContent", _wrap_delete_MediaContent},
|
||||
{"tinyWRAPc::MediaContent_getType", _wrap_MediaContent_getType},
|
||||
{"tinyWRAPc::MediaContent_getDataLength", _wrap_MediaContent_getDataLength},
|
||||
|
|
|
@ -189,6 +189,8 @@ class MediaSessionMgr(_object):
|
|||
if _newclass:defaultsSet100relEnabled = staticmethod(_tinyWRAP.MediaSessionMgr_defaultsSet100relEnabled)
|
||||
__swig_getmethods__["defaultsGet100relEnabled"] = lambda x: _tinyWRAP.MediaSessionMgr_defaultsGet100relEnabled
|
||||
if _newclass:defaultsGet100relEnabled = staticmethod(_tinyWRAP.MediaSessionMgr_defaultsGet100relEnabled)
|
||||
__swig_getmethods__["defaultsSetScreenSize"] = lambda x: _tinyWRAP.MediaSessionMgr_defaultsSetScreenSize
|
||||
if _newclass:defaultsSetScreenSize = staticmethod(_tinyWRAP.MediaSessionMgr_defaultsSetScreenSize)
|
||||
MediaSessionMgr_swigregister = _tinyWRAP.MediaSessionMgr_swigregister
|
||||
MediaSessionMgr_swigregister(MediaSessionMgr)
|
||||
|
||||
|
@ -264,6 +266,10 @@ def MediaSessionMgr_defaultsGet100relEnabled():
|
|||
return _tinyWRAP.MediaSessionMgr_defaultsGet100relEnabled()
|
||||
MediaSessionMgr_defaultsGet100relEnabled = _tinyWRAP.MediaSessionMgr_defaultsGet100relEnabled
|
||||
|
||||
def MediaSessionMgr_defaultsSetScreenSize(*args):
|
||||
return _tinyWRAP.MediaSessionMgr_defaultsSetScreenSize(*args)
|
||||
MediaSessionMgr_defaultsSetScreenSize = _tinyWRAP.MediaSessionMgr_defaultsSetScreenSize
|
||||
|
||||
class MediaContent(_object):
|
||||
__swig_setmethods__ = {}
|
||||
__setattr__ = lambda self, name, value: _swig_setattr(self, MediaContent, name, value)
|
||||
|
|
|
@ -6404,6 +6404,37 @@ fail:
|
|||
}
|
||||
|
||||
|
||||
SWIGINTERN PyObject *_wrap_MediaSessionMgr_defaultsSetScreenSize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
|
||||
PyObject *resultobj = 0;
|
||||
int32_t arg1 ;
|
||||
int32_t arg2 ;
|
||||
int val1 ;
|
||||
int ecode1 = 0 ;
|
||||
int val2 ;
|
||||
int ecode2 = 0 ;
|
||||
PyObject * obj0 = 0 ;
|
||||
PyObject * obj1 = 0 ;
|
||||
bool result;
|
||||
|
||||
if (!PyArg_ParseTuple(args,(char *)"OO:MediaSessionMgr_defaultsSetScreenSize",&obj0,&obj1)) SWIG_fail;
|
||||
ecode1 = SWIG_AsVal_int(obj0, &val1);
|
||||
if (!SWIG_IsOK(ecode1)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "MediaSessionMgr_defaultsSetScreenSize" "', argument " "1"" of type '" "int32_t""'");
|
||||
}
|
||||
arg1 = static_cast< int32_t >(val1);
|
||||
ecode2 = SWIG_AsVal_int(obj1, &val2);
|
||||
if (!SWIG_IsOK(ecode2)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "MediaSessionMgr_defaultsSetScreenSize" "', argument " "2"" of type '" "int32_t""'");
|
||||
}
|
||||
arg2 = static_cast< int32_t >(val2);
|
||||
result = (bool)MediaSessionMgr::defaultsSetScreenSize(arg1,arg2);
|
||||
resultobj = SWIG_From_bool(static_cast< bool >(result));
|
||||
return resultobj;
|
||||
fail:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
SWIGINTERN PyObject *MediaSessionMgr_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
|
||||
PyObject *obj;
|
||||
if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
|
||||
|
@ -20705,6 +20736,7 @@ static PyMethodDef SwigMethods[] = {
|
|||
{ (char *)"MediaSessionMgr_defaultsGetNoiseSuppLevel", _wrap_MediaSessionMgr_defaultsGetNoiseSuppLevel, METH_VARARGS, NULL},
|
||||
{ (char *)"MediaSessionMgr_defaultsSet100relEnabled", _wrap_MediaSessionMgr_defaultsSet100relEnabled, METH_VARARGS, NULL},
|
||||
{ (char *)"MediaSessionMgr_defaultsGet100relEnabled", _wrap_MediaSessionMgr_defaultsGet100relEnabled, METH_VARARGS, NULL},
|
||||
{ (char *)"MediaSessionMgr_defaultsSetScreenSize", _wrap_MediaSessionMgr_defaultsSetScreenSize, METH_VARARGS, NULL},
|
||||
{ (char *)"MediaSessionMgr_swigregister", MediaSessionMgr_swigregister, METH_VARARGS, NULL},
|
||||
{ (char *)"delete_MediaContent", _wrap_delete_MediaContent, METH_VARARGS, NULL},
|
||||
{ (char *)"MediaContent_getType", _wrap_MediaContent_getType, METH_VARARGS, NULL},
|
||||
|
|
|
@ -80,9 +80,9 @@ int tdav_codec_h261_open(tmedia_codec_t* self)
|
|||
|
||||
h261->encoder.context->pix_fmt = PIX_FMT_YUV420P;
|
||||
h261->encoder.context->time_base.num = 1;
|
||||
h261->encoder.context->time_base.den = TMEDIA_CODEC_VIDEO(h261)->fps;
|
||||
h261->encoder.context->width = TMEDIA_CODEC_VIDEO(h261)->width;
|
||||
h261->encoder.context->height = TMEDIA_CODEC_VIDEO(h261)->height;
|
||||
h261->encoder.context->time_base.den = TMEDIA_CODEC_VIDEO(h261)->out.fps;
|
||||
h261->encoder.context->width = TMEDIA_CODEC_VIDEO(h261)->out.width;
|
||||
h261->encoder.context->height = TMEDIA_CODEC_VIDEO(h261)->out.height;
|
||||
|
||||
h261->encoder.context->mb_qmin = h261->encoder.context->qmin = 4;
|
||||
h261->encoder.context->mb_qmax = h261->encoder.context->qmax = 31;
|
||||
|
@ -93,7 +93,7 @@ int tdav_codec_h261_open(tmedia_codec_t* self)
|
|||
h261->encoder.context->opaque = tsk_null;
|
||||
h261->encoder.context->bit_rate = (float) (500000) * 0.80f;
|
||||
h261->encoder.context->bit_rate_tolerance = (int) (500000 * 0.20f);
|
||||
h261->encoder.context->gop_size = TMEDIA_CODEC_VIDEO(h261)->fps*4; /* each 4 seconds */
|
||||
h261->encoder.context->gop_size = TMEDIA_CODEC_VIDEO(h261)->out.fps*4; /* each 4 seconds */
|
||||
|
||||
// Picture (YUV 420)
|
||||
if(!(h261->encoder.picture = avcodec_alloc_frame())){
|
||||
|
@ -128,8 +128,8 @@ int tdav_codec_h261_open(tmedia_codec_t* self)
|
|||
avcodec_get_context_defaults(h261->decoder.context);
|
||||
|
||||
h261->decoder.context->pix_fmt = PIX_FMT_YUV420P;
|
||||
h261->decoder.context->width = TMEDIA_CODEC_VIDEO(h261)->width;
|
||||
h261->decoder.context->height = TMEDIA_CODEC_VIDEO(h261)->height;
|
||||
h261->decoder.context->width = TMEDIA_CODEC_VIDEO(h261)->in.width;
|
||||
h261->decoder.context->height = TMEDIA_CODEC_VIDEO(h261)->in.height;
|
||||
|
||||
// Picture (YUV 420)
|
||||
if(!(h261->decoder.picture = avcodec_alloc_frame())){
|
||||
|
@ -329,6 +329,8 @@ tsk_size_t tdav_codec_h261_decode(tmedia_codec_t* self, const void* in_data, tsk
|
|||
}
|
||||
else{
|
||||
retsize = xsize;
|
||||
TMEDIA_CODEC_VIDEO(h261)->in.width = h261->decoder.context->width;
|
||||
TMEDIA_CODEC_VIDEO(h261)->in.height = h261->decoder.context->height;
|
||||
if(self->video.flip.decoded){
|
||||
tdav_converter_video_flip(h261->decoder.picture, h261->decoder.context->height);
|
||||
}
|
||||
|
@ -350,10 +352,10 @@ tsk_bool_t tdav_codec_h261_fmtp_match(const tmedia_codec_t* codec, const char* f
|
|||
tmedia_codec_video_t* h261 = (tmedia_codec_video_t*)codec;
|
||||
|
||||
if(!(ret = tmedia_codec_parse_fmtp(fmtp, &maxbr, &fps, &width, &height))){
|
||||
h261->max_br = maxbr * 1000;
|
||||
h261->fps = fps;
|
||||
h261->width = width;
|
||||
h261->height = height;
|
||||
h261->in.max_br = h261->out.max_br = maxbr * 1000;
|
||||
h261->in.fps = h261->out.fps = fps;
|
||||
h261->in.width = h261->out.width = width;
|
||||
h261->in.height = h261->out.height = height;
|
||||
return tsk_true;
|
||||
}
|
||||
else{
|
||||
|
|
|
@ -130,9 +130,9 @@ int tdav_codec_h263_open(tmedia_codec_t* self)
|
|||
|
||||
h263->encoder.context->pix_fmt = PIX_FMT_YUV420P;
|
||||
h263->encoder.context->time_base.num = 1;
|
||||
h263->encoder.context->time_base.den = TMEDIA_CODEC_VIDEO(h263)->fps;
|
||||
h263->encoder.context->width = TMEDIA_CODEC_VIDEO(h263)->width;
|
||||
h263->encoder.context->height = TMEDIA_CODEC_VIDEO(h263)->height;
|
||||
h263->encoder.context->time_base.den = TMEDIA_CODEC_VIDEO(h263)->out.fps;
|
||||
h263->encoder.context->width = TMEDIA_CODEC_VIDEO(h263)->out.width;
|
||||
h263->encoder.context->height = TMEDIA_CODEC_VIDEO(h263)->out.height;
|
||||
|
||||
/*h263->encoder.context->mb_qmin =*/ h263->encoder.context->qmin = 4;
|
||||
/*h263->encoder.context->mb_qmax =*/ h263->encoder.context->qmax = 31;
|
||||
|
@ -141,7 +141,7 @@ int tdav_codec_h263_open(tmedia_codec_t* self)
|
|||
h263->encoder.context->thread_count = 1;
|
||||
h263->encoder.context->rtp_payload_size = RTP_PAYLOAD_SIZE;
|
||||
h263->encoder.context->opaque = tsk_null;
|
||||
h263->encoder.context->gop_size = TMEDIA_CODEC_VIDEO(h263)->fps*2; /* each 2 seconds */
|
||||
h263->encoder.context->gop_size = TMEDIA_CODEC_VIDEO(h263)->out.fps*2; /* each 2 seconds */
|
||||
h263->encoder.context->flags |= CODEC_FLAG_QSCALE;
|
||||
h263->encoder.context->global_quality = FF_QP2LAMBDA * tmedia_get_video_qscale(self->bl);
|
||||
|
||||
|
@ -201,8 +201,8 @@ int tdav_codec_h263_open(tmedia_codec_t* self)
|
|||
avcodec_get_context_defaults(h263->decoder.context);
|
||||
|
||||
h263->decoder.context->pix_fmt = PIX_FMT_YUV420P;
|
||||
h263->decoder.context->width = TMEDIA_CODEC_VIDEO(h263)->width;
|
||||
h263->decoder.context->height = TMEDIA_CODEC_VIDEO(h263)->height;
|
||||
h263->decoder.context->width = TMEDIA_CODEC_VIDEO(h263)->in.width;
|
||||
h263->decoder.context->height = TMEDIA_CODEC_VIDEO(h263)->in.height;
|
||||
|
||||
// Picture (YUV 420)
|
||||
if(!(h263->decoder.picture = avcodec_alloc_frame())){
|
||||
|
@ -440,6 +440,8 @@ tsk_size_t tdav_codec_h263_decode(tmedia_codec_t* self, const void* in_data, tsk
|
|||
}
|
||||
else{
|
||||
retsize = xsize;
|
||||
TMEDIA_CODEC_VIDEO(h263)->in.width = h263->decoder.context->width;
|
||||
TMEDIA_CODEC_VIDEO(h263)->in.height = h263->decoder.context->height;
|
||||
// flip
|
||||
if(self->video.flip.decoded){
|
||||
tdav_converter_video_flip(h263->decoder.picture, h263->decoder.context->height);
|
||||
|
@ -466,11 +468,11 @@ tsk_bool_t tdav_codec_h263_fmtp_match(const tmedia_codec_t* codec, const char* f
|
|||
case tmedia_bl_low:
|
||||
default:
|
||||
if(tsk_params_have_param(params, "QCIF")){
|
||||
h263->width = 176, h263->height = 144;
|
||||
h263->in.width = h263->out.width = 176, h263->in.height = h263->out.height = 144;
|
||||
ret = tsk_true;
|
||||
}
|
||||
else if(tsk_params_have_param(params, "SQCIF")){
|
||||
h263->width = 128, h263->height = 96;
|
||||
h263->in.width = h263->out.width = 128, h263->in.height = h263->out.height = 96;
|
||||
ret = tsk_true;
|
||||
}
|
||||
break;
|
||||
|
@ -479,19 +481,19 @@ tsk_bool_t tdav_codec_h263_fmtp_match(const tmedia_codec_t* codec, const char* f
|
|||
case tmedia_bl_hight:
|
||||
case tmedia_bl_unrestricted:
|
||||
if(tsk_params_have_param(params, "CIF")){
|
||||
h263->width = 352, h263->height = 288;
|
||||
h263->in.width = h263->out.width = 352, h263->in.height = h263->out.height = 288;
|
||||
ret = tsk_true;
|
||||
}
|
||||
else if(tsk_params_have_param(params, "QCIF")){
|
||||
h263->width = 176, h263->height = 144;
|
||||
h263->in.width = h263->out.width = 176, h263->in.height = h263->out.height = 144;
|
||||
ret = tsk_true;
|
||||
}
|
||||
else if(tsk_params_have_param(params, "SQCIF")){
|
||||
h263->width = 128, h263->height = 96;
|
||||
h263->in.width = h263->out.width = 128, h263->in.height = h263->out.height = 96;
|
||||
ret = tsk_true;
|
||||
}
|
||||
else { // Default: to be fixed
|
||||
h263->width = 352, h263->height = 288;
|
||||
h263->in.width = h263->out.width = 352, h263->in.height = h263->out.height = 288;
|
||||
ret = tsk_true;
|
||||
}
|
||||
|
||||
|
@ -1073,7 +1075,7 @@ static void tdav_codec_h263_rtp_callback(tdav_codec_h263_t *self, const void *da
|
|||
|
||||
// Send data over the network
|
||||
if(TMEDIA_CODEC_VIDEO(self)->callback){
|
||||
TMEDIA_CODEC_VIDEO(self)->callback(TMEDIA_CODEC_VIDEO(self)->callback_data, self->rtp.ptr, (size + H263_HEADER_MODE_A_SIZE), (3003* (30/TMEDIA_CODEC_VIDEO(self)->fps)), marker);
|
||||
TMEDIA_CODEC_VIDEO(self)->callback(TMEDIA_CODEC_VIDEO(self)->callback_data, self->rtp.ptr, (size + H263_HEADER_MODE_A_SIZE), (3003* (30/TMEDIA_CODEC_VIDEO(self)->out.fps)), marker);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1214,7 +1216,7 @@ static void tdav_codec_h263p_rtp_callback(tdav_codec_h263_t *self, const void *d
|
|||
|
||||
// Send data over the network
|
||||
if(TMEDIA_CODEC_VIDEO(self)->callback){
|
||||
TMEDIA_CODEC_VIDEO(self)->callback(TMEDIA_CODEC_VIDEO(self)->callback_data, _ptr, _size, (3003* (30/TMEDIA_CODEC_VIDEO(self)->fps)), marker);
|
||||
TMEDIA_CODEC_VIDEO(self)->callback(TMEDIA_CODEC_VIDEO(self)->callback_data, _ptr, _size, (3003* (30/TMEDIA_CODEC_VIDEO(self)->out.fps)), marker);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ int tdav_codec_h264_open(tmedia_codec_t* self)
|
|||
return -1;
|
||||
}
|
||||
|
||||
/* the caller (base class) already checked that the codec is not opened */
|
||||
/* the caller (base class) alreasy checked that the codec is not opened */
|
||||
|
||||
|
||||
//
|
||||
|
@ -83,9 +83,9 @@ int tdav_codec_h264_open(tmedia_codec_t* self)
|
|||
|
||||
h264->encoder.context->pix_fmt = PIX_FMT_YUV420P;
|
||||
h264->encoder.context->time_base.num = 1;
|
||||
h264->encoder.context->time_base.den = TMEDIA_CODEC_VIDEO(h264)->fps;
|
||||
h264->encoder.context->width = TMEDIA_CODEC_VIDEO(h264)->width;
|
||||
h264->encoder.context->height = TMEDIA_CODEC_VIDEO(h264)->height;
|
||||
h264->encoder.context->time_base.den = TMEDIA_CODEC_VIDEO(h264)->out.fps;
|
||||
h264->encoder.context->width = TMEDIA_CODEC_VIDEO(h264)->out.width;
|
||||
h264->encoder.context->height = TMEDIA_CODEC_VIDEO(h264)->out.height;
|
||||
|
||||
h264->encoder.context->rc_lookahead = 0;
|
||||
|
||||
|
@ -129,7 +129,7 @@ int tdav_codec_h264_open(tmedia_codec_t* self)
|
|||
h264->encoder.context->thread_count = 0;
|
||||
h264->encoder.context->rtp_payload_size = H264_RTP_PAYLOAD_SIZE;
|
||||
h264->encoder.context->opaque = tsk_null;
|
||||
h264->encoder.context->gop_size = TMEDIA_CODEC_VIDEO(h264)->fps*4; // Each 4 second(s)
|
||||
h264->encoder.context->gop_size = TMEDIA_CODEC_VIDEO(h264)->out.fps * 2; // Each 2 second(s)
|
||||
|
||||
|
||||
// Picture (YUV 420)
|
||||
|
@ -160,8 +160,8 @@ int tdav_codec_h264_open(tmedia_codec_t* self)
|
|||
|
||||
h264->decoder.context->pix_fmt = PIX_FMT_YUV420P;
|
||||
h264->decoder.context->flags2 |= CODEC_FLAG2_FAST;
|
||||
h264->decoder.context->width = TMEDIA_CODEC_VIDEO(h264)->width;
|
||||
h264->decoder.context->height = TMEDIA_CODEC_VIDEO(h264)->height;
|
||||
h264->decoder.context->width = TMEDIA_CODEC_VIDEO(h264)->in.width;
|
||||
h264->decoder.context->height = TMEDIA_CODEC_VIDEO(h264)->in.height;
|
||||
|
||||
#if TDAV_UNDER_WINDOWS
|
||||
h264->decoder.context->dsp_mask = (FF_MM_MMX | FF_MM_MMXEXT | FF_MM_SSE);
|
||||
|
@ -198,7 +198,7 @@ int tdav_codec_h264_close(tmedia_codec_t* self)
|
|||
return -1;
|
||||
}
|
||||
|
||||
/* the caller (base class) already checked that the codec is opened */
|
||||
/* the caller (base class) alreasy checked that the codec is opened */
|
||||
|
||||
//
|
||||
// Encoder
|
||||
|
@ -262,8 +262,8 @@ tsk_size_t tdav_codec_h264_encode(tmedia_codec_t* self, const void* in_data, tsk
|
|||
tdav_converter_video_flip(h264->encoder.picture, h264->encoder.context->height);
|
||||
}
|
||||
|
||||
if(h264->encoder.frame_count++ == 0 || (h264->encoder.frame_count < (int)TMEDIA_CODEC_VIDEO(h264)->fps*4)
|
||||
&& ((h264->encoder.frame_count %TMEDIA_CODEC_VIDEO(h264)->fps)==0)){
|
||||
if(h264->encoder.frame_count++ == 0 || (h264->encoder.frame_count < (int)TMEDIA_CODEC_VIDEO(h264)->out.fps*4)
|
||||
&& ((h264->encoder.frame_count %TMEDIA_CODEC_VIDEO(h264)->out.fps)==0)){
|
||||
|
||||
// You must patch FFmpeg to switch from X264_TYPE_AUTO to X264_TYPE_IDR
|
||||
h264->encoder.picture->pict_type = FF_I_TYPE;
|
||||
|
@ -368,7 +368,7 @@ tsk_size_t tdav_codec_h264_decode(tmedia_codec_t* self, const void* in_data, tsk
|
|||
}
|
||||
/* fill out */
|
||||
if(*out_max_size<xsize){
|
||||
if((*out_data = tsk_realloc(*out_data, xsize))){
|
||||
if((*out_data = tsk_realloc(*out_data, (xsize + FF_INPUT_BUFFER_PADDING_SIZE)))){
|
||||
*out_max_size = xsize;
|
||||
}
|
||||
else{
|
||||
|
@ -377,6 +377,8 @@ tsk_size_t tdav_codec_h264_decode(tmedia_codec_t* self, const void* in_data, tsk
|
|||
}
|
||||
}
|
||||
retsize = xsize;
|
||||
TMEDIA_CODEC_VIDEO(h264)->in.width = h264->decoder.context->width;
|
||||
TMEDIA_CODEC_VIDEO(h264)->in.height = h264->decoder.context->height;
|
||||
avpicture_layout((AVPicture *)h264->decoder.picture, h264->decoder.context->pix_fmt, h264->decoder.context->width, h264->decoder.context->height,
|
||||
*out_data, retsize);
|
||||
}
|
||||
|
@ -390,7 +392,7 @@ tsk_bool_t tdav_codec_h264_fmtp_match(const tmedia_codec_t* codec, const char* f
|
|||
{
|
||||
tdav_codec_h264_t* h264 = (tdav_codec_h264_t*)codec;
|
||||
tsk_params_L_t* params = tsk_null;
|
||||
int val_int;
|
||||
int val_int, sx = -1, sy = -1;
|
||||
const char* val_str;
|
||||
tsk_bool_t ret = tsk_true;
|
||||
tdav_codec_h264_profile_t profile;
|
||||
|
@ -414,13 +416,13 @@ tsk_bool_t tdav_codec_h264_fmtp_match(const tmedia_codec_t* codec, const char* f
|
|||
/* === max-br ===*/
|
||||
if((val_int = tsk_params_get_param_value_as_int(params, "max-br")) != -1){
|
||||
// should compare "max-br"?
|
||||
TMEDIA_CODEC_VIDEO(h264)->max_br = val_int*1000;
|
||||
TMEDIA_CODEC_VIDEO(h264)->out.max_br = val_int*1000;
|
||||
}
|
||||
|
||||
/* === max-mbps ===*/
|
||||
if((val_int = tsk_params_get_param_value_as_int(params, "max-mbps")) != -1){
|
||||
// should compare "max-mbps"?
|
||||
TMEDIA_CODEC_VIDEO(h264)->max_mbps = val_int*1000;
|
||||
TMEDIA_CODEC_VIDEO(h264)->out.max_mbps = val_int*1000;
|
||||
}
|
||||
|
||||
/* === packetization-mode ===*/
|
||||
|
@ -435,22 +437,37 @@ tsk_bool_t tdav_codec_h264_fmtp_match(const tmedia_codec_t* codec, const char* f
|
|||
}
|
||||
}
|
||||
|
||||
/* === sx and sy used by doubango clients ===*/
|
||||
sx = tsk_params_get_param_value_as_int(params, "sx");
|
||||
sy = tsk_params_get_param_value_as_int(params, "sy");
|
||||
|
||||
/* === profile-level-id ===*/
|
||||
if((val_str = tsk_params_get_param_value(params, "profile-level-id"))){
|
||||
level_idc_t l_idc;
|
||||
/* profile-idc and level-idc already tested by tdav_codec_h264_get_profile() */
|
||||
int std_w, std_h;
|
||||
/* profile-idc and level-idc alreasy tested by tdav_codec_h264_get_profile() */
|
||||
tdav_codec_h264_parse_profile(val_str, tsk_null, tsk_null, &l_idc);
|
||||
switch(l_idc){
|
||||
case level_idc_1_0:
|
||||
case level_idc_1_b:
|
||||
case level_idc_1_1:
|
||||
TMEDIA_CODEC_VIDEO(h264)->width = 176, TMEDIA_CODEC_VIDEO(h264)->height = 144;
|
||||
std_w = 176, std_h = 144;
|
||||
break;
|
||||
default:
|
||||
TMEDIA_CODEC_VIDEO(h264)->width = 352, TMEDIA_CODEC_VIDEO(h264)->height = 288;
|
||||
//TMEDIA_CODEC_VIDEO(h264)->width = 704, TMEDIA_CODEC_VIDEO(h264)->height = 480;
|
||||
std_w = 352, std_h = 288;
|
||||
break;
|
||||
}
|
||||
|
||||
//set it high to avoid overflow on the accumulator (codec::open)
|
||||
// will be update with codec::context after first successful decode
|
||||
TMEDIA_CODEC_VIDEO(h264)->in.width = 680, TMEDIA_CODEC_VIDEO(h264)->in.height = 480;
|
||||
if(sx > 0 && sy > 0){
|
||||
while((sx > std_w && sy > std_h) || (sx > std_h && sy > std_w)){
|
||||
sx >>= 1;
|
||||
sy >>= 1;
|
||||
}
|
||||
TMEDIA_CODEC_VIDEO(h264)->out.width = sx&(~1), TMEDIA_CODEC_VIDEO(h264)->out.height = sy&(~1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -483,7 +500,7 @@ char* tdav_codec_h264_fmtp_get(const tmedia_codec_t* self)
|
|||
|
||||
if(fmtp){
|
||||
tsk_strcat_2(&fmtp, "; packetization-mode=%d; max-br=%d; max-mbps=%d",
|
||||
h264->pack_mode, TMEDIA_CODEC_VIDEO(h264)->max_br/1000, TMEDIA_CODEC_VIDEO(h264)->max_mbps/1000);
|
||||
h264->pack_mode, TMEDIA_CODEC_VIDEO(h264)->in.max_br/1000, TMEDIA_CODEC_VIDEO(h264)->in.max_mbps/1000);
|
||||
}
|
||||
|
||||
return fmtp;
|
||||
|
@ -731,13 +748,13 @@ int tdav_codec_h264_init(tdav_codec_h264_t* self, tdav_codec_h264_profile_t prof
|
|||
|
||||
self->pack_mode = H264_PACKETIZATION_MODE;
|
||||
self->profile = profile;
|
||||
TMEDIA_CODEC_VIDEO(self)->max_mbps = H264_MAX_MBPS*1000;
|
||||
TMEDIA_CODEC_VIDEO(self)->max_br = H264_MAX_BR*1000;
|
||||
TMEDIA_CODEC_VIDEO(self)->in.max_mbps = TMEDIA_CODEC_VIDEO(self)->out.max_mbps = H264_MAX_MBPS*1000;
|
||||
TMEDIA_CODEC_VIDEO(self)->in.max_br = TMEDIA_CODEC_VIDEO(self)->out.max_br = H264_MAX_BR*1000;
|
||||
|
||||
// At this time self->plugin is Null
|
||||
TMEDIA_CODEC_VIDEO(self)->width = 176;
|
||||
TMEDIA_CODEC_VIDEO(self)->height = 144;
|
||||
TMEDIA_CODEC_VIDEO(self)->fps = 15;
|
||||
TMEDIA_CODEC_VIDEO(self)->in.width = TMEDIA_CODEC_VIDEO(self)->out.width = 176;
|
||||
TMEDIA_CODEC_VIDEO(self)->in.height = TMEDIA_CODEC_VIDEO(self)->out.height = 144;
|
||||
TMEDIA_CODEC_VIDEO(self)->in.fps = TMEDIA_CODEC_VIDEO(self)->out.fps = 15;
|
||||
|
||||
if(!(self->encoder.codec = avcodec_find_encoder(CODEC_ID_H264))){
|
||||
TSK_DEBUG_ERROR("Failed to find H.264 encoder");
|
||||
|
|
|
@ -300,7 +300,7 @@ void tdav_codec_h264_rtp_callback(struct tdav_codec_h264_s *self, const void *da
|
|||
/* Can be packet in a Single Nal Unit */
|
||||
// Send data over the network
|
||||
if(TMEDIA_CODEC_VIDEO(self)->callback){
|
||||
TMEDIA_CODEC_VIDEO(self)->callback(TMEDIA_CODEC_VIDEO(self)->callback_data, pdata, size, (3003* (30/TMEDIA_CODEC_VIDEO(self)->fps)), marker);
|
||||
TMEDIA_CODEC_VIDEO(self)->callback(TMEDIA_CODEC_VIDEO(self)->callback_data, pdata, size, (3003* (30/TMEDIA_CODEC_VIDEO(self)->out.fps)), marker);
|
||||
}
|
||||
}
|
||||
else if(size > H264_NAL_UNIT_TYPE_HEADER_SIZE){
|
||||
|
@ -342,7 +342,7 @@ void tdav_codec_h264_rtp_callback(struct tdav_codec_h264_s *self, const void *da
|
|||
|
||||
// send data
|
||||
if(TMEDIA_CODEC_VIDEO(self)->callback){
|
||||
TMEDIA_CODEC_VIDEO(self)->callback(TMEDIA_CODEC_VIDEO(self)->callback_data, self->rtp.ptr, (packet_size + H264_FUA_HEADER_SIZE), (3003* (30/TMEDIA_CODEC_VIDEO(self)->fps)), (size == 0));
|
||||
TMEDIA_CODEC_VIDEO(self)->callback(TMEDIA_CODEC_VIDEO(self)->callback_data, self->rtp.ptr, (packet_size + H264_FUA_HEADER_SIZE), (3003* (30/TMEDIA_CODEC_VIDEO(self)->out.fps)), (size == 0));
|
||||
#if TDAV_UNDER_WINDOWS// FIXME: WinSock problem: Why do we get packet lost (burst case only)?
|
||||
if(burst && (++count % 2 == 0)){
|
||||
tsk_thread_sleep(1); // 1 millisecond
|
||||
|
|
|
@ -143,9 +143,9 @@ int tdav_codec_mp4ves_open(tmedia_codec_t* self)
|
|||
|
||||
mp4v->encoder.context->pix_fmt = PIX_FMT_YUV420P;
|
||||
mp4v->encoder.context->time_base.num = 1;
|
||||
mp4v->encoder.context->time_base.den = TMEDIA_CODEC_VIDEO(mp4v)->fps;
|
||||
mp4v->encoder.context->width = TMEDIA_CODEC_VIDEO(mp4v)->width;
|
||||
mp4v->encoder.context->height = TMEDIA_CODEC_VIDEO(mp4v)->height;
|
||||
mp4v->encoder.context->time_base.den = TMEDIA_CODEC_VIDEO(mp4v)->in.fps;
|
||||
mp4v->encoder.context->width = TMEDIA_CODEC_VIDEO(mp4v)->in.width;
|
||||
mp4v->encoder.context->height = TMEDIA_CODEC_VIDEO(mp4v)->in.height;
|
||||
mp4v->encoder.context->mb_decision = FF_MB_DECISION_RD;
|
||||
mp4v->encoder.context->noise_reduction = 250;
|
||||
mp4v->encoder.context->flags |= CODEC_FLAG_QSCALE;
|
||||
|
@ -158,7 +158,7 @@ int tdav_codec_mp4ves_open(tmedia_codec_t* self)
|
|||
//mp4v->encoder.context->bit_rate_tolerance = (int) (bitRate * 0.20f);
|
||||
mp4v->encoder.context->profile = mp4v->profile>>4;
|
||||
mp4v->encoder.context->level = mp4v->profile & 0x0F;
|
||||
mp4v->encoder.context->gop_size = TMEDIA_CODEC_VIDEO(mp4v)->fps*2; // each 2 seconds
|
||||
mp4v->encoder.context->gop_size = TMEDIA_CODEC_VIDEO(mp4v)->in.fps*2; // each 2 seconds
|
||||
mp4v->encoder.context->max_b_frames = 0;
|
||||
mp4v->encoder.context->b_frame_strategy = 1;
|
||||
mp4v->encoder.context->flags |= CODEC_FLAG_AC_PRED;
|
||||
|
@ -192,8 +192,8 @@ int tdav_codec_mp4ves_open(tmedia_codec_t* self)
|
|||
avcodec_get_context_defaults(mp4v->decoder.context);
|
||||
|
||||
mp4v->decoder.context->pix_fmt = PIX_FMT_YUV420P;
|
||||
mp4v->decoder.context->width = TMEDIA_CODEC_VIDEO(mp4v)->width;
|
||||
mp4v->decoder.context->height = TMEDIA_CODEC_VIDEO(mp4v)->height;
|
||||
mp4v->decoder.context->width = TMEDIA_CODEC_VIDEO(mp4v)->out.width;
|
||||
mp4v->decoder.context->height = TMEDIA_CODEC_VIDEO(mp4v)->out.height;
|
||||
|
||||
// Picture (YUV 420)
|
||||
if(!(mp4v->decoder.picture = avcodec_alloc_frame())){
|
||||
|
@ -367,6 +367,8 @@ tsk_size_t tdav_codec_mp4ves_decode(tmedia_codec_t* self, const void* in_data, t
|
|||
}
|
||||
else{
|
||||
retsize = xsize;
|
||||
TMEDIA_CODEC_VIDEO(mp4v)->in.width = mp4v->decoder.context->width;
|
||||
TMEDIA_CODEC_VIDEO(mp4v)->in.height = mp4v->decoder.context->height;
|
||||
// flip
|
||||
if(self->video.flip.decoded){
|
||||
tdav_converter_video_flip(mp4v->decoder.picture, mp4v->decoder.context->height);
|
||||
|
@ -403,12 +405,12 @@ tsk_bool_t tdav_codec_mp4ves_fmtp_match(const tmedia_codec_t* codec, const char*
|
|||
|
||||
switch (mp4v->profile ) {
|
||||
case Simple_Profile_Level_1:
|
||||
TMEDIA_CODEC_VIDEO(mp4v)->width = 176, TMEDIA_CODEC_VIDEO(mp4v)->height = 144;
|
||||
TMEDIA_CODEC_VIDEO(mp4v)->out.width = TMEDIA_CODEC_VIDEO(mp4v)->in.width = 176, TMEDIA_CODEC_VIDEO(mp4v)->in.height = TMEDIA_CODEC_VIDEO(mp4v)->out.height = 144;
|
||||
break;
|
||||
case Simple_Profile_Level_2:
|
||||
case Simple_Profile_Level_3:
|
||||
default:
|
||||
TMEDIA_CODEC_VIDEO(mp4v)->width = 352, TMEDIA_CODEC_VIDEO(mp4v)->height = 288;
|
||||
TMEDIA_CODEC_VIDEO(mp4v)->out.width = TMEDIA_CODEC_VIDEO(mp4v)->in.width = 352, TMEDIA_CODEC_VIDEO(mp4v)->in.height = TMEDIA_CODEC_VIDEO(mp4v)->out.height = 288;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -564,7 +566,7 @@ static void tdav_codec_mp4ves_rtp_callback(tdav_codec_mp4ves_t *mp4v, const void
|
|||
{
|
||||
// Send data over the network
|
||||
if(TMEDIA_CODEC_VIDEO(mp4v)->callback){
|
||||
TMEDIA_CODEC_VIDEO(mp4v)->callback(TMEDIA_CODEC_VIDEO(mp4v)->callback_data, data, size, (3003* (30/TMEDIA_CODEC_VIDEO(mp4v)->fps)), marker);
|
||||
TMEDIA_CODEC_VIDEO(mp4v)->callback(TMEDIA_CODEC_VIDEO(mp4v)->callback_data, data, size, (3003* (30/TMEDIA_CODEC_VIDEO(mp4v)->out.fps)), marker);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -101,12 +101,12 @@ int tdav_codec_theora_open(tmedia_codec_t* self)
|
|||
|
||||
theora->encoder.context->pix_fmt = PIX_FMT_YUV420P;
|
||||
theora->encoder.context->time_base.num = 1;
|
||||
theora->encoder.context->time_base.den = TMEDIA_CODEC_VIDEO(theora)->fps;
|
||||
theora->encoder.context->width = TMEDIA_CODEC_VIDEO(theora)->width;
|
||||
theora->encoder.context->height = TMEDIA_CODEC_VIDEO(theora)->height;
|
||||
theora->encoder.context->time_base.den = TMEDIA_CODEC_VIDEO(theora)->out.fps;
|
||||
theora->encoder.context->width = TMEDIA_CODEC_VIDEO(theora)->out.width;
|
||||
theora->encoder.context->height = TMEDIA_CODEC_VIDEO(theora)->out.height;
|
||||
|
||||
theora->encoder.context->mb_decision = FF_MB_DECISION_RD;
|
||||
|
||||
|
||||
// Theoraenc doesn't honor 'CODEC_FLAG_QSCALE'
|
||||
switch(self->bl){
|
||||
case tmedia_bl_low:
|
||||
|
@ -129,7 +129,7 @@ int tdav_codec_theora_open(tmedia_codec_t* self)
|
|||
theora->encoder.context->opaque = tsk_null;
|
||||
theora->encoder.context->bit_rate = (int) (bitRate * 0.80f);
|
||||
theora->encoder.context->bit_rate_tolerance = (int) (bitRate * 0.20f);
|
||||
theora->encoder.context->gop_size = TMEDIA_CODEC_VIDEO(theora)->fps*2; // each 2 seconds
|
||||
theora->encoder.context->gop_size = TMEDIA_CODEC_VIDEO(theora)->out.fps*2; // each 2 seconds
|
||||
|
||||
// Picture (YUV 420)
|
||||
if(!(theora->encoder.picture = avcodec_alloc_frame())){
|
||||
|
@ -161,8 +161,8 @@ int tdav_codec_theora_open(tmedia_codec_t* self)
|
|||
avcodec_get_context_defaults(theora->decoder.context);
|
||||
|
||||
theora->decoder.context->pix_fmt = PIX_FMT_YUV420P;
|
||||
theora->decoder.context->width = TMEDIA_CODEC_VIDEO(theora)->width;
|
||||
theora->decoder.context->height = TMEDIA_CODEC_VIDEO(theora)->height;
|
||||
theora->decoder.context->width = TMEDIA_CODEC_VIDEO(theora)->in.width;
|
||||
theora->decoder.context->height = TMEDIA_CODEC_VIDEO(theora)->in.height;
|
||||
|
||||
// Picture (YUV 420)
|
||||
if(!(theora->decoder.picture = avcodec_alloc_frame())){
|
||||
|
@ -363,6 +363,8 @@ tsk_size_t tdav_codec_theora_decode(tmedia_codec_t* self, const void* in_data, t
|
|||
}
|
||||
else{
|
||||
retsize = xsize;
|
||||
TMEDIA_CODEC_VIDEO(theora)->in.width = theora->decoder.context->width;
|
||||
TMEDIA_CODEC_VIDEO(theora)->in.height = theora->decoder.context->height;
|
||||
if(self->video.flip.decoded){
|
||||
tdav_converter_video_flip(theora->decoder.picture, theora->decoder.context->height);
|
||||
}
|
||||
|
@ -498,10 +500,10 @@ tsk_bool_t tdav_codec_theora_fmtp_match(const tmedia_codec_t* codec, const char*
|
|||
case tmedia_bl_low:
|
||||
default:
|
||||
if(width<=176 && height<=144){
|
||||
theora->width = width, theora->height = height;
|
||||
theora->in.width = theora->out.width = width, theora->in.height = theora->out.height = height;
|
||||
}
|
||||
else{
|
||||
theora->width = 176, theora->height = 144;
|
||||
theora->in.width = theora->out.width = 176, theora->in.height = theora->out.height = 144;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -509,10 +511,10 @@ tsk_bool_t tdav_codec_theora_fmtp_match(const tmedia_codec_t* codec, const char*
|
|||
case tmedia_bl_hight:
|
||||
case tmedia_bl_unrestricted:
|
||||
if(width<=352 && height<=288){
|
||||
theora->width = width, theora->height = height;
|
||||
theora->in.width = theora->out.width = width, theora->in.height = theora->out.height = height;
|
||||
}
|
||||
else{
|
||||
theora->width = 352, theora->height = 288;
|
||||
theora->in.width = theora->out.width = 352, theora->in.height = theora->out.height = 288;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -703,7 +705,7 @@ int tdav_codec_theora_send(tdav_codec_theora_t* self, const uint8_t* data, tsk_s
|
|||
|
||||
// Send data over the network
|
||||
if(TMEDIA_CODEC_VIDEO(self)->callback){
|
||||
TMEDIA_CODEC_VIDEO(self)->callback(TMEDIA_CODEC_VIDEO(self)->callback_data, self->rtp.ptr, (pay_size + sizeof(pay_hdr)), (3003* (30/TMEDIA_CODEC_VIDEO(self)->fps)), (size == 0));
|
||||
TMEDIA_CODEC_VIDEO(self)->callback(TMEDIA_CODEC_VIDEO(self)->callback_data, self->rtp.ptr, (pay_size + sizeof(pay_hdr)), (3003* (30/TMEDIA_CODEC_VIDEO(self)->out.fps)), (size == 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ tsk_size_t tdav_converter_video_convert(tdav_converter_video_t* self, const void
|
|||
|
||||
size = avpicture_get_size(dstFormat, self->dstWidth, self->dstHeight);
|
||||
if((int)*output_max_size <size){
|
||||
if(!(*output = tsk_realloc(*output, size))){
|
||||
if(!(*output = tsk_realloc(*output, (size + FF_INPUT_BUFFER_PADDING_SIZE)))){
|
||||
*output_max_size = 0;
|
||||
TSK_DEBUG_ERROR("Failed to allocate buffer");
|
||||
return 0;
|
||||
|
|
|
@ -91,11 +91,10 @@ static int tdav_session_video_rtp_cb(const void* callback_data, const struct trt
|
|||
|
||||
// Create video converter if not already done
|
||||
if(!session->conv.fromYUV420 || CONSUMER_DISPLAYSIZE_CHANGED || CONSUMER_INSIZE_CHANGED){
|
||||
const tmedia_video_size_t* video_size = tmedia_get_video_size(tmedia_yuv420p, out_size);
|
||||
TSK_OBJECT_SAFE_FREE(session->conv.fromYUV420);
|
||||
// update in (set by the codec)
|
||||
session->consumer->video.in.width = video_size->width;
|
||||
session->consumer->video.in.height = video_size->height;
|
||||
session->consumer->video.in.width = TMEDIA_CODEC_VIDEO(codec)->in.width;//decoded width
|
||||
session->consumer->video.in.height = TMEDIA_CODEC_VIDEO(codec)->in.height;//decoded height
|
||||
|
||||
// important: do not override the display size (used by the end-user) unless requested
|
||||
if(session->consumer->video.display.auto_resize){
|
||||
|
@ -105,7 +104,7 @@ static int tdav_session_video_rtp_cb(const void* callback_data, const struct trt
|
|||
// set xdisplay with latest valid sizes (set by the user)
|
||||
session->conv.consumerLastWidth = session->consumer->video.display.width;
|
||||
session->conv.consumerLastHeight = session->consumer->video.display.height;
|
||||
if(!(session->conv.fromYUV420 = tdav_converter_video_create(video_size->width, video_size->height, session->conv.consumerLastWidth, session->conv.consumerLastHeight,
|
||||
if(!(session->conv.fromYUV420 = tdav_converter_video_create(TMEDIA_CODEC_VIDEO(codec)->in.width, TMEDIA_CODEC_VIDEO(codec)->in.height, session->conv.consumerLastWidth, session->conv.consumerLastHeight,
|
||||
session->consumer->video.display.chroma, tsk_false))){
|
||||
TSK_DEBUG_ERROR("Failed to create video converter");
|
||||
ret = -3;
|
||||
|
@ -201,7 +200,7 @@ static int tdav_session_video_producer_enc_cb(const void* callback_data, const v
|
|||
session->conv.producerHeight = session->producer->video.height;
|
||||
session->conv.xProducerSize = size;
|
||||
|
||||
if(!(session->conv.toYUV420 = tdav_converter_video_create(session->producer->video.width, session->producer->video.height, TMEDIA_CODEC_VIDEO(codec)->width, TMEDIA_CODEC_VIDEO(codec)->height,
|
||||
if(!(session->conv.toYUV420 = tdav_converter_video_create(session->producer->video.width, session->producer->video.height, TMEDIA_CODEC_VIDEO(codec)->out.width, TMEDIA_CODEC_VIDEO(codec)->out.height,
|
||||
session->producer->video.chroma, tsk_true))){
|
||||
TSK_DEBUG_ERROR("Failed to create video converter");
|
||||
ret = -5;
|
||||
|
|
|
@ -56,8 +56,8 @@ public:
|
|||
virtual void stop();
|
||||
|
||||
virtual bool setCaptureParameters(int format, int f);
|
||||
virtual bool setCaptureParameters(int w, int h, int f);
|
||||
|
||||
virtual VIDEOFORMAT getCaptureFormat();
|
||||
virtual int getFramerate();
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE SampleCB(double SampleTime, IMediaSample *pSample);
|
||||
|
|
|
@ -25,17 +25,18 @@
|
|||
// Define supported video formats
|
||||
typedef enum _VIDEOFORMAT
|
||||
{
|
||||
VIDEOFORMAT_NULL = 0, // 0 x 0 : Null
|
||||
VIDEOFORMAT_SQCIF, // 128 x 96 : SQCIF
|
||||
VIDEOFORMAT_QCIF, // 176 x 144 : QCIF
|
||||
VIDEOFORMAT_QVGA, // 320 x 240 : QVGA
|
||||
VIDEOFORMAT_CIF, // 352 x 288 : CIF
|
||||
VIDEOFORMAT_VGA, // 640 x 480 : VGA
|
||||
VIDEOFORMAT_4CIF, // 704 x 576 : 4CIF
|
||||
VIDEOFORMAT_SVGA, // 800 x 600 : SVGA
|
||||
VIDEOFORMAT_XGA, // 1024 x 768 : XGA
|
||||
VIDEOFORMAT_SXGA, // 1280 x 1024 : SXGA
|
||||
VIDEOFORMAT_16CIF, // 1408 x 1152 : 16CIF
|
||||
VIDEOFORMAT_NULL = 0, // 0 x 0 : Null
|
||||
VIDEOFORMAT_SQCIF, // 128 x 96 : SQCIF
|
||||
VIDEOFORMAT_QCIF, // 176 x 144 : QCIF
|
||||
VIDEOFORMAT_QVGA, // 320 x 240 : QVGA
|
||||
VIDEOFORMAT_CIF, // 352 x 288 : CIF
|
||||
VIDEOFORMAT_IOS_MEDIUM, // 480 x 360 : IOS_MEDIUM
|
||||
VIDEOFORMAT_VGA, // 640 x 480 : VGA
|
||||
VIDEOFORMAT_4CIF, // 704 x 576 : 4CIF
|
||||
VIDEOFORMAT_SVGA, // 800 x 600 : SVGA
|
||||
VIDEOFORMAT_XGA, // 1024 x 768 : XGA
|
||||
VIDEOFORMAT_SXGA, // 1280 x 1024 : SXGA
|
||||
VIDEOFORMAT_16CIF, // 1408 x 1152 : 16CIF
|
||||
} VIDEOFORMAT;
|
||||
|
||||
|
||||
|
@ -43,34 +44,36 @@ typedef enum _VIDEOFORMAT
|
|||
#define VIDEOFORMAT_TO_SIZE(format, width, height) \
|
||||
switch(format) \
|
||||
{ \
|
||||
case VIDEOFORMAT_SQCIF: width = 128; height = 96; break; \
|
||||
case VIDEOFORMAT_QCIF: width = 176; height = 144; break; \
|
||||
case VIDEOFORMAT_QVGA: width = 320; height = 240; break; \
|
||||
case VIDEOFORMAT_CIF: width = 352; height = 288; break; \
|
||||
case VIDEOFORMAT_VGA: width = 640; height = 480; break; \
|
||||
case VIDEOFORMAT_4CIF: width = 704; height = 576; break; \
|
||||
case VIDEOFORMAT_SVGA: width = 800; height = 600; break; \
|
||||
case VIDEOFORMAT_XGA: width = 1024; height = 768; break; \
|
||||
case VIDEOFORMAT_SXGA: width = 1280; height = 1024; break; \
|
||||
case VIDEOFORMAT_16CIF: width = 1408; height = 1152; break; \
|
||||
case VIDEOFORMAT_SQCIF: width = 128; height = 96; break; \
|
||||
case VIDEOFORMAT_QCIF: width = 176; height = 144; break; \
|
||||
case VIDEOFORMAT_QVGA: width = 320; height = 240; break; \
|
||||
case VIDEOFORMAT_CIF: width = 352; height = 288; break; \
|
||||
case VIDEOFORMAT_IOS_MEDIUM: width = 480; height = 360; break; \
|
||||
case VIDEOFORMAT_VGA: width = 640; height = 480; break; \
|
||||
case VIDEOFORMAT_4CIF: width = 704; height = 576; break; \
|
||||
case VIDEOFORMAT_SVGA: width = 800; height = 600; break; \
|
||||
case VIDEOFORMAT_XGA: width = 1024; height = 768; break; \
|
||||
case VIDEOFORMAT_SXGA: width = 1280; height = 1024; break; \
|
||||
case VIDEOFORMAT_16CIF: width = 1408; height = 1152; break; \
|
||||
case VIDEOFORMAT_NULL: \
|
||||
default: width = 0; height = 0; break; \
|
||||
default: width = 0; height = 0; break; \
|
||||
} \
|
||||
|
||||
|
||||
// Macro to get a video format from its size
|
||||
#define SIZE_TO_VIDEOFORMAT(width, height, format) \
|
||||
if ((width == 128) && (height = 96)) format = VIDEOFORMAT_SQCIF; \
|
||||
else if ((width == 176) && (height = 144)) format = VIDEOFORMAT_QCIF; \
|
||||
else if ((width == 320) && (height = 240)) format = VIDEOFORMAT_QVGA; \
|
||||
else if ((width == 352) && (height = 288)) format = VIDEOFORMAT_CIF; \
|
||||
else if ((width == 640) && (height = 480)) format = VIDEOFORMAT_VGA; \
|
||||
else if ((width == 704) && (height = 576)) format = VIDEOFORMAT_4CIF; \
|
||||
else if ((width == 800) && (height = 600)) format = VIDEOFORMAT_SVGA; \
|
||||
else if ((width == 1024) && (height = 768)) format = VIDEOFORMAT_XGA; \
|
||||
else if ((width == 1280) && (height = 1024)) format = VIDEOFORMAT_SXGA; \
|
||||
else if ((width == 1408) && (height = 1152)) format = VIDEOFORMAT_16CIF; \
|
||||
else format = VIDEOFORMAT_NULL; \
|
||||
#define SIZE_TO_VIDEOFORMAT(width, height, format) \
|
||||
if ((width == 128) && (height = 96)) format = VIDEOFORMAT_SQCIF; \
|
||||
else if ((width == 176) && (height = 144)) format = VIDEOFORMAT_QCIF; \
|
||||
else if ((width == 320) && (height = 240)) format = VIDEOFORMAT_QVGA; \
|
||||
else if ((width == 352) && (height = 288)) format = VIDEOFORMAT_CIF; \
|
||||
else if ((width == 480) && (height = 360)) format = VIDEOFORMAT_IOS_MEDIUM; \
|
||||
else if ((width == 640) && (height = 480)) format = VIDEOFORMAT_VGA; \
|
||||
else if ((width == 704) && (height = 576)) format = VIDEOFORMAT_4CIF; \
|
||||
else if ((width == 800) && (height = 600)) format = VIDEOFORMAT_SVGA; \
|
||||
else if ((width == 1024) && (height = 768)) format = VIDEOFORMAT_XGA; \
|
||||
else if ((width == 1280) && (height = 1024)) format = VIDEOFORMAT_SXGA; \
|
||||
else if ((width == 1408) && (height = 1152)) format = VIDEOFORMAT_16CIF; \
|
||||
else format = VIDEOFORMAT_NULL; \
|
||||
|
||||
|
||||
// Constants for consumer and producer Ids
|
||||
|
|
|
@ -103,15 +103,14 @@ void DSGrabber::stop()
|
|||
}
|
||||
}
|
||||
|
||||
bool DSGrabber::setCaptureParameters(int format, int f)
|
||||
bool DSGrabber::setCaptureParameters(int w, int h, int f)
|
||||
{
|
||||
tsk_mutex_lock(this->mutex_buffer);
|
||||
|
||||
// Get size from the format
|
||||
VIDEOFORMAT_TO_SIZE(format, this->width, this->height)
|
||||
|
||||
// Store the framerate
|
||||
this->fps = f;
|
||||
this->width = w;
|
||||
this->height = h;
|
||||
|
||||
// Store the required dimensions
|
||||
this->bitmapInfo.biWidth = this->width;
|
||||
|
@ -149,11 +148,12 @@ bool DSGrabber::setCaptureParameters(int format, int f)
|
|||
return SUCCEEDED(hr);
|
||||
}
|
||||
|
||||
VIDEOFORMAT DSGrabber::getCaptureFormat()
|
||||
bool DSGrabber::setCaptureParameters(int format, int f)
|
||||
{
|
||||
VIDEOFORMAT format;
|
||||
SIZE_TO_VIDEOFORMAT(this->width, this->height, format);
|
||||
return format;
|
||||
int w, h;
|
||||
// Get size from the format
|
||||
VIDEOFORMAT_TO_SIZE(format, w, h);
|
||||
return this->setCaptureParameters(w, h, f);
|
||||
}
|
||||
|
||||
int DSGrabber::getFramerate()
|
||||
|
|
|
@ -82,9 +82,9 @@ int tdshow_consumer_prepare(tmedia_consumer_t* self, const tmedia_codec_t* codec
|
|||
return -1;
|
||||
}
|
||||
|
||||
TMEDIA_CONSUMER(consumer)->video.fps = TMEDIA_CODEC_VIDEO(codec)->fps;
|
||||
TMEDIA_CONSUMER(consumer)->video.in.width = TMEDIA_CODEC_VIDEO(codec)->width;
|
||||
TMEDIA_CONSUMER(consumer)->video.in.height = TMEDIA_CODEC_VIDEO(codec)->height;
|
||||
TMEDIA_CONSUMER(consumer)->video.fps = TMEDIA_CODEC_VIDEO(codec)->in.fps;
|
||||
TMEDIA_CONSUMER(consumer)->video.in.width = TMEDIA_CODEC_VIDEO(codec)->in.width;
|
||||
TMEDIA_CONSUMER(consumer)->video.in.height = TMEDIA_CODEC_VIDEO(codec)->in.height;
|
||||
|
||||
if(!TMEDIA_CONSUMER(consumer)->video.display.width){
|
||||
TMEDIA_CONSUMER(consumer)->video.display.width = TMEDIA_CONSUMER(consumer)->video.in.width;
|
||||
|
@ -218,7 +218,7 @@ static tsk_object_t* tdshow_consumer_ctor(tsk_object_t * self, va_list * app)
|
|||
|
||||
/* init self */
|
||||
TMEDIA_CONSUMER(consumer)->video.fps = 15;
|
||||
TMEDIA_CONSUMER(consumer)->video.display.width = 352;
|
||||
TMEDIA_CONSUMER(consumer)->video.display.width = 320;
|
||||
TMEDIA_CONSUMER(consumer)->video.display.height = 288;
|
||||
TMEDIA_CONSUMER(consumer)->video.display.auto_resize = tsk_true;
|
||||
|
||||
|
|
|
@ -91,9 +91,9 @@ int tdshow_producer_prepare(tmedia_producer_t* self, const tmedia_codec_t* codec
|
|||
return -1;
|
||||
}
|
||||
|
||||
producer->fps = TMEDIA_CODEC_VIDEO(codec)->fps;
|
||||
producer->width = TMEDIA_CODEC_VIDEO(codec)->width;
|
||||
producer->height = TMEDIA_CODEC_VIDEO(codec)->height;
|
||||
producer->fps = TMEDIA_CODEC_VIDEO(codec)->out.fps;
|
||||
producer->width = TMEDIA_CODEC_VIDEO(codec)->out.width;
|
||||
producer->height = TMEDIA_CODEC_VIDEO(codec)->out.height;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -101,7 +101,6 @@ int tdshow_producer_prepare(tmedia_producer_t* self, const tmedia_codec_t* codec
|
|||
int tdshow_producer_start(tmedia_producer_t* self)
|
||||
{
|
||||
tdshow_producer_t* producer = (tdshow_producer_t*)self;
|
||||
VIDEOFORMAT format;
|
||||
HRESULT hr;
|
||||
|
||||
if(!producer){
|
||||
|
@ -130,8 +129,7 @@ int tdshow_producer_start(tmedia_producer_t* self)
|
|||
producer->grabber->setCaptureDevice("Null");
|
||||
|
||||
// set parameters
|
||||
SIZE_TO_VIDEOFORMAT(producer->width, producer->height, format);
|
||||
producer->grabber->setCaptureParameters(format, producer->fps);
|
||||
producer->grabber->setCaptureParameters(producer->width, producer->height, producer->fps);
|
||||
|
||||
// set callback function
|
||||
producer->grabber->setCallback(tdshow_plugin_cb, producer);
|
||||
|
|
|
@ -264,11 +264,21 @@ typedef struct tmedia_codec_video_s
|
|||
{
|
||||
TMEDIA_DECLARE_CODEC;
|
||||
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
unsigned fps;
|
||||
unsigned max_br;
|
||||
unsigned max_mbps;
|
||||
struct{
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
unsigned fps;
|
||||
unsigned max_br;
|
||||
unsigned max_mbps;
|
||||
}in;// decoded
|
||||
struct{
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
unsigned fps;
|
||||
unsigned max_br;
|
||||
unsigned max_mbps;
|
||||
}out;// encoded
|
||||
|
||||
|
||||
tmedia_codec_video_rtpcb_f callback;
|
||||
const void* callback_data;
|
||||
|
|
|
@ -72,6 +72,7 @@ typedef enum tmedia_video_size_type_e
|
|||
tmedia_vst_hd1080p,
|
||||
|
||||
tmedia_vst_ios_low,
|
||||
tmedia_vst_ios_medium,
|
||||
tmedia_vst_ios_high
|
||||
}
|
||||
tmedia_video_size_type_t;
|
||||
|
|
|
@ -53,6 +53,9 @@ TINYMEDIA_API int tmedia_defaults_set_noise_supp_level(int32_t noise_supp_level)
|
|||
TINYMEDIA_API int32_t tmedia_defaults_get_noise_supp_level();
|
||||
TINYMEDIA_API int tmedia_defaults_set_100rel_enabled(tsk_bool_t _100rel_enabled);
|
||||
TINYMEDIA_API tsk_bool_t tmedia_defaults_get_100rel_enabled();
|
||||
TINYMEDIA_API int tmedia_defaults_set_screen_size(int32_t sx, int32_t sy);
|
||||
TINYMEDIA_API int32_t tmedia_defaults_get_screen_x();
|
||||
TINYMEDIA_API int32_t tmedia_defaults_get_screen_y();
|
||||
|
||||
TMEDIA_END_DECLS
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
*/
|
||||
#include "tinymedia/tmedia_codec.h"
|
||||
#include "tinymedia/tmedia_defaults.h"
|
||||
|
||||
#include "tsk_string.h"
|
||||
#include "tsk_memory.h"
|
||||
|
@ -281,9 +282,9 @@ tmedia_codec_t* tmedia_codec_create(const char* format)
|
|||
{ /* Video codec */
|
||||
tmedia_codec_video_t* video = TMEDIA_CODEC_VIDEO(codec);
|
||||
tmedia_codec_video_init(TMEDIA_CODEC(video), plugin->name, plugin->desc, plugin->format);
|
||||
video->width = plugin->video.width;
|
||||
video->height = plugin->video.height;
|
||||
video->fps = plugin->video.fps;
|
||||
video->in.width = video->out.width = plugin->video.width;
|
||||
video->in.width = video->out.height = plugin->video.height;
|
||||
video->in.fps = video->out.fps = plugin->video.fps;
|
||||
break;
|
||||
}
|
||||
case tmedia_msrp:
|
||||
|
@ -454,13 +455,19 @@ int tmedia_codec_to_sdp(const tmedia_codecs_L_t* codecs, tsdp_header_M_t* m)
|
|||
}
|
||||
|
||||
tsk_list_foreach(item, codecs){
|
||||
tsk_bool_t is_audio, is_video;
|
||||
const char *neg_format;
|
||||
codec = item->data;
|
||||
/* add fmt */
|
||||
if((ret = tsdp_header_M_add_fmt(m, codec->neg_format? codec->neg_format : codec->format))){
|
||||
neg_format = codec->neg_format? codec->neg_format : codec->format;
|
||||
if((ret = tsdp_header_M_add_fmt(m, neg_format))){
|
||||
TSK_DEBUG_ERROR("Failed to add format");
|
||||
return ret;
|
||||
}
|
||||
if(tsk_striequals(m->media, "audio") || tsk_striequals(m->media, "video")){
|
||||
is_audio = tsk_striequals(m->media, "audio");
|
||||
is_video = tsk_striequals(m->media, "video");
|
||||
if(is_audio || is_video){
|
||||
char* temp = tsk_null;
|
||||
/* add rtpmap attributes */
|
||||
if((rtpmap = tmedia_codec_get_rtpmap(codec))){
|
||||
tsdp_header_M_add_headers(m,
|
||||
|
@ -470,8 +477,12 @@ int tmedia_codec_to_sdp(const tmedia_codecs_L_t* codecs, tsdp_header_M_t* m)
|
|||
}
|
||||
/* add fmtp attributes */
|
||||
if((fmtp = tmedia_codec_get_fmtp(codec))){
|
||||
char* temp = tsk_null;
|
||||
tsk_sprintf(&temp, "%s %s", codec->neg_format? codec->neg_format : codec->format, fmtp);
|
||||
if(is_video){
|
||||
tsk_sprintf(&temp, "%s %s;sx=%d;sy=%d", neg_format, fmtp, tmedia_defaults_get_screen_x(), tmedia_defaults_get_screen_y());//doubango clients
|
||||
}
|
||||
else{
|
||||
tsk_sprintf(&temp, "%s %s", neg_format, fmtp);
|
||||
}
|
||||
tsdp_header_M_add_headers(m,
|
||||
TSDP_HEADER_A_VA_ARGS("fmtp", temp),
|
||||
tsk_null);
|
||||
|
|
|
@ -140,6 +140,7 @@ static const tmedia_video_size_t tmedia_video_sizes[] =
|
|||
{tmedia_vst_hd1080p, 1920, 1080},
|
||||
|
||||
{tmedia_vst_ios_low, 200, 152},
|
||||
{tmedia_vst_ios_medium, 480, 360},
|
||||
{tmedia_vst_ios_high, 400, 304},
|
||||
};
|
||||
|
||||
|
|
|
@ -52,6 +52,8 @@ static tsk_bool_t __vad_enabled = tsk_false;
|
|||
static tsk_bool_t __noise_supp_enabled = tsk_true;
|
||||
static int32_t __noise_supp_level = -30;
|
||||
static tsk_bool_t __100rel_enabled = tsk_true;
|
||||
static int32_t __sx = -1;
|
||||
static int32_t __sy = -1;
|
||||
|
||||
int tmedia_defaults_set_echo_tail(uint32_t echo_tail)
|
||||
{
|
||||
|
@ -138,3 +140,16 @@ tsk_bool_t tmedia_defaults_get_100rel_enabled(){
|
|||
return __100rel_enabled;
|
||||
}
|
||||
|
||||
int tmedia_defaults_set_screen_size(int32_t sx, int32_t sy){
|
||||
__sx = sx;
|
||||
__sy = sy;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tmedia_defaults_get_screen_x(){
|
||||
return __sx;
|
||||
}
|
||||
|
||||
int32_t tmedia_defaults_get_screen_y(){
|
||||
return __sy;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue