/**
   * Notifies this <tt>Conference</tt> that the ordered list of <tt>Endpoint</tt>s of {@link
   * #speechActivity} i.e. the dominant speaker history has changed.
   *
   * <p>This instance notifies the video <tt>Channel</tt>s about the change so that they may update
   * their last-n lists and report to this instance which <tt>Endpoint</tt>s are to be asked for
   * video keyframes.
   */
  private void speechActivityEndpointsChanged() {
    List<Endpoint> endpoints = null;

    for (Content content : getContents()) {
      if (MediaType.VIDEO.equals(content.getMediaType())) {
        Set<Endpoint> endpointsToAskForKeyframes = null;

        endpoints = speechActivity.getEndpoints();
        for (Channel channel : content.getChannels()) {
          if (!(channel instanceof RtpChannel)) continue;

          RtpChannel rtpChannel = (RtpChannel) channel;
          List<Endpoint> channelEndpointsToAskForKeyframes =
              rtpChannel.speechActivityEndpointsChanged(endpoints);

          if ((channelEndpointsToAskForKeyframes != null)
              && !channelEndpointsToAskForKeyframes.isEmpty()) {
            if (endpointsToAskForKeyframes == null) {
              endpointsToAskForKeyframes = new HashSet<>();
            }
            endpointsToAskForKeyframes.addAll(channelEndpointsToAskForKeyframes);
          }
        }

        if ((endpointsToAskForKeyframes != null) && !endpointsToAskForKeyframes.isEmpty()) {
          content.askForKeyframes(endpointsToAskForKeyframes);
        }
      }
    }
  }
Пример #2
0
  /**
   * Adds <tt>listener</tt> to the list of {@link CapsVerListener}s that we notify when new features
   * occur and the version hash needs to be regenerated. The method would also notify
   * <tt>listener</tt> if our current caps version has been generated and is different than
   * <tt>null</tt>.
   *
   * @param listener the {@link CapsVerListener} we'd like to register.
   */
  public void addCapsVerListener(CapsVerListener listener) {
    synchronized (capsVerListeners) {
      if (capsVerListeners.contains(listener)) return;

      capsVerListeners.add(listener);

      if (currentCapsVersion != null) listener.capsVerUpdated(currentCapsVersion);
    }
  }
 private MetaTypeProviderWrapper[] getMetaTypeProviders() {
   Map<ServiceReference<Object>, Object> services = _tracker.getTracked();
   if (services.isEmpty()) return new MetaTypeProviderWrapper[0];
   Set<ServiceReference<Object>> serviceReferences = services.keySet();
   Set<MetaTypeProviderWrapper> result = new HashSet<MetaTypeProviderWrapper>();
   for (ServiceReference<Object> serviceReference : serviceReferences) {
     if (serviceReference.getBundle() == _bundle) {
       Object service = services.get(serviceReference);
       // If the service is not a MetaTypeProvider, we're not interested in it.
       if (service instanceof MetaTypeProvider) {
         // Include the METATYPE_PID, if present, to return as part of getPids(). Also, include the
         // METATYPE_FACTORY_PID, if present, to return as part of getFactoryPids().
         // The filter ensures at least one of these properties was set for a standalone
         // MetaTypeProvider.
         addMetaTypeProviderWrappers(
             MetaTypeProvider.METATYPE_PID,
             serviceReference,
             (MetaTypeProvider) service,
             false,
             result);
         addMetaTypeProviderWrappers(
             MetaTypeProvider.METATYPE_FACTORY_PID,
             serviceReference,
             (MetaTypeProvider) service,
             true,
             result);
         // If the service is a ManagedService, include the SERVICE_PID to return as part of
         // getPids().
         // The filter ensures the SERVICE_PID property was set.
         if (service instanceof ManagedService) {
           addMetaTypeProviderWrappers(
               Constants.SERVICE_PID, serviceReference, (MetaTypeProvider) service, false, result);
         }
         // If the service is a ManagedServiceFactory, include the SERVICE_PID to return as part of
         // getFactoryPids().
         // The filter ensures the SERVICE_PID property was set.
         else if (service instanceof ManagedServiceFactory) {
           addMetaTypeProviderWrappers(
               Constants.SERVICE_PID, serviceReference, (MetaTypeProvider) service, true, result);
         }
       }
     }
   }
   return result.toArray(new MetaTypeProviderWrapper[result.size()]);
 }
 private static Object mapValue(Object v) {
   if ((v == null)
       || v instanceof Number
       || v instanceof Boolean
       || v instanceof Character
       || v instanceof String
       || v instanceof DTO) {
     return v;
   }
   if (v instanceof Map) {
     Map<?, ?> m = (Map<?, ?>) v;
     Map<Object, Object> map = newMap(m.size());
     for (Map.Entry<?, ?> e : m.entrySet()) {
       map.put(mapValue(e.getKey()), mapValue(e.getValue()));
     }
     return map;
   }
   if (v instanceof List) {
     List<?> c = (List<?>) v;
     List<Object> list = newList(c.size());
     for (Object o : c) {
       list.add(mapValue(o));
     }
     return list;
   }
   if (v instanceof Set) {
     Set<?> c = (Set<?>) v;
     Set<Object> set = newSet(c.size());
     for (Object o : c) {
       set.add(mapValue(o));
     }
     return set;
   }
   if (v.getClass().isArray()) {
     final int length = Array.getLength(v);
     final Class<?> componentType = mapComponentType(v.getClass().getComponentType());
     Object array = Array.newInstance(componentType, length);
     for (int i = 0; i < length; i++) {
       Array.set(array, i, mapValue(Array.get(v, i)));
     }
     return array;
   }
   return String.valueOf(v);
 }
