List Info

Thread: CR: Flash Guest Player NS fixes for multiple instances




CR: Flash Guest Player NS fixes for multiple instances
country flaguser name
United States
2007-10-03 22:55:56
Synopsis: Nimbus would hang or crash if there were more than
one 
instance of a SWF, when using the Netscape version of the
Flash Guest Player.

Overview: There were several issues regarding multiple
instance 
creation and destruction.
- Call NPP_DestroyStream after all writes to Flash have been
completed.
- Call NPP_StreamAsFile instead of NPP_URLNotify for local
files, 
regardless of what NPP_NewStream returns as the stream type.

StreamAsFile is for local files as indicated by the
documentation.
- Call NPP_Destroy on only the first instance that was
created, and 
if it's the last instance destroyed. This is the only
scenario that 
would not crash for multiple instances.
- DisableLocalSecurity can only be called once, similar to 
NP_Initialize. It did not create a crash, but it always
fails on 
subsequent calls.
- Set the m_bTerminated flag inside of the block that
actually 
terminates the Flash plugin. This fixed a bug where you
could not 
play an FLV twice, due to the first instance not being
destroyed.
- For FLV, only call FinishFile on the SWF wrapper object,
not the 
FLV, which will cause the timeline to stop after HTTP file
system 
reports that it is done reading.

Files:
datatype/flash/flashhost/flash_guest_player_ns.cpp
datatype/flash/flashhost/pub/flash_guest_player_ns.h

Branches:
HEAD, atlas310

Index: flash_guest_player_ns.cpp
============================================================
=======
RCS file:
/cvsroot/datatype/flash/flashhost/flash_guest_player_ns.cpp,
v
retrieving revision 1.27.2.8
diff -w -u -5 -r1.27.2.8 flash_guest_player_ns.cpp
--- flash_guest_player_ns.cpp	28 Sep 2007 21:15:10
-0000	1.27.2.8
+++ flash_guest_player_ns.cpp	4 Oct 2007 03:37:05 -0000
 -122,10
+122,11 
  const char* const  
CFlashGuestPlayerNS::m_pszFlashMimeType = 
"application/x-shockwave-flash";
  CHXStringList	    CFlashGuestPlayerNS::m_StringIds;
  CHXSimpleList	    CFlashGuestPlayerNS::m_IntIds;
  CHXString	    CFlashGuestPlayerNS::m_pUserAgentStr;
  INT32		    CFlashGuestPlayerNS::m_lFlashRefCount = 0;
