Package org.red5.server.net.remoting.message

Examples of org.red5.server.net.remoting.message.RemotingPacket


      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


   * @throws Exception
   */
  public Object decode(IoBuffer in) throws Exception {
    Map<String, Object> headers = readHeaders(in);
    List<RemotingCall> calls = decodeCalls(in);
    return new RemotingPacket(headers, calls);
  }
View Full Code Here

   * @param message
   * @return buffer
   * @throws Exception
   */
  public IoBuffer encode(Object message) throws Exception {
    RemotingPacket resp = (RemotingPacket) message;
    IoBuffer buf = IoBuffer.allocate(1024);
    buf.setAutoExpand(true);
    Output output;
    if (resp.getEncoding() == Encoding.AMF0) {
      buf.putShort((short) 0); // encoded using AMF0
    } else {
      buf.putShort((short) 3); // encoded using AMF3
    }

    IRemotingConnection conn = (IRemotingConnection) Red5.getConnectionLocal();
    Collection<IRemotingHeader> headers = conn.getHeaders();
    buf.putShort((short) headers.size()); // write the header count
    if (resp.getEncoding() == Encoding.AMF0) {
      output = new Output(buf);
    } else {
      output = new org.red5.io.amf3.Output(buf);
    }
    for (IRemotingHeader header : headers) {
      Output.putString(buf, IRemotingHeader.PERSISTENT_HEADER);
      output.writeBoolean(false);
      Map<String, Object> param = new HashMap<String, Object>();
      param.put("name", header.getName());
      param.put("mustUnderstand", header.getMustUnderstand() ? Boolean.TRUE : Boolean.FALSE);
      param.put("data", header.getValue());
      Serializer.serialize(output, param);
    }
    headers.clear();

    buf.putShort((short) resp.getCalls().size()); // write the number of bodies
    for (RemotingCall call : resp.getCalls()) {
      log.debug("Call");
      Output.putString(buf, call.getClientResponse());
      if (!call.isMessaging) {
        Output.putString(buf, "null");
      } else {
View Full Code Here

   */
  protected void serviceAMF(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    log.debug("Servicing AMF");
    IRemotingConnection conn = null;
    try {
      RemotingPacket packet = decodeRequest(req);
      if (packet == null) {
        log.error("Packet should not be null");
        return;
      }
      // Provide a valid IConnection in the Red5 object
      final IGlobalScope global = getGlobalScope(req);
      final IContext context = global.getContext();
      final IScope scope = context.resolveScope(global, packet.getScopePath());
      conn = new RemotingConnection(req, scope, packet);
      // Make sure the connection object isn't garbage collected
      req.setAttribute(CONNECTION, conn);
      // set thread local reference
      Red5.setConnectionLocal(conn);
View Full Code Here

  protected RemotingPacket decodeRequest(HttpServletRequest req) throws Exception {
    log.debug("Decoding request");
    IoBuffer reqBuffer = IoBuffer.allocate(req.getContentLength());
    ServletUtils.copy(req, reqBuffer.asOutputStream());
    reqBuffer.flip();
    RemotingPacket packet = (RemotingPacket) codecFactory.getRemotingDecoder().decode(reqBuffer);
    String path = req.getContextPath();
    if (path == null) {
      path = "";
    }
    if (req.getPathInfo() != null) {
      path += req.getPathInfo();
    }
    // check for header path, this is used by the AMF tunnel servlet
    String headerPath = req.getHeader("Tunnel-request");
    // it is only used if the path is set to root
    if (headerPath != null && path.length() < 1) {
      path = headerPath;
    }
    if (path.length() > 0 && path.charAt(0) == '/') {
      path = path.substring(1);
    }
    log.debug("Path: {} Scope path: {}", path, packet.getScopePath());
    packet.setScopePath(path);
    reqBuffer.free();
    reqBuffer = null;
    return packet;
  }
View Full Code Here

   */
  protected void serviceAMF(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    log.debug("Servicing AMF");
    try {
      RemotingPacket packet = decodeRequest(req);
      if (packet == null) {
        log.error("Packet should not be null");
        return;
      }
      // Provide a valid IConnection in the Red5 object
      final IGlobalScope global = getGlobalScope(req);
      final IContext context = global.getContext();
      final IScope scope = context.resolveScope(global, packet.getScopePath());
      IRemotingConnection conn = new RemotingConnection(req, scope, packet);
      // Make sure the connection object isn't garbage collected
      req.setAttribute(CONNECTION, conn);
      try {
        Red5.setConnectionLocal(conn);
View Full Code Here

      throws Exception {
    log.debug("Decoding request");
    ByteBuffer reqBuffer = ByteBuffer.allocate(req.getContentLength());
    ServletUtils.copy(req.getInputStream(), reqBuffer.asOutputStream());
    reqBuffer.flip();
    RemotingPacket packet = (RemotingPacket) codecFactory
        .getSimpleDecoder().decode(null, reqBuffer);
    String path = req.getContextPath();
    if (path == null) {
      path = "";
    }
    if (req.getPathInfo() != null) {
      path += req.getPathInfo();
    }
    // check for header path, this is used by the AMF tunnel servlet
    String headerPath = req.getHeader("Tunnel-request");
    // it is only used if the path is set to root
    if (headerPath != null && path.length() < 1) {
      path = headerPath;
    }
    if (path.length() > 0 && path.charAt(0) == '/') {
      path = path.substring(1);
    }
    log.debug("Path: {} Scope path: {}", path, packet.getScopePath());
    packet.setScopePath(path);
    reqBuffer.release();
    reqBuffer = null;
    return packet;
  }
View Full Code Here

  /** {@inheritDoc} */
    public Object decode(ProtocolState state, ByteBuffer in) throws Exception {
    Map<String, Object> headers = readHeaders(in);
    List<RemotingCall> calls = decodeCalls(in);
    return new RemotingPacket(headers, calls);
  }
View Full Code Here

     */
    private Serializer serializer;

  /** {@inheritDoc} */
    public ByteBuffer encode(ProtocolState state, Object message) throws Exception {
    RemotingPacket resp = (RemotingPacket) message;
    ByteBuffer buf = ByteBuffer.allocate(1024);
    buf.setAutoExpand(true);
    Output output;
    if (resp.getEncoding() == Encoding.AMF0) {
      buf.putShort((short) 0)// encoded using AMF0
    } else {
      buf.putShort((short) 3)// encoded using AMF3
    }
   
    IRemotingConnection conn = (IRemotingConnection) Red5.getConnectionLocal();
    Collection<IRemotingHeader> headers = conn.getHeaders();
    synchronized (headers) {
      buf.putShort((short) headers.size()); // write the header count
      if (resp.getEncoding() == Encoding.AMF0) {
        output = new Output(buf);
      } else {
        output = new org.red5.io.amf3.Output(buf);
      }
      for (IRemotingHeader header: headers) {
        Output.putString(buf, IRemotingHeader.PERSISTENT_HEADER);
        output.writeBoolean(false);
        Map<String, Object> param = new HashMap<String, Object>();
        param.put("name", header.getName());
        param.put("mustUnderstand", header.getMustUnderstand() ? Boolean.TRUE : Boolean.FALSE);
        param.put("data", header.getName());
        serializer.serialize(output, param);
      }
      headers.clear();
    }
   
    buf.putShort((short) resp.getCalls().size()); // write the number of bodies
    for (RemotingCall call: resp.getCalls()) {
      if (log.isDebugEnabled()) {
        log.debug("Call");
      }
      Output.putString(buf, call.getClientResponse());
      if (!call.isMessaging) {
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.net.remoting.message.RemotingPacket

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.