Пример #5
0
  /**
   * Handles chat room presence status updates.
   *
   * @param evt the <tt>LocalUserChatRoomPresenceChangeEvent</tt> instance containing the chat room
   *     and the type, and reason of the change
   */
  @Override
  public void localUserPresenceChanged(LocalUserChatRoomPresenceChangeEvent evt) {
    ChatRoom sourceChatRoom = evt.getChatRoom();

    String eventType = evt.getEventType();

    boolean existingContact = false;
    ChatRoomSourceContact foundContact = null;
    synchronized (contactResults) {
      for (ChatRoomSourceContact contact : contactResults) {
        if (contactEqualsChatRoom(contact, sourceChatRoom)) {
          existingContact = true;
          foundContact = contact;
          contactResults.remove(contact);
          break;
        }
      }
    }

    if (LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_JOINED.equals(eventType)) {
      if (existingContact) {
        foundContact.setPresenceStatus(ChatRoomPresenceStatus.CHAT_ROOM_ONLINE);
        synchronized (contactResults) {
          contactResults.add(foundContact);
        }
        fireContactChanged(foundContact);
      } else {
        ChatRoomWrapper chatRoom =
            MUCActivator.getMUCService().findChatRoomWrapperFromChatRoom(sourceChatRoom);
        if (chatRoom != null) addChatRoom(sourceChatRoom, false, chatRoom.isAutojoin());
      }
    } else if ((LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_LEFT.equals(eventType)
        || LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_KICKED.equals(eventType)
        || LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_DROPPED.equals(eventType))) {
      if (existingContact) {
        foundContact.setPresenceStatus(ChatRoomPresenceStatus.CHAT_ROOM_OFFLINE);
        synchronized (contactResults) {
          contactResults.add(foundContact);
        }
        fireContactChanged(foundContact);
      }
    }
  }
Пример #6
0
 /**
  * Returns the index of the contact in the contact results list.
  *
  * @param contact the contact.
  * @return the index of the contact in the contact results list.
  */
 public synchronized int indexOf(ChatRoomSourceContact contact) {
   Iterator<ChatRoomSourceContact> it = contactResults.iterator();
   int i = 0;
   while (it.hasNext()) {
     if (contact.equals(it.next())) {
       return i;
     }
     i++;
   }
   return -1;
 }
 private void addMetaTypeProviderWrappers(
     String servicePropertyName,
     ServiceReference<Object> serviceReference,
     MetaTypeProvider service,
     boolean factory,
     Set<MetaTypeProviderWrapper> wrappers) {
   String[] pids =
       getStringProperty(servicePropertyName, serviceReference.getProperty(servicePropertyName));
   for (String pid : pids) {
     wrappers.add(new MetaTypeProviderWrapper(service, pid, factory));
   }
 }
	public void testPersistenceBug343020() throws BundleException, InvalidSyntaxException {
		// get the system region
		Region systemRegion = digraph.getRegion(0);
		// create a test region
		Region testRegion = digraph.createRegion(getName());

		RegionFilterBuilder builder = digraph.createRegionFilterBuilder();
		// Import the system bundle from the systemRegion
		builder.allow(RegionFilter.VISIBLE_BUNDLE_NAMESPACE, "(id=0)");
		// import PP1
		builder.allow(RegionFilter.VISIBLE_PACKAGE_NAMESPACE, "(" + RegionFilter.VISIBLE_PACKAGE_NAMESPACE + "=pkg1.*)");
		digraph.connect(testRegion, builder.build(), systemRegion);
		// install CP2
		Bundle cp2 = bundleInstaller.installBundle(CP2, testRegion);

		bundleInstaller.resolveBundles(new Bundle[] {cp2});
		assertEquals("Wrong state for pc1.", Bundle.INSTALLED, cp2.getState());

		regionBundle.stop();

		// install PP1 there is no region alive
		bundleInstaller.installBundle(PP1);

		// start region bundle and confirm we can resolve cp2 now
		startRegionBundle();

		bundleInstaller.refreshPackages(new Bundle[] {cp2});
		assertEquals("Wrong state for pc1.", Bundle.RESOLVED, cp2.getState());

		// stop region bundle to test uninstalling bundles while stopped
		regionBundle.stop();
		cp2.uninstall();

		startRegionBundle();
		testRegion = digraph.getRegion(getName());
		assertNotNull("No test region found.", testRegion);
		Set<Long> testIds = testRegion.getBundleIds();
		assertEquals("Wrong number of test ids.", 0, testIds.size());
	}