+_NPP		    CFlashGuestPlayerNS::m_firstNPP = {NULL,NULL};

  NPClass CNPObjectWrapper::m_npclass =
  {
      NP_CLASS_STRUCT_VERSION,
      CNPObjectWrapper::NP_Allocate,
 -616,22
+617,10 

          if (m_pDLLAccess &&
m_pDLLAccess->isOpen())
          {
              NPError npstatus;
  	
-	    // Disable local security
-	    NP_DISABLELOCALSECURITY pfnDisableLocalSecurity = 
(NP_DISABLELOCALSECURITY) 
m_pDLLAccess->getSymbol("Flash_DisableLocalSecurity&
quot;);
-	    if (pfnDisableLocalSecurity &&
-		((npstatus = pfnDisableLocalSecurity()) ==
NPERR_NO_ERROR))
-	    {
-		HXLOGL4(HXLOG_FPHR,
"CFlashGuestPlayerNS::InitNSPlugin() 
Flash_DisableLocalSecurity succeeded");
-	    }
-	    else
-	    {
-		HXLOGL4(HXLOG_FPHR,
"CFlashGuestPlayerNS::InitNSPlugin() 
Flash_DisableLocalSecurity failed");
-	    }
-
              NP_GETENTRYPOINTS pfnGetEntryPoints = 
(NP_GETENTRYPOINTS)
m_pDLLAccess->getSymbol("NP_GetEntryPoints");
              // Get the SWF plug-in entry points
              if (pfnGetEntryPoints &&
                  ((npstatus = pfnGetEntryPoints(
&m_PluginFuncs )) 
== NPERR_NO_ERROR))
              {
 -645,10
+634,22 
              }

              // Set the callbacks for the plug-in
  	    if (m_lFlashRefCount == 0)
  	    {
+		// Disable local security
+		NP_DISABLELOCALSECURITY pfnDisableLocalSecurity = 
(NP_DISABLELOCALSECURITY) 
m_pDLLAccess->getSymbol("Flash_DisableLocalSecurity&
quot;);
+		if (pfnDisableLocalSecurity &&
+		    ((npstatus = pfnDisableLocalSecurity()) ==
NPERR_NO_ERROR))
+		{
+		    HXLOGL4(HXLOG_FPHR,
"CFlashGuestPlayerNS::InitNSPlugin() 
Flash_DisableLocalSecurity succeeded");
+		}
+		else
+		{
+		    HXLOGL4(HXLOG_FPHR,
"CFlashGuestPlayerNS::InitNSPlugin() 
Flash_DisableLocalSecurity failed");
+		}
+
  		NP_INITIALIZE pfnInitialize = (NP_INITIALIZE) 
m_pDLLAccess->getSymbol("NP_Initialize");
  		if (pfnInitialize &&
  		    ((npstatus = pfnInitialize( &m_HostFuncs)) ==
NPERR_NO_ERROR))
  		{
  		    HXLOGL4(HXLOG_FPHR,
"CFlashGuestPlayerNS::InitNSPlugin() Set 
callbacks.");
 -799,10
+800,18 
  	    // so that we do not destroy the shared data on
Terminate.
  	    m_lFlashRefCount++;
  	
  	    m_bTerminated = FALSE;

+	    //XXXctd Keep track of the first instance, so that we
can call 
NPP_Destroy on it.
+	    // For multiple instances, only call destroy on the
first.
+	    if (m_lFlashRefCount == 1)
+	    {
+		m_firstNPP.ndata = NULL;
+		m_firstNPP.pdata = m_NPP.pdata;
+	    }
+
  	    // MBO - Test
  #if defined(_MAC_UNIX)
  #if defined(_DEBUG)
  	    //
printf("CFlashGuestPlayerNS::CreatePluginInstance
m_NPP=%p 
RefCount=%ldn", &m_NPP, m_lFlashRefCount);
  #endif	// _DEBUG
 -1094,12
+1103,10 
  HX_RESULT
  CFlashGuestPlayerNS::OpenStreamPerPluginRequest(void*
pNotifyData)
  {
      HX_RESULT retVal = HXR_FAIL;

-    HX_ASSERT(m_bIsFLVSource);
-		
      // We support one open stream at the time - the one
passed in 
for FLV playback.
      // We create new stream if this is FLV playback case
and FLV file object
      // is set-up as the current file object (SWF has been
processed) and we
      // have not opened the stream yet.
      if (m_bIsFLVSource && m_pFileObject &&
(!m_pFLVFileObject) && 
(!m_NPStream.url))
 -1264,29
+1271,29 
  	    DeleteObject(m_hBitmap); // Delete after the dc has
been deleted.
  	}
  	m_hdc = NULL;
  	m_hwnd = NULL;
  #endif
-
  	if (!m_bTerminated && (m_lFlashRefCount > 0))
  	{
  	    m_lFlashRefCount--;
  	}
  	
  	if (m_lFlashRefCount <= 0)
  	{
  	    // Destroy the plugin instance - this should be done
for every instances
  	    // but causes problem for other instances - needs to
be investigated.
-	    if ((!m_bTerminated) &&
m_PluginFuncs.destroy)
+	    //XXXctd Added m_pFirstInstance var, only the first
instance 
can be called with NPP_Destroy
+	    if (m_PluginFuncs.destroy && m_firstNPP.pdata
== m_NPP.pdata)
  	    {
  		HXLOGL4(HXLOG_FPHR, "tcalling NPP_Destroy");
  #if defined(_MAC_UNIX)
  		// MBO - Test
  		// printf("m_PluginFuncs.destroy 
m_NPP=%p  m_lFlashRefCount=%ldn", &m_NPP,
m_lFlashRefCount);
  #endif	// _MAC_UNIX
  		m_PluginFuncs.destroy(&m_NPP, NULL);
-		// m_lFlashRefCount--;
+		m_firstNPP.pdata = NULL;
  	    }
  	
  	    // This is the last reference, so destroy the statc
object and 
close the dll
  	    m_StringIds.RemoveAll();
  	    m_IntIds.RemoveAll();
 -1306,13
+1313,13 

  	HX_RELEASE(m_pOffscreenBuffer);
  	HX_RELEASE(m_pMutex);
  	HX_RELEASE(m_pSite);
  	HX_RELEASE(m_pScheduler);
-    }

      m_bTerminated = TRUE;
+    }

      return HXR_OK;
  }

  //
 -4507,40
+4514,45 

  void
  CFlashGuestPlayerNS::FinishFile()
  {
      HXLOGL4(HXLOG_FPHR,
"CFlashGuestPlayerNS::FinishFile()");
-    if (m_dStreamType == NP_ASFILE)
+    if (m_dStreamType == NP_ASFILE ||
m_pszURL.Find("file://") == 0)
      {
          // Send the plugin the url of the file we just
wrote to it.
+        // NPP_StreamAsFile        Provides a local file
name for 
the data from a stream.
+	// Call this method instead of urlnotify, no matter what
newstream 
returns, otherwise
+	// the second instance call to urlnotify will hang.
          m_PluginFuncs.asfile( &m_NPP, &m_NPStream,
(const char*) m_pszURL );
  #if defined(_MAC_UNIX)
  	// MBO - Test
  	// printf("m_PluginFuncs.asfile(m_NPP=%p
m_NPStream=%p URL=%sn", 
&m_NPP, &m_NPStream, m_pszURL);
  #endif	// _MAC_UNIX
      }
      else if (m_dStreamType == NP_NORMAL)
      {
          // Notify the plugin we are done writing
-        m_PluginFuncs.urlnotify( &m_NPP , m_pszURL,
NPRES_DONE , NULL );
+        // NPP_URLNotify Notifies the instance of the
completion of 
a URL request.
+        m_PluginFuncs.urlnotify( &m_NPP , (const
char*)m_pszURL, 
NPRES_DONE , NULL );
  #if defined(_MAC_UNIX)
  	// MBO - Test
  	// printf("m_PluginFuncs.urlnotify(m_NPP=%p
URL=%sn", &m_NPP, 
(const char*) m_pszURL);
  #endif	// _MAC_UNIX
      }

      m_bStreamDone = TRUE;

+    DestroyStream(&m_NPStream);
+
      // If this is an FLV source and FLV file object is on
the sidelines
      // waiting to be used, shut-down the current stream we
just finished
      // loading (SWF player) and make FLV file object the
current active
      // object to use.
      if (m_bIsFLVSource && m_pFLVFileObject)
      {
  	HX_RESULT status = HXR_OK;
  	
-	DestroyStream(&m_NPStream);
  	if (m_pFileObject)
  	{
  	    m_pFileObject->Close();
  	    HX_RELEASE(m_pFileObject);
  	}
 -4823,12
+4835,16 
              {
                  // Have we read the entire file?
                  if ((m_ulFileSize != 0) &&
(m_ulFileOffset >= m_ulFileSize))
                  {
                      // We've read the whole file, so tell
the 
NSPlugin we're done
+		    // For FLV, only call FinishFile on the SWF wrapper
object, not the FLV
+		    if (!m_bIsFLVSource || m_pFLVFileObject)
+		    {
                      FinishFile();
                  }
+                }
                  else
                  {
                      // Call SendStream again
                      SendStream();
                  }
Index: pub/flash_guest_player_ns.h
============================================================
=======
RCS file:
/cvsroot/datatype/flash/flashhost/pub/flash_guest_player_ns.
h,v
retrieving revision 1.14.2.4
diff -w -u -5 -r1.14.2.4 flash_guest_player_ns.h
--- pub/flash_guest_player_ns.h	28 Sep 2007 21:15:11
-0000	1.14.2.4
+++ pub/flash_guest_player_ns.h	4 Oct 2007 03:38:00 -0000
 -289,10
+289,11 
      static const char* const	m_pszFlashMimeType;
      static CHXStringList	m_StringIds;
      static CHXSimpleList	m_IntIds;
      static CHXString	    	m_pUserAgentStr;
      static INT32		m_lFlashRefCount;
+    static _NPP			m_firstNPP;	// first instance

      NPRect*	m_pOutstandingInvalidRect;

      _NPP	m_NPP;		// instance
      NPObject*	m_psobj;	// scriptable object


_______________________________________________
Datatype-dev mailing list
Datatype-devhelixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/da
tatype-dev

RE: CR: Flash Guest Player NS fixes for multipleinstances
country flaguser name
United States
2007-10-05 09:52:58
Looks good to me.

=============================================
Eric Hyche (ehychereal.com)
Technical Lead
RealNetworks, Inc.  

> -----Original Message-----
> From: datatype-dev-bounceshelixcommunity.org 
> [mailto:datatype-dev-bounceshelixcommunity.org] On
Behalf Of 
> Christina Dunn
> Sent: Wednesday, October 03, 2007 11:56 PM
> To: datatype-devhelixcommunity.org
> Subject: [datatype-dev] CR: Flash Guest Player NS fixes
for 
> multipleinstances
> 
> Synopsis: Nimbus would hang or crash if there were more
than one 
> instance of a SWF, when using the Netscape version of
the 
> Flash Guest Player.
> 
> Overview: There were several issues regarding multiple
instance 
> creation and destruction.
> - Call NPP_DestroyStream after all writes to Flash have
been 
> completed.
> - Call NPP_StreamAsFile instead of NPP_URLNotify for
local files, 
> regardless of what NPP_NewStream returns as the stream
type. 
> StreamAsFile is for local files as indicated by the
documentation.
> - Call NPP_Destroy on only the first instance that was
created, and 
> if it's the last instance destroyed. This is the only
scenario that 
> would not crash for multiple instances.
> - DisableLocalSecurity can only be called once, similar
to 
> NP_Initialize. It did not create a crash, but it always
fails on 
> subsequent calls.
> - Set the m_bTerminated flag inside of the block that
actually 
> terminates the Flash plugin. This fixed a bug where you
could not 
> play an FLV twice, due to the first instance not being
destroyed.
> - For FLV, only call FinishFile on the SWF wrapper
object, not the 
> FLV, which will cause the timeline to stop after HTTP
file system 
> reports that it is done reading.
> 
> Files:
> datatype/flash/flashhost/flash_guest_player_ns.cpp
> datatype/flash/flashhost/pub/flash_guest_player_ns.h
> 
> Branches:
> HEAD, atlas310
> 
> Index: flash_guest_player_ns.cpp
>
============================================================
=======
> RCS file: 
>
/cvsroot/datatype/flash/flashhost/flash_guest_player_ns.cpp,
v
> retrieving revision 1.27.2.8
> diff -w -u -5 -r1.27.2.8 flash_guest_player_ns.cpp
> --- flash_guest_player_ns.cpp	28 Sep 2007 21:15:10
-0000	1.27.2.8
> +++ flash_guest_player_ns.cpp	4 Oct 2007 03:37:05
-0000
>  -122,10 +122,11 
>   const char* const  
CFlashGuestPlayerNS::m_pszFlashMimeType = 
> "application/x-shockwave-flash";
>   CHXStringList	    CFlashGuestPlayerNS::m_StringIds;
>   CHXSimpleList	    CFlashGuestPlayerNS::m_IntIds;
>   CHXString	    CFlashGuestPlayerNS::m_pUserAgentStr;
>   INT32		    CFlashGuestPlayerNS::m_lFlashRefCount =
0;
> +_NPP		    CFlashGuestPlayerNS::m_firstNPP =
{NULL,NULL};
> 
>   NPClass CNPObjectWrapper::m_npclass =
>   {
>       NP_CLASS_STRUCT_VERSION,
>       CNPObjectWrapper::NP_Allocate,
>  -616,22 +617,10 
> 
>           if (m_pDLLAccess &&
m_pDLLAccess->isOpen())
>           {
>               NPError npstatus;
>   	
> -	    // Disable local security
> -	    NP_DISABLELOCALSECURITY pfnDisableLocalSecurity =

> (NP_DISABLELOCALSECURITY) 
>
m_pDLLAccess->getSymbol("Flash_DisableLocalSecurity&
quot;);
> -	    if (pfnDisableLocalSecurity &&
> -		((npstatus = pfnDisableLocalSecurity()) == 
> NPERR_NO_ERROR))
> -	    {
> -		HXLOGL4(HXLOG_FPHR, 
> "CFlashGuestPlayerNS::InitNSPlugin() 
> Flash_DisableLocalSecurity succeeded");
> -	    }
> -	    else
> -	    {
> -		HXLOGL4(HXLOG_FPHR, 
> "CFlashGuestPlayerNS::InitNSPlugin() 
> Flash_DisableLocalSecurity failed");
> -	    }
> -
>               NP_GETENTRYPOINTS pfnGetEntryPoints = 
> (NP_GETENTRYPOINTS)
m_pDLLAccess->getSymbol("NP_GetEntryPoints");
>               // Get the SWF plug-in entry points
>               if (pfnGetEntryPoints &&
>                   ((npstatus = pfnGetEntryPoints(
&m_PluginFuncs )) 
> == NPERR_NO_ERROR))
>               {
>  -645,10 +634,22 
>               }
> 
>               // Set the callbacks for the plug-in
>   	    if (m_lFlashRefCount == 0)
>   	    {
> +		// Disable local security
> +		NP_DISABLELOCALSECURITY pfnDisableLocalSecurity = 
> (NP_DISABLELOCALSECURITY) 
>
m_pDLLAccess->getSymbol("Flash_DisableLocalSecurity&
quot;);
> +		if (pfnDisableLocalSecurity &&
> +		    ((npstatus = pfnDisableLocalSecurity()) == 
> NPERR_NO_ERROR))
> +		{
> +		    HXLOGL4(HXLOG_FPHR, 
> "CFlashGuestPlayerNS::InitNSPlugin() 
> Flash_DisableLocalSecurity succeeded");
> +		}
> +		else
> +		{
> +		    HXLOGL4(HXLOG_FPHR, 
> "CFlashGuestPlayerNS::InitNSPlugin() 
> Flash_DisableLocalSecurity failed");
> +		}
> +
>   		NP_INITIALIZE pfnInitialize = (NP_INITIALIZE) 
> m_pDLLAccess->getSymbol("NP_Initialize");
>   		if (pfnInitialize &&
>   		    ((npstatus = pfnInitialize( &m_HostFuncs))

> == NPERR_NO_ERROR))
>   		{
>   		    HXLOGL4(HXLOG_FPHR, 
> "CFlashGuestPlayerNS::InitNSPlugin() Set 
> callbacks.");
>  -799,10 +800,18 
>   	    // so that we do not destroy the shared data on
Terminate.
>   	    m_lFlashRefCount++;
>   	
>   	    m_bTerminated = FALSE;
> 
> +	    //XXXctd Keep track of the first instance, so
that 
> we can call 
> NPP_Destroy on it.
> +	    // For multiple instances, only call destroy on
the first.
> +	    if (m_lFlashRefCount == 1)
> +	    {
> +		m_firstNPP.ndata = NULL;
> +		m_firstNPP.pdata = m_NPP.pdata;
> +	    }
> +
>   	    // MBO - Test
>   #if defined(_MAC_UNIX)
>   #if defined(_DEBUG)
>   	    // 
> printf("CFlashGuestPlayerNS::CreatePluginInstance
m_NPP=%p 
> RefCount=%ldn", &m_NPP, m_lFlashRefCount);
>   #endif	// _DEBUG
>  -1094,12 +1103,10 
>   HX_RESULT
>   CFlashGuestPlayerNS::OpenStreamPerPluginRequest(void*
pNotifyData)
>   {
>       HX_RESULT retVal = HXR_FAIL;
> 
> -    HX_ASSERT(m_bIsFLVSource);
> -		
>       // We support one open stream at the time - the
one passed in 
> for FLV playback.
>       // We create new stream if this is FLV playback
case 
> and FLV file object
>       // is set-up as the current file object (SWF has
been 
> processed) and we
>       // have not opened the stream yet.
>       if (m_bIsFLVSource && m_pFileObject
&& (!m_pFLVFileObject) && 
> (!m_NPStream.url))
>  -1264,29 +1271,29 
>   	    DeleteObject(m_hBitmap); // Delete after the dc
has 
> been deleted.
>   	}
>   	m_hdc = NULL;
>   	m_hwnd = NULL;
>   #endif
> -
>   	if (!m_bTerminated && (m_lFlashRefCount >
0))
>   	{
>   	    m_lFlashRefCount--;
>   	}
>   	
>   	if (m_lFlashRefCount <= 0)
>   	{
>   	    // Destroy the plugin instance - this should be

> done for every instances
>   	    // but causes problem for other instances -
needs 
> to be investigated.
> -	    if ((!m_bTerminated) &&
m_PluginFuncs.destroy)
> +	    //XXXctd Added m_pFirstInstance var, only the
first 
> instance 
> can be called with NPP_Destroy
> +	    if (m_PluginFuncs.destroy &&
m_firstNPP.pdata == 
> m_NPP.pdata)
>   	    {
>   		HXLOGL4(HXLOG_FPHR, "tcalling
NPP_Destroy");
>   #if defined(_MAC_UNIX)
>   		// MBO - Test
>   		// printf("m_PluginFuncs.destroy 
> m_NPP=%p  m_lFlashRefCount=%ldn", &m_NPP,
m_lFlashRefCount);
>   #endif	// _MAC_UNIX
>   		m_PluginFuncs.destroy(&m_NPP, NULL);
> -		// m_lFlashRefCount--;
> +		m_firstNPP.pdata = NULL;
>   	    }
>   	
>   	    // This is the last reference, so destroy the
statc 
> object and 
> close the dll
>   	    m_StringIds.RemoveAll();
>   	    m_IntIds.RemoveAll();
>  -1306,13 +1313,13 
> 
>   	HX_RELEASE(m_pOffscreenBuffer);
>   	HX_RELEASE(m_pMutex);
>   	HX_RELEASE(m_pSite);
>   	HX_RELEASE(m_pScheduler);
> -    }
> 
>       m_bTerminated = TRUE;
> +    }
> 
>       return HXR_OK;
>   }
> 
>   //
>  -4507,40 +4514,45 
> 
>   void
>   CFlashGuestPlayerNS::FinishFile()
>   {
>       HXLOGL4(HXLOG_FPHR,
"CFlashGuestPlayerNS::FinishFile()");
> -    if (m_dStreamType == NP_ASFILE)
> +    if (m_dStreamType == NP_ASFILE ||
m_pszURL.Find("file://") == 0)
>       {
>           // Send the plugin the url of the file we
just wrote to it.
> +        // NPP_StreamAsFile        Provides a local
file name for 
> the data from a stream.
> +	// Call this method instead of urlnotify, no matter 
> what newstream 
> returns, otherwise
> +	// the second instance call to urlnotify will hang.
>           m_PluginFuncs.asfile( &m_NPP,
&m_NPStream, (const 
> char*) m_pszURL );
>   #if defined(_MAC_UNIX)
>   	// MBO - Test
>   	// printf("m_PluginFuncs.asfile(m_NPP=%p
m_NPStream=%p 
> URL=%sn", 
> &m_NPP, &m_NPStream, m_pszURL);
>   #endif	// _MAC_UNIX
>       }
>       else if (m_dStreamType == NP_NORMAL)
>       {
>           // Notify the plugin we are done writing
> -        m_PluginFuncs.urlnotify( &m_NPP ,
m_pszURL, 
> NPRES_DONE , NULL );
> +        // NPP_URLNotify Notifies the instance of the
completion of 
> a URL request.
> +        m_PluginFuncs.urlnotify( &m_NPP , (const
char*)m_pszURL, 
> NPRES_DONE , NULL );
>   #if defined(_MAC_UNIX)
>   	// MBO - Test
>   	// printf("m_PluginFuncs.urlnotify(m_NPP=%p
URL=%sn", &m_NPP, 
> (const char*) m_pszURL);
>   #endif	// _MAC_UNIX
>       }
> 
>       m_bStreamDone = TRUE;
> 
> +    DestroyStream(&m_NPStream);
> +
>       // If this is an FLV source and FLV file object
is on 
> the sidelines
>       // waiting to be used, shut-down the current
stream we 
> just finished
>       // loading (SWF player) and make FLV file object
the 
> current active
>       // object to use.
>       if (m_bIsFLVSource && m_pFLVFileObject)
>       {
>   	HX_RESULT status = HXR_OK;
>   	
> -	DestroyStream(&m_NPStream);
>   	if (m_pFileObject)
>   	{
>   	    m_pFileObject->Close();
>   	    HX_RELEASE(m_pFileObject);
>   	}
>  -4823,12 +4835,16 
>               {
>                   // Have we read the entire file?
>                   if ((m_ulFileSize != 0) &&
(m_ulFileOffset 
> >= m_ulFileSize))
>                   {
>                       // We've read the whole file, so
tell the 
> NSPlugin we're done
> +		    // For FLV, only call FinishFile on the SWF 
> wrapper object, not the FLV
> +		    if (!m_bIsFLVSource || m_pFLVFileObject)
> +		    {
>                       FinishFile();
>                   }
> +                }
>                   else
>                   {
>                       // Call SendStream again
>                       SendStream();
>                   }
> Index: pub/flash_guest_player_ns.h
>
============================================================
=======
> RCS file: 
>
/cvsroot/datatype/flash/flashhost/pub/flash_guest_player_ns.
h,v
> retrieving revision 1.14.2.4
> diff -w -u -5 -r1.14.2.4 flash_guest_player_ns.h
> --- pub/flash_guest_player_ns.h	28 Sep 2007 21:15:11 
> -0000	1.14.2.4
> +++ pub/flash_guest_player_ns.h	4 Oct 2007 03:38:00
-0000
>  -289,10 +289,11 
>       static const char* const	m_pszFlashMimeType;
>       static CHXStringList	m_StringIds;
>       static CHXSimpleList	m_IntIds;
>       static CHXString	    	m_pUserAgentStr;
>       static INT32		m_lFlashRefCount;
> +    static _NPP			m_firstNPP;	// 
> first instance
> 
>       NPRect*	m_pOutstandingInvalidRect;
> 
>       _NPP	m_NPP;		// instance
>       NPObject*	m_psobj;	// scriptable object
> 
> 
> _______________________________________________
> Datatype-dev mailing list
> Datatype-devhelixcommunity.org
> http://lists.helixcommunity.org/mailman/listinfo/da
tatype-dev
> 


_______________________________________________
Datatype-dev mailing list
Datatype-devhelixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/da
tatype-dev

CN: Flash Guest Player NS fixes for multipleinstances
country flaguser name
United States
2007-10-05 16:41:54
Thank you, checked into HEAD and atlas310.
--christina

At 07:52 AM 10/5/2007, Eric Hyche wrote:

>Looks good to me.
>
>=============================================
>Eric Hyche (ehychereal.com)
>Technical Lead
>RealNetworks, Inc.
>
> > -----Original Message-----
> > From: datatype-dev-bounceshelixcommunity.org
> > [mailto:datatype-dev-bounceshelixcommunity.org] On
Behalf Of
> > Christina Dunn
> > Sent: Wednesday, October 03, 2007 11:56 PM
> > To: datatype-devhelixcommunity.org
> > Subject: [datatype-dev] CR: Flash Guest Player NS
fixes for
> > multipleinstances
> >
> > Synopsis: Nimbus would hang or crash if there were
more than one
> > instance of a SWF, when using the Netscape version
of the
> > Flash Guest Player.
> >
> > Overview: There were several issues regarding
multiple instance
> > creation and destruction.
> > - Call NPP_DestroyStream after all writes to Flash
have been
> > completed.
> > - Call NPP_StreamAsFile instead of NPP_URLNotify
for local files,
> > regardless of what NPP_NewStream returns as the
stream type.
> > StreamAsFile is for local files as indicated by
the documentation.
> > - Call NPP_Destroy on only the first instance that
was created, and
> > if it's the last instance destroyed. This is the
only scenario that
> > would not crash for multiple instances.
> > - DisableLocalSecurity can only be called once,
similar to
> > NP_Initialize. It did not create a crash, but it
always fails on
> > subsequent calls.
> > - Set the m_bTerminated flag inside of the block
that actually
> > terminates the Flash plugin. This fixed a bug
where you could not
> > play an FLV twice, due to the first instance not
being destroyed.
> > - For FLV, only call FinishFile on the SWF wrapper
object, not the
> > FLV, which will cause the timeline to stop after
HTTP file system
> > reports that it is done reading.
> >
> > Files:
> >
datatype/flash/flashhost/flash_guest_player_ns.cpp
> >
datatype/flash/flashhost/pub/flash_guest_player_ns.h
> >
> > Branches:
> > HEAD, atlas310
> >
> > Index: flash_guest_player_ns.cpp
> >
============================================================
=======
> > RCS file:
> >
/cvsroot/datatype/flash/flashhost/flash_guest_player_ns.cpp,
v
> > retrieving revision 1.27.2.8
> > diff -w -u -5 -r1.27.2.8
flash_guest_player_ns.cpp
> > --- flash_guest_player_ns.cpp 28 Sep 2007 21:15:10
-0000      1.27.2.8
> > +++ flash_guest_player_ns.cpp 4 Oct 2007 03:37:05
-0000
> >  -122,10 +122,11 
> >   const char* const  
CFlashGuestPlayerNS::m_pszFlashMimeType =
> > "application/x-shockwave-flash";
> >   CHXStringList          
CFlashGuestPlayerNS::m_StringIds;
> >   CHXSimpleList          
CFlashGuestPlayerNS::m_IntIds;
> >   CHXString      
CFlashGuestPlayerNS::m_pUserAgentStr;
> >   INT32                  
CFlashGuestPlayerNS::m_lFlashRefCount = 0;
> > +_NPP             CFlashGuestPlayerNS::m_firstNPP
= {NULL,NULL};
> >
> >   NPClass CNPObjectWrapper::m_npclass =
> >   {
> >       NP_CLASS_STRUCT_VERSION,
> >       CNPObjectWrapper::NP_Allocate,
> >  -616,22 +617,10 
> >
> >           if (m_pDLLAccess &&
m_pDLLAccess->isOpen())
> >           {
> >               NPError npstatus;
> >
> > -         // Disable local security
> > -         NP_DISABLELOCALSECURITY
pfnDisableLocalSecurity =
> > (NP_DISABLELOCALSECURITY)
> >
m_pDLLAccess->getSymbol("Flash_DisableLocalSecurity&
quot;);
> > -         if (pfnDisableLocalSecurity &&
> > -             ((npstatus =
pfnDisableLocalSecurity()) ==
> > NPERR_NO_ERROR))
> > -         {
> > -             HXLOGL4(HXLOG_FPHR,
> > "CFlashGuestPlayerNS::InitNSPlugin()
> > Flash_DisableLocalSecurity succeeded");
> > -         }
> > -         else
> > -         {
> > -             HXLOGL4(HXLOG_FPHR,
> > "CFlashGuestPlayerNS::InitNSPlugin()
> > Flash_DisableLocalSecurity failed");
> > -         }
> > -
> >               NP_GETENTRYPOINTS pfnGetEntryPoints
=
> > (NP_GETENTRYPOINTS)
m_pDLLAccess->getSymbol("NP_GetEntryPoints");
> >               // Get the SWF plug-in entry points
> >               if (pfnGetEntryPoints &&
> >                   ((npstatus = pfnGetEntryPoints(
&m_PluginFuncs ))
> > == NPERR_NO_ERROR))
> >               {
> >  -645,10 +634,22 
> >               }
> >
> >               // Set the callbacks for the
plug-in
> >           if (m_lFlashRefCount == 0)
> >           {
> > +             // Disable local security
> > +             NP_DISABLELOCALSECURITY
pfnDisableLocalSecurity =
> > (NP_DISABLELOCALSECURITY)
> >
m_pDLLAccess->getSymbol("Flash_DisableLocalSecurity&
quot;);
> > +             if (pfnDisableLocalSecurity
&&
> > +                 ((npstatus =
pfnDisableLocalSecurity()) ==
> > NPERR_NO_ERROR))
> > +             {
> > +                 HXLOGL4(HXLOG_FPHR,
> > "CFlashGuestPlayerNS::InitNSPlugin()
> > Flash_DisableLocalSecurity succeeded");
> > +             }
> > +             else
> > +             {
> > +                 HXLOGL4(HXLOG_FPHR,
> > "CFlashGuestPlayerNS::InitNSPlugin()
> > Flash_DisableLocalSecurity failed");
> > +             }
> > +
> >               NP_INITIALIZE pfnInitialize =
(NP_INITIALIZE)
> >
m_pDLLAccess->getSymbol("NP_Initialize");
> >               if (pfnInitialize &&
> >                   ((npstatus = pfnInitialize(
&m_HostFuncs))
> > == NPERR_NO_ERROR))
> >               {
> >                   HXLOGL4(HXLOG_FPHR,
> > "CFlashGuestPlayerNS::InitNSPlugin() Set
> > callbacks.");
> >  -799,10 +800,18 
> >           // so that we do not destroy the shared
data on Terminate.
> >           m_lFlashRefCount++;
> >
> >           m_bTerminated = FALSE;
> >
> > +         //XXXctd Keep track of the first
instance, so that
> > we can call
> > NPP_Destroy on it.
> > +         // For multiple instances, only call
destroy on the first.
> > +         if (m_lFlashRefCount == 1)
> > +         {
> > +             m_firstNPP.ndata = NULL;
> > +             m_firstNPP.pdata = m_NPP.pdata;
> > +         }
> > +
> >           // MBO - Test
> >   #if defined(_MAC_UNIX)
> >   #if defined(_DEBUG)
> >           //
> >
printf("CFlashGuestPlayerNS::CreatePluginInstance
m_NPP=%p
> > RefCount=%ldn", &m_NPP,
m_lFlashRefCount);
> >   #endif      // _DEBUG
> >  -1094,12 +1103,10 
> >   HX_RESULT
> >  
CFlashGuestPlayerNS::OpenStreamPerPluginRequest(void*
pNotifyData)
> >   {
> >       HX_RESULT retVal = HXR_FAIL;
> >
> > -    HX_ASSERT(m_bIsFLVSource);
> > -
> >       // We support one open stream at the time -
the one passed in
> > for FLV playback.
> >       // We create new stream if this is FLV
playback case
> > and FLV file object
> >       // is set-up as the current file object (SWF
has been
> > processed) and we
> >       // have not opened the stream yet.
> >       if (m_bIsFLVSource && m_pFileObject
&& (!m_pFLVFileObject) &&
> > (!m_NPStream.url))
> >  -1264,29 +1271,29 
> >           DeleteObject(m_hBitmap); // Delete after
the dc has
> > been deleted.
> >       }
> >       m_hdc = NULL;
> >       m_hwnd = NULL;
> >   #endif
> > -
> >       if (!m_bTerminated &&
(m_lFlashRefCount > 0))
> >       {
> >           m_lFlashRefCount--;
> >       }
> >
> >       if (m_lFlashRefCount <= 0)
> >       {
> >           // Destroy the plugin instance - this
should be
> > done for every instances
> >           // but causes problem for other
instances - needs
> > to be investigated.
> > -         if ((!m_bTerminated) &&
m_PluginFuncs.destroy)
> > +         //XXXctd Added m_pFirstInstance var,
only the first
> > instance
> > can be called with NPP_Destroy
> > +         if (m_PluginFuncs.destroy &&
m_firstNPP.pdata ==
> > m_NPP.pdata)
> >           {
> >               HXLOGL4(HXLOG_FPHR, "tcalling
NPP_Destroy");
> >   #if defined(_MAC_UNIX)
> >               // MBO - Test
> >               //
printf("m_PluginFuncs.destroy
> > m_NPP=%p  m_lFlashRefCount=%ldn",
&m_NPP, m_lFlashRefCount);
> >   #endif      // _MAC_UNIX
> >               m_PluginFuncs.destroy(&m_NPP,
NULL);
> > -             // m_lFlashRefCount--;
> > +             m_firstNPP.pdata = NULL;
> >           }
> >
> >           // This is the last reference, so
destroy the statc
> > object and
> > close the dll
> >           m_StringIds.RemoveAll();
> >           m_IntIds.RemoveAll();
> >  -1306,13 +1313,13 
> >
> >       HX_RELEASE(m_pOffscreenBuffer);
> >       HX_RELEASE(m_pMutex);
> >       HX_RELEASE(m_pSite);
> >       HX_RELEASE(m_pScheduler);
> > -    }
> >
> >       m_bTerminated = TRUE;
> > +    }
> >
> >       return HXR_OK;
> >   }
> >
> >   //
> >  -4507,40 +4514,45 
> >
> >   void
> >   CFlashGuestPlayerNS::FinishFile()
> >   {
> >       HXLOGL4(HXLOG_FPHR,
"CFlashGuestPlayerNS::FinishFile()");
> > -    if (m_dStreamType == NP_ASFILE)
> > +    if (m_dStreamType == NP_ASFILE ||
m_pszURL.Find("file://") == 0)
> >       {
> >           // Send the plugin the url of the file
we just wrote to it.
> > +        // NPP_StreamAsFile        Provides a
local file name for
> > the data from a stream.
> > +     // Call this method instead of urlnotify, no
matter
> > what newstream
> > returns, otherwise
> > +     // the second instance call to urlnotify
will hang.
> >           m_PluginFuncs.asfile( &m_NPP,
&m_NPStream, (const
> > char*) m_pszURL );
> >   #if defined(_MAC_UNIX)
> >       // MBO - Test
> >       //
printf("m_PluginFuncs.asfile(m_NPP=%p m_NPStream=%p
> > URL=%sn",
> > &m_NPP, &m_NPStream, m_pszURL);
> >   #endif      // _MAC_UNIX
> >       }
> >       else if (m_dStreamType == NP_NORMAL)
> >       {
> >           // Notify the plugin we are done
writing
> > -        m_PluginFuncs.urlnotify( &m_NPP ,
m_pszURL,
> > NPRES_DONE , NULL );
> > +        // NPP_URLNotify Notifies the instance of
the completion of
> > a URL request.
> > +        m_PluginFuncs.urlnotify( &m_NPP ,
(const char*)m_pszURL,
> > NPRES_DONE , NULL );
> >   #if defined(_MAC_UNIX)
> >       // MBO - Test
> >       //
printf("m_PluginFuncs.urlnotify(m_NPP=%p
URL=%sn", &m_NPP,
> > (const char*) m_pszURL);
> >   #endif      // _MAC_UNIX
> >       }
> >
> >       m_bStreamDone = TRUE;
> >
> > +    DestroyStream(&m_NPStream);
> > +
> >       // If this is an FLV source and FLV file
object is on
> > the sidelines
> >       // waiting to be used, shut-down the current
stream we
> > just finished
> >       // loading (SWF player) and make FLV file
object the
> > current active
> >       // object to use.
> >       if (m_bIsFLVSource &&
m_pFLVFileObject)
> >       {
> >       HX_RESULT status = HXR_OK;
> >
> > -     DestroyStream(&m_NPStream);
> >       if (m_pFileObject)
> >       {
> >           m_pFileObject->Close();
> >           HX_RELEASE(m_pFileObject);
> >       }
> >  -4823,12 +4835,16 
> >               {
> >                   // Have we read the entire
file?
> >                   if ((m_ulFileSize != 0)
&& (m_ulFileOffset
> > >= m_ulFileSize))
> >                   {
> >                       // We've read the whole
file, so tell the
> > NSPlugin we're done
> > +                 // For FLV, only call FinishFile
on the SWF
> > wrapper object, not the FLV
> > +                 if (!m_bIsFLVSource ||
m_pFLVFileObject)
> > +                 {
> >                       FinishFile();
> >                   }
> > +                }
> >                   else
> >                   {
> >                       // Call SendStream again
> >                       SendStream();
> >                   }
> > Index: pub/flash_guest_player_ns.h
> >
============================================================
=======
> > RCS file:
> >
/cvsroot/datatype/flash/flashhost/pub/flash_guest_player_ns.
h,v
> > retrieving revision 1.14.2.4
> > diff -w -u -5 -r1.14.2.4 flash_guest_player_ns.h
> > --- pub/flash_guest_player_ns.h       28 Sep 2007
21:15:11
> > -0000 1.14.2.4
> > +++ pub/flash_guest_player_ns.h       4 Oct 2007
03:38:00 -0000
> >  -289,10 +289,11 
> >       static const char* const       
m_pszFlashMimeType;
> >       static CHXStringList    m_StringIds;
> >       static CHXSimpleList    m_IntIds;
> >       static CHXString               
m_pUserAgentStr;
> >       static INT32            m_lFlashRefCount;
> > +    static _NPP                      m_firstNPP; 
   //
> > first instance
> >
> >       NPRect* m_pOutstandingInvalidRect;
> >
> >       _NPP    m_NPP;          // instance
> >       NPObject*       m_psobj;        //
scriptable object
> >
> >
> > _______________________________________________
> > Datatype-dev mailing list
> > Datatype-devhelixcommunity.org
> > http://lists.helixcommunity.org/mailman/listinfo/da
tatype-dev
> >



_______________________________________________
Datatype-dev mailing list
Datatype-devhelixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/da
tatype-dev

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )