Exemplo n.º 1
0
 @Override
 public boolean add(IElement element) {
   BaseGstElement elem = (BaseGstElement) element;
   synchronized (elem.ownershipLock()) {
     elem.takeOwnership();
     if (!gst_bin_add(ptr, element.getPointer())) {
       elem.releaseOwnership();
       return false;
     }
   }
   return true;
 }
Exemplo n.º 2
0
  @Override
  public void visitSources(IElementVisitor visitor) {
    if (visitor == null) return;

    Pointer pIterator = gst_bin_iterate_sources(ptr);
    if (pIterator == null || pIterator == Pointer.NULL) return;

    boolean done = false;
    PointerByReference ref = new PointerByReference();
    while (!done) {
      // This will increase the ref counter -- so we need to create an object
      // that doesn't increase the ref counter when it's built so on dispose(),
      // the ref count will be zero.
      switch (IteratorResult.fromNative(gst_iterator_next(pIterator, ref))) {
        case OK:
          // Passing true here tells it to increase the ref count
          // when building a new element from the pointer.
          IElement element = Element.from(ref.getValue(), true);
          boolean ret = visitor.visit(this, element);
          element.unref();
          done = !ret;
          break;
        case Resync:
          gst_iterator_resync(pIterator);
          break;
        case Error:
        case Done:
        case Unknown:
          done = true;
          break;
        default:
          done = true;
          break;
      }
    }
    gst_iterator_free(pIterator);
  }
Exemplo n.º 3
0
 @Override
 public boolean remove(IElement element) {
   return gst_bin_remove(ptr, element.getPointer());
 }