1
/*****************************************************************************
2
* vlccontrol2.cpp: ActiveX control for VLC
3
*****************************************************************************
4
* Copyright (C) 2006 the VideoLAN team
5
* Copyright (C) 2010 M2X BV
7
* Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
8
* Jean-Paul Saman <jpsaman _at_ m2x _dot_ nl>
10
* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version.
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
20
* You should have received a copy of the GNU General Public License along
21
* with this program; if not, write to the Free Software Foundation, Inc.,
22
* 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23
*****************************************************************************/
32
#include "vlccontrol2.h"
33
#include "vlccontrol.h"
39
HRESULT VLCInterfaceBase::loadTypeInfo(REFIID riid)
41
// if( _ti ) return NOERROR; // unnecessairy
44
HRESULT hr = _plug->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
47
hr = p_typelib->GetTypeInfoOfGuid(riid, &_ti);
48
if( FAILED(hr) ) _ti = NULL;
54
#define BIND_INTERFACE( class ) \
55
template<> REFIID VLCInterface<class, I##class>::_riid = IID_I##class;
57
BIND_INTERFACE( VLCAudio )
58
BIND_INTERFACE( VLCInput )
59
BIND_INTERFACE( VLCMarquee )
60
BIND_INTERFACE( VLCLogo )
61
BIND_INTERFACE( VLCDeinterlace )
62
BIND_INTERFACE( VLCPlaylistItems )
63
BIND_INTERFACE( VLCPlaylist )
64
BIND_INTERFACE( VLCVideo )
65
BIND_INTERFACE( VLCSubtitle )
69
template<class I> static inline
70
HRESULT object_get(I **dst, I *src)
85
VARIANT_BOOL varbool(bool b) { return b ? VARIANT_TRUE : VARIANT_FALSE; }
89
STDMETHODIMP VLCAudio::get_mute(VARIANT_BOOL* mute)
94
libvlc_media_player_t *p_md;
95
HRESULT hr = getMD(&p_md);
97
*mute = varbool( libvlc_audio_get_mute(p_md) );
101
STDMETHODIMP VLCAudio::put_mute(VARIANT_BOOL mute)
103
libvlc_media_player_t *p_md;
104
HRESULT hr = getMD(&p_md);
106
libvlc_audio_set_mute(p_md, VARIANT_FALSE != mute);
110
STDMETHODIMP VLCAudio::get_volume(long* volume)
115
libvlc_media_player_t *p_md;
116
HRESULT hr = getMD(&p_md);
118
*volume = libvlc_audio_get_volume(p_md);
122
STDMETHODIMP VLCAudio::put_volume(long volume)
124
libvlc_media_player_t *p_md;
125
HRESULT hr = getMD(&p_md);
128
libvlc_audio_set_volume(p_md, volume);
133
STDMETHODIMP VLCAudio::get_track(long* track)
138
libvlc_media_player_t* p_md;
139
HRESULT hr = getMD(&p_md);
142
*track = libvlc_audio_get_track(p_md);
147
STDMETHODIMP VLCAudio::put_track(long track)
149
libvlc_media_player_t *p_md;
150
HRESULT hr = getMD(&p_md);
153
libvlc_audio_set_track(p_md, track);
158
STDMETHODIMP VLCAudio::get_count(long* trackNumber)
160
if( NULL == trackNumber )
163
libvlc_media_player_t* p_md;
164
HRESULT hr = getMD(&p_md);
167
// get the number of audio track available and return it
168
*trackNumber = libvlc_audio_get_track_count(p_md);
174
STDMETHODIMP VLCAudio::description(long trackID, BSTR* name)
179
libvlc_media_player_t* p_md;
181
HRESULT hr = getMD(&p_md);
185
const char *psz_name;
186
libvlc_track_description_t *p_trackDesc;
188
// get tracks description
189
p_trackDesc = libvlc_audio_get_track_description(p_md);
193
//get the number of available track
194
i_limit = libvlc_audio_get_track_count(p_md);
198
// check if the number given is a good one
199
if ( ( trackID > ( i_limit -1 ) ) || ( trackID < 0 ) )
202
// get the good trackDesc
203
for( i = 0 ; i < trackID ; i++ )
205
p_trackDesc = p_trackDesc->p_next;
207
// get the track name
208
psz_name = p_trackDesc->psz_name;
211
if( psz_name != NULL )
213
*name = BSTRFromCStr(CP_UTF8, psz_name);
214
return (NULL == *name) ? E_OUTOFMEMORY : NOERROR;
222
STDMETHODIMP VLCAudio::get_channel(long *channel)
224
if( NULL == channel )
227
libvlc_media_player_t *p_md;
228
HRESULT hr = getMD(&p_md);
231
*channel = libvlc_audio_get_channel(p_md);
236
STDMETHODIMP VLCAudio::put_channel(long channel)
238
libvlc_media_player_t *p_md;
239
HRESULT hr = getMD(&p_md);
242
libvlc_audio_set_channel(p_md, channel);
247
STDMETHODIMP VLCAudio::toggleMute()
249
libvlc_media_player_t *p_md;
250
HRESULT hr = getMD(&p_md);
252
libvlc_audio_toggle_mute(p_md);
256
/****************************************************************************/
258
STDMETHODIMP VLCDeinterlace::disable()
260
libvlc_media_player_t *p_md;
261
HRESULT hr = getMD(&p_md);
264
libvlc_video_set_deinterlace(p_md, "");
269
STDMETHODIMP VLCDeinterlace::enable(BSTR mode)
271
libvlc_media_player_t *p_md;
272
HRESULT hr = getMD(&p_md);
275
char *psz_mode = CStrFromBSTR(CP_UTF8, mode);
276
libvlc_video_set_deinterlace(p_md, psz_mode);
277
CoTaskMemFree(psz_mode);
282
/****************************************************************************/
284
STDMETHODIMP VLCInput::get_length(double* length)
290
libvlc_media_player_t *p_md;
291
HRESULT hr = getMD(&p_md);
294
*length = (double)libvlc_media_player_get_length(p_md);
299
STDMETHODIMP VLCInput::get_position(double* position)
301
if( NULL == position )
305
libvlc_media_player_t *p_md;
306
HRESULT hr = getMD(&p_md);
309
*position = libvlc_media_player_get_position(p_md);
314
STDMETHODIMP VLCInput::put_position(double position)
316
libvlc_media_player_t *p_md;
317
HRESULT hr = getMD(&p_md);
320
libvlc_media_player_set_position(p_md, position);
325
STDMETHODIMP VLCInput::get_time(double* time)
330
libvlc_media_player_t *p_md;
331
HRESULT hr = getMD(&p_md);
334
*time = (double)libvlc_media_player_get_time(p_md);
339
STDMETHODIMP VLCInput::put_time(double time)
341
libvlc_media_player_t *p_md;
342
HRESULT hr = getMD(&p_md);
345
libvlc_media_player_set_time(p_md, (int64_t)time);
350
STDMETHODIMP VLCInput::get_state(long* state)
355
libvlc_media_player_t *p_md;
356
HRESULT hr = getMD(&p_md);
359
*state = libvlc_media_player_get_state(p_md);
364
STDMETHODIMP VLCInput::get_rate(double* rate)
369
libvlc_media_player_t *p_md;
370
HRESULT hr = getMD(&p_md);
373
*rate = libvlc_media_player_get_rate(p_md);
378
STDMETHODIMP VLCInput::put_rate(double rate)
380
libvlc_media_player_t *p_md;
381
HRESULT hr = getMD(&p_md);
384
libvlc_media_player_set_rate(p_md, rate);
389
STDMETHODIMP VLCInput::get_fps(double* fps)
395
libvlc_media_player_t *p_md;
396
HRESULT hr = getMD(&p_md);
399
*fps = libvlc_media_player_get_fps(p_md);
404
STDMETHODIMP VLCInput::get_hasVout(VARIANT_BOOL* hasVout)
406
if( NULL == hasVout )
409
libvlc_media_player_t *p_md;
410
HRESULT hr = getMD(&p_md);
413
*hasVout = varbool( libvlc_media_player_has_vout(p_md) );
418
/****************************************************************************/
420
HRESULT VLCMarquee::do_put_int(unsigned idx, LONG val)
422
libvlc_media_player_t *p_md;
423
HRESULT hr = getMD(&p_md);
426
libvlc_video_set_marquee_int(p_md, idx, val);
431
HRESULT VLCMarquee::do_get_int(unsigned idx, LONG *val)
436
libvlc_media_player_t *p_md;
437
HRESULT hr = getMD(&p_md);
440
*val = libvlc_video_get_marquee_int(p_md, idx);
445
STDMETHODIMP VLCMarquee::get_position(BSTR* val)
451
HRESULT hr = do_get_int(libvlc_marquee_Position, &i);
453
*val = BSTRFromCStr(CP_UTF8, position_bynumber(i));
458
STDMETHODIMP VLCMarquee::put_position(BSTR val)
460
char *n = CStrFromBSTR(CP_UTF8, val);
461
if( !n ) return E_OUTOFMEMORY;
465
if( position_byname( n, i ) )
466
hr = do_put_int(libvlc_marquee_Position,i);
474
STDMETHODIMP VLCMarquee::get_text(BSTR *val)
480
libvlc_media_player_t *p_md;
481
HRESULT hr = getMD(&p_md);
484
psz = libvlc_video_get_marquee_string(p_md, libvlc_marquee_Text);
486
*val = BSTRFromCStr(CP_UTF8, psz);
491
STDMETHODIMP VLCMarquee::put_text(BSTR val)
493
libvlc_media_player_t *p_md;
494
HRESULT hr = getMD(&p_md);
497
char *psz_text = CStrFromBSTR(CP_UTF8, val);
498
libvlc_video_set_marquee_string(p_md, libvlc_marquee_Text, psz_text);
499
CoTaskMemFree(psz_text);
504
/****************************************************************************/
506
STDMETHODIMP VLCPlaylistItems::get_count(long* count)
511
*count = Instance()->playlist_count();
515
STDMETHODIMP VLCPlaylistItems::clear()
517
Instance()->playlist_clear();
521
STDMETHODIMP VLCPlaylistItems::remove(long item)
523
libvlc_instance_t* p_libvlc;
524
HRESULT hr = getVLC(&p_libvlc);
527
Instance()->playlist_delete_item(item);
532
/****************************************************************************/
534
STDMETHODIMP VLCPlaylist::get_itemCount(long* count)
540
*count = Instance()->playlist_count();
544
STDMETHODIMP VLCPlaylist::get_isPlaying(VARIANT_BOOL* isPlaying)
546
if( NULL == isPlaying )
549
libvlc_media_player_t *p_md;
550
HRESULT hr = getMD(&p_md);
553
*isPlaying = varbool( libvlc_media_player_is_playing(p_md) );
558
STDMETHODIMP VLCPlaylist::add(BSTR uri, VARIANT name, VARIANT options, long* item)
563
if( 0 == SysStringLen(uri) )
566
libvlc_instance_t* p_libvlc;
567
HRESULT hr = getVLC(&p_libvlc);
570
char *psz_uri = NULL;
571
if( SysStringLen(Instance()->getBaseURL()) > 0 )
574
** if the MRL a relative URL, we should end up with an absolute URL
576
LPWSTR abs_url = CombineURL(Instance()->getBaseURL(), uri);
577
if( NULL != abs_url )
579
psz_uri = CStrFromWSTR(CP_UTF8, abs_url, wcslen(abs_url));
580
CoTaskMemFree(abs_url);
584
psz_uri = CStrFromBSTR(CP_UTF8, uri);
590
** baseURL is empty, assume MRL is absolute
592
psz_uri = CStrFromBSTR(CP_UTF8, uri);
595
if( NULL == psz_uri )
597
return E_OUTOFMEMORY;
603
hr = VLCControl::CreateTargetOptions(CP_UTF8, &options, &ppsz_options, &i_options);
606
CoTaskMemFree(psz_uri);
610
char *psz_name = NULL;
612
VariantInit(&v_name);
613
if( SUCCEEDED(VariantChangeType(&v_name, &name, 0, VT_BSTR)) )
615
if( SysStringLen(V_BSTR(&v_name)) > 0 )
616
psz_name = CStrFromBSTR(CP_UTF8, V_BSTR(&v_name));
618
VariantClear(&v_name);
621
*item = Instance()->playlist_add_extended_untrusted(psz_uri,
622
i_options, const_cast<const char **>(ppsz_options));
624
VLCControl::FreeTargetOptions(ppsz_options, i_options);
625
CoTaskMemFree(psz_uri);
626
if( psz_name ) /* XXX Do we even need to check? */
627
CoTaskMemFree(psz_name);
632
STDMETHODIMP VLCPlaylist::play()
634
Instance()->playlist_play();
638
STDMETHODIMP VLCPlaylist::playItem(long item)
640
Instance()->playlist_play_item(item);
644
STDMETHODIMP VLCPlaylist::togglePause()
646
libvlc_media_player_t* p_md;
647
HRESULT hr = getMD(&p_md);
650
libvlc_media_player_pause(p_md);
655
STDMETHODIMP VLCPlaylist::stop()
657
libvlc_media_player_t *p_md;
658
HRESULT hr = getMD(&p_md);
661
libvlc_media_player_stop(p_md);
666
STDMETHODIMP VLCPlaylist::next()
668
Instance()->playlist_next();
672
STDMETHODIMP VLCPlaylist::prev()
674
Instance()->playlist_prev();
678
STDMETHODIMP VLCPlaylist::clear()
680
Instance()->playlist_clear();
684
STDMETHODIMP VLCPlaylist::removeItem(long item)
686
libvlc_instance_t* p_libvlc;
687
HRESULT hr = getVLC(&p_libvlc);
690
Instance()->playlist_delete_item(item);
695
STDMETHODIMP VLCPlaylist::get_items(IVLCPlaylistItems** obj)
700
*obj = _p_vlcplaylistitems;
701
if( NULL != _p_vlcplaylistitems )
703
_p_vlcplaylistitems->AddRef();
706
return E_OUTOFMEMORY;
709
/****************************************************************************/
711
STDMETHODIMP VLCSubtitle::get_track(long* spu)
716
libvlc_media_player_t *p_md;
717
HRESULT hr = getMD(&p_md);
720
*spu = libvlc_video_get_spu(p_md);
725
STDMETHODIMP VLCSubtitle::put_track(long spu)
727
libvlc_media_player_t *p_md;
728
HRESULT hr = getMD(&p_md);
731
libvlc_video_set_spu(p_md, spu);
736
STDMETHODIMP VLCSubtitle::get_count(long* spuNumber)
738
if( NULL == spuNumber )
741
libvlc_media_player_t *p_md;
742
HRESULT hr = getMD(&p_md);
745
// get the number of video subtitle available and return it
746
*spuNumber = libvlc_video_get_spu_count(p_md);
752
STDMETHODIMP VLCSubtitle::description(long nameID, BSTR* name)
757
libvlc_media_player_t* p_md;
759
HRESULT hr = getMD(&p_md);
763
const char *psz_name;
764
libvlc_track_description_t *p_spuDesc;
766
// get subtitles description
767
p_spuDesc = libvlc_video_get_spu_description(p_md);
771
// get the number of available subtitle
772
i_limit = libvlc_video_get_spu_count(p_md);
776
// check if the number given is a good one
777
if ( ( nameID > ( i_limit -1 ) ) || ( nameID < 0 ) )
780
// get the good spuDesc
781
for( i = 0 ; i < nameID ; i++ )
783
p_spuDesc = p_spuDesc->p_next;
785
// get the subtitle name
786
psz_name = p_spuDesc->psz_name;
789
if( psz_name != NULL )
791
*name = BSTRFromCStr(CP_UTF8, psz_name);
792
return (NULL == *name) ? E_OUTOFMEMORY : NOERROR;
800
/****************************************************************************/
802
STDMETHODIMP VLCVideo::get_fullscreen(VARIANT_BOOL* fullscreen)
804
if( NULL == fullscreen )
807
libvlc_media_player_t *p_md;
808
HRESULT hr = getMD(&p_md);
811
*fullscreen = varbool( libvlc_get_fullscreen(p_md) );
816
STDMETHODIMP VLCVideo::put_fullscreen(VARIANT_BOOL fullscreen)
818
libvlc_media_player_t *p_md;
819
HRESULT hr = getMD(&p_md);
822
libvlc_set_fullscreen(p_md, VARIANT_FALSE != fullscreen);
827
STDMETHODIMP VLCVideo::get_width(long* width)
832
libvlc_media_player_t *p_md;
833
HRESULT hr = getMD(&p_md);
836
*width = libvlc_video_get_width(p_md);
841
STDMETHODIMP VLCVideo::get_height(long* height)
846
libvlc_media_player_t *p_md;
847
HRESULT hr = getMD(&p_md);
850
*height = libvlc_video_get_height(p_md);
855
STDMETHODIMP VLCVideo::get_aspectRatio(BSTR* aspect)
860
libvlc_media_player_t *p_md;
861
HRESULT hr = getMD(&p_md);
864
char *psz_aspect = libvlc_video_get_aspect_ratio(p_md);
868
*aspect = BSTRFromCStr(CP_UTF8, psz_aspect);
869
if( NULL == *aspect )
871
} else if( NULL == psz_aspect)
878
STDMETHODIMP VLCVideo::put_aspectRatio(BSTR aspect)
883
libvlc_media_player_t *p_md;
884
HRESULT hr = getMD(&p_md);
887
char *psz_aspect = CStrFromBSTR(CP_UTF8, aspect);
890
return E_OUTOFMEMORY;
893
libvlc_video_set_aspect_ratio(p_md, psz_aspect);
895
CoTaskMemFree(psz_aspect);
900
STDMETHODIMP VLCVideo::get_subtitle(long* spu)
905
libvlc_media_player_t *p_md;
906
HRESULT hr = getMD(&p_md);
909
*spu = libvlc_video_get_spu(p_md);
914
STDMETHODIMP VLCVideo::put_subtitle(long spu)
916
libvlc_media_player_t *p_md;
917
HRESULT hr = getMD(&p_md);
920
libvlc_video_set_spu(p_md, spu);
925
STDMETHODIMP VLCVideo::get_crop(BSTR* geometry)
927
if( NULL == geometry )
930
libvlc_media_player_t *p_md;
931
HRESULT hr = getMD(&p_md);
934
char *psz_geometry = libvlc_video_get_crop_geometry(p_md);
937
*geometry = BSTRFromCStr(CP_UTF8, psz_geometry);
940
} else if( !psz_geometry )
942
free( psz_geometry );
947
STDMETHODIMP VLCVideo::put_crop(BSTR geometry)
949
if( NULL == geometry )
952
if( 0 == SysStringLen(geometry) )
955
libvlc_media_player_t *p_md;
956
HRESULT hr = getMD(&p_md);
959
char *psz_geometry = CStrFromBSTR(CP_UTF8, geometry);
962
return E_OUTOFMEMORY;
965
libvlc_video_set_crop_geometry(p_md, psz_geometry);
967
CoTaskMemFree(psz_geometry);
972
STDMETHODIMP VLCVideo::get_teletext(long* page)
977
libvlc_media_player_t *p_md;
978
HRESULT hr = getMD(&p_md);
981
*page = libvlc_video_get_teletext(p_md);
987
STDMETHODIMP VLCVideo::put_teletext(long page)
989
libvlc_media_player_t *p_md;
990
HRESULT hr = getMD(&p_md);
994
libvlc_video_set_teletext(p_md, page);
999
STDMETHODIMP VLCVideo::takeSnapshot(LPPICTUREDISP* picture)
1001
if( NULL == picture )
1004
libvlc_media_player_t *p_md;
1005
HRESULT hr = getMD(&p_md);
1008
static int uniqueId = 0;
1009
TCHAR path[MAX_PATH+1];
1011
int pathlen = GetTempPath(MAX_PATH-24, path);
1012
if( (0 == pathlen) || (pathlen > (MAX_PATH-24)) )
1015
/* check temp directory path by openning it */
1017
HANDLE dirHandle = CreateFile(path, GENERIC_READ,
1018
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
1019
NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
1020
if( INVALID_HANDLE_VALUE == dirHandle )
1022
Instance()->setErrorInfo(IID_IVLCVideo,
1023
"Invalid temporary directory for snapshot images, check values of TMP, TEMP envars.");
1028
BY_HANDLE_FILE_INFORMATION bhfi;
1029
BOOL res = GetFileInformationByHandle(dirHandle, &bhfi);
1030
CloseHandle(dirHandle);
1031
if( !res || !(bhfi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
1033
Instance()->setErrorInfo(IID_IVLCVideo,
1034
"Invalid temporary directory for snapshot images, check values of TMP, TEMP envars.");
1040
TCHAR filepath[MAX_PATH+1];
1042
_stprintf(filepath, TEXT("%sAXVLC%lXS%lX.bmp"),
1043
path, GetCurrentProcessId(), ++uniqueId);
1046
/* reuse path storage for UTF8 string */
1047
char *psz_filepath = (char *)path;
1048
WCHAR* wpath = filepath;
1050
char *psz_filepath = path;
1051
/* first convert to unicode using current code page */
1052
WCHAR wpath[MAX_PATH+1];
1053
if( 0 == MultiByteToWideChar(CP_ACP, 0, filepath, -1,
1054
wpath, sizeof(wpath)/sizeof(WCHAR)) )
1057
/* convert to UTF8 */
1058
pathlen = WideCharToMultiByte(CP_UTF8, 0, wpath, -1,
1059
psz_filepath, sizeof(path), NULL, NULL);
1060
// fail if path is 0 or too short (i.e pathlen is the same as
1063
if( (0 == pathlen) || (sizeof(path) == pathlen) )
1066
/* take snapshot into file */
1067
if( libvlc_video_take_snapshot(p_md, 0, psz_filepath, 0, 0) == 0 )
1069
/* open snapshot file */
1070
HANDLE snapPic = LoadImage(NULL, filepath, IMAGE_BITMAP, 0, 0,
1071
LR_CREATEDIBSECTION|LR_LOADFROMFILE);
1076
snapDesc.cbSizeofstruct = sizeof(PICTDESC);
1077
snapDesc.picType = PICTYPE_BITMAP;
1078
snapDesc.bmp.hbitmap = (HBITMAP)snapPic;
1079
snapDesc.bmp.hpal = NULL;
1081
hr = OleCreatePictureIndirect(&snapDesc, IID_IPictureDisp,
1082
TRUE, (LPVOID*)picture);
1086
DeleteObject(snapPic);
1089
DeleteFile(filepath);
1095
STDMETHODIMP VLCVideo::toggleFullscreen()
1097
libvlc_media_player_t *p_md;
1098
HRESULT hr = getMD(&p_md);
1101
Instance()->toggleFullscreen();
1106
STDMETHODIMP VLCVideo::toggleTeletext()
1108
libvlc_media_player_t *p_md;
1109
HRESULT hr = getMD(&p_md);
1112
libvlc_toggle_teletext(p_md);
1117
STDMETHODIMP VLCVideo::get_marquee(IVLCMarquee** obj)
1119
return object_get(obj,_p_vlcmarquee);
1122
STDMETHODIMP VLCVideo::get_logo(IVLCLogo** obj)
1124
return object_get(obj,_p_vlclogo);
1127
STDMETHODIMP VLCVideo::get_deinterlace(IVLCDeinterlace** obj)
1129
return object_get(obj,_p_vlcdeint);
1132
/****************************************************************************/
1134
HRESULT VLCLogo::do_put_int(unsigned idx, LONG val)
1136
libvlc_media_player_t *p_md;
1137
HRESULT hr = getMD(&p_md);
1140
libvlc_video_set_logo_int(p_md, idx, val);
1145
HRESULT VLCLogo::do_get_int(unsigned idx, LONG *val)
1150
libvlc_media_player_t *p_md;
1151
HRESULT hr = getMD(&p_md);
1154
*val = libvlc_video_get_logo_int(p_md, idx);
1159
STDMETHODIMP VLCLogo::file(BSTR fname)
1161
libvlc_media_player_t *p_md;
1162
HRESULT hr = getMD(&p_md);
1164
char *n = CStrFromBSTR(CP_UTF8, fname);
1165
if( !n ) hr = E_OUTOFMEMORY;
1169
libvlc_video_set_logo_string(p_md, libvlc_logo_file, n);
1176
STDMETHODIMP VLCLogo::get_position(BSTR* val)
1182
HRESULT hr = do_get_int(libvlc_logo_position, &i);
1185
*val = BSTRFromCStr(CP_UTF8, position_bynumber(i));
1190
STDMETHODIMP VLCLogo::put_position(BSTR val)
1192
char *n = CStrFromBSTR(CP_UTF8, val);
1193
if( !n ) return E_OUTOFMEMORY;
1197
if( position_byname( n, i ) )
1198
hr = do_put_int(libvlc_logo_position,i);
1206
/****************************************************************************/
1208
VLCControl2::VLCControl2(VLCPlugin *p_instance) :
1209
_p_instance(p_instance),
1211
_p_vlcaudio(new VLCAudio(p_instance)),
1212
_p_vlcinput(new VLCInput(p_instance)),
1213
_p_vlcplaylist(new VLCPlaylist(p_instance)),
1214
_p_vlcsubtitle(new VLCSubtitle(p_instance)),
1215
_p_vlcvideo(new VLCVideo(p_instance))
1219
VLCControl2::~VLCControl2()
1222
delete _p_vlcsubtitle;
1223
delete _p_vlcplaylist;
1227
_p_typeinfo->Release();
1230
HRESULT VLCControl2::loadTypeInfo(void)
1232
HRESULT hr = NOERROR;
1233
if( NULL == _p_typeinfo )
1235
ITypeLib *p_typelib;
1237
hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
1240
hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCControl2, &_p_typeinfo);
1245
p_typelib->Release();
1251
STDMETHODIMP VLCControl2::GetTypeInfoCount(UINT* pctInfo)
1253
if( NULL == pctInfo )
1254
return E_INVALIDARG;
1256
if( SUCCEEDED(loadTypeInfo()) )
1264
STDMETHODIMP VLCControl2::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
1266
if( NULL == ppTInfo )
1267
return E_INVALIDARG;
1269
if( SUCCEEDED(loadTypeInfo()) )
1271
_p_typeinfo->AddRef();
1272
*ppTInfo = _p_typeinfo;
1279
STDMETHODIMP VLCControl2::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
1280
UINT cNames, LCID lcid, DISPID* rgDispID)
1282
if( SUCCEEDED(loadTypeInfo()) )
1284
return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
1289
STDMETHODIMP VLCControl2::Invoke(DISPID dispIdMember, REFIID riid,
1290
LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
1291
VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
1293
if( SUCCEEDED(loadTypeInfo()) )
1295
return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
1296
pVarResult, pExcepInfo, puArgErr);
1301
STDMETHODIMP VLCControl2::get_AutoLoop(VARIANT_BOOL *autoloop)
1303
if( NULL == autoloop )
1306
*autoloop = varbool( _p_instance->getAutoLoop() );
1310
STDMETHODIMP VLCControl2::put_AutoLoop(VARIANT_BOOL autoloop)
1312
_p_instance->setAutoLoop((VARIANT_FALSE != autoloop) ? TRUE: FALSE);
1316
STDMETHODIMP VLCControl2::get_AutoPlay(VARIANT_BOOL *autoplay)
1318
if( NULL == autoplay )
1321
*autoplay = varbool( _p_instance->getAutoPlay() );
1325
STDMETHODIMP VLCControl2::put_AutoPlay(VARIANT_BOOL autoplay)
1327
_p_instance->setAutoPlay((VARIANT_FALSE != autoplay) ? TRUE: FALSE);
1331
STDMETHODIMP VLCControl2::get_BaseURL(BSTR *url)
1336
*url = SysAllocStringLen(_p_instance->getBaseURL(),
1337
SysStringLen(_p_instance->getBaseURL()));
1341
STDMETHODIMP VLCControl2::put_BaseURL(BSTR mrl)
1343
_p_instance->setBaseURL(mrl);
1348
STDMETHODIMP VLCControl2::get_MRL(BSTR *mrl)
1353
*mrl = SysAllocStringLen(_p_instance->getMRL(),
1354
SysStringLen(_p_instance->getMRL()));
1358
STDMETHODIMP VLCControl2::put_MRL(BSTR mrl)
1360
_p_instance->setMRL(mrl);
1366
STDMETHODIMP VLCControl2::get_Toolbar(VARIANT_BOOL *visible)
1368
if( NULL == visible )
1372
* Note to developers
1374
* Returning the _b_toolbar is closer to the method specification.
1375
* But returning True when toolbar is not implemented so not displayed
1376
* could be bad for ActiveX users which rely on this value to show their
1377
* own toolbar if not provided by the ActiveX.
1379
* This is the reason why FALSE is returned, until toolbar get implemented.
1382
/* DISABLED for now */
1383
// *visible = varbool( _p_instance->getShowToolbar() );
1385
*visible = VARIANT_FALSE;
1390
STDMETHODIMP VLCControl2::put_Toolbar(VARIANT_BOOL visible)
1392
_p_instance->setShowToolbar((VARIANT_FALSE != visible) ? TRUE: FALSE);
1397
STDMETHODIMP VLCControl2::get_StartTime(long *seconds)
1399
if( NULL == seconds )
1402
*seconds = _p_instance->getStartTime();
1406
STDMETHODIMP VLCControl2::put_StartTime(long seconds)
1408
_p_instance->setStartTime(seconds);
1412
STDMETHODIMP VLCControl2::get_VersionInfo(BSTR *version)
1414
if( NULL == version )
1417
const char *versionStr = libvlc_get_version();
1418
if( NULL != versionStr )
1420
*version = BSTRFromCStr(CP_UTF8, versionStr);
1422
return (NULL == *version) ? E_OUTOFMEMORY : NOERROR;
1428
STDMETHODIMP VLCControl2::get_Visible(VARIANT_BOOL *isVisible)
1430
if( NULL == isVisible )
1433
*isVisible = varbool( _p_instance->getVisible() );
1438
STDMETHODIMP VLCControl2::put_Visible(VARIANT_BOOL isVisible)
1440
_p_instance->setVisible(isVisible != VARIANT_FALSE);
1444
STDMETHODIMP VLCControl2::get_Volume(long *volume)
1446
if( NULL == volume )
1449
*volume = _p_instance->getVolume();
1453
STDMETHODIMP VLCControl2::put_Volume(long volume)
1455
_p_instance->setVolume(volume);
1459
STDMETHODIMP VLCControl2::get_BackColor(OLE_COLOR *backcolor)
1461
if( NULL == backcolor )
1464
*backcolor = _p_instance->getBackColor();
1468
STDMETHODIMP VLCControl2::put_BackColor(OLE_COLOR backcolor)
1470
_p_instance->setBackColor(backcolor);
1474
STDMETHODIMP VLCControl2::get_audio(IVLCAudio** obj)
1476
return object_get(obj,_p_vlcaudio);
1479
STDMETHODIMP VLCControl2::get_input(IVLCInput** obj)
1481
return object_get(obj,_p_vlcinput);
1484
STDMETHODIMP VLCControl2::get_playlist(IVLCPlaylist** obj)
1486
return object_get(obj,_p_vlcplaylist);
1489
STDMETHODIMP VLCControl2::get_subtitle(IVLCSubtitle** obj)
1491
return object_get(obj,_p_vlcsubtitle);
1494
STDMETHODIMP VLCControl2::get_video(IVLCVideo** obj)
1496
return object_get(obj,_p_vlcvideo);