Package org.red5.codec

Examples of org.red5.codec.IAudioStreamCodec


              }
            }
          } else {
            log.debug("Could not initialize stream output, videoCodec is null.");
          }
          IAudioStreamCodec audioCodec = info.getAudioCodec();
          log.debug("Audio codec: {}", audioCodec);
          if (audioCodec != null) {
            //check for decoder configuration to send
            IoBuffer config = audioCodec.getDecoderConfiguration();
            if (config != null) {
              log.debug("Decoder configuration is available for {}", audioCodec.getName());
              AudioData audioConf = new AudioData(config.asReadOnlyBuffer());
              try {
                log.debug("Setting decoder configuration for recording");
                listener.getFileConsumer().setAudioDecoderConfiguration(audioConf);
              } finally {
View Full Code Here


     * Create and return new audio codec applicable for byte buffer data
     * @param data                 Byte buffer data
     * @return                     audio codec
     */
  public static IAudioStreamCodec getAudioCodec(IoBuffer data) {
    IAudioStreamCodec result = null;
    try {
      //get the codec identifying byte
      int codecId = (data.get() & 0xf0) >> 4;   
        switch (codecId) {
          case 10: //aac
            result = (IAudioStreamCodec) Class.forName("org.red5.codec.AACAudio").newInstance();
            break;
          // TODO add SPEEX support?
        }
        data.rewind();
    } catch (Exception ex) {
      log.error("Error creating codec instance", ex);     
    }
    //if codec is not found do the old-style loop
    if (result == null) {
        for (IAudioStreamCodec storedCodec: codecs) {
          IAudioStreamCodec codec;
          // XXX: this is a bit of a hack to create new instances of the
          // configured audio codec for each stream
          try {
            codec = storedCodec.getClass().newInstance();
          } catch (Exception e) {
            log.error("Could not create audio codec instance", e);
            continue;
          }
          if (codec.canHandleData(data)) {
            result = codec;
            break;
          }
        }
    }
View Full Code Here

            }
          } else {
            log.debug("Could not initialize stream output, videoCodec is null");
          }
          // SplitmediaLabs - begin AAC fix
          IAudioStreamCodec audioCodec = info.getAudioCodec();
          log.debug("Audio codec: {}", audioCodec);
          if (audioCodec != null) {
            // check for decoder configuration to send
            IoBuffer config = audioCodec.getDecoderConfiguration();
            if (config != null) {
              log.debug("Decoder configuration is available for {}", audioCodec.getName());
              //log.debug("Dump:\n{}", Hex.encodeHex(config.array()));
              AudioData conf = new AudioData(config.asReadOnlyBuffer());
              log.trace("Configuration ts: {}", conf.getTimestamp());
              RTMPMessage confMsg = RTMPMessage.build(conf);
              try {
View Full Code Here

          if (codecInfo instanceof StreamCodecInfo) {
            info = (StreamCodecInfo) codecInfo;
          }
          //log.trace("Stream codec info: {}", info);
          if (rtmpEvent instanceof AudioData) {
            IAudioStreamCodec audioStreamCodec = null;
            if (checkAudioCodec) {
              // dont try to read codec info from 0 length audio packets
              if (buf.limit() > 0) {
                  audioStreamCodec = AudioCodecFactory.getAudioCodec(buf);
                  if (info != null) {
                    info.setAudioCodec(audioStreamCodec);
                  }
                  checkAudioCodec = false;
              }
            } else if (codecInfo != null) {
              audioStreamCodec = codecInfo.getAudioCodec();
            }
            if (audioStreamCodec != null) {
              audioStreamCodec.addData(buf.asReadOnlyBuffer());
            }
            if (info != null) {
              info.setHasAudio(true);
            }
            eventTime = rtmpEvent.getTimestamp();
View Full Code Here

              }
            }
          } else {
            log.debug("Could not initialize stream output, videoCodec is null.");
          }
          IAudioStreamCodec audioCodec = info.getAudioCodec();
          log.debug("Audio codec: {}", audioCodec);
          if (audioCodec != null) {
            //check for decoder configuration to send
            IoBuffer config = audioCodec.getDecoderConfiguration();
            if (config != null) {
              log.debug("Decoder configuration is available for {}", audioCodec.getName());
              AudioData audioConf = new AudioData(config.asReadOnlyBuffer());
              try {
                log.debug("Setting decoder configuration for recording");
                listener.getFileConsumer().setAudioDecoderConfiguration(audioConf);
              } finally {
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

     */

    private void init() throws IOException {

   
    IStreamableFileFactory factory = (IStreamableFileFactory) ScopeUtils

        .getScopeService(scope, IStreamableFileFactory.class,

            StreamableFileFactory.class);

    File folder = file.getParentFile();

    if (!folder.exists()) {

      if (!folder.mkdirs()) {

        throw new IOException("Could not create parent folder");

      }

    }

    if (!file.isFile()) {

      // Maybe the (previously existing) file has been deleted

      file.createNewFile();

    } else if (!file.canWrite()) {

      throw new IOException("The file is read-only");

    }

    IStreamableFileService service = factory.getService(file);

    IStreamableFile flv = service.getStreamableFile(file);

    writer = flv.getWriter();

View Full Code Here

     *
     * @throws IOException          I/O exception
     */
    protected void init() throws IOException {

    IStreamableFileFactory factory = (IStreamableFileFactory) ScopeUtils
        .getScopeService(this.scope, IStreamableFileFactory.class,
            StreamableFileFactory.class);
   
    File folder = file.getParentFile();

    if (!folder.exists()) {
      if (!folder.mkdirs()) {
        throw new IOException("Could not create parent folder");
      }
    }

    if (!this.file.isFile()) {

      // Maybe the (previously existing) file has been deleted
      this.file.createNewFile();

    } 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

      throw new IOException("The file is read-only");

    }

    IStreamableFileService service = factory.getService(file);

    IStreamableFile flv = service.getStreamableFile(file);

    writer = flv.getWriter();

  }
View Full Code Here

TOP

Related Classes of org.red5.codec.IAudioStreamCodec

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.