Commit dc1ce798 authored by Jean-Paul Saman's avatar Jean-Paul Saman

Add support to the activex, mozilla, firefox, safari plugin for changing audio...

Add support to the activex, mozilla, firefox, safari plugin for changing audio track and audio output channel (reverse, stereo, left, right, dolby).
parent 53a76832
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
* Copyright (C) 2006 the VideoLAN team * Copyright (C) 2006 the VideoLAN team
* *
* Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net> * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
* Jean-Paul Saman <jpsaman _at_ m2x _dot_ nl>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
...@@ -198,6 +199,16 @@ library AXVLC ...@@ -198,6 +199,16 @@ library AXVLC
[helpstring("Mute/unmute audio playback.")] [helpstring("Mute/unmute audio playback.")]
HRESULT toggleMute(); HRESULT toggleMute();
[propget, helpstring("Returns/sets audio track used/to use.")]
HRESULT track([out, retval] long* track);
[propput, helpstring("Returns/sets audio track used/to use.")]
HRESULT track([in] long track);
[propget, helpstring("Returns audio channel: reverse, stereo, left, right, dolby.")]
HRESULT channel([out, retval] BSTR* channel);
[propput, helpstring("Sets audio channel to: reverse, stereo, left, right, dolby.")]
HRESULT channel([in] BSTR channel);
}; };
[ [
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
* Copyright (C) 2006 the VideoLAN team * Copyright (C) 2006 the VideoLAN team
* *
* Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net> * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
* Jean-Paul Saman <jpsaman _at_ m2x _dot_ nl>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
...@@ -198,6 +199,119 @@ STDMETHODIMP VLCAudio::put_volume(long volume) ...@@ -198,6 +199,119 @@ STDMETHODIMP VLCAudio::put_volume(long volume)
return hr; return hr;
}; };
STDMETHODIMP VLCAudio::get_track(long* track)
{
if( NULL == track )
return E_POINTER;
libvlc_instance_t* p_libvlc;
HRESULT hr = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
*track = libvlc_audio_get_track(p_libvlc, &ex);
if( libvlc_exception_raised(&ex) )
{
_p_instance->setErrorInfo(IID_IVLCAudio, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
return NOERROR;
}
return hr;
};
STDMETHODIMP VLCAudio::put_track(long track)
{
libvlc_instance_t* p_libvlc;
HRESULT hr = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_audio_set_track(p_libvlc, track, &ex);
if( libvlc_exception_raised(&ex) )
{
_p_instance->setErrorInfo(IID_IVLCAudio, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
return NOERROR;
}
return hr;
};
STDMETHODIMP VLCAudio::get_channel(BSTR *channel)
{
if( NULL == channel )
return E_POINTER;
libvlc_instance_t* p_libvlc;
HRESULT hr = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(hr) )
{
char *psz_channel = NULL;
libvlc_exception_t ex;
libvlc_exception_init(&ex);
psz_channel = libvlc_audio_get_channel(p_libvlc, &ex);
if( ! libvlc_exception_raised(&ex) )
{
if( NULL == psz_channel )
return E_OUTOFMEMORY;
*channel = SysAllocStringByteLen(psz_channel, strlen(psz_channel));
free( psz_channel );
psz_channel = NULL;
return NOERROR;
}
if( psz_channel ) free( psz_channel );
_p_instance->setErrorInfo(IID_IVLCAudio,
libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
return hr;
};
STDMETHODIMP VLCAudio::put_channel(BSTR channel)
{
if( NULL == channel )
return E_POINTER;
if( 0 == SysStringLen(channel) )
return E_INVALIDARG;
libvlc_instance_t* p_libvlc;
HRESULT hr = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(hr) )
{
char *psz_channel = NULL;
libvlc_exception_t ex;
libvlc_exception_init(&ex);
psz_channel = CStrFromBSTR(CP_UTF8, channel);
if( NULL == psz_channel )
return E_OUTOFMEMORY;
libvlc_audio_set_channel(p_libvlc, psz_channel, &ex);
CoTaskMemFree(psz_channel);
if( libvlc_exception_raised(&ex) )
{
_p_instance->setErrorInfo(IID_IVLCAudio,
libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
return NOERROR;
}
return hr;
};
STDMETHODIMP VLCAudio::toggleMute() STDMETHODIMP VLCAudio::toggleMute()
{ {
libvlc_instance_t* p_libvlc; libvlc_instance_t* p_libvlc;
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
* Copyright (C) 2006 the VideoLAN team * Copyright (C) 2006 the VideoLAN team
* *
* Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net> * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
* Jean-Paul Saman <jpsaman _at_ m2x _dot_ nl>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
...@@ -65,6 +66,10 @@ public: ...@@ -65,6 +66,10 @@ public:
STDMETHODIMP put_mute(VARIANT_BOOL); STDMETHODIMP put_mute(VARIANT_BOOL);
STDMETHODIMP get_volume(long*); STDMETHODIMP get_volume(long*);
STDMETHODIMP put_volume(long); STDMETHODIMP put_volume(long);
STDMETHODIMP get_track(long*);
STDMETHODIMP put_track(long);
STDMETHODIMP get_channel(BSTR*);
STDMETHODIMP put_channel(BSTR);
STDMETHODIMP toggleMute(); STDMETHODIMP toggleMute();
protected: protected:
...@@ -530,7 +535,6 @@ private: ...@@ -530,7 +535,6 @@ private:
class VLCControl2 : public IVLCControl2 class VLCControl2 : public IVLCControl2
{ {
public: public:
VLCControl2(VLCPlugin *p_instance); VLCControl2(VLCPlugin *p_instance);
...@@ -599,4 +603,3 @@ private: ...@@ -599,4 +603,3 @@ private:
}; };
#endif #endif
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
* $Id: vlc.h 13701 2005-12-12 17:58:56Z zorglub $ * $Id: vlc.h 13701 2005-12-12 17:58:56Z zorglub $
* *
* Authors: Clément Stenac <zorglub@videolan.org> * Authors: Clément Stenac <zorglub@videolan.org>
* Jean-Paul Saman <jpsaman _at_ m2x _dot_ nl>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
...@@ -486,7 +487,41 @@ int libvlc_audio_get_volume( libvlc_instance_t *, libvlc_exception_t * ); ...@@ -486,7 +487,41 @@ int libvlc_audio_get_volume( libvlc_instance_t *, libvlc_exception_t * );
* \param p_exception an initialized exception * \param p_exception an initialized exception
* \return void * \return void
*/ */
void libvlc_audio_set_volume( libvlc_instance_t *, int , libvlc_exception_t *); void libvlc_audio_set_volume( libvlc_instance_t *, int, libvlc_exception_t *);
/**
* Get current audio track
* \param p_instance libvlc instance
* \param p_exception an initialized exception
* \return the audio track (int)
*/
int libvlc_audio_get_track( libvlc_instance_t *, libvlc_exception_t * );
/**
* Set current audio track
* \param p_instance libvlc instance
* \param i_track the track (int)
* \param p_exception an initialized exception
* \return void
*/
void libvlc_audio_set_track( libvlc_instance_t *, int, libvlc_exception_t * );
/**
* Get current audio channel
* \param p_instance libvlc instance
* \param p_exception an initialized exception
* \return the audio channel (char *)
*/
char *libvlc_audio_get_channel( libvlc_instance_t *, libvlc_exception_t * );
/**
* Set current audio track
* \param p_instance libvlc instance
* \param psz_channel the audio channel (char *)
* \param p_exception an initialized exception
* \return void
*/
void libvlc_audio_set_channel( libvlc_instance_t *, char *, libvlc_exception_t * );
/** @} */ /** @} */
......
...@@ -177,6 +177,8 @@ const NPUTF8 * const LibvlcAudioNPObject::propertyNames[] = ...@@ -177,6 +177,8 @@ const NPUTF8 * const LibvlcAudioNPObject::propertyNames[] =
{ {
"mute", "mute",
"volume", "volume",
"track",
"channel",
}; };
const int LibvlcAudioNPObject::propertyCount = sizeof(LibvlcAudioNPObject::propertyNames)/sizeof(NPUTF8 *); const int LibvlcAudioNPObject::propertyCount = sizeof(LibvlcAudioNPObject::propertyNames)/sizeof(NPUTF8 *);
...@@ -185,6 +187,8 @@ enum LibvlcAudioNPObjectPropertyIds ...@@ -185,6 +187,8 @@ enum LibvlcAudioNPObjectPropertyIds
{ {
ID_audio_mute, ID_audio_mute,
ID_audio_volume, ID_audio_volume,
ID_audio_track,
ID_audio_channel,
}; };
RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVariant &result) RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVariant &result)
...@@ -221,6 +225,46 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVari ...@@ -221,6 +225,46 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVari
INT32_TO_NPVARIANT(volume, result); INT32_TO_NPVARIANT(volume, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_audio_track:
{
int track = libvlc_audio_get_track(p_plugin->getVLC(), &ex);
if( libvlc_exception_raised(&ex) )
{
NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR;
}
INT32_TO_NPVARIANT(track, result);
return INVOKERESULT_NO_ERROR;
}
case ID_audio_channel:
{
char *channel = libvlc_audio_get_channel(p_plugin->getVLC(), &ex);
if( libvlc_exception_raised(&ex) )
{
NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR;
}
if( channel )
{
int len = strlen(channel);
NPUTF8 *retval = (NPUTF8*)NPN_MemAlloc(len);
if( retval )
{
memcpy(retval, channel, len);
STRINGN_TO_NPVARIANT(retval, len, result);
}
else
{
NULL_TO_NPVARIANT(result);
}
free( channel );
channel = NULL;
return INVOKERESULT_NO_ERROR;
}
return INVOKERESULT_NO_SUCH_METHOD;
}
default: default:
; ;
} }
...@@ -266,6 +310,45 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::setProperty(int index, const ...@@ -266,6 +310,45 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::setProperty(int index, const
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
return INVOKERESULT_INVALID_VALUE; return INVOKERESULT_INVALID_VALUE;
case ID_audio_track:
if( isNumberValue(value) )
{
libvlc_audio_set_track(p_plugin->getVLC(),
numberValue(value), &ex);
if( libvlc_exception_raised(&ex) )
{
NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR;
}
return INVOKERESULT_NO_ERROR;
}
return INVOKERESULT_INVALID_VALUE;
case ID_audio_channel:
{
char *psz_channel = NULL;
if( ! NPVARIANT_IS_STRING(value) )
{
return INVOKERESULT_INVALID_VALUE;
}
psz_channel = stringValue(NPVARIANT_TO_STRING(value));
if( !psz_channel )
return INVOKERESULT_GENERIC_ERROR;
libvlc_audio_set_channel(p_plugin->getVLC(), psz_channel, &ex);
if( psz_channel )
free( psz_channel );
if( libvlc_exception_raised(&ex) )
{
NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR;
}
return INVOKERESULT_NO_ERROR;
}
default: default:
; ;
} }
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
* $Id$ * $Id$
* *
* Authors: Filippo Carone <filippo@carone.org> * Authors: Filippo Carone <filippo@carone.org>
* Jean-Paul Saman <jpsaman _at_ m2x _dot_ nl>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
...@@ -90,3 +91,99 @@ void libvlc_audio_set_volume( libvlc_instance_t *p_instance, int i_volume, ...@@ -90,3 +91,99 @@ void libvlc_audio_set_volume( libvlc_instance_t *p_instance, int i_volume,
} }
} }
/*****************************************************************************
* libvlc_audio_get_track : Get the current audio track
*****************************************************************************/
int libvlc_audio_get_track( libvlc_instance_t *p_instance,
libvlc_exception_t *p_e )
{
int i_track = 0;
i_track = var_GetInteger( p_instance->p_libvlc_int, "audio-track" );
return i_track;
}
/*****************************************************************************
* libvlc_audio_set_track : Set the current audio track
*****************************************************************************/
void libvlc_audio_set_track( libvlc_instance_t *p_instance, int i_track,
libvlc_exception_t *p_e )
{
int i_ret = -1;
i_ret = var_SetInteger( p_instance->p_libvlc_int, "audio-track", i_track );
if( i_ret < 0 )
{
libvlc_exception_raise( p_e, "Audio track out of range" );
}
}
/*****************************************************************************
* libvlc_audio_get_channel : Get the current audio channel
*****************************************************************************/
char *libvlc_audio_get_channel( libvlc_instance_t *p_instance,
libvlc_exception_t *p_e )
{
char *psz_channel = NULL;
int i_channel = 0;
i_channel = var_GetInteger( p_instance->p_libvlc_int, "audio-channel" );
switch( i_channel )
{
case AOUT_VAR_CHAN_RSTEREO:
psz_channel = strdup("reverse");
break;
case AOUT_VAR_CHAN_STEREO:
psz_channel = strdup("stereo");
break;
case AOUT_VAR_CHAN_LEFT:
psz_channel = strdup("left");
break;
case AOUT_VAR_CHAN_RIGHT:
psz_channel = strdup("right");
break;
case AOUT_VAR_CHAN_DOLBYS:
psz_channel = strdup("dolby");
break;
default:
psz_channel = strdup("disabled");
break;
}
return psz_channel;
}
/*****************************************************************************
* libvlc_audio_set_channel : Set the current audio channel
*****************************************************************************/
void libvlc_audio_set_channel( libvlc_instance_t *p_instance, char *psz_channel,
libvlc_exception_t *p_e )
{
int i_ret = -1;
int i_channel = 0;
if( !psz_channel )
{
libvlc_exception_raise( p_e, "Audio track out of range" );
}
else
{
if( strncmp( psz_channel, "reverse", 7 ) == 0 )
i_channel = AOUT_VAR_CHAN_RSTEREO;
else if( strncmp( psz_channel, "stereo", 6 ) == 0 )
i_channel = AOUT_VAR_CHAN_STEREO;
else if( strncmp( psz_channel, "left", 4 ) == 0 )
i_channel = AOUT_VAR_CHAN_LEFT;
else if( strncmp( psz_channel, "right", 5 ) == 0 )
i_channel = AOUT_VAR_CHAN_RIGHT;
else if( strncmp( psz_channel, "dolby", 5 ) == 0 )
i_channel = AOUT_VAR_CHAN_DOLBYS;
i_ret = var_SetInteger( p_instance->p_libvlc_int, "audio-channel", i_channel );
if( i_ret < 0 )
{
libvlc_exception_raise( p_e, "Audio track out of range" );
}
}
}
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