return;
}
// Get stream codec
IStreamCodecInfo codecInfo = getCodecInfo();
StreamCodecInfo info = null;
if (codecInfo instanceof StreamCodecInfo) {
info = (StreamCodecInfo) codecInfo;
}
IRTMPEvent rtmpEvent;
try {
rtmpEvent = (IRTMPEvent) event;
} catch (ClassCastException e) {
log.error("Class cast exception in event dispatch", e);
return;
}
int eventTime = -1;
// If this is first packet save it's timestamp
if (firstPacketTime == -1) {
firstPacketTime = rtmpEvent.getTimestamp();
}
if (rtmpEvent instanceof AudioData) {
if (info != null) {
info.setHasAudio(true);
}
if (rtmpEvent.getHeader().isTimerRelative()) {
audioTime += rtmpEvent.getTimestamp();
} else {
audioTime = rtmpEvent.getTimestamp();
}
eventTime = audioTime;
} else if (rtmpEvent instanceof VideoData) {
IVideoStreamCodec videoStreamCodec = null;
if (videoCodecFactory != null && checkVideoCodec) {
videoStreamCodec = videoCodecFactory
.getVideoCodec(((VideoData) rtmpEvent).getData());
if (codecInfo instanceof StreamCodecInfo) {
((StreamCodecInfo) codecInfo)
.setVideoCodec(videoStreamCodec);
}
checkVideoCodec = false;
} else if (codecInfo != null) {
videoStreamCodec = codecInfo.getVideoCodec();
}
if (videoStreamCodec != null) {
videoStreamCodec.addData(((VideoData) rtmpEvent).getData());
}
if (info != null) {
info.setHasVideo(true);
}
if (rtmpEvent.getHeader().isTimerRelative()) {
videoTime += rtmpEvent.getTimestamp();
} else {
videoTime = rtmpEvent.getTimestamp();