Package org.red5.io.object

Examples of org.red5.io.object.Output


     */
  private void writeMetadataTag(double duration, Integer videoCodecId, Integer audioCodecId) throws IOException {
    metaPosition = channel.position();
    IoBuffer buf = IoBuffer.allocate(1024);
    buf.setAutoExpand(true);
    Output out = new Output(buf);
    out.writeString("onMetaData");
    Map<Object, Object> params = new HashMap<Object, Object>(4);
    params.put("duration", duration);
    if (videoCodecId != null) {
      params.put("videocodecid", videoCodecId.intValue());
    }
    if (audioCodecId != null) {
      params.put("audiocodecid", audioCodecId.intValue());
    }
    params.put("canSeekToEnd", true);
    out.writeMap(params, new Serializer());
    buf.flip();

    if (fileMetaSize == 0) {
      fileMetaSize = buf.limit();
    }
View Full Code Here


   *
   * @throws IOException      Any I/O exception
   */
  public void writeHeader() throws IOException {
    //Header fields (in same order than spec, for comparison purposes)
    FLVHeader flvHeader = new FLVHeader();
    flvHeader.setSignature("FLV".getBytes());
    flvHeader.setVersion ((byte)0x01);
    flvHeader.setFlagReserved01 ((byte) 0x0);
    flvHeader.setFlagAudio (true);
    flvHeader.setFlagReserved02 ((byte) 0x0);
    flvHeader.setFlagVideo (true);
    flvHeader.write(out);
   
    //Dump header to output channel
    channel.write(out.buf());
  }
View Full Code Here

    if (writer != null && !this.isClosed) {
      try {
       
        log.debug("#################### -start- closeStream ########################");
        log.debug("#################### -start- closeStream ########################");
        FLVWriter flvWriter = (FLVWriter) writer;
        //log.debug("duration: "+flvWriter.getDuration());
        //log.debug(writer.getClass().getName());
       
        writer.close();
       
View Full Code Here

       
        int timeStamp = streampacket.getTimestamp();
       
        timeStamp -= startTimeStamp;
       
              ITag tag = new Tag();
              tag.setDataType(streampacket.getDataType());
             
              //log.debug("data.limit() :: "+data.limit());
        tag.setBodySize(data.limit());
        tag.setTimestamp(timeStamp);
        tag.setBody(data);
       
       
        if (this.isInterview) {
          if (timeStamp <= 500) {
            //We will cut the first 0.5 seconds
View Full Code Here

    if (fileMetaSize == 0) {
      fileMetaSize = buf.limit();
    }

    ITag onMetaData = new Tag(ITag.TYPE_METADATA, 0, fileMetaSize, buf, 0);
    writeTag(onMetaData);
  }
View Full Code Here

         
          FlvRecordingMetaDeltaDaoImpl.getInstance().addFlvRecordingMetaDelta(flvRecordingMetaDelta);
         
        }
       
              ITag tag = new Tag();
              tag.setDataType(streampacket.getDataType());
             
              //log.debug("data.limit() :: "+data.limit());
        tag.setBodySize(data.limit());
        tag.setTimestamp(timeStamp);
        tag.setBody(data);
       
        writer.writeTag(tag);
     
      }
     
View Full Code Here

//           
//          }
         
        }
             
              ITag tag = new Tag();
              tag.setDataType(streampacket.getDataType());
             
              //log.debug("data.limit() :: "+data.limit());
        tag.setBodySize(data.limit());
        tag.setTimestamp(timeStamp);
        tag.setBody(data);
       
        //log.debug("duration: "+flvWriter.getDuration());
       
        if (debug) {
         
          String filePath = folderPath + File.separatorChar
              + "Packet"
              +"_t_"+tag.getTimestamp()
              +"_d_"+deltaTime
              +"_s_"+tag.getBodySize()
              +".flv";
         
          //File out = new File();
         
          FLVDebugWriter flvWriterDebug = new FLVDebugWriter( new File( filePath ), false);
         
          flvWriterDebug.writeBytesFromTag(streampacket.getData().asReadOnlyBuffer());

          flvWriterDebug.closeBytesFile();
         
        }

        writer.writeTag(tag);
 
      } else if (streampacket.getDataType() == 9) {
       
        //Video data is handled just without calculating deltas
        int timeStamp = streampacket.getTimestamp();
       
        timeStamp -= startTimeStamp;
       
        ITag tag = new Tag();
              tag.setDataType(streampacket.getDataType());
             
              //log.debug("data.limit() :: "+data.limit());
        tag.setBodySize(data.limit());
        tag.setTimestamp(timeStamp);
        tag.setBody(data);
       
        writer.writeTag(tag);
       
      }
     
