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 {
msgOut.pushMessage(metaMsg);
} catch (IOException e) {
log.warn("Error sending metadata", e);
}
} else {
log.debug("No metadata available");
}
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()));
RTMPMessage videoMsg = RTMPMessage.build(video);
try {
log.debug("Pushing keyframe");
msgOut.pushMessage(videoMsg);
} finally {
video.release();
}
}
} 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 {
log.debug("Pushing decoder configuration");
msgOut.pushMessage(confMsg);
} finally {
conf.release();