Package org.red5.codec

Examples of org.red5.codec.IVideoStreamCodec


        // get decoder info if it exists for the stream
        IStreamCodecInfo codecInfo = getCodecInfo();
        log.debug("Codec info: {}", codecInfo);
        if (codecInfo instanceof StreamCodecInfo) {
          StreamCodecInfo info = (StreamCodecInfo) codecInfo;
          IVideoStreamCodec videoCodec = info.getVideoCodec();
          log.debug("Video codec: {}", videoCodec);
          if (videoCodec != null) {
            //check for decoder configuration to send
            IoBuffer config = videoCodec.getDecoderConfiguration();
            if (config != null) {
              log.debug("Decoder configuration is available for {}", videoCodec.getName());
              VideoData videoConf = new VideoData(config.asReadOnlyBuffer());
              try {
                log.debug("Setting decoder configuration for recording");
                listener.getFileConsumer().setVideoDecoderConfiguration(videoConf);
              } finally {
View Full Code Here


          //drop all frames up to the next keyframe
          videoFrameDropper.reset(IFrameDropper.SEND_KEYFRAMES_CHECK);
          if (msgIn instanceof IBroadcastScope) {
            IBroadcastStream stream = (IBroadcastStream) ((IBroadcastScope) msgIn).getClientBroadcastStream();
            if (stream != null && stream.getCodecInfo() != null) {
              IVideoStreamCodec videoCodec = stream.getCodecInfo().getVideoCodec();
              if (videoCodec != null) {
                if (withReset) {
                  sendReset();
                  sendResetStatus(item);
                  sendStartStatus(item);
View Full Code Here

        IStreamCodecInfo codecInfo = stream.getCodecInfo();
        log.debug("Codec info: {}", codecInfo);
        if (codecInfo instanceof StreamCodecInfo) {
          StreamCodecInfo info = (StreamCodecInfo) codecInfo;
          IVideoStreamCodec videoCodec = info.getVideoCodec();
          log.debug("Video codec: {}", videoCodec);
          if (videoCodec != null) {
            //check for decoder configuration to send
            IoBuffer config = videoCodec.getDecoderConfiguration();
            if (config != null) {
              log.debug("Decoder configuration is available for {}", videoCodec.getName());
              //log.debug("Dump:\n{}", Hex.encodeHex(config.array()));
              VideoData conf = new VideoData(config.asReadOnlyBuffer());
              log.trace("Configuration ts: {}", conf.getTimestamp());
              RTMPMessage confMsg = RTMPMessage.build(conf);
              try {
                log.debug("Pushing decoder configuration");
                msgOut.pushMessage(confMsg);
              } finally {
                conf.release();
              }
            }
            //check for a keyframe to send
            IoBuffer keyFrame = videoCodec.getKeyframe();
            if (keyFrame != null) {
              log.debug("Keyframe is available");
              VideoData video = new VideoData(keyFrame.asReadOnlyBuffer());
              log.trace("Keyframe ts: {}", video.getTimestamp());
              //log.debug("Dump:\n{}", Hex.encodeHex(keyFrame.array()));
View Full Code Here

        }
        if (body instanceof VideoData) {
          if (msgIn instanceof IBroadcastScope) {
            IBroadcastStream stream = (IBroadcastStream) ((IBroadcastScope) msgIn).getClientBroadcastStream();
            if (stream != null && stream.getCodecInfo() != null) {
              IVideoStreamCodec videoCodec = stream.getCodecInfo().getVideoCodec();
              //dont try to drop frames if video codec is null - related to SN-77
              if (videoCodec != null && videoCodec.canDropFrames()) {
                if (!receiveVideo) {
                  // The client disabled video or the app doesn't have enough bandwidth
                  // allowed for this stream.
                  log.debug("Dropping packet because we cant receive video or token acquire failed");
                  videoFrameDropper.dropPacket(rtmpMessage);
View Full Code Here

     * Create and return new video codec applicable for byte buffer data
     * @param data                 Byte buffer data
     * @return                     Video codec
     */
  public static IVideoStreamCodec getVideoCodec(IoBuffer data) {
    IVideoStreamCodec result = null;
    //get the codec identifying byte
    int codecId = data.get() & 0x0f;   
    try {
        switch (codecId) {
          case 2: //sorenson
            result = (IVideoStreamCodec) Class.forName("org.red5.codec.SorensonVideo").newInstance();
            break;
          case 3: //screen video
            result = (IVideoStreamCodec) Class.forName("org.red5.codec.ScreenVideo").newInstance();
            break;
          case 6: //screen video 2
            result = (IVideoStreamCodec) Class.forName("org.red5.codec.ScreenVideo2").newInstance();
            break;
          case 7: //avc/h.264 video
            result = (IVideoStreamCodec) Class.forName("org.red5.codec.AVCVideo").newInstance();
            break;
        }
    } catch (Exception ex) {
      log.error("Error creating codec instance", ex);     
    }
    data.rewind();
    //if codec is not found do the old-style loop
    if (result == null) {
        for (IVideoStreamCodec storedCodec: codecs) {
          IVideoStreamCodec codec;
          // XXX: this is a bit of a hack to create new instances of the
          // configured video codec for each stream
          try {
            codec = storedCodec.getClass().newInstance();
          } catch (Exception e) {
            log.error("Could not create video codec instance", e);
            continue;
          }
          if (codec.canHandleData(data)) {
            result = codec;
            break;
          }
        }
    }
View Full Code Here

              info.setHasAudio(true);
            }
            eventTime = rtmpEvent.getTimestamp();
            log.trace("Audio: {}", eventTime);
          } else if (rtmpEvent instanceof VideoData) {
            IVideoStreamCodec videoStreamCodec = null;
            if (checkVideoCodec) {
              videoStreamCodec = VideoCodecFactory.getVideoCodec(buf);
              if (info != null) {
                info.setVideoCodec(videoStreamCodec);
              }
              checkVideoCodec = false;
            } else if (codecInfo != null) {
              videoStreamCodec = codecInfo.getVideoCodec();
            }
            if (videoStreamCodec != null) {
              videoStreamCodec.addData(buf.asReadOnlyBuffer());
            }
            if (info != null) {
              info.setHasVideo(true);
            }
            eventTime = rtmpEvent.getTimestamp();
View Full Code Here

        // get decoder info if it exists for the stream
        IStreamCodecInfo codecInfo = getCodecInfo();
        log.debug("Codec info: {}", codecInfo);
        if (codecInfo instanceof StreamCodecInfo) {
          StreamCodecInfo info = (StreamCodecInfo) codecInfo;
          IVideoStreamCodec videoCodec = info.getVideoCodec();
          log.debug("Video codec: {}", videoCodec);
          if (videoCodec != null) {
            //check for decoder configuration to send
            IoBuffer config = videoCodec.getDecoderConfiguration();
            if (config != null) {
              log.debug("Decoder configuration is available for {}", videoCodec.getName());
              VideoData videoConf = new VideoData(config.asReadOnlyBuffer());
              try {
                log.debug("Setting decoder configuration for recording");
                listener.getFileConsumer().setVideoDecoderConfiguration(videoConf);
              } finally {
View Full Code Here

         
          if (creationTime == null)
            creationTime = (long)rtmpEvent.getTimestamp();
         
          try {
            IVideoStreamCodec videoStreamCodec = new ScreenVideo();
            streamCodecInfo.setHasVideo(true);
            streamCodecInfo.setVideoCodec(videoStreamCodec);
            videoStreamCodec.reset();
            videoStreamCodec.addData(((VideoData) rtmpEvent).getData());
            livePipe.pushMessage(msg);

            // Notify listeners about received packet
            if (rtmpEvent instanceof IStreamPacket) {
              for (IStreamListener listener : getStreamListeners()) {
View Full Code Here

    }

    IStreamableFileService service = factory.getService(file);

    IStreamableFile flv = service.getStreamableFile(file);

    writer = flv.getWriter();

  }
View Full Code Here

    } else if (!file.canWrite()) {
      throw new IOException("The file is read-only");
    }

    IStreamableFileService service = factory.getService(this.file);
    IStreamableFile flv = service.getStreamableFile(this.file);
    this.writer = flv.getWriter();

  }
View Full Code Here

TOP

Related Classes of org.red5.codec.IVideoStreamCodec

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.