Package org.red5.server.api.plugin

Examples of org.red5.server.api.plugin.IRed5Plugin


         }
         String scopeName = "hibernate";
         if (rcl.getRoom_id() != null) {
           scopeName = rcl.getRoom_id().toString();
         }
         IScope currentScope = this.scopeApplicationAdapter.getRoomScope(scopeName);
         this.scopeApplicationAdapter.roomLeaveByScope(rcl, currentScope);
        
        
         HashMap<Integer,String> messageObj = new HashMap<Integer,String>();
         messageObj.put(0, "kick");
View Full Code Here


          }
          String scopeName = "hibernate";
          if (rcl.getRoom_id() != null) {
            scopeName = rcl.getRoom_id().toString();
          }
          IScope currentScope = this.scopeApplicationAdapter.getRoomScope(scopeName);
         
          HashMap<Integer,String> messageObj = new HashMap<Integer,String>();
          messageObj.put(0, "kick");
         
          this.scopeApplicationAdapter.sendMessageById(messageObj, rcl.getStreamid(), currentScope);
View Full Code Here

          //ensure plug-in class can be resolved
          ClassLoader classLoader = scope.getClassLoader();
          Class<?> clazz = Class.forName(desc.getPluginType(), true, classLoader);
          log.trace("Class: {}", clazz);
          //get the plug-in from the registry
          IRed5Plugin plugin = PluginRegistry.getPlugin(desc.getPluginName());
          log.debug("Got plugin from the registry: {}", plugin);
          //if the plugin class extends the red5 plug-in we will add the application to it
          if (plugin instanceof Red5Plugin) {
            //pass the app to the plugin so that it may be manipulated directly by the plug-in
            ((Red5Plugin) plugin).setApplication(this);
          }
          //when a plug-in method is specified do invokes
          if (desc.getMethod() != null) {
            Method method = plugin.getClass().getMethod(desc.getMethod(), (Class[]) null);
            //if a return type is not specified for the plug-in method just invoke it
            if (desc.getMethodReturnType() == null) {
              log.debug("Invoking plugin");
              method.invoke(plugin, (Object[]) null);
            } else {
View Full Code Here

      }
    });
   
    if (plugins != null) {

      IRed5Plugin red5Plugin = null;

      log.debug("{} plugins to launch", plugins.length);
      for (File plugin : plugins) {
          JarFile jar = null;
          Manifest manifest = null;
        try {
          jar = new JarFile(plugin, false);
          manifest = jar.getManifest();
        } catch (Exception e1) {
          log.warn("Error loading plugin manifest: {}", plugin);
        } finally {
          jar.close();
        }
        if (manifest == null) {
          continue;
        }       
          Attributes attributes = manifest.getMainAttributes();
          if (attributes == null) {
            continue;
          }
          String pluginMainClass = attributes.getValue("Red5-Plugin-Main-Class");
          if (pluginMainClass == null || pluginMainClass.length() <= 0) {
            continue;
          }
          // attempt to load the class; since it's in the plugins directory this should work
          ClassLoader loader = common.getClassLoader();
          Class<?> pluginClass;
          String pluginMainMethod = null;
          try {
            pluginClass = Class.forName(pluginMainClass, true, loader);
          } catch (ClassNotFoundException e) {
            continue;
          }
          try {
          //handle plug-ins without "main" methods
          pluginMainMethod = attributes.getValue("Red5-Plugin-Main-Method");
          if (pluginMainMethod == null || pluginMainMethod.length() <= 0) {
            //just get an instance of the class
            red5Plugin = (IRed5Plugin) pluginClass.newInstance();           
          } else {
            Method method = pluginClass.getMethod(pluginMainMethod, (Class<?>[]) null);
            Object o = method.invoke(null, (Object[]) null);
            if (o != null && o instanceof IRed5Plugin) {
              red5Plugin = (IRed5Plugin) o;
            }
          }
          //register and start
          if (red5Plugin != null) {
            //set top-level context
            red5Plugin.setApplicationContext(applicationContext);
            //set server reference
            red5Plugin.setServer(server);
            //register the plug-in to make it available for lookups
            PluginRegistry.register(red5Plugin);
            //start the plugin
            red5Plugin.doStart();
          }
          log.info("Loaded plugin: {}", pluginMainClass);
        } catch (Throwable t) {
          log.warn("Error loading plugin: {}; Method: {}", pluginMainClass, pluginMainMethod);
          log.error("", t);
View Full Code Here

    //get a write lock
    pluginWriteLock.lock();
    try {
      if (plugins.containsKey(pluginName)) {
        //get old plugin
        IRed5Plugin oldPlugin = plugins.get(pluginName);
        //if they are not the same shutdown the older one
        if (!plugin.equals(oldPlugin)) {     
          try {
            oldPlugin.doStop();
          } catch (Exception e) {
            log.warn("Exception caused when stopping old plugin", e);
          }
          //replace old one
          plugins.replace(pluginName, plugin);
View Full Code Here

   *
   * @param pluginName
   * @return requested plug-in matching the name given or null if not found
   */
  public static IRed5Plugin getPlugin(String pluginName) {
    IRed5Plugin plugin = null;
    pluginReadLock.lock();
    try {
      plugin = plugins.get(pluginName);
    } finally {
      pluginReadLock.unlock();
View Full Code Here

    log.info("Destroying and cleaning up {} plugins", plugins.size())
    //loop through the plugins and stop them
    pluginReadLock.lock();
    try {
      for (Entry<String, IRed5Plugin> pluginEntry : plugins.entrySet()) {
        IRed5Plugin plugin = pluginEntry.getValue();
        try {
          plugin.doStop();
        } catch (Exception ex) {
          if (plugin != null) {
            log.warn("Plugin stop failed for: {}", plugin.getName(), ex);
          } else {
            log.warn("Plugin stop failed", ex);
          }
        }
      }
View Full Code Here

    // ------------------------------------------------------------------------

    private void createPlayStream( IPendingServiceCallback callback ) {

        logger.debug( "create play stream" );
        IPendingServiceCallback wrapper = new CreatePlayStreamCallBack( callback );
        invoke( "createStream", null, wrapper );
    }
View Full Code Here

      if (stream.getStreamListeners() != null) {
       
        for (Iterator<IStreamListener> iter = stream.getStreamListeners().iterator();iter.hasNext();) {
         
          IStreamListener iStreamListener = iter.next();
         
          ListenerAdapter listenerAdapter = (ListenerAdapter) iStreamListener;
         
          log.debug("Stream Closing ?? "+listenerAdapter.getFlvRecordingMetaDataId()+ " " +flvRecordingMetaDataId);
         
View Full Code Here

            if ( !( event instanceof IRTMPEvent ) ) {
                logger.debug( "skipping non rtmp event: " + event );
                return;
            }

            IRTMPEvent rtmpEvent = (IRTMPEvent) event;

            if ( logger.isDebugEnabled() ) {
                // logger.debug("rtmp event: " + rtmpEvent.getHeader() + ", " +
                // rtmpEvent.getClass().getSimpleName());
            }

            if ( !( rtmpEvent instanceof IStreamData ) ) {
                logger.debug( "skipping non stream data" );
                return;
            }

            if ( rtmpEvent.getHeader().getSize() == 0 ) {
                logger.debug( "skipping event where size == 0" );
                return;
            }

            if ( rtmpEvent instanceof VideoData ) {
View Full Code Here

TOP

Related Classes of org.red5.server.api.plugin.IRed5Plugin

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.