Пример #9
0
  @Override
  public void chatRoomProviderWrapperRemoved(ChatRoomProviderWrapper provider) {
    LinkedList<ChatRoomSourceContact> tmpContactResults;
    synchronized (contactResults) {
      tmpContactResults = new LinkedList<ChatRoomSourceContact>(contactResults);

      for (ChatRoomSourceContact contact : tmpContactResults) {
        if (contact.getProvider().equals(provider.getProtocolProvider())) {
          contactResults.remove(contact);
          fireContactRemoved(contact);
        }
      }
    }
  }
Пример #10
0
  /**
   * Adds found result to the query results.
   *
   * @param room the chat room.
   * @param addQueryResult indicates whether we should add the chat room to the query results or
   *     fire an event without adding it to the results.
   * @param isAutoJoin the auto join state of the contact.
   */
  private void addChatRoom(ChatRoom room, boolean addQueryResult, boolean isAutoJoin) {
    if (queryString == null
        || ((room.getName().contains(queryString) || room.getIdentifier().contains(queryString)))) {
      ChatRoomSourceContact contact = new ChatRoomSourceContact(room, this, isAutoJoin);
      synchronized (contactResults) {
        contactResults.add(contact);
      }

      if (addQueryResult) {
        addQueryResult(contact, false);
      } else {
        fireContactReceived(contact, false);
      }
    }
  }
Пример #11
0
  /**
   * Adds found result to the query results.
   *
   * @param pps the protocol provider associated with the found chat room.
   * @param chatRoomName the name of the chat room.
   * @param chatRoomID the id of the chat room.
   * @param addQueryResult indicates whether we should add the chat room to the query results or
   *     fire an event without adding it to the results.
   * @param isAutoJoin the auto join state of the contact.
   */
  private void addChatRoom(
      ProtocolProviderService pps,
      String chatRoomName,
      String chatRoomID,
      boolean addQueryResult,
      boolean isAutoJoin) {
    if (queryString == null
        || ((chatRoomName.contains(queryString) || chatRoomID.contains(queryString)))) {
      ChatRoomSourceContact contact =
          new ChatRoomSourceContact(chatRoomName, chatRoomID, this, pps, isAutoJoin);
      synchronized (contactResults) {
        contactResults.add(contact);
      }

      if (addQueryResult) {
        addQueryResult(contact, false);
      } else {
        fireContactReceived(contact, false);
      }
    }
  }
Пример #12
0
  /**
   * Indicates that a change has occurred in the chat room data list.
   *
   * @param evt the event that describes the change.
   */
  @Override
  public void contentChanged(final ChatRoomListChangeEvent evt) {
    ChatRoomWrapper chatRoom = evt.getSourceChatRoom();
    switch (evt.getEventID()) {
      case ChatRoomListChangeEvent.CHAT_ROOM_ADDED:
        addChatRoom(chatRoom.getChatRoom(), false, chatRoom.isAutojoin());
        break;
      case ChatRoomListChangeEvent.CHAT_ROOM_REMOVED:
        LinkedList<ChatRoomSourceContact> tmpContactResults;
        synchronized (contactResults) {
          tmpContactResults = new LinkedList<ChatRoomSourceContact>(contactResults);

          for (ChatRoomSourceContact contact : tmpContactResults) {
            if (contactEqualsChatRoom(contact, chatRoom)) {
              contactResults.remove(contact);
              fireContactRemoved(contact);
              break;
            }
          }
        }
        break;
      case ChatRoomListChangeEvent.CHAT_ROOM_CHANGED:
        synchronized (contactResults) {
          for (ChatRoomSourceContact contact : contactResults) {
            if (contactEqualsChatRoom(contact, chatRoom.getChatRoom())) {
              if (chatRoom.isAutojoin() != contact.isAutoJoin()) {
                contact.setAutoJoin(chatRoom.isAutojoin());
                fireContactChanged(contact);
              }
              break;
            }
          }
        }
        break;
      default:
        break;
    }
  }
