3 Replies Latest reply on Nov 18, 2010 7:06 AM by Mykola3296

    DVRCastNetConnectionFactory feature request

    Mykola3296 Level 2

      Hello OSMF!

       

      Could you please make a minor enhancement to DVRCastNetConnectionFactory?

       

      In our project we use a NetConnection library to make extra communication through the FMS server.

      That assumes single connection sharing between all streaming resources + some API calls through that channels.

      So we use NetConnectionFactory with shareNetConnections set to true to create the connection and share it.

       

      We use proprietary MediaFactory based on DefaultMediaFactory design to create loaders that share the same connection factory.

      The problem apperas when trying to share the connection with DVRCastNetConnectionFactory by using the following code:

      //Create base connection factory
      var connectionFactory:NetConnectionFactoryBase = new NetConnectionFactory(true);
      
       
      //Create DVRCastNetLoader based on shared factory
      dvrCastLoader = new DVRCastNetLoader(new DVRCastNetConnectionFactory(connectionFactory));
      

       

      When using this code no stream except DVR could be played.

       

      The problem is in onCreationComplete function. Here is the abstract:

       

      private function onCreationComplete(event:NetConnectionFactoryEvent):void
      {
           var urlResource:URLResource = event.resource as URLResource;
           var netConnection:NetConnection = event.netConnection;
           var streamNames:Vector.<String> = new Vector.<String>();
           var totalRpcSubscribeInvocation:int = 0;
                     
           // Capture this event, whithold it from the outside world until
           // we have succeeded subscribing to the DVRCast stream:
           event.stopImmediatePropagation();
      
           .....................
      }               
      
       
      

       

      So if we create DVRCastNetConnectionFactory that wraps NetConnectionFactory it will block any connection request except DVR (as noted in comment) for .

       

       

      The fix seems to be very simple. I've tried it in our project and it seems to work fine. Here is the modified function:

       

      private function onCreationComplete(event:NetConnectionFactoryEvent):void
      {
           var urlResource:URLResource = event.resource as URLResource;
      
           //POTENTIAL FIX
           //Check if DVR stream is required
           //If not pass the connection further
           var isDVRRequired:Boolean = urlResource is StreamingURLResource && StreamType.DVR == StreamingURLResource(urlResource).streamType; 
           if (!isDVRRequired) return;
           //END OF FIX
      
           var netConnection:NetConnection = event.netConnection;
           var streamNames:Vector.<String> = new Vector.<String>();
           var totalRpcSubscribeInvocation:int = 0;
                     
           // Capture this event, whithold it from the outside world until
           // we have succeeded subscribing to the DVRCast stream:
           event.stopImmediatePropagation();
      
      
           ..................
      }
       
      

       

      By adding two lines in the beginning we check if the required connection is for a DVR stream or not. If not - we just give it away to the event chain.

       

      A little more information about our approach.

      As I've said we use a proprietary media factory based on DefaultMediaFactory design.

      In DefaultMediaFactory loader creation order appears to be critical to said problem due to event dispatching and propagation way.

      Here is the order loaders are created in factory (init() function):

      1) F4MLoader

      2) DVRCastNetLoader

      3) HTTPStreamingNetLoader

      4) MulticastNetLoader

      5) RTMPDynamicStreamingNetLoader

      6) NetLoader

       

      Note that DVRCastNetLoader is created BEFORE NetLoader thus DVRCastNetLoader onCreationComplete is called BEFORE any other handler and event.stopImmediatePropagation(); blocks other stream type loaders.

      So the quick fix - is just move DVRCastNetLoader creation DOWN the list :O)

      That way, NetLoader onCreationComplete is called before DVRCastNetLoader's and other connection types are not blocked.

      However that could not be considered as a reliable fix...

       

      Thank you!