Package org.red5.io.object

Examples of org.red5.io.object.Input


   * @param in
   * @param input
   */
  protected void doDecodeSharedObject(SharedObjectMessage so, IoBuffer in, Input input) {
    // Parse request body
    Input amf3Input = new org.red5.io.amf3.Input(in);
    while (in.hasRemaining()) {
      final ISharedObjectEvent.Type type = SharedObjectTypeMapping.toType(in.get());
      if (type == null) {
        in.skip(in.remaining());
        return;
      }
      String key = null;
      Object value = null;

      // if (log.isDebugEnabled())
      // log.debug("type: "+SharedObjectTypeMapping.toString(type));

      // SharedObjectEvent event = new SharedObjectEvent(,null,null);
      final int length = in.getInt();
      if (type == ISharedObjectEvent.Type.CLIENT_STATUS) {
        // Status code
        key = input.getString();
        // Status level
        value = input.getString();
      } else if (type == ISharedObjectEvent.Type.CLIENT_UPDATE_DATA) {
        key = null;
        // Map containing new attribute values
        final Map<String, Object> map = new HashMap<String, Object>();
        final int start = in.position();
        while (in.position() - start < length) {
          String tmp = input.getString();
          map.put(tmp, Deserializer.deserialize(input, Object.class));
        }
        value = map;
      } else if (type != ISharedObjectEvent.Type.SERVER_SEND_MESSAGE && type != ISharedObjectEvent.Type.CLIENT_SEND_MESSAGE) {
        if (length > 0) {
          key = input.getString();
          if (length > key.length() + 2) {
            // determine if the object is encoded with amf3
            byte objType = in.get();
            in.position(in.position() - 1);
            Input propertyInput;
            if (objType == AMF.TYPE_AMF3_OBJECT && !(input instanceof org.red5.io.amf3.Input)) {
              // The next parameter is encoded using AMF3
              propertyInput = amf3Input;
            } else {
              // The next parameter is encoded using AMF0
              propertyInput = input;
            }
            value = Deserializer.deserialize(propertyInput, Object.class);
          }
        }
      } else {
        final int start = in.position();
        // the "send" event seems to encode the handler name as complete AMF string including the string type byte
        key = Deserializer.deserialize(input, String.class);
        // read parameters
        final List<Object> list = new LinkedList<Object>();
        while (in.position() - start < length) {
          byte objType = in.get();
          in.position(in.position() - 1);
          // determine if the object is encoded with amf3
          Input propertyInput;
          if (objType == AMF.TYPE_AMF3_OBJECT && !(input instanceof org.red5.io.amf3.Input)) {
            // The next parameter is encoded using AMF3
            propertyInput = amf3Input;
          } else {
            // The next parameter is encoded using AMF0
View Full Code Here


   * @return decoded notify result
   */
  public Notify decodeNotify(Encoding encoding, IoBuffer in, Header header) {
    Notify notify = new Notify();
    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);
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);
View Full Code Here

   * @return Notify
   */
  @SuppressWarnings("unchecked")
  public Notify decodeStreamMetadata(IoBuffer in) {
    Encoding encoding = ((RTMPConnection) Red5.getConnectionLocal()).getEncoding();
    Input input = null;

    // check to see if the encoding is set to AMF3.
    // if it is then check to see if first byte is set to AMF0
    byte amfVersion = 0x00;
    if (encoding == Encoding.AMF3) {
      amfVersion = in.get();
    }
   
    // reset the position back to 0
    in.position(0);
   
    //make a pre-emptive copy of the incoming buffer here to prevent issues that occur fairly often
    IoBuffer copy = in.duplicate();
   
   
    if (encoding == Encoding.AMF0 || amfVersion != AMF.TYPE_AMF3_OBJECT ) {
      input = new org.red5.io.amf.Input(copy);
    } else {
      org.red5.io.amf3.Input.RefStorage refStorage = new org.red5.io.amf3.Input.RefStorage();
      input = new org.red5.io.amf3.Input(copy, refStorage);
    }
    //get the first datatype
    byte dataType = input.readDataType();
    if (dataType == DataTypes.CORE_STRING) {
      String setData = input.readString(String.class);
      if ("@setDataFrame".equals(setData)) {
        // get the second datatype
        byte dataType2 = input.readDataType();
        log.debug("Dataframe method type: {}", dataType2);
        String onCueOrOnMeta = input.readString(String.class);
        // get the params datatype
        byte object = input.readDataType();
        log.debug("Dataframe params type: {}", object);
        Map<Object, Object> params;
        if (object == DataTypes.CORE_MAP) {
          // the params are sent as a Mixed-Array. Required to support the RTMP publish provided by ffmpeg/xuggler
          params = (Map<Object, Object>) input.readMap(null);
        } else {
          // read the params as a standard object
          params = (Map<Object, Object>) input.readObject(Object.class);
        }
        log.debug("Dataframe: {} params: {}", onCueOrOnMeta, params.toString());

        IoBuffer buf = IoBuffer.allocate(1024);
        buf.setAutoExpand(true);
        Output out = new Output(buf);
        out.writeString(onCueOrOnMeta);
        out.writeMap(params);

        buf.flip();
        return new Notify(buf);
      } else if ("onFI".equals(setData)) {
        // the onFI request contains 2 items relative to the publishing client application
        // sd = system date (12-07-2011)
        // st = system time (09:11:33.387)
        byte object = input.readDataType();
        log.debug("onFI params type: {}", object);
        Map<Object, Object> params;
        if (object == DataTypes.CORE_MAP) {
          // the params are sent as a Mixed-Array
          params = (Map<Object, Object>) input.readMap(null);
        } else {
          // read the params as a standard object
          params = (Map<Object, Object>) input.readObject(Object.class);
        }
        log.debug("onFI params: {}", params.toString());
      } else {
        log.info("Unhandled request: {}", setData);
        if (log.isDebugEnabled()) {
          byte object = input.readDataType();
          log.debug("Params type: {}", object);
          if (object == DataTypes.CORE_MAP) {
            Map<Object, Object> params = (Map<Object, Object>) input.readMap(null);
            log.debug("Params: {}", params.toString());
          } else {
            log.debug("The unknown request was did not provide a parameter map");
          }
        }
View Full Code Here

    log.trace("Flex byte: {}", flexByte);
    // Encoding of message params can be mixed - some params may be in AMF0, others in AMF3,
    // but according to AMF3 spec, we should collect AMF3 references for the whole message body (through all params)
    org.red5.io.amf3.Input.RefStorage refStorage = new org.red5.io.amf3.Input.RefStorage();

    Input input = new org.red5.io.amf.Input(in);
    String action = Deserializer.deserialize(input, String.class);
    int transactionId = Deserializer.<Number> deserialize(input, Number.class).intValue();
    FlexMessage msg = new FlexMessage();
    msg.setTransactionId(transactionId);
    Object[] params = new Object[] {};
View Full Code Here

  }

  /** {@inheritDoc} */
  public ISharedObjectMessage decodeFlexSharedObject(ByteBuffer in, RTMP rtmp) {
    byte encoding = in.get();
    Input input;
    if (encoding == 0) {
      input = new org.red5.io.amf.Input(in);
    } else if (encoding == 3) {
      input = new org.red5.io.amf3.Input(in);
    } else {
      throw new RuntimeException("Unknown SO encoding: " + encoding);
    }
    String name = input.getString();
    // Read version of SO to modify
    int version = in.getInt();
    // Read persistence informations
    boolean persistent = in.getInt() == 2;
    // Skip unknown bytes
View Full Code Here

    return so;
  }

  /** {@inheritDoc} */
  public ISharedObjectMessage decodeSharedObject(ByteBuffer in, RTMP rtmp) {
    final Input input = new org.red5.io.amf.Input(in);
    String name = input.getString();
    // Read version of SO to modify
    int version = in.getInt();
    // Read persistence informations
    boolean persistent = in.getInt() == 2;
    // Skip unknown bytes
View Full Code Here

   * @param input
   */
  protected void doDecodeSharedObject(SharedObjectMessage so, ByteBuffer in, Input input) {
    // Parse request body
    setupClassLoader();
    Input amf3Input = new org.red5.io.amf3.Input(in);
    while (in.hasRemaining()) {

      final ISharedObjectEvent.Type type = SharedObjectTypeMapping
          .toType(in.get());
      if (type == null) {
        in.skip(in.remaining());
        return;
      }
      String key = null;
      Object value = null;

      //if(log.isDebugEnabled())
      //  log.debug("type: "+SharedObjectTypeMapping.toString(type));

      //SharedObjectEvent event = new SharedObjectEvent(,null,null);
      final int length = in.getInt();
      if (type == ISharedObjectEvent.Type.CLIENT_STATUS) {
        // Status code
        key = input.getString();
        // Status level
        value = input.getString();
      } else if (type == ISharedObjectEvent.Type.CLIENT_UPDATE_DATA) {
        key = null;
        // Map containing new attribute values
        final Map<String, Object> map = new HashMap<String, Object>();
        final int start = in.position();
        while (in.position() - start < length) {
          String tmp = input.getString();
          map.put(tmp, deserializer.deserialize(input, Object.class));
        }
        value = map;
      } else if (type != ISharedObjectEvent.Type.SERVER_SEND_MESSAGE
          && type != ISharedObjectEvent.Type.CLIENT_SEND_MESSAGE) {
        if (length > 0) {
          key = input.getString();
          if (length > key.length() + 2) {
            // FIXME workaround for player version >= 9.0.115.0
            byte objType = in.get();
            in.position(in.position()-1);
            Input propertyInput;
            if (objType == AMF.TYPE_AMF3_OBJECT && !(input instanceof org.red5.io.amf3.Input)) {
              // The next parameter is encoded using AMF3
              propertyInput = amf3Input;
            } else {
              // The next parameter is encoded using AMF0
View Full Code Here

     * @return                   Notification event
     */
    protected Notify decodeNotifyOrInvoke(Notify notify, ByteBuffer in, Header header, RTMP rtmp) {
    // TODO: we should use different code depending on server or client mode
    int start = in.position();
    Input input;
    if (rtmp.getEncoding() == Encoding.AMF3)
      input = new org.red5.io.amf3.Input(in);
    else
      input = new org.red5.io.amf.Input(in);

View Full Code Here

     * @return                 FlexMessage event
     */
    public FlexMessage decodeFlexMessage(ByteBuffer in, RTMP rtmp) {
    // TODO: Unknown byte, probably encoding as with Flex SOs?
    in.skip(1);
    Input input = new org.red5.io.amf.Input(in);
    String action = deserializer.deserialize(input, String.class);
    int invokeId = deserializer.deserialize(input, Number.class).intValue();
    FlexMessage msg = new FlexMessage();
    msg.setInvokeId(invokeId);
    Object[] params = new Object[] {};
View Full Code Here

TOP

Related Classes of org.red5.io.object.Input

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.