Commit f64e68a7 authored by JP Dinger's avatar JP Dinger

mozilla plugin: move deinterlace to own video subobject, and fix memleak.

parent da87f0fe
...@@ -1252,6 +1252,16 @@ LibvlcSubtitleNPObject::invoke(int index, const NPVariant *args, ...@@ -1252,6 +1252,16 @@ LibvlcSubtitleNPObject::invoke(int index, const NPVariant *args,
** implementation of libvlc video object ** implementation of libvlc video object
*/ */
LibvlcVideoNPObject::~LibvlcVideoNPObject()
{
if( isValid() )
{
if( marqueeObj ) NPN_ReleaseObject(marqueeObj);
if( logoObj ) NPN_ReleaseObject(logoObj);
if( deintObj ) NPN_ReleaseObject(deintObj);
}
}
const NPUTF8 * const LibvlcVideoNPObject::propertyNames[] = const NPUTF8 * const LibvlcVideoNPObject::propertyNames[] =
{ {
"fullscreen", "fullscreen",
...@@ -1262,7 +1272,8 @@ const NPUTF8 * const LibvlcVideoNPObject::propertyNames[] = ...@@ -1262,7 +1272,8 @@ const NPUTF8 * const LibvlcVideoNPObject::propertyNames[] =
"crop", "crop",
"teletext", "teletext",
"marquee", "marquee",
"logo" "logo",
"deinterlace",
}; };
enum LibvlcVideoNPObjectPropertyIds enum LibvlcVideoNPObjectPropertyIds
...@@ -1275,7 +1286,8 @@ enum LibvlcVideoNPObjectPropertyIds ...@@ -1275,7 +1286,8 @@ enum LibvlcVideoNPObjectPropertyIds
ID_video_crop, ID_video_crop,
ID_video_teletext, ID_video_teletext,
ID_video_marquee, ID_video_marquee,
ID_video_logo ID_video_logo,
ID_video_deinterlace,
}; };
COUNTNAMES(LibvlcVideoNPObject,propertyCount,propertyNames); COUNTNAMES(LibvlcVideoNPObject,propertyCount,propertyNames);
...@@ -1363,6 +1375,12 @@ LibvlcVideoNPObject::getProperty(int index, NPVariant &result) ...@@ -1363,6 +1375,12 @@ LibvlcVideoNPObject::getProperty(int index, NPVariant &result)
OBJECT_TO_NPVARIANT(NPN_RetainObject(logoObj), result); OBJECT_TO_NPVARIANT(NPN_RetainObject(logoObj), result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_video_deinterlace:
{
InstantObj<LibvlcDeinterlaceNPObject>( deintObj );
OBJECT_TO_NPVARIANT(NPN_RetainObject(deintObj), result);
return INVOKERESULT_NO_ERROR;
}
} }
} }
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
...@@ -1471,8 +1489,6 @@ const NPUTF8 * const LibvlcVideoNPObject::methodNames[] = ...@@ -1471,8 +1489,6 @@ const NPUTF8 * const LibvlcVideoNPObject::methodNames[] =
{ {
"toggleFullscreen", "toggleFullscreen",
"toggleTeletext", "toggleTeletext",
"deinterlaceEnable",
"deinterlaceDisable"
}; };
COUNTNAMES(LibvlcVideoNPObject,methodCount,methodNames); COUNTNAMES(LibvlcVideoNPObject,methodCount,methodNames);
...@@ -1480,8 +1496,6 @@ enum LibvlcVideoNPObjectMethodIds ...@@ -1480,8 +1496,6 @@ enum LibvlcVideoNPObjectMethodIds
{ {
ID_video_togglefullscreen, ID_video_togglefullscreen,
ID_video_toggleteletext, ID_video_toggleteletext,
ID_video_deinterlaceenable,
ID_video_deinterlacedisable
}; };
RuntimeNPObject::InvokeResult RuntimeNPObject::InvokeResult
...@@ -1522,32 +1536,6 @@ LibvlcVideoNPObject::invoke(int index, const NPVariant *args, ...@@ -1522,32 +1536,6 @@ LibvlcVideoNPObject::invoke(int index, const NPVariant *args,
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
} }
case ID_video_deinterlacedisable:
{
libvlc_video_set_deinterlace(p_md, 0, "", &ex);
RETURN_ON_EXCEPTION(this,ex);
return INVOKERESULT_NO_ERROR;
}
case ID_video_deinterlaceenable:
{
if(argCount == 1)
{
if( NPVARIANT_IS_STRING( args[0] ) )
{
/* get deinterlace mode from the user */
char *psz_mode = stringValue( NPVARIANT_TO_STRING( args[0] ) );
/* enable deinterlace filter if possible */
libvlc_video_set_deinterlace(p_md, 1, psz_mode, &ex);
free(psz_mode);
RETURN_ON_EXCEPTION(this,ex);
return INVOKERESULT_NO_ERROR;
}
else
{
return INVOKERESULT_INVALID_VALUE;
}
}
}
default: default:
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
} }
...@@ -1925,6 +1913,75 @@ LibvlcLogoNPObject::invoke(int index, const NPVariant *args, ...@@ -1925,6 +1913,75 @@ LibvlcLogoNPObject::invoke(int index, const NPVariant *args,
RETURN_ON_EXCEPTION(this,ex); RETURN_ON_EXCEPTION(this,ex);
VOID_TO_NPVARIANT(result); VOID_TO_NPVARIANT(result);
break; break;
default:
return INVOKERESULT_NO_SUCH_METHOD;
}
return INVOKERESULT_NO_ERROR;
}
const NPUTF8 * const LibvlcDeinterlaceNPObject::propertyNames[] = {
};
enum LibvlcDeinterlaceNPObjectPropertyIds {
};
COUNTNAMES(LibvlcDeinterlaceNPObject,propertyCount,propertyNames);
RuntimeNPObject::InvokeResult
LibvlcDeinterlaceNPObject::getProperty(int index, NPVariant &result)
{
return INVOKERESULT_GENERIC_ERROR;
}
RuntimeNPObject::InvokeResult
LibvlcDeinterlaceNPObject::setProperty(int index, const NPVariant &value)
{
return INVOKERESULT_GENERIC_ERROR;
}
const NPUTF8 * const LibvlcDeinterlaceNPObject::methodNames[] = {
"enable",
"disable",
};
enum LibvlcDeinterlaceNPObjectMethodIds {
ID_deint_enable,
ID_deint_disable,
};
COUNTNAMES(LibvlcDeinterlaceNPObject,methodCount,methodNames);
RuntimeNPObject::InvokeResult
LibvlcDeinterlaceNPObject::invoke(int index, const NPVariant *args,
uint32_t argCount, NPVariant &result)
{
char *psz;
if( !isPluginRunning() )
return INVOKERESULT_GENERIC_ERROR;
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_media_player_t *p_md = getPrivate<VlcPlugin>()->getMD(&ex);
RETURN_ON_EXCEPTION(this,ex);
switch( index )
{
case ID_deint_disable:
libvlc_video_set_deinterlace(p_md, 0, "", &ex);
RETURN_ON_EXCEPTION(this,ex);
break;
case ID_deint_enable:
if( argCount != 1 || !NPVARIANT_IS_STRING( args[0] ) )
return INVOKERESULT_INVALID_VALUE;
psz = stringValue( NPVARIANT_TO_STRING( args[0] ) );
libvlc_video_set_deinterlace(p_md, 1, psz, &ex);
free(psz);
RETURN_ON_EXCEPTION(this,ex);
break;
default:
return INVOKERESULT_NO_SUCH_METHOD;
} }
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
......
...@@ -180,8 +180,8 @@ protected: ...@@ -180,8 +180,8 @@ protected:
LibvlcVideoNPObject(NPP instance, const NPClass *aClass) : LibvlcVideoNPObject(NPP instance, const NPClass *aClass) :
RuntimeNPObject(instance, aClass), RuntimeNPObject(instance, aClass),
marqueeObj(NULL), logoObj(NULL) { } marqueeObj(NULL), logoObj(NULL), deintObj(NULL) { }
virtual ~LibvlcVideoNPObject() { } virtual ~LibvlcVideoNPObject();
static const int propertyCount; static const int propertyCount;
static const NPUTF8 * const propertyNames[]; static const NPUTF8 * const propertyNames[];
...@@ -197,6 +197,7 @@ protected: ...@@ -197,6 +197,7 @@ protected:
private: private:
NPObject *marqueeObj; NPObject *marqueeObj;
NPObject *logoObj; NPObject *logoObj;
NPObject *deintObj;
}; };
class LibvlcMarqueeNPObject: public RuntimeNPObject class LibvlcMarqueeNPObject: public RuntimeNPObject
...@@ -240,3 +241,24 @@ protected: ...@@ -240,3 +241,24 @@ protected:
InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result); InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result);
}; };
class LibvlcDeinterlaceNPObject: public RuntimeNPObject
{
protected:
friend class RuntimeNPClass<LibvlcDeinterlaceNPObject>;
LibvlcDeinterlaceNPObject(NPP instance, const NPClass *aClass) :
RuntimeNPObject(instance, aClass) { }
virtual ~LibvlcDeinterlaceNPObject() { }
static const int propertyCount;
static const NPUTF8 * const propertyNames[];
InvokeResult getProperty(int index, NPVariant &result);
InvokeResult setProperty(int index, const NPVariant &value);
static const int methodCount;
static const NPUTF8 * const methodNames[];
InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result);
};
...@@ -205,9 +205,9 @@ Insert Slider widget ...@@ -205,9 +205,9 @@ Insert Slider widget
</TR> </TR>
<TR> <TR>
<TD>Deinterlacing: <TD>Deinterlacing:
<INPUT type=button value="BLEND" onClick='getVLC("vlc").video.deinterlaceEnable("blend");'> <INPUT type=button value="BLEND" onClick='getVLC("vlc").video.deinterlace.enable("blend");'>
<INPUT type=button value=" X " onClick='getVLC("vlc").video.deinterlaceEnable("x");'> <INPUT type=button value=" X " onClick='getVLC("vlc").video.deinterlace.enable("x");'>
<INPUT type=button value="Disable" onClick='getVLC("vlc").video.deinterlaceDisable();'> <INPUT type=button value="Disable" onClick='getVLC("vlc").video.deinterlace.disable();'>
</TD> </TD>
</TR> </TR>
<TR> <TR>
......
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