Пример #13
0
 static Set toImmutableSet(Object obj) {
   Set set = new HashSet();
   set.add(obj);
   set = Collections.unmodifiableSet(set);
   return set;
 }
	public void testMbeans() throws MalformedObjectNameException, BundleException, InstanceNotFoundException, ReflectionException, MBeanException, AttributeNotFoundException {
		MBeanServer server = ManagementFactory.getPlatformMBeanServer();
		ObjectName digraphName = new ObjectName(REGION_DOMAIN_PROP + ":type=RegionDigraph,*");
		ObjectName regionNameAllQuery = new ObjectName(REGION_DOMAIN_PROP + ":type=Region,name=*,*");
		Set<ObjectInstance> digraphs = server.queryMBeans(null, digraphName);
		assertEquals("Expected only one instance of digraph", 1, digraphs.size());
		Set<ObjectInstance> regions = server.queryMBeans(null, regionNameAllQuery);
		assertEquals("Expected only one instance of region", 1, regions.size());

		Region pp1Region = digraph.createRegion(PP1);
		Bundle pp1Bundle = bundleInstaller.installBundle(PP1, pp1Region);
		Region sp1Region = digraph.createRegion(SP1);
		Bundle sp1Bundle = bundleInstaller.installBundle(SP1, sp1Region);

		regions = server.queryMBeans(null, regionNameAllQuery);
		assertEquals("Wrong number of regions", 3, regions.size());

		Set<ObjectInstance> pp1Query = server.queryMBeans(null, new ObjectName(REGION_DOMAIN_PROP + ":type=Region,name=" + PP1 + ",*"));
		assertEquals("Expected only one instance of: " + PP1, 1, pp1Query.size());
		Set<ObjectInstance> sp1Query = server.queryMBeans(null, new ObjectName(REGION_DOMAIN_PROP + ":type=Region,name=" + SP1 + ",*"));
		assertEquals("Expected only one instance of: " + SP1, 1, sp1Query.size());
		ObjectName pp1Name = (ObjectName) server.invoke(digraphs.iterator().next().getObjectName(), "getRegion", new Object[] {PP1}, new String[] {String.class.getName()});
		assertEquals(PP1 + " regions not equal.", pp1Query.iterator().next().getObjectName(), pp1Name);
		ObjectName sp1Name = (ObjectName) server.invoke(digraphs.iterator().next().getObjectName(), "getRegion", new Object[] {SP1}, new String[] {String.class.getName()});
		assertEquals(SP1 + " regions not equal.", sp1Query.iterator().next().getObjectName(), sp1Name);

		// test non existing region
		ObjectName shouldNotExistName = (ObjectName) server.invoke(digraphs.iterator().next().getObjectName(), "getRegion", new Object[] {"ShouldNotExist"}, new String[] {String.class.getName()});
		assertNull("Should not exist", shouldNotExistName);

		long[] bundleIds = (long[]) server.getAttribute(pp1Name, "BundleIds");
		assertEquals("Wrong number of bundles", 1, bundleIds.length);
		assertEquals("Wrong bundle", pp1Bundle.getBundleId(), bundleIds[0]);
		String name = (String) server.getAttribute(pp1Name, "Name");
		assertEquals("Wrong name", PP1, name);

		bundleIds = (long[]) server.getAttribute(sp1Name, "BundleIds");
		assertEquals("Wrong number of bundles", 1, bundleIds.length);
		assertEquals("Wrong bundle", sp1Bundle.getBundleId(), bundleIds[0]);
		name = (String) server.getAttribute(sp1Name, "Name");
		assertEquals("Wrong name", SP1, name);

		regionBundle.stop();

		// Now make sure we have no mbeans
		digraphs = server.queryMBeans(digraphName, null);
		assertEquals("Wrong number of digraphs", 0, digraphs.size());
		regions = server.queryMBeans(null, regionNameAllQuery);
		assertEquals("Wrong number of regions", 0, regions.size());
	}
 public static String[] getApplicationNames() {
   Set result = getApplicationNameSet();
   return (String[]) result.toArray(new String[result.size()]);
 }
Пример #16
0
 /**
  * Removes <tt>listener</tt> from the list of currently registered {@link CapsVerListener}s.
  *
  * @param listener the {@link CapsVerListener} we'd like to unregister.
  */
 public void removeCapsVerListener(CapsVerListener listener) {
   synchronized (capsVerListeners) {
     capsVerListeners.remove(listener);
   }
 }