Commit 0e37071a authored by Jean-Paul Saman's avatar Jean-Paul Saman

Backport of rev [18432] [19304] [19383] with audio.track audio.channel and video.subtitle support.

parent dfbb4a96
...@@ -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 [1-5] indicating; stereo, reverse stereo, left, right, dolby.")]
HRESULT channel([out, retval] long* channel);
[propput, helpstring("Sets audio channel to [1-5] indicating; stereo, reverse stereo, left, right, dolby.")]
HRESULT channel([in] long channel);
}; };
[ [
...@@ -411,6 +422,11 @@ library AXVLC ...@@ -411,6 +422,11 @@ library AXVLC
[propput, helpstring("Sets video aspect ratio.")] [propput, helpstring("Sets video aspect ratio.")]
HRESULT aspectRatio([in] BSTR aspect); HRESULT aspectRatio([in] BSTR aspect);
[propget, helpstring("Returns video subtitle used.")]
HRESULT subtitle([out, retval] long* spu);
[propput, helpstring("Sets video subtitle to use.")]
HRESULT subtitle([in] long spu);
[helpstring("toggle fullscreen/windowed state.")] [helpstring("toggle fullscreen/windowed state.")]
HRESULT toggleFullscreen(); HRESULT toggleFullscreen();
}; };
......
/*** Autogenerated by WIDL 0.9.30 from axvlc.idl - Do not edit ***/
/* this ALWAYS GENERATED file contains the IIDs and CLSIDs */
/* link this file in with the server and any clients */
/* File created by MIDL compiler version 6.00.0361 */
/* at Fri Dec 08 20:17:16 2006
*/
/* Compiler settings for axvlc.idl:
Oicf, W1, Zp8, env=Win32 (32b run)
protocol : dce , ms_ext, c_ext, robust
error checks: allocation ref bounds_check enum stub_data
VC __declspec() decoration level:
__declspec(uuid()), __declspec(selectany), __declspec(novtable)
DECLSPEC_UUID(), MIDL_INTERFACE()
*/
//@@MIDL_FILE_HEADING( )
#if !defined(_M_IA64) && !defined(_M_AMD64)
#pragma warning( disable: 4049 ) /* more than 64k source lines */
#ifdef __cplusplus
extern "C"{
#endif
#include <rpc.h> #include <rpc.h>
#include <rpcndr.h> #include <rpcndr.h>
#ifdef _MIDL_USE_GUIDDEF_
#ifndef INITGUID
#define INITGUID #define INITGUID
#include <guiddef.h> #include <guiddef.h>
#undef INITGUID
#else
#include <guiddef.h>
#endif
#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
DEFINE_GUID(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8)
#else // !_MIDL_USE_GUIDDEF_
#ifndef __IID_DEFINED__
#define __IID_DEFINED__
typedef struct _IID
{
unsigned long x;
unsigned short s1;
unsigned short s2;
unsigned char c[8];
} IID;
#endif // __IID_DEFINED__
#ifndef CLSID_DEFINED
#define CLSID_DEFINED
typedef IID CLSID;
#endif // CLSID_DEFINED
#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
const type name = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}
#endif !_MIDL_USE_GUIDDEF_
MIDL_DEFINE_GUID(IID, LIBID_AXVLC,0xDF2BBE39,0x40A8,0x433b,0xA2,0x79,0x07,0x3F,0x48,0xDA,0x94,0xB6);
MIDL_DEFINE_GUID(IID, IID_IVLCControl,0xC2FA41D0,0xB113,0x476e,0xAC,0x8C,0x9B,0xD1,0x49,0x99,0xC1,0xC1);
MIDL_DEFINE_GUID(IID, IID_IVLCAudio,0x9E0BD17B,0x2D3C,0x4656,0xB9,0x4D,0x03,0x08,0x4F,0x3F,0xD9,0xD4);
#ifdef __cplusplus
extern "C" {
#endif
MIDL_DEFINE_GUID(IID, IID_IVLCInput,0x49E0DBD1,0x9440,0x466C,0x9C,0x97,0x95,0xC6,0x71,0x90,0xC6,0x03); DEFINE_GUID(LIBID_AXVLC, 0xdf2bbe39, 0x40a8, 0x433b, 0xa2,0x79, 0x07,0x3f,0x48,0xda,0x94,0xb6);
DEFINE_GUID(IID_IVLCControl, 0xc2fa41d0, 0xb113, 0x476e, 0xac,0x8c, 0x9b,0xd1,0x49,0x99,0xc1,0xc1);
DEFINE_GUID(DIID_DVLCEvents, 0xdf48072f, 0x5ef8, 0x434e, 0x9b,0x40, 0xe2,0xf3,0xae,0x75,0x9b,0x5f);
MIDL_DEFINE_GUID(IID, IID_IVLCLog,0x8E3BC3D9,0x62E9,0x48FB,0x8A,0x6D,0x99,0x3F,0x9A,0xBC,0x4A,0x0A); DEFINE_GUID(IID_IVLCAudio, 0x9e0bd17b, 0x2d3c, 0x4656, 0xb9,0x4d, 0x03,0x08,0x4f,0x3f,0xd9,0xd4);
DEFINE_GUID(IID_IVLCInput, 0x49e0dbd1, 0x9440, 0x466c, 0x9c,0x97, 0x95,0xc6,0x71,0x90,0xc6,0x03);
DEFINE_GUID(IID_IVLCMessage, 0x9ed00afa, 0x7bcd, 0x4fff, 0x8d,0x48, 0x7d,0xd4,0xdb,0x2c,0x80,0x0d);
MIDL_DEFINE_GUID(IID, IID_IVLCMessage,0x9ED00AFA,0x7BCD,0x4FFF,0x8D,0x48,0x7D,0xD4,0xDB,0x2C,0x80,0x0D); DEFINE_GUID(IID_IVLCMessageIterator, 0x15179cd8, 0xcc12, 0x4242, 0xa5,0x8e, 0xe4,0x12,0x21,0x7f,0xf3,0x43);
DEFINE_GUID(IID_IVLCMessages, 0x6c5ce55d, 0x2d6c, 0x4aad, 0x82,0x99, 0xc6,0x2d,0x23,0x71,0xf1,0x06);
DEFINE_GUID(IID_IVLCLog, 0x8e3bc3d9, 0x62e9, 0x48fb, 0x8a,0x6d, 0x99,0x3f,0x9a,0xbc,0x4a,0x0a);
MIDL_DEFINE_GUID(IID, IID_IVLCMessageIterator,0x15179CD8,0xCC12,0x4242,0xA5,0x8E,0xE4,0x12,0x21,0x7F,0xF3,0x43); DEFINE_GUID(IID_IVLCPlaylistItems, 0xfd37fe32, 0x82bc, 0x4a25, 0xb0,0x56, 0x31,0x5f,0x4d,0xbb,0x19,0x4d);
DEFINE_GUID(IID_IVLCPlaylist, 0x54613049, 0x40bf, 0x4035, 0x9e,0x70, 0x0a,0x93,0x12,0xc0,0x18,0x8d);
DEFINE_GUID(IID_IVLCVideo, 0x0aaedf0b, 0xd333, 0x4b27, 0xa0,0xc6, 0xbb,0xf3,0x14,0x13,0xa4,0x2e);
MIDL_DEFINE_GUID(IID, IID_IVLCMessages,0x6C5CE55D,0x2D6C,0x4AAD,0x82,0x99,0xC6,0x2D,0x23,0x71,0xF1,0x06); DEFINE_GUID(IID_IVLCControl2, 0x2d719729, 0x5333, 0x406c, 0xbf,0x12, 0x8d,0xe7,0x87,0xfd,0x65,0xe3);
DEFINE_GUID(CLSID_VLCPlugin, 0xe23fe9c6, 0x778e, 0x49d4, 0xb5,0x37, 0x38,0xfc,0xde,0x48,0x87,0xd8);
DEFINE_GUID(CLSID_VLCPlugin2, 0x9be31822, 0xfdad, 0x461b, 0xad,0x51, 0xbe,0x1d,0x1c,0x15,0x99,0x21);
MIDL_DEFINE_GUID(IID, IID_IVLCPlaylist,0x54613049,0x40BF,0x4035,0x9E,0x70,0x0A,0x93,0x12,0xC0,0x18,0x8D);
MIDL_DEFINE_GUID(IID, IID_IVLCVideo,0x0AAEDF0B,0xD333,0x4B27,0xA0,0xC6,0xBB,0xF3,0x14,0x13,0xA4,0x2E);
MIDL_DEFINE_GUID(IID, IID_IVLCControl2,0x2D719729,0x5333,0x406C,0xBF,0x12,0x8D,0xE7,0x87,0xFD,0x65,0xE3);
MIDL_DEFINE_GUID(IID, DIID_DVLCEvents,0xDF48072F,0x5EF8,0x434e,0x9B,0x40,0xE2,0xF3,0xAE,0x75,0x9B,0x5F);
MIDL_DEFINE_GUID(IID, IID_IVLCPlaylistItems,0xFD37FE32,0x82BC,0x4A25,0xB0,0x56,0x31,0x5F,0x4D,0xBB,0x19,0x4D);
MIDL_DEFINE_GUID(CLSID, CLSID_VLCPlugin,0xE23FE9C6,0x778E,0x49D4,0xB5,0x37,0x38,0xFC,0xDE,0x48,0x87,0xD8);
MIDL_DEFINE_GUID(CLSID, CLSID_VLCPlugin2,0x9BE31822,0xFDAD,0x461B,0xAD,0x51,0xBE,0x1D,0x1C,0x15,0x99,0x21);
#undef MIDL_DEFINE_GUID
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* !defined(_M_IA64) && !defined(_M_AMD64)*/
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -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,8 +199,11 @@ STDMETHODIMP VLCAudio::put_volume(long volume) ...@@ -198,8 +199,11 @@ STDMETHODIMP VLCAudio::put_volume(long volume)
return hr; return hr;
}; };
STDMETHODIMP VLCAudio::toggleMute() STDMETHODIMP VLCAudio::get_track(long* track)
{ {
if( NULL == track )
return E_POINTER;
libvlc_instance_t* p_libvlc; libvlc_instance_t* p_libvlc;
HRESULT hr = _p_instance->getVLC(&p_libvlc); HRESULT hr = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(hr) ) if( SUCCEEDED(hr) )
...@@ -207,7 +211,9 @@ STDMETHODIMP VLCAudio::toggleMute() ...@@ -207,7 +211,9 @@ STDMETHODIMP VLCAudio::toggleMute()
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_audio_toggle_mute(p_libvlc, &ex); libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
*track = libvlc_audio_get_track(p_input, &ex);
libvlc_input_free(p_input);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
_p_instance->setErrorInfo(IID_IVLCAudio, libvlc_exception_get_message(&ex)); _p_instance->setErrorInfo(IID_IVLCAudio, libvlc_exception_get_message(&ex));
...@@ -219,6 +225,98 @@ STDMETHODIMP VLCAudio::toggleMute() ...@@ -219,6 +225,98 @@ STDMETHODIMP VLCAudio::toggleMute()
return hr; 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_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
libvlc_audio_set_track(p_input, track, &ex);
libvlc_input_free(p_input);
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(long *channel)
{
if( NULL == channel )
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);
*channel = libvlc_audio_get_channel(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_channel(long channel)
{
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_channel(p_libvlc, channel, &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::toggleMute()
{
libvlc_instance_t* p_libvlc = NULL;
HRESULT hr = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_audio_toggle_mute(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;
};
/*******************************************************************************/ /*******************************************************************************/
VLCInput::~VLCInput() VLCInput::~VLCInput()
...@@ -527,6 +625,7 @@ STDMETHODIMP VLCInput::get_fps(double* fps) ...@@ -527,6 +625,7 @@ STDMETHODIMP VLCInput::get_fps(double* fps)
if( NULL == fps ) if( NULL == fps )
return E_POINTER; return E_POINTER;
*fps = 0.0;
libvlc_instance_t* p_libvlc; libvlc_instance_t* p_libvlc;
HRESULT hr = _p_instance->getVLC(&p_libvlc); HRESULT hr = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(hr) ) if( SUCCEEDED(hr) )
...@@ -1974,12 +2073,13 @@ STDMETHODIMP VLCVideo::get_aspectRatio(BSTR* aspect) ...@@ -1974,12 +2073,13 @@ STDMETHODIMP VLCVideo::get_aspectRatio(BSTR* aspect)
if( NULL == psz_aspect ) if( NULL == psz_aspect )
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
*aspect = SysAllocStringByteLen(psz_aspect, strlen(psz_aspect)); *aspect = BSTRFromCStr(CP_UTF8, psz_aspect);
free( psz_aspect ); free( psz_aspect );
psz_aspect = NULL; psz_aspect = NULL;
return NOERROR; return (NULL == aspect) ? E_OUTOFMEMORY : NOERROR;
} }
if( psz_aspect ) free( psz_aspect ); if( psz_aspect ) free( psz_aspect );
psz_aspect = NULL;
} }
_p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex)); _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
...@@ -2009,9 +2109,7 @@ STDMETHODIMP VLCVideo::put_aspectRatio(BSTR aspect) ...@@ -2009,9 +2109,7 @@ STDMETHODIMP VLCVideo::put_aspectRatio(BSTR aspect)
{ {
psz_aspect = CStrFromBSTR(CP_UTF8, aspect); psz_aspect = CStrFromBSTR(CP_UTF8, aspect);
if( NULL == psz_aspect ) if( NULL == psz_aspect )
{
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
}
libvlc_video_set_aspect_ratio(p_input, psz_aspect, &ex); libvlc_video_set_aspect_ratio(p_input, psz_aspect, &ex);
...@@ -2030,6 +2128,58 @@ STDMETHODIMP VLCVideo::put_aspectRatio(BSTR aspect) ...@@ -2030,6 +2128,58 @@ STDMETHODIMP VLCVideo::put_aspectRatio(BSTR aspect)
return hr; return hr;
}; };
STDMETHODIMP VLCVideo::get_subtitle(long* spu)
{
if( NULL == spu )
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);
libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
if( ! libvlc_exception_raised(&ex) )
{
*spu = libvlc_video_get_spu(p_input, &ex);
libvlc_input_free(p_input);
if( ! libvlc_exception_raised(&ex) )
{
return NOERROR;
}
}
_p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
return hr;
};
STDMETHODIMP VLCVideo::put_subtitle(long spu)
{
libvlc_instance_t* p_libvlc;
HRESULT hr = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
libvlc_video_set_spu(p_input, spu, &ex);
libvlc_input_free(p_input);
if( libvlc_exception_raised(&ex) )
{
_p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
return NOERROR;
}
return hr;
};
STDMETHODIMP VLCVideo::toggleFullscreen() STDMETHODIMP VLCVideo::toggleFullscreen()
{ {
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(long*);
STDMETHODIMP put_channel(long);
STDMETHODIMP toggleMute(); STDMETHODIMP toggleMute();
protected: protected:
...@@ -517,6 +522,8 @@ public: ...@@ -517,6 +522,8 @@ public:
STDMETHODIMP get_height(long*); STDMETHODIMP get_height(long*);
STDMETHODIMP get_aspectRatio(BSTR*); STDMETHODIMP get_aspectRatio(BSTR*);
STDMETHODIMP put_aspectRatio(BSTR); STDMETHODIMP put_aspectRatio(BSTR);
STDMETHODIMP get_subtitle(long*);
STDMETHODIMP put_subtitle(long);
STDMETHODIMP toggleFullscreen(); STDMETHODIMP toggleFullscreen();
protected: protected:
...@@ -530,7 +537,6 @@ private: ...@@ -530,7 +537,6 @@ private:
class VLCControl2 : public IVLCControl2 class VLCControl2 : public IVLCControl2
{ {
public: public:
VLCControl2(VLCPlugin *p_instance); VLCControl2(VLCPlugin *p_instance);
...@@ -599,4 +605,3 @@ private: ...@@ -599,4 +605,3 @@ private:
}; };
#endif #endif
...@@ -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)
...@@ -195,11 +199,20 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVari ...@@ -195,11 +199,20 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVari
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_input_t *p_input = libvlc_playlist_get_input(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;
}
switch( index ) switch( index )
{ {
case ID_audio_mute: case ID_audio_mute:
{ {
vlc_bool_t muted = libvlc_audio_get_mute(p_plugin->getVLC(), &ex); vlc_bool_t muted = libvlc_audio_get_mute(p_plugin->getVLC(), &ex);
libvlc_input_free(p_input);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
NPN_SetException(this, libvlc_exception_get_message(&ex)); NPN_SetException(this, libvlc_exception_get_message(&ex));
...@@ -212,6 +225,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVari ...@@ -212,6 +225,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVari
case ID_audio_volume: case ID_audio_volume:
{ {
int volume = libvlc_audio_get_volume(p_plugin->getVLC(), &ex); int volume = libvlc_audio_get_volume(p_plugin->getVLC(), &ex);
libvlc_input_free(p_input);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
NPN_SetException(this, libvlc_exception_get_message(&ex)); NPN_SetException(this, libvlc_exception_get_message(&ex));
...@@ -221,9 +235,36 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVari ...@@ -221,9 +235,36 @@ 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_input, &ex);
libvlc_input_free(p_input);
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:
{
int channel = libvlc_audio_get_channel(p_plugin->getVLC(), &ex);
libvlc_input_free(p_input);
if( libvlc_exception_raised(&ex) )
{
NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR;
}
INT32_TO_NPVARIANT(channel, result);
return INVOKERESULT_NO_ERROR;
}
default: default:
; ;
} }
libvlc_input_free(p_input);
} }
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
} }
...@@ -236,6 +277,14 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::setProperty(int index, const ...@@ -236,6 +277,14 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::setProperty(int index, const
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_input_t *p_input = libvlc_playlist_get_input(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;
}
switch( index ) switch( index )
{ {
case ID_audio_mute: case ID_audio_mute:
...@@ -243,6 +292,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::setProperty(int index, const ...@@ -243,6 +292,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::setProperty(int index, const
{ {
libvlc_audio_set_mute(p_plugin->getVLC(), libvlc_audio_set_mute(p_plugin->getVLC(),
NPVARIANT_TO_BOOLEAN(value), &ex); NPVARIANT_TO_BOOLEAN(value), &ex);
libvlc_input_free(p_input);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
NPN_SetException(this, libvlc_exception_get_message(&ex)); NPN_SetException(this, libvlc_exception_get_message(&ex));
...@@ -251,12 +301,14 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::setProperty(int index, const ...@@ -251,12 +301,14 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::setProperty(int index, const
} }
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
libvlc_input_free(p_input);
return INVOKERESULT_INVALID_VALUE; return INVOKERESULT_INVALID_VALUE;
case ID_audio_volume: case ID_audio_volume:
if( isNumberValue(value) ) if( isNumberValue(value) )
{ {
libvlc_audio_set_volume(p_plugin->getVLC(), libvlc_audio_set_volume(p_plugin->getVLC(),
numberValue(value), &ex); numberValue(value), &ex);
libvlc_input_free(p_input);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
NPN_SetException(this, libvlc_exception_get_message(&ex)); NPN_SetException(this, libvlc_exception_get_message(&ex));
...@@ -265,10 +317,45 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::setProperty(int index, const ...@@ -265,10 +317,45 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::setProperty(int index, const
} }
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
libvlc_input_free(p_input);
return INVOKERESULT_INVALID_VALUE; return INVOKERESULT_INVALID_VALUE;
case ID_audio_track:
if( isNumberValue(value) )
{
libvlc_audio_set_track(p_input,
numberValue(value), &ex);
libvlc_input_free(p_input);
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;
}
libvlc_input_free(p_input);
return INVOKERESULT_INVALID_VALUE;
case ID_audio_channel:
{
libvlc_input_free(p_input);
if( isNumberValue(value) )
{
libvlc_audio_set_channel(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;
}
default: default:
; ;
} }
libvlc_input_free(p_input);
} }
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
} }
...@@ -1676,7 +1763,8 @@ const NPUTF8 * const LibvlcVideoNPObject::propertyNames[] = ...@@ -1676,7 +1763,8 @@ const NPUTF8 * const LibvlcVideoNPObject::propertyNames[] =
"fullscreen", "fullscreen",
"height", "height",
"width", "width",
"aspectRatio" "aspectRatio",
"subtitle"
}; };
enum LibvlcVideoNPObjectPropertyIds enum LibvlcVideoNPObjectPropertyIds
...@@ -1684,7 +1772,8 @@ enum LibvlcVideoNPObjectPropertyIds ...@@ -1684,7 +1772,8 @@ enum LibvlcVideoNPObjectPropertyIds
ID_video_fullscreen, ID_video_fullscreen,
ID_video_height, ID_video_height,
ID_video_width, ID_video_width,
ID_video_aspectratio ID_video_aspectratio,
ID_video_subtitle
}; };
const int LibvlcVideoNPObject::propertyCount = sizeof(LibvlcVideoNPObject::propertyNames)/sizeof(NPUTF8 *); const int LibvlcVideoNPObject::propertyCount = sizeof(LibvlcVideoNPObject::propertyNames)/sizeof(NPUTF8 *);
...@@ -1762,6 +1851,19 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::getProperty(int index, NPVari ...@@ -1762,6 +1851,19 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::getProperty(int index, NPVari
STRINGZ_TO_NPVARIANT(psz_aspect, result); STRINGZ_TO_NPVARIANT(psz_aspect, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_video_subtitle:
{
int i_spu = libvlc_video_get_spu(p_input, &ex);
libvlc_input_free(p_input);
if( libvlc_exception_raised(&ex) )
{
NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR;
}
INT32_TO_NPVARIANT(i_spu, result);
return INVOKERESULT_NO_ERROR;
}
} }
libvlc_input_free(p_input); libvlc_input_free(p_input);
} }
...@@ -1817,7 +1919,10 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::setProperty(int index, const ...@@ -1817,7 +1919,10 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::setProperty(int index, const
psz_aspect = stringValue(NPVARIANT_TO_STRING(value)); psz_aspect = stringValue(NPVARIANT_TO_STRING(value));
if( !psz_aspect ) if( !psz_aspect )
{
libvlc_input_free(p_input);
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
}
libvlc_video_set_aspect_ratio(p_input, psz_aspect, &ex); libvlc_video_set_aspect_ratio(p_input, psz_aspect, &ex);
if( psz_aspect ) if( psz_aspect )
...@@ -1832,6 +1937,24 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::setProperty(int index, const ...@@ -1832,6 +1937,24 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::setProperty(int index, const
} }
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_video_subtitle:
{
if( isNumberValue(value) )
{
libvlc_video_set_spu(p_input,
numberValue(value), &ex);
libvlc_input_free(p_input);
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;
}
libvlc_input_free(p_input);
return INVOKERESULT_INVALID_VALUE;
}
} }
libvlc_input_free(p_input); libvlc_input_free(p_input);
} }
...@@ -1902,4 +2025,3 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::invoke(int index, const NPVar ...@@ -1902,4 +2025,3 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::invoke(int index, const NPVar
} }
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
} }
...@@ -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
...@@ -24,8 +25,56 @@ ...@@ -24,8 +25,56 @@
#include <libvlc_internal.h> #include <libvlc_internal.h>
#include <vlc/libvlc.h> #include <vlc/libvlc.h>
#include <audio_output.h> /* for audio_volume_t, AOUT_VOLUME_MAX */ #include <vlc/aout.h>
#include <vlc/intf.h> #include <vlc/intf.h>
#include <audio_output.h> /* for audio_volume_t, AOUT_VOLUME_MAX */
#include <aout_internal.h>
/*
* Remember to release the returned input_thread_t since it is locked at
* the end of this function.
*/
static input_thread_t *GetInput( libvlc_input_t *p_input,
libvlc_exception_t *p_exception )
{
input_thread_t *p_input_thread = NULL;
if( !p_input )
{
libvlc_exception_raise( p_exception, "Input is NULL" );
return NULL;
}
p_input_thread = (input_thread_t*)vlc_object_get(
p_input->p_instance->p_vlc,
p_input->i_input_id );
if( !p_input_thread )
{
libvlc_exception_raise( p_exception, "Input does not exist" );
return NULL;
}
return p_input_thread;
}
/*
* Remember to release the returned aout_instance_t since it is locked at
* the end of this function.
*/
static aout_instance_t *GetAOut( libvlc_instance_t *p_instance,
libvlc_exception_t *p_exception )
{
aout_instance_t * p_aout = NULL;
p_aout = vlc_object_find( p_instance->p_vlc, VLC_OBJECT_AOUT, FIND_CHILD );
if( !p_aout )
{
libvlc_exception_raise( p_exception, "No active audio output" );
return NULL;
}
return p_aout;
}
/***************************************************************************** /*****************************************************************************
* libvlc_audio_get_mute : Get the volume state, true if muted * libvlc_audio_get_mute : Get the volume state, true if muted
...@@ -100,3 +149,129 @@ void libvlc_audio_set_volume( libvlc_instance_t *p_instance, int i_volume, ...@@ -100,3 +149,129 @@ 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_input_t *p_input,
libvlc_exception_t *p_e )
{
input_thread_t *p_input_thread = GetInput( p_input, p_e );
vlc_value_t val_list;
vlc_value_t val;
int i_track = -1;
int i_ret = -1;
int i;
if( !p_input_thread )
return -1;
i_ret = var_Get( p_input_thread, "audio-es", &val );
if( i_ret < 0 )
{
libvlc_exception_raise( p_e, "Getting Audio track information failed" );
vlc_object_release( p_input_thread );
return i_ret;
}
var_Change( p_input_thread, "audio-es", VLC_VAR_GETCHOICES, &val_list, NULL );
for( i = 0; i < val_list.p_list->i_count; i++ )
{
vlc_value_t track_val = val_list.p_list->p_values[i];
if( track_val.i_int == val.i_int )
{
i_track = i;
break;
}
}
vlc_object_release( p_input_thread );
return i_track;
}
/*****************************************************************************
* libvlc_audio_set_track : Set the current audio track
*****************************************************************************/
void libvlc_audio_set_track( libvlc_input_t *p_input, int i_track,
libvlc_exception_t *p_e )
{
input_thread_t *p_input_thread = GetInput( p_input, p_e );
vlc_value_t val_list;
int i_ret = -1;
int i;
if( !p_input_thread )
return -1;
var_Change( p_input_thread, "audio-es", VLC_VAR_GETCHOICES, &val_list, NULL );
for( i = 0; i < val_list.p_list->i_count; i++ )
{
vlc_value_t val = val_list.p_list->p_values[i];
if( i_track == i )
{
i_ret = var_Set( p_input_thread, "audio-es", val );
if( i_ret < 0 )
{
libvlc_exception_raise( p_e, "Setting audio track failed" );
}
vlc_object_release( p_input_thread );
return;
}
}
libvlc_exception_raise( p_e, "Audio track out of range" );
vlc_object_release( p_input_thread );
}
/*****************************************************************************
* libvlc_audio_get_channel : Get the current audio channel
*****************************************************************************/
int libvlc_audio_get_channel( libvlc_instance_t *p_instance,
libvlc_exception_t *p_e )
{
aout_instance_t *p_aout = GetAOut( p_instance, p_e );
if( p_aout )
{
vlc_value_t val;
var_Get( p_aout, "audio-channels", &val );
vlc_object_release( p_aout );
return val.i_int;
}
return -1;
}
/*****************************************************************************
* libvlc_audio_set_channel : Set the current audio channel
*****************************************************************************/
void libvlc_audio_set_channel( libvlc_instance_t *p_instance, int i_channel,
libvlc_exception_t *p_e )
{
aout_instance_t *p_aout = GetAOut( p_instance, p_e );
vlc_value_t val;
int i_ret = -1;
if( !p_aout )
return;
val.i_int = i_channel;
switch( i_channel )
{
case AOUT_VAR_CHAN_RSTEREO:
case AOUT_VAR_CHAN_STEREO:
case AOUT_VAR_CHAN_LEFT:
case AOUT_VAR_CHAN_RIGHT:
case AOUT_VAR_CHAN_DOLBYS:
i_ret = var_Set( p_aout, "audio-channels", val );
if( i_ret < 0 )
{
libvlc_exception_raise( p_e, "Failed setting audio channel" );
vlc_object_release( p_aout );
return;
}
vlc_object_release( p_aout );
return;
default:
libvlc_exception_raise( p_e, "Audio channel out of range" );
break;
}
vlc_object_release( p_aout );
}
...@@ -29,6 +29,33 @@ ...@@ -29,6 +29,33 @@
#include <vlc/vout.h> #include <vlc/vout.h>
#include <vlc/intf.h> #include <vlc/intf.h>
/*
* Remember to release the returned input_thread_t since it is locked at
* the end of this function.
*/
static input_thread_t *GetInput( libvlc_input_t *p_input,
libvlc_exception_t *p_exception )
{
input_thread_t *p_input_thread = NULL;
if( !p_input )
{
libvlc_exception_raise( p_exception, "Input is NULL" );
return NULL;
}
p_input_thread = (input_thread_t*)vlc_object_get(
p_input->p_instance->p_vlc,
p_input->i_input_id );
if( !p_input_thread )
{
libvlc_exception_raise( p_exception, "Input does not exist" );
return NULL;
}
return p_input_thread;
}
/* /*
* Remember to release the returned vout_thread_t since it is locked at * Remember to release the returned vout_thread_t since it is locked at
* the end of this function. * the end of this function.
...@@ -351,6 +378,74 @@ void libvlc_video_set_aspect_ratio( libvlc_input_t *p_input, ...@@ -351,6 +378,74 @@ void libvlc_video_set_aspect_ratio( libvlc_input_t *p_input,
vlc_object_release( p_vout ); vlc_object_release( p_vout );
} }
int libvlc_video_get_spu( libvlc_input_t *p_input,
libvlc_exception_t *p_e )
{
input_thread_t *p_input_thread = GetInput( p_input, p_e );
vlc_value_t val_list;
vlc_value_t val;
int i_spu = -1;
int i_ret = -1;
int i;
if( !p_input_thread )
return -1;
i_ret = var_Get( p_input_thread, "spu-es", &val );
if( i_ret < 0 )
{
libvlc_exception_raise( p_e, "Getting subtitle information failed" );
vlc_object_release( p_input_thread );
return i_ret;
}
var_Change( p_input_thread, "spu-es", VLC_VAR_GETCHOICES, &val_list, NULL );
for( i = 0; i < val_list.p_list->i_count; i++ )
{
vlc_value_t spu_val = val_list.p_list->p_values[i];
if( val.i_int == spu_val.i_int )
{
i_spu = i;
break;
}
}
vlc_object_release( p_input_thread );
return i_spu;
}
void libvlc_video_set_spu( libvlc_input_t *p_input, int i_spu,
libvlc_exception_t *p_e )
{
input_thread_t *p_input_thread = GetInput( p_input, p_e );
vlc_value_t val_list;
int i_ret = -1;
int i;
if( !p_input_thread )
return;
var_Change( p_input_thread, "spu-es", VLC_VAR_GETCHOICES, &val_list, NULL );
for( i = 0; i < val_list.p_list->i_count; i++ )
{
vlc_value_t val = val_list.p_list->p_values[i];
if( i_spu == i )
{
vlc_value_t new_val;
new_val.i_int = val.i_int;
i_ret = var_Set( p_input_thread, "spu-es", new_val );
if( i_ret < 0 )
{
libvlc_exception_raise( p_e, "Setting subtitle value failed" );
}
vlc_object_release( p_input_thread );
return;
}
}
libvlc_exception_raise( p_e, "Subtitle value out of range" );
vlc_object_release( p_input_thread );
}
int libvlc_video_destroy( libvlc_input_t *p_input, int libvlc_video_destroy( libvlc_input_t *p_input,
libvlc_exception_t *p_e ) libvlc_exception_t *p_e )
{ {
......
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