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

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


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


            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);
View Full Code Here

            //do we want to return from here?
            //event / stream listeners will not be notified of invokes
            return;
          } else if (rtmpEvent instanceof Notify) {
            // store the metadata
            Notify notifyEvent = (Notify) rtmpEvent;
            if (metaData == null && notifyEvent.getHeader().getDataType() == Notify.TYPE_STREAM_METADATA) {
              try {
                metaData = notifyEvent.duplicate();
              } catch (Exception e) {
                log.warn("Metadata could not be duplicated for this stream", e);
              }
            }
            eventTime = rtmpEvent.getTimestamp();
View Full Code Here

          ping.setHeader(header);
          conn.ping(ping);
          break;
        case Constants.TYPE_STREAM_METADATA:
          log.trace("Meta data");
          Notify notify = new Notify(((Notify) msg).getData().asReadOnlyBuffer());
          notify.setHeader(header);
          notify.setTimestamp(header.getTimer());
          data.write(notify);
          break;
        case Constants.TYPE_FLEX_STREAM_SEND:
          log.trace("Flex stream send");
          // TODO: okay to send this also to AMF0 clients?
View Full Code Here

              event = new VideoData(buffer);
              event.setTimestamp(cachedEvent.getTimestamp());
              message = RTMPMessage.build(event);
              break;
            default:
              event = new Notify(buffer);
              event.setTimestamp(cachedEvent.getTimestamp());
              message = RTMPMessage.build(event);
              break;
          }
          // push it down to the recorder
View Full Code Here

    notify(call, 3);
  }

  /** {@inheritDoc} */
  public void notify(IServiceCall call, int channel) {
    Notify notify = new Notify();
    notify.setCall(call);
    getChannel(channel).write(notify);
  }
View Full Code Here

    if (msgIn != null && msgOut != null) {
      // get the stream so that we can grab any metadata and decoder configs
      IBroadcastStream stream = (IBroadcastStream) ((IBroadcastScope) msgIn).getClientBroadcastStream();
      // prevent an NPE when a play list is created and then immediately flushed
      if (stream != null) {
        Notify metaData = stream.getMetaData();
        //check for metadata to send
        if (metaData != null) {
          log.debug("Metadata is available");
          RTMPMessage metaMsg = RTMPMessage.build(metaData, 0);
          try {
View Full Code Here

        event = new VideoData(dataReference);
        event.setTimestamp(messageIn.getBody().getTimestamp());
        break;
      default:
        dataReference = ((Notify) messageIn.getBody()).getData();
        event = new Notify(dataReference);
        event.setTimestamp(messageIn.getBody().getTimestamp());
        break;
    }
    RTMPMessage messageOut = RTMPMessage.build(event);
    //get the current timestamp from the message
View Full Code Here

      props.put("isFastPlay", false);
    }
    out.writeMap(props);
    buf.flip();

    IRTMPEvent event = new Notify(buf);
    if (lastMessageTs > 0) {
      event.setTimestamp(lastMessageTs);
    } else {
      event.setTimestamp(0);
    }
    RTMPMessage msg = RTMPMessage.build(event);
    doPushMessage(msg);
  }
View Full Code Here

   * @param in
   * @param header
   * @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);
      ((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) {
      //TODO Handle NetStream.send? Where and how?
      if (header != null && header.getStreamId() != 0 && !isStreamCommand(action)) {
        // don't decode "NetStream.send" requests
        in.position(start);
        notify.setData(in.asReadOnlyBuffer());
        return notify;
      }
      if (header == null || header.getStreamId() == 0) {
        int invokeId = Deserializer.<Number> deserialize(input, Number.class).intValue();
        if (invokeId != 0) {
          throw new RuntimeException("Notify invoke / transaction id was non-zero");
        }
      }
      // 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, notify, input);
      // determine service information
      final int dotIndex = action.lastIndexOf('.');
      String serviceName = (dotIndex == -1) ? null : action.substring(0, dotIndex);
      // pull off the prefixes since java doesn't 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 doesnt allow this on a method name
      if (serviceMethod.startsWith("@") || serviceMethod.startsWith("|")) {
        serviceMethod = serviceMethod.substring(1);
      }
      Call call = new Call(serviceName, serviceMethod, params);
      notify.setCall(call);
      return notify;
    } else {
      //TODO replace this with something better as time permits
      throw new RuntimeException("Action was null");
    }
View Full Code Here

TOP

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

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.