3
* Copyright (C) 2004 Bastien Nocera <hadess@hadess.net>
4
* Copyright (C) 2002 David A. Schleef <ds@schleef.org>
5
* Copyright (C) 2006 Christian Persch
7
* This library is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Library General Public
9
* License as published by the Free Software Foundation; either
10
* version 2 of the License, or (at your option) any later version.
12
* This library is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Library General Public License for more details.
17
* You should have received a copy of the GNU Library General Public
18
* License along with this library; if not, write to the
19
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20
* Boston, MA 02111-1307, USA.
22
* $Id: totemBasicPlugin.cpp 4463 2007-07-27 16:07:42Z fcrozat $
25
#include <mozilla-config.h>
30
#include <nsISupportsImpl.h>
33
#include <nsIProgrammingLanguage.h>
35
#define GNOME_ENABLE_DEBUG 1
36
/* define GNOME_ENABLE_DEBUG for more debug spew */
39
#include "totemICone.h"
41
#include "totemDebug.h"
42
#include "totemClassInfo.h"
44
#include "totemConePlugin.h"
46
/* 11ef8fce-9eb4-494e-804e-d56eae788625 */
47
static const nsCID kClassID =
48
{ 0x11ef8fce, 0x9eb4, 0x494e,
49
{ 0x80, 0x4e, 0xd5, 0x6e, 0xae, 0x78, 0x86, 0x25 } };
51
static const char kClassDescription[] = "totemConePlugin";
52
#define TOTEM_CONE_VERSION "0.8.6"
53
static const char kPluginDescription[] = "VLC Multimedia Plugin (compatible Totem " VERSION ")";
55
static const totemPluginMimeEntry kMimeTypes[] = {
56
{ "application/x-vlc-plugin", "", "application/octet-stream" },
57
{ "application/vlc", "", "application/octet-stream" },
58
{ "video/x-google-vlc-plugin", "", "application/octet-stream" },
61
totemScriptablePlugin::totemScriptablePlugin (totemPlugin *aPlugin)
65
D ("%s ctor [%p]", kClassDescription, (void*) this);
68
totemScriptablePlugin::~totemScriptablePlugin ()
70
D ("%s dtor [%p]", kClassDescription, (void*) this);
74
totemScriptablePlugin::PluginDescription ()
76
return (char*) kPluginDescription;
80
totemScriptablePlugin::PluginLongDescription ()
82
return (char*) totem_plugin_get_long_description();
86
totemScriptablePlugin::PluginMimeTypes (const totemPluginMimeEntry **_entries,
89
*_entries = kMimeTypes;
90
*_count = G_N_ELEMENTS (kMimeTypes);
93
/* Interface implementations */
95
NS_IMPL_ISUPPORTS7 (totemScriptablePlugin,
98
totemIConePlaylistItems,
106
TOTEM_CLASSINFO_BEGIN (totemScriptablePlugin,
110
TOTEM_CLASSINFO_ENTRY (0, totemICone)
111
TOTEM_CLASSINFO_ENTRY (1, totemIConePlaylist)
112
TOTEM_CLASSINFO_ENTRY (2, totemIConePlaylistItems)
113
TOTEM_CLASSINFO_ENTRY (3, totemIConeInput)
114
TOTEM_CLASSINFO_ENTRY (4, totemIConeAudio)
115
TOTEM_CLASSINFO_ENTRY (5, totemIConeVideo)
120
#define TOTEM_SCRIPTABLE_INTERFACE "totemICone"
122
/* readonly attribute AUTF8String VersionInfo; */
124
totemScriptablePlugin::GetVersionInfo(nsACString & aVersionInfo)
126
aVersionInfo.Assign (TOTEM_CONE_VERSION);
130
/* attribute totemIConeAudio audio; */
132
totemScriptablePlugin::GetAudio(totemIConeAudio * *aAudio)
134
return CallQueryInterface (this, aAudio);
137
/* attribute totemIConeInput input; */
139
totemScriptablePlugin::GetInput(totemIConeInput * *aInput)
141
return CallQueryInterface (this, aInput);
144
/* attribute totemIConePlaylist playlist; */
146
totemScriptablePlugin::GetPlaylist(totemIConePlaylist * *aPlaylist)
148
return CallQueryInterface (this, aPlaylist);
151
/* attribute totemIConeVideo video; */
153
totemScriptablePlugin::GetVideo(totemIConeVideo * *aVideo)
155
return CallQueryInterface (this, aVideo);
158
/* totemIConePlaylist */
159
#undef TOTEM_SCRIPTABLE_INTERFACE
160
#define TOTEM_SCRIPTABLE_INTERFACE "totemIConePlaylist"
162
/* attribute totemIConePlaylistItems items; */
164
totemScriptablePlugin::GetItems(totemIConePlaylistItems * *aItems)
166
return CallQueryInterface (this, aItems);
169
/* readonly attribute boolean isPlaying */
171
totemScriptablePlugin::GetIsPlaying(PRBool *aIsPlaying)
173
TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
175
return NS_ERROR_NOT_IMPLEMENTED;
178
/* long add (in AUTF8String MRL, in AUTF8String name, in AUTF8String options) */
180
totemScriptablePlugin::Add(const nsACString & aURL, const nsACString & aName, const nsACString & aOptions, PRInt32 *aItemNumber)
182
TOTEM_SCRIPTABLE_LOG_ACCESS ();
184
NS_ENSURE_STATE (IsValid ());
189
return mPlugin->AddItem (aURL);
194
totemScriptablePlugin::Play()
196
TOTEM_SCRIPTABLE_LOG_ACCESS ();
198
NS_ENSURE_STATE (IsValid ());
200
return mPlugin->DoCommand (TOTEM_COMMAND_PLAY);
203
/* void playItem (in long number) */
205
totemScriptablePlugin::PlayItem(PRInt32 aNumber)
207
TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
209
return NS_ERROR_NOT_IMPLEMENTED;
212
/* void togglePause () */
214
totemScriptablePlugin::TogglePause()
216
TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
218
return NS_ERROR_NOT_IMPLEMENTED;
222
totemScriptablePlugin::Stop()
224
TOTEM_SCRIPTABLE_LOG_ACCESS ();
226
NS_ENSURE_STATE (IsValid ());
228
return mPlugin->DoCommand (TOTEM_COMMAND_STOP);
233
totemScriptablePlugin::Next()
235
TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
237
return NS_ERROR_NOT_IMPLEMENTED;
242
totemScriptablePlugin::Prev()
244
TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
246
return NS_ERROR_NOT_IMPLEMENTED;
249
/* void removeItem (in long number) */
251
totemScriptablePlugin::RemoveItem(PRInt32 aNumber)
253
TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
255
return NS_ERROR_NOT_IMPLEMENTED;
258
/* totemIConePlaylistItems */
259
#undef TOTEM_SCRIPTABLE_INTERFACE
260
#define TOTEM_SCRIPTABLE_INTERFACE "totemIConePlaylistItems"
262
/* readonly attribute long count */
264
totemScriptablePlugin::GetCount (PRInt32 *aCount)
266
TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
268
return NS_ERROR_NOT_IMPLEMENTED;
273
totemScriptablePlugin::Clear()
275
TOTEM_SCRIPTABLE_LOG_ACCESS ();
277
NS_ENSURE_STATE (IsValid ());
279
return mPlugin->ClearPlaylist ();
282
/* totemIConeInput */
283
#undef TOTEM_SCRIPTABLE_INTERFACE
284
#define TOTEM_SCRIPTABLE_INTERFACE "totemIConeInput"
286
/* readonly attribute long length */
288
totemScriptablePlugin::GetLength (PRInt32 *aLength)
290
TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
292
return NS_ERROR_NOT_IMPLEMENTED;
295
/* readonly attribute long fps */
297
totemScriptablePlugin::GetFps (PRInt32 *aFps)
299
TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
301
return NS_ERROR_NOT_IMPLEMENTED;
304
/* readonly attribute boolean hasVout */
306
totemScriptablePlugin::GetHasVout (PRBool *aItemCount)
308
TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
310
return NS_ERROR_NOT_IMPLEMENTED;
313
/* attribute double position */
315
totemScriptablePlugin::GetPosition(double *aPosition)
317
TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
319
return NS_ERROR_NOT_IMPLEMENTED;
323
totemScriptablePlugin::SetPosition(double aPosition)
325
TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
327
return NS_ERROR_NOT_IMPLEMENTED;
330
/* attribute long time */
332
totemScriptablePlugin::GetTime(PRInt32 *aPosition)
334
TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
336
return NS_ERROR_NOT_IMPLEMENTED;
340
totemScriptablePlugin::SetTime(PRInt32 aPosition)
342
TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
344
return NS_ERROR_NOT_IMPLEMENTED;
347
/* attribute long state */
349
totemScriptablePlugin::GetState(PRInt32 *aState)
351
TOTEM_SCRIPTABLE_LOG_ACCESS ();
353
NS_ENSURE_STATE (IsValid());
363
if (mPlugin->mState == TOTEM_STATE_PLAYING) {
365
} else if (mPlugin->mState == TOTEM_STATE_PAUSED) {
375
totemScriptablePlugin::SetState(PRInt32 aState)
377
TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
379
return NS_ERROR_NOT_IMPLEMENTED;
382
/* attribute double rate */
384
totemScriptablePlugin::GetRate(double *aRate)
386
TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
388
return NS_ERROR_NOT_IMPLEMENTED;
392
totemScriptablePlugin::SetRate(double aRate)
394
TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
399
/* totemIConeAudio */
400
#undef TOTEM_SCRIPTABLE_INTERFACE
401
#define TOTEM_SCRIPTABLE_INTERFACE "totemIConeAudio"
403
/* attribute boolean mute */
405
totemScriptablePlugin::GetMute(PRBool *_retval)
407
TOTEM_SCRIPTABLE_LOG_ACCESS ();
414
totemScriptablePlugin::SetMute(PRBool enabled)
418
TOTEM_SCRIPTABLE_LOG_ACCESS ();
420
NS_ENSURE_STATE (IsValid ());
422
if (enabled == PR_FALSE) {
424
rv = mPlugin->SetVolume (mSavedVolume);
427
mSavedVolume = mPlugin->mVolume;
428
rv = mPlugin->SetVolume (0);
434
/* attribute long volume */
436
totemScriptablePlugin::GetVolume(PRInt32 *_retval)
438
TOTEM_SCRIPTABLE_LOG_ACCESS ();
440
NS_ENSURE_STATE (IsValid ());
442
*_retval = (PRInt32) (mPlugin->mVolume * 200.0);
447
totemScriptablePlugin::SetVolume(PRInt32 aVolume)
449
TOTEM_SCRIPTABLE_LOG_ACCESS ();
451
NS_ENSURE_STATE (IsValid ());
453
nsresult rv = mPlugin->SetVolume ((double) aVolume / 200.0);
455
/* Volume passed in is 0 through to 200 */
456
mPlugin->mVolume = (double) aVolume / 200.0;
461
/* attribute long track */
463
totemScriptablePlugin::GetTrack(PRInt32 *_retval)
465
TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
467
return NS_ERROR_NOT_IMPLEMENTED;
471
totemScriptablePlugin::SetTrack(PRInt32 aTrack)
473
TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
475
return NS_ERROR_NOT_IMPLEMENTED;
478
/* attribute long channel */
480
totemScriptablePlugin::GetChannel(PRInt32 *_retval)
482
TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
484
return NS_ERROR_NOT_IMPLEMENTED;
488
totemScriptablePlugin::SetChannel(PRInt32 aChannel)
490
TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
492
return NS_ERROR_NOT_IMPLEMENTED;
494
/* void toggleMute () */
496
totemScriptablePlugin::ToggleMute()
498
TOTEM_SCRIPTABLE_LOG_ACCESS ();
500
return SetMute (!mMute);
503
/* totemIConeAudio */
504
#undef TOTEM_SCRIPTABLE_INTERFACE
505
#define TOTEM_SCRIPTABLE_INTERFACE "totemIConeVideo"
507
/* readonly attribute long width */
509
totemScriptablePlugin::GetWidth (PRInt32 *aWidth)
511
TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
513
return NS_ERROR_NOT_IMPLEMENTED;
516
/* readonly attribute long height */
518
totemScriptablePlugin::GetHeight (PRInt32 *aHeight)
520
TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
522
return NS_ERROR_NOT_IMPLEMENTED;
525
/* attribute boolean fullscreen */
527
totemScriptablePlugin::GetFullscreen(PRBool *_retval)
529
TOTEM_SCRIPTABLE_LOG_ACCESS ();
531
NS_ENSURE_STATE (IsValid ());
533
*_retval = mPlugin->mIsFullscreen;
539
totemScriptablePlugin::SetFullscreen(PRBool enabled)
541
TOTEM_SCRIPTABLE_LOG_ACCESS ();
543
NS_ENSURE_STATE (IsValid ());
545
nsresult rv = mPlugin->SetFullscreen (enabled);
547
mPlugin->mIsFullscreen = enabled != PR_FALSE;
552
/* attribute AUTF8String aspectRatio */
554
totemScriptablePlugin::GetAspectRatio(nsACString & aAspectRatio)
556
// aVersionInfo.Assign (TOTEM_CONE_VERSION);
558
TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
560
return NS_ERROR_NOT_IMPLEMENTED;
564
totemScriptablePlugin::SetAspectRatio(const nsACString & aAspectRatio)
566
TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
568
return NS_ERROR_NOT_IMPLEMENTED;
570
/* attribute long subtitle */
572
totemScriptablePlugin::GetSubtitle(PRInt32 *aSubtitle)
574
TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
576
return NS_ERROR_NOT_IMPLEMENTED;
580
totemScriptablePlugin::SetSubtitle(PRInt32 aSubtitle)
582
TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
584
return NS_ERROR_NOT_IMPLEMENTED;
587
/* attribute long teletext */
589
totemScriptablePlugin::GetTeletext(PRInt32 *aTeletext)
591
TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
593
return NS_ERROR_NOT_IMPLEMENTED;
597
totemScriptablePlugin::SetTeletext(PRInt32 aTeletext)
599
TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
601
return NS_ERROR_NOT_IMPLEMENTED;
604
/* void toggleFullscreen () */
606
totemScriptablePlugin::ToggleFullscreen()
608
TOTEM_SCRIPTABLE_LOG_ACCESS ();
610
NS_ENSURE_STATE (IsValid ());
612
nsresult rv = mPlugin->SetFullscreen (!mPlugin->mIsFullscreen);
614
mPlugin->mIsFullscreen = !mPlugin->mIsFullscreen;
619
/* void toggleTeletext () */
621
totemScriptablePlugin::ToggleTeletext()
623
TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
625
return NS_ERROR_NOT_IMPLEMENTED;