1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
|
/* Totem browser plugin
*
* Copyright © 2004 Bastien Nocera <hadess@hadess.net>
* Copyright © 2002 David A. Schleef <ds@schleef.org>
* Copyright © 2006, 2008 Christian Persch
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*/
#ifndef __TOTEM_PLUGIN_H__
#define __TOTEM_PLUGIN_H__
#include <stdint.h>
#include <gio/gio.h>
#include "npapi.h"
#include "totemNPClass.h"
#include "totemNPObject.h"
#include "totemNPObjectWrapper.h"
#include "totemNPVariantWrapper.h"
#include "totem-plugin-viewer-constants.h"
#define TOTEM_NARROWSPACE_VERSION "7.6.6"
#define TOTEM_MULLY_VERSION "1.4.0.233"
#define TOTEM_CONE_VERSION "0.8.6"
#define TOTEM_GMP_VERSION_BUILD "11.0.0.1024"
#define TOTEM_VEGAS_SMALL_SWF_SIZE 50
typedef struct {
const char *mimetype;
const char *extensions;
const char *mime_alias;
} totemPluginMimeEntry;
typedef enum {
TOTEM_QUEUE_TYPE_SET_VOLUME,
TOTEM_QUEUE_TYPE_CLEAR_PLAYLIST,
TOTEM_QUEUE_TYPE_ADD_ITEM,
TOTEM_QUEUE_TYPE_SET_BOOLEAN,
TOTEM_QUEUE_TYPE_SET_STRING,
TOTEM_QUEUE_TYPE_SET_PLAYLIST
} TotemQueueCommandType;
typedef struct {
TotemQueueCommandType type;
union {
float volume;
struct {
char *uri;
char *title;
char *subtitle;
} add_item;
gboolean boolean;
char *string;
};
} TotemQueueCommand;
class totemBasicPlayer;
class totemConePlayer;
class totemGMPControls;
class totemGMPError;
class totemGMPPlayer;
class totemGMPSettings;
class totemMullYPlayer;
class totemNarrowSpacePlayer;
class totemPlugin {
public:
totemPlugin (NPP aNPP);
~totemPlugin ();
void* operator new (size_t aSize) throw ();
/* plugin glue */
static NPError Initialise ();
static NPError Shutdown ();
NPError Init (NPMIMEType mimetype,
uint16_t mode,
int16_t argc,
char *argn[],
char *argv[],
NPSavedData *saved);
NPError SetWindow (NPWindow *aWindow);
NPError NewStream (NPMIMEType type,
NPStream* stream_ptr,
NPBool seekable,
uint16* stype);
NPError DestroyStream (NPStream* stream,
NPError reason);
int32_t WriteReady (NPStream *stream);
int32_t Write (NPStream *stream,
int32_t offset,
int32_t len,
void *buffer);
void StreamAsFile (NPStream *stream,
const char* fname);
void URLNotify (const char *url,
NPReason reason,
void *notifyData);
NPError GetScriptableNPObject (void *_retval);
static char *PluginDescription ();
static char *PluginLongDescription();
static void PluginMimeTypes (const totemPluginMimeEntry **, uint32_t *);
/* static */ void BusNameAppearedCallback (GDBusConnection *connection,
const gchar *name,
const gchar *aNameOwner);
/* static */ void BusNameVanishedCallback (GDBusConnection *connection,
const gchar *aName);
private:
static gboolean ViewerForkTimeoutCallback (void *aData);
static void ProxySignalCallback (GDBusProxy *aProxy,
gchar *sender_name,
gchar *signal_name,
GVariant *parameters,
void *aData);
static void ViewerSetWindowCallback (GObject *aObject,
GAsyncResult *aRes,
void *aData);
static void ViewerOpenStreamCallback (GObject *aObject,
GAsyncResult *aRes,
void *aData);
static void ViewerSetupStreamCallback (GObject *aObject,
GAsyncResult *aRes,
void *aData);
static void ViewerOpenURICallback (GObject *aObject,
GAsyncResult *aRes,
void *aData);
NPError ViewerFork ();
void ViewerSetup ();
void ViewerSetWindow ();
void ViewerReady ();
void ViewerCleanup ();
void ViewerButtonPressed (guint aTimestamp,
guint aButton);
void ClearRequest ();
void RequestStream (bool aForceViewer);
void UnsetStream ();
void TickCallback (guint aTime,
guint aDuration,
char *aState);
void ButtonPressCallback (guint aTimestamp,
guint aButton);
void StopStreamCallback (void);
void PropertyChangeCallback (const char *aType,
GVariant *aVariant);
bool IsMimeTypeSupported (const char *aMimeType,
const char *aURL);
bool IsSchemeSupported (const char *aURI, const char *aBaseURI);
void SetRealMimeType (const char *aMimeType);
bool ParseBoolean (const char *key,
const char *value,
bool default_val);
bool GetBooleanValue (GHashTable *args,
const char *key,
bool default_val);
uint32_t GetEnumIndex (GHashTable *args,
const char *key,
const char *values[],
uint32_t n_values,
uint32_t default_value);
NPP mNPP;
totemNPObjectWrapper mPluginElement;
guint mTimerID;
/* Stream data */
NPStream *mStream;
public:
uint32_t mBytesStreamed;
uint32_t mBytesLength;
private:
uint8_t mStreamType;
char* mMimeType;
char* mDocumentURI;
char* mBaseURI;
char* mSrcURI; /* relative to mBaseURI */
char* mRequestBaseURI;
char* mRequestURI; /* relative to mRequestBaseURI */
GDBusProxy *mViewerProxy;
GCancellable *mCancellable;
guint mSignalId;
char* mViewerBusAddress;
char* mViewerServiceName;
guint mBusWatchId;
int mViewerPID;
int mViewerFD;
Window mWindow;
int mWidth;
int mHeight;
private:
bool mAllowContextMenu;
bool mAudioOnly;
bool mAutoPlay;
bool mCache;
bool mCheckedForPlaylist;
bool mControllerHidden;
bool mControllerVisible;
bool mExpectingStream;
bool mHadStream;
bool mHidden;
bool mIsFullscreen;
bool mIsLooping;
bool mIsMute;
bool mIsPlaylist;
bool mIsSupportedSrc;
bool mIsWindowless;
bool mKioskMode;
bool mLoopIsPalindrome;
bool mMute;
bool mNeedViewer;
bool mPlayEveryFrame;
bool mRepeat;
bool mRequestIsSrc;
bool mResetPropertiesOnReload;
bool mShowStatusbar;
bool mTimerRunning;
bool mUnownedViewerSetUp;
bool mViewerReady;
bool mViewerSetUp;
bool mWaitingForButtonPress;
bool mWindowSet;
char *mBackgroundColor;
char *mMatrix;
char *mRectangle;
char *mMovieName;
double mVolume;
TotemStates mState;
uint32_t mDuration;
uint32_t mTime;
GQueue *mQueue;
#ifdef TOTEM_GMP_PLUGIN
public:
void SetURL (const char* aURL);
void SetBaseURL (const char* aBaseURL);
const char* URL() const { return mURLURI; }
private:
char* mURLURI;
#endif
#ifdef TOTEM_NARROWSPACE_PLUGIN
public:
bool SetQtsrc (const char* aURL);
bool SetHref (const char* aURL);
void SetURL (const NPString&);
const char* QtSrc () const { return mQtsrcURI; }
const char* Href () const { return mHref; }
const char* Target () const { return mTarget; }
private:
bool ParseURLExtensions (const char* aString,
char* *_url,
char* *_target);
void LaunchTotem (const char* aURL,
uint32_t aTimestamp);
char* mQtsrcURI;
char* mHref;
char* mHrefURI;
char* mTarget;
bool mAutoHref;
#endif
public:
enum ObjectEnum {
ePluginScriptable,
#if defined(TOTEM_GMP_PLUGIN)
eGMPControls,
eGMPNetwork,
eGMPSettings,
#elif defined(TOTEM_CONE_PLUGIN)
eConeAudio,
eConeInput,
eConePlaylist,
eConePlaylistItems,
eConeVideo,
#endif
eLastNPObject
};
private:
totemNPObjectWrapper mNPObjects[eLastNPObject];
public:
NPObject* GetNPObject (ObjectEnum which);
bool SetSrc (const char* aURL);
bool SetSrc (const NPString& aURL);
const char* Src() const { return mSrcURI; }
void Command (const char *aCommand);
void ClearPlaylist ();
int32_t AddItem (const NPString&, const NPString&, const char *aSubtitle);
void SetIsWindowless (bool enabled) { mIsWindowless = enabled; }
bool IsWindowless () const { return mIsWindowless; }
void SetVolume (double aVolume);
double Volume () const { return mVolume; }
void SetMute (bool mute);
bool IsMute () const { return mIsMute; }
void SetFullscreen (bool enabled);
bool IsFullscreen () const { return mIsFullscreen; }
void SetAllowContextMenu (bool enabled) { mAllowContextMenu = enabled; }
bool AllowContextMenu () const { return mAllowContextMenu; }
void SetLooping (bool enabled);
bool IsLooping () const { return mIsLooping; }
void SetAutoPlay (bool enabled);
bool AutoPlay () const { return mAutoPlay; }
void SetControllerVisible (bool enabled);
bool IsControllerVisible () const { return !mControllerHidden; }
void SetKioskMode (bool enabled) { mKioskMode = enabled; }
bool IsKioskMode () const { return mKioskMode; }
void SetLoopIsPalindrome (bool enabled) { mLoopIsPalindrome = enabled; }
bool IsLoopPalindrome () const { return mLoopIsPalindrome; }
void SetPlayEveryFrame (bool enabled) { mPlayEveryFrame = enabled; }
bool PlayEveryFrame () const { return mPlayEveryFrame; }
void SetBackgroundColor (const NPString& color);
const char *BackgroundColor () const { return mBackgroundColor; }
void SetMatrix (const NPString& matrix);
const char* Matrix () const { return mMatrix; }
void SetRectangle (const NPString& rectangle);
const char* Rectangle () const { return mRectangle; }
void SetMovieName (const NPString& name);
const char* MovieName () const { return mMovieName; }
void SetResetPropertiesOnReload (bool enabled) { mResetPropertiesOnReload = enabled; }
bool ResetPropertiesOnReload () const { return mResetPropertiesOnReload; }
void SetRate (double rate);
double Rate () const;
void QueueCommand (TotemQueueCommand *cmd);
double Duration () const { return double (mDuration); }
int32_t BytesStreamed () const { return mBytesStreamed; }
int32_t BytesLength () const { return mBytesLength; }
uint64_t GetTime () const { return mTime; }
void SetTime (uint64_t aTime);
TotemStates State () const { return mState; }
uint32_t Bandwidth () const { return 300000; /* bit/s */ /* FIXMEchpe! */ }
};
#endif /* __TOTEM_PLUGIN_H__ */
|