//Calculate the delta between the initial start and the first audio-packet data
this.initialDelta = new Date().getTime() - this.startedSessionTimeDate.getTime();
FlvRecordingMetaDelta flvRecordingMetaDelta = new FlvRecordingMetaDelta();
flvRecordingMetaDelta.setDeltaTime(this.initialDelta);
flvRecordingMetaDelta.setFlvRecordingMetaDataId(this.flvRecordingMetaDataId);
flvRecordingMetaDelta.setTimeStamp(0);
flvRecordingMetaDelta.setDebugStatus("INIT AUDIO");
flvRecordingMetaDelta.setOffset(this.offset);
flvRecordingMetaDelta.setIsStartPadding(true);
flvRecordingMetaDelta.setIsEndPadding(false);
flvRecordingMetaDelta.setDataLengthPacket(data.limit());
flvRecordingMetaDelta.setReceivedAudioDataLength(this.byteCount);
flvRecordingMetaDelta.setStartTime(this.startedSessionTimeDate);
flvRecordingMetaDelta.setStreamCreationTime(broadcastStream.getCreationTime());
flvRecordingMetaDelta.setStreamCreationTimeDate(new Date(broadcastStream.getCreationTime()));
flvRecordingMetaDelta.setPacketTimeStamp(streampacket.getTimestamp());
Date current_date = new Date();
Long deltaTimeStamp = current_date.getTime() - this.startedSessionTimeDate.getTime();
//this.duration = Math.max(this.duration, 0 + this.writer.getOffset());
flvRecordingMetaDelta.setDuration(0);
Long missingTime = deltaTimeStamp - 0;
flvRecordingMetaDelta.setMissingTime(missingTime);
flvRecordingMetaDelta.setCurrentTime(current_date);
flvRecordingMetaDelta.setDeltaTimeStamp(deltaTimeStamp);
flvRecordingMetaDelta.setStartTimeStamp(startTimeStamp);
this.flvRecordingMetaDeltas.add(flvRecordingMetaDelta);
FlvRecordingMetaDeltaDaoImpl.getInstance().addFlvRecordingMetaDelta(flvRecordingMetaDelta);
//That will be not bigger then long value
this.startTimeStamp = (int) (streampacket.getTimestamp());
//We have to set that to bypass the initial delta
//lastTimeStamp = startTimeStamp;
}
if (writer == null) {
File folder = new File(ScopeApplicationAdapter.webAppPath + File.separatorChar +
"streams" + File.separatorChar +
this.scope.getName());
if (!folder.exists()) {
folder.mkdir();
}
String flvName = ScopeApplicationAdapter.webAppPath + File.separatorChar +
"streams" + File.separatorChar +
this.scope.getName() + File.separatorChar +
this.streamName+".flv";
file = new File(flvName);
init();
}
int timeStamp = streampacket.getTimestamp();
this.lastStreamPacketTimeStamp = streampacket.getTimestamp();
timeStamp -= this.startTimeStamp;
timeStamp += this.offset;
long deltaTime = 0;
if (lastTimeStamp == -1) {
deltaTime = 0; //Offset at the beginning is calculated above
} else {
deltaTime = timeStamp - lastTimeStamp;
}
Long preLastTimeStamp = Long.parseLong(lastTimeStamp.toString());
lastTimeStamp = timeStamp;
if (deltaTime > 75){
FlvRecordingMetaDelta flvRecordingMetaDelta = new FlvRecordingMetaDelta();
flvRecordingMetaDelta.setDeltaTime(deltaTime);
flvRecordingMetaDelta.setFlvRecordingMetaDataId(this.flvRecordingMetaDataId);
flvRecordingMetaDelta.setTimeStamp(timeStamp);
flvRecordingMetaDelta.setDebugStatus("RUN AUDIO");
flvRecordingMetaDelta.setIsStartPadding(false);
flvRecordingMetaDelta.setLastTimeStamp(preLastTimeStamp);
flvRecordingMetaDelta.setOffset(this.offset);
flvRecordingMetaDelta.setIsEndPadding(false);
flvRecordingMetaDelta.setDataLengthPacket(data.limit());
flvRecordingMetaDelta.setReceivedAudioDataLength(this.byteCount);
flvRecordingMetaDelta.setStartTime(this.startedSessionTimeDate);
flvRecordingMetaDelta.setStreamCreationTime(broadcastStream.getCreationTime());
flvRecordingMetaDelta.setStreamCreationTimeDate(new Date(broadcastStream.getCreationTime()));
flvRecordingMetaDelta.setPacketTimeStamp(streampacket.getTimestamp());
Date current_date = new Date();
Long deltaTimeStamp = current_date.getTime() - this.startedSessionTimeDate.getTime();
this.duration = Math.max(this.duration, timeStamp + this.writer.getOffset());
flvRecordingMetaDelta.setDuration(this.duration);
Long missingTime = deltaTimeStamp - timeStamp;
flvRecordingMetaDelta.setMissingTime(missingTime);
flvRecordingMetaDelta.setCurrentTime(current_date);
flvRecordingMetaDelta.setDeltaTimeStamp(deltaTimeStamp);
flvRecordingMetaDelta.setStartTimeStamp(startTimeStamp);
this.flvRecordingMetaDeltas.add(flvRecordingMetaDelta);
FlvRecordingMetaDeltaDaoImpl.getInstance().addFlvRecordingMetaDelta(flvRecordingMetaDelta);