Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

vlcplugin.cpp

00001 /*****************************************************************************
00002  * vlcplugin.cpp: a VLC plugin for Mozilla
00003  *****************************************************************************
00004  * Copyright (C) 2002-2005 the VideoLAN team
00005  * $Id: vlcplugin.cpp 11664 2005-07-09 06:17:09Z courmisch $
00006  *
00007  * Authors: Samuel Hocevar <[email protected]>
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00022  *****************************************************************************/
00023 
00024 /*****************************************************************************
00025  * Preamble
00026  *****************************************************************************/
00027 #include "config.h"
00028 
00029 #include <vlc/vlc.h>
00030 
00031 #ifdef HAVE_MOZILLA_CONFIG_H
00032 #   include <mozilla-config.h>
00033 #endif
00034 #include <nsISupports.h>
00035 #include <nsMemory.h>
00036 #include <npapi.h>
00037 
00038 #if !defined(XP_MACOSX) && !defined(XP_UNIX) && !defined(XP_WIN)
00039 #define XP_UNIX 1
00040 #elif defined(XP_MACOSX)
00041 #undef XP_UNIX
00042 #endif
00043 
00044 #include "vlcpeer.h"
00045 #include "vlcplugin.h"
00046 
00047 /*****************************************************************************
00048  * VlcPlugin constructor and destructor
00049  *****************************************************************************/
00050 VlcPlugin::VlcPlugin( NPP instance )
00051 {
00052     p_instance = instance;
00053     p_peer = NULL;
00054 }
00055 
00056 
00057 VlcPlugin::~VlcPlugin()
00058 {
00059     if( p_peer )
00060     {
00061         p_peer->Disable();
00062         p_peer->Release();
00063     }
00064 }
00065 
00066 
00067 /*****************************************************************************
00068  * VlcPlugin methods
00069  *****************************************************************************/
00070 void VlcPlugin::SetInstance( NPP instance )
00071 {
00072     p_instance = instance;
00073 }
00074 
00075 
00076 NPP VlcPlugin::GetInstance()
00077 {
00078     return p_instance;
00079 }
00080 
00081 
00082 VlcIntf* VlcPlugin::GetPeer()
00083 {
00084     if( !p_peer )
00085     {
00086         p_peer = new VlcPeer( this );
00087         if( p_peer == NULL )
00088         {
00089             return NULL;
00090         }
00091 
00092         NS_ADDREF( p_peer );
00093     }
00094 
00095     NS_ADDREF( p_peer );
00096     return p_peer;
00097 }
00098 
00099 void VlcPlugin::SetFileName(const char * filename)
00100 {
00101 #if 0
00102     FILE * fh;
00103     fh = fopen(filename, "rb");
00104     if(!fh)
00105     {
00106         fprintf(stderr, "Error while opening %s.\n", filename);
00107         return;
00108     }
00109     fseek(fh, 0, SEEK_END);
00110     m_lSize = ftell(fh);
00111     m_szSound = (char*) malloc(m_lSize);
00112     if(!m_szSound)
00113     {
00114         fprintf(stderr, "Error while allocating memory.\n");
00115         fclose(fh);
00116         return;
00117     }
00118     rewind(fh);
00119     long pos = 0;
00120     do
00121     {
00122         pos += fread(m_szSound + pos, 1, m_lSize - pos, fh);
00123         fprintf(stderr, "pos = %d\n", pos);
00124     }
00125     while (pos < m_lSize -1);
00126     fclose (fh);
00127     fprintf(stderr, "File loaded\n");
00128 #endif
00129     return;
00130 }
00131 

Generated on Tue Dec 20 10:14:59 2005 for vlc-0.8.4a by  doxygen 1.4.2