View Full Code Here

   * @param so shared object
   * @param out output buffer
   */
  private void doEncodeSharedObject(ISharedObjectMessage so, IoBuffer out) {
    final Encoding encoding = Red5.getConnectionLocal().getEncoding();
    final Output output = new org.red5.io.amf.Output(out);
    final Output amf3output = new org.red5.io.amf3.Output(out);
    output.putString(so.getName());
    // SO version
    out.putInt(so.getVersion());
    // Encoding (this always seems to be 2 for persistent shared objects)
    out.putInt(so.isPersistent() ? 2 : 0);
View Full Code Here

   * @param out Buffer to fill
   * @param command Command event
   */
  protected void encodeCommand(IoBuffer out, ICommand command) {
    // TODO: tidy up here
    Output output = new org.red5.io.amf.Output(out);
    final IServiceCall call = command.getCall();
    final boolean isPending = (call.getStatus() == Call.STATUS_PENDING);
    log.debug("Call: {} pending: {}", call, isPending);
    if (!isPending) {
      log.debug("Call has been executed, send result");
View Full Code Here

     * @param so
     * @param rtmp
     * @param out
     */
    public void doEncodeSharedObject(ISharedObjectMessage so, RTMP rtmp, ByteBuffer out) {
    final Output output = new org.red5.io.amf.Output(out);

    output.putString(so.getName());
    // SO version
    out.putInt(so.getVersion());
    // Encoding (this always seems to be 2 for persistent shared objects)
    out.putInt(so.isPersistent() ? 2 : 0);
    // unknown field
    out.putInt(0);

    int mark, len;

        for (ISharedObjectEvent event : so.getEvents()) {
            byte type = SharedObjectTypeMapping.toByte(event.getType());

            switch (event.getType()) {
                case SERVER_CONNECT:
                case CLIENT_INITIAL_DATA:
                case CLIENT_CLEAR_DATA:
                    out.put(type);
                    out.putInt(0);
                    break;

                case SERVER_DELETE_ATTRIBUTE:
                case CLIENT_DELETE_DATA:
                case CLIENT_UPDATE_ATTRIBUTE:
                    out.put(type);
                    mark = out.position();
                    out.skip(4); // we will be back
                    output.putString(event.getKey());
                    len = out.position() - mark - 4;
                    out.putInt(mark, len);
                    break;

                case SERVER_SET_ATTRIBUTE:
                case CLIENT_UPDATE_DATA:
                    if (event.getKey() == null) {
                        // Update multiple attributes in one request
                        Map initialData = (Map) event.getValue();

                        for (Object o : initialData.keySet()) {

                            out.put(type);
                            mark = out.position();
                            out.skip(4); // we will be back

                            String key = (String) o;
                            output.putString(key);
                            serializer.serialize(output, initialData.get(key));

                            len = out.position() - mark - 4;
                            out.putInt(mark, len);
                        }
                    } else {
                        out.put(type);
                        mark = out.position();
                        out.skip(4); // we will be back

                        output.putString(event.getKey());
                        serializer.serialize(output, event.getValue());

                        len = out.position() - mark - 4;
                        out.putInt(mark, len);
                    }
                    break;

                case CLIENT_SEND_MESSAGE:
                case SERVER_SEND_MESSAGE:
                    // Send method name and value
                    out.put(type);
                    mark = out.position();
                    out.skip(4);
                    // Serialize name of the handler to call...
                    serializer.serialize(output, event.getKey());
                    // ...and the arguments
                    for (Object arg : (List) event.getValue()) {
                        serializer.serialize(output, arg);
                    }
                    len = out.position() - mark - 4;
                    //log.debug(len);
                    out.putInt(mark, len);
                    //log.info(out.getHexDump());
                    break;

                case CLIENT_STATUS:
                    out.put(type);
                  final String status = event.getKey();
                  final String message = (String) event.getValue();
                  out.putInt(message.length() + status.length() + 4);
                  output.putString(message);
                  output.putString(status);
                    break;
                   
                default:
                    //log.error("Unknown event " + event.getType());
                    // XXX: come back here, need to make this work in server or
                    // client mode
                    // talk to joachim about this part.
                    out.put(type);
                    mark = out.position();
                    //out.putInt(0);
                    out.skip(4); // we will be back
                    output.putString(event.getKey());
                    serializer.serialize(output, event.getValue());
                    len = out.position() - mark - 4;
                    out.putInt(mark, len);
                    break;

View Full Code Here

TOP

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

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.