2002-09-17 16:18:24 +08:00
|
|
|
/*****************************************************************************
|
2003-02-18 21:13:12 +08:00
|
|
|
* vlcplugin.cpp: a VLC plugin for Mozilla
|
2002-09-17 16:18:24 +08:00
|
|
|
*****************************************************************************
|
|
|
|
* Copyright (C) 2002 VideoLAN
|
2004-09-28 21:55:00 +08:00
|
|
|
* $Id$
|
2002-09-17 16:18:24 +08:00
|
|
|
*
|
|
|
|
* Authors: Samuel Hocevar <sam@zoy.org>
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* Preamble
|
|
|
|
*****************************************************************************/
|
2003-10-24 01:04:40 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2002-09-17 16:18:24 +08:00
|
|
|
#include <vlc/vlc.h>
|
|
|
|
|
2003-10-24 01:04:40 +08:00
|
|
|
#ifdef HAVE_MOZILLA_CONFIG_H
|
|
|
|
# include <mozilla-config.h>
|
|
|
|
#endif
|
2003-07-17 00:33:59 +08:00
|
|
|
#include <nsISupports.h>
|
|
|
|
#include <nsMemory.h>
|
2002-09-30 19:05:42 +08:00
|
|
|
#include <npapi.h>
|
|
|
|
|
2003-10-24 01:04:40 +08:00
|
|
|
#if !defined(XP_MACOSX) && !defined(XP_UNIX) && !defined(XP_WIN)
|
|
|
|
#define XP_UNIX 1
|
|
|
|
#elif defined(XP_MACOSX)
|
|
|
|
#undef XP_UNIX
|
|
|
|
#endif
|
|
|
|
|
2002-09-17 16:18:24 +08:00
|
|
|
#include "vlcpeer.h"
|
|
|
|
#include "vlcplugin.h"
|
|
|
|
|
|
|
|
/*****************************************************************************
|
2002-09-30 19:05:42 +08:00
|
|
|
* VlcPlugin constructor and destructor
|
2002-09-17 16:18:24 +08:00
|
|
|
*****************************************************************************/
|
|
|
|
VlcPlugin::VlcPlugin( NPP instance )
|
|
|
|
{
|
2003-02-02 02:54:10 +08:00
|
|
|
p_instance = instance;
|
2002-09-17 16:18:24 +08:00
|
|
|
p_peer = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VlcPlugin::~VlcPlugin()
|
|
|
|
{
|
|
|
|
if( p_peer )
|
|
|
|
{
|
|
|
|
p_peer->Disable();
|
|
|
|
p_peer->Release();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-09-30 19:05:42 +08:00
|
|
|
/*****************************************************************************
|
|
|
|
* VlcPlugin methods
|
|
|
|
*****************************************************************************/
|
2002-09-17 16:18:24 +08:00
|
|
|
void VlcPlugin::SetInstance( NPP instance )
|
|
|
|
{
|
|
|
|
p_instance = instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NPP VlcPlugin::GetInstance()
|
|
|
|
{
|
|
|
|
return p_instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-09-30 19:05:42 +08:00
|
|
|
VlcIntf* VlcPlugin::GetPeer()
|
|
|
|
{
|
|
|
|
if( !p_peer )
|
|
|
|
{
|
|
|
|
p_peer = new VlcPeer( this );
|
2003-02-02 02:54:10 +08:00
|
|
|
if( p_peer == NULL )
|
2002-09-30 19:05:42 +08:00
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2003-02-02 02:54:10 +08:00
|
|
|
|
2002-09-30 19:05:42 +08:00
|
|
|
NS_ADDREF( p_peer );
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_ADDREF( p_peer );
|
|
|
|
return p_peer;
|
|
|
|
}
|
|
|
|
|
2002-09-17 16:18:24 +08:00
|
|
|
void VlcPlugin::SetFileName(const char * filename)
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
FILE * fh;
|
|
|
|
fh = fopen(filename, "rb");
|
|
|
|
if(!fh)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Error while opening %s.\n", filename);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
fseek(fh, 0, SEEK_END);
|
|
|
|
m_lSize = ftell(fh);
|
|
|
|
m_szSound = (char*) malloc(m_lSize);
|
|
|
|
if(!m_szSound)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Error while allocating memory.\n");
|
|
|
|
fclose(fh);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rewind(fh);
|
|
|
|
long pos = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
pos += fread(m_szSound + pos, 1, m_lSize - pos, fh);
|
|
|
|
fprintf(stderr, "pos = %d\n", pos);
|
|
|
|
}
|
|
|
|
while (pos < m_lSize -1);
|
|
|
|
fclose (fh);
|
|
|
|
fprintf(stderr, "File loaded\n");
|
|
|
|
#endif
|
2003-02-02 02:54:10 +08:00
|
|
|
return;
|
2002-09-17 16:18:24 +08:00
|
|
|
}
|
|
|
|
|