Package org.red5.server.net.rtmp.event

Examples of org.red5.server.net.rtmp.event.Invoke


   * @param status           Status
   */
  public void sendStatus(Status status) {
    if (connection != null) {
      final boolean andReturn = !status.getCode().equals(StatusCodes.NS_DATA_START);
      final Invoke event = new Invoke();
      if (andReturn) {
        final PendingCall call = new PendingCall(null, CALL_ON_STATUS, new Object[] { status });
        if (status.getCode().equals(StatusCodes.NS_PLAY_START)) {
          IScope scope = connection.getScope();
          if (scope.getContext().getApplicationContext().containsBean(IRtmpSampleAccess.BEAN_NAME)) {
            IRtmpSampleAccess sampleAccess = (IRtmpSampleAccess) scope.getContext().getApplicationContext().getBean(IRtmpSampleAccess.BEAN_NAME);
            boolean videoAccess = sampleAccess.isVideoAllowed(scope);
            boolean audioAccess = sampleAccess.isAudioAllowed(scope);
            if (videoAccess || audioAccess) {
              final Call call2 = new Call(null, "|RtmpSampleAccess", null);
              Notify notify = new Notify();
              notify.setCall(call2);
              notify.setData(IoBuffer.wrap(new byte[] { 0x01, (byte) (audioAccess ? 0x01 : 0x00), 0x01, (byte) (videoAccess ? 0x01 : 0x00) }));
              write(notify, connection.getStreamIdForChannel(id));
            }
          }
        }
        event.setCall(call);
      } else {
        final Call call = new Call(null, CALL_ON_STATUS, new Object[] { status });
        event.setCall(call);
      }
      // send directly to the corresponding stream as for some status codes, no stream has been created  and thus "getStreamByChannelId" will fail
      write(event, connection.getStreamIdForChannel(id));
    }
  }
View Full Code Here


    if (channel == null) {
      log.warn("The client is no longer connected.");
      return;
    }
    call.setResult(result);
    Invoke reply = new Invoke();
    reply.setCall(call);
    reply.setTransactionId(transactionId);
    channel.write(reply);
    channel.getConnection().unregisterDeferredResult(this);
  }
View Full Code Here

  }

  /** {@inheritDoc} */
  public void invoke(IServiceCall call, int channel) {
    // We need to use Invoke for all calls to the client
    Invoke invoke = new Invoke();
    invoke.setCall(call);
    invoke.setTransactionId(getTransactionId());
    if (call instanceof IPendingServiceCall) {
      registerPendingCall(invoke.getTransactionId(), (IPendingServiceCall) call);
    }
    getChannel(channel).write(invoke);
  }
View Full Code Here

//    resp.flushBuffer();
   
    // create and send a rejected status
    Status status = new Status(StatusCodes.NC_CONNECT_REJECTED, Status.ERROR, message);
    PendingCall call = new PendingCall(null, "onStatus", new Object[] { status });
    Invoke event = new Invoke();
    event.setCall(call);
    Header header = new Header();
    Packet packet = new Packet(header, event);
    header.setDataType(event.getDataType());
    // create dummy connection if local is empty
    RTMPConnection conn = (RTMPConnection) Red5.getConnectionLocal();
    if (conn == null) {
      try {
        conn = ((RTMPConnManager) manager).createConnectionInstance(RTMPTConnection.class);
View Full Code Here

          sendResult = false;
        }
      }
      if (sendResult) {
        // The client expects a result for the method call.
        Invoke reply = new Invoke();
        reply.setCall(call);
        reply.setTransactionId(command.getTransactionId());
        channel.write(reply);
        if (disconnectOnReturn) {
          log.debug("Close connection due to connect handling exception: {}", conn.getSessionId());
          conn.close();
        }
View Full Code Here

    }
  }

  /** {@inheritDoc} */
  public Invoke decodeInvoke(Encoding encoding, IoBuffer in) {
    Invoke invoke = new Invoke();
    int start = in.position();
    Input input;
    // for response, the action string and invokeId is always encoded as AMF0 we use the first byte to decide which encoding to use.
    byte tmp = in.get();
    in.position(start);
    if (encoding == Encoding.AMF3 && tmp == AMF.TYPE_AMF3_OBJECT) {
      input = new org.red5.io.amf3.Input(in);
      ((org.red5.io.amf3.Input) input).enforceAMF3();
    } else {
      input = new org.red5.io.amf.Input(in);
    }
    // get the action
    String action = Deserializer.deserialize(input, String.class);
    if (log.isTraceEnabled()) {
      log.trace("Action " + action);
    }
    //throw a runtime exception if there is no action
    if (action != null) {
      invoke.setTransactionId(Deserializer.<Number> deserialize(input, Number.class).intValue());
      // now go back to the actual encoding to decode parameters
      if (encoding == Encoding.AMF3) {
        input = new org.red5.io.amf3.Input(in);
        ((org.red5.io.amf3.Input) input).enforceAMF3();
      } else {
        input = new org.red5.io.amf.Input(in);
      }
      // get / set the parameters if there any
      Object[] params = handleParameters(in, invoke, input);
      // determine service information
      final int dotIndex = action.lastIndexOf('.');
      String serviceName = (dotIndex == -1) ? null : action.substring(0, dotIndex);
      // pull off the prefixes since java doesnt allow this on a method name
      if (serviceName != null && (serviceName.startsWith("@") || serviceName.startsWith("|"))) {
        serviceName = serviceName.substring(1);
      }
      String serviceMethod = (dotIndex == -1) ? action : action.substring(dotIndex + 1, action.length());
      // pull off the prefixes since java doesn't allow this on a method name
      if (serviceMethod.startsWith("@") || serviceMethod.startsWith("|")) {
        serviceMethod = serviceMethod.substring(1);
      }
      PendingCall call = new PendingCall(serviceName, serviceMethod, params);
      invoke.setCall(call);
      return invoke;
    } else {
      //TODO replace this with something better as time permits
      throw new RuntimeException("Action was null");
    }
View Full Code Here

          break;
        case TYPE_VIDEO_DATA:
          msg = new VideoData(tag.getBody());
          break;
        case TYPE_INVOKE:
          msg = new Invoke(tag.getBody());
          break;
        case TYPE_NOTIFY:
          msg = new Notify(tag.getBody());
          break;
        default:
View Full Code Here

    assertEquals(header, result);
    Red5.setConnectionLocal(null);
  }

  public void testInvokePacket() {
    @SuppressWarnings("unused")
    Invoke invoke = new Invoke();
  }
View Full Code Here

        break;
      case TYPE_VIDEO_DATA:
        msg = new VideoData(tag.getBody());
        break;
      case TYPE_INVOKE:
        msg = new Invoke(tag.getBody());
        break;
      case TYPE_NOTIFY:
        msg = new Notify(tag.getBody());
        break;
      default:
View Full Code Here

  }

  /** {@inheritDoc} */
  public void invoke(IServiceCall call, int channel) {
    // We need to use Invoke for all calls to the client
    Invoke invoke = new Invoke();
    invoke.setCall(call);
    invoke.setInvokeId(getInvokeId());
    if (call instanceof IPendingServiceCall) {
      registerPendingCall(invoke.getInvokeId(),
          (IPendingServiceCall) call);
    }
    getChannel(channel).write(invoke);
  }
View Full Code Here

TOP

Related Classes of org.red5.server.net.rtmp.event.Invoke

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.