Implement SEEK to offset using two 32bit integers to represent the double value

pull/3076/head
Isaac Connor 2020-10-06 16:35:46 -04:00
parent 0e89d28c26
commit 061c889394
1 changed files with 13 additions and 3 deletions

View File

@ -505,9 +505,18 @@ void EventStream::processCommand(const CmdMsg *msg) {
case CMD_SEEK : case CMD_SEEK :
{ {
// offset is in seconds // offset is in seconds
int offset = ((unsigned char)msg->msg_data[1]<<24)|((unsigned char)msg->msg_data[2]<<16)|((unsigned char)msg->msg_data[3]<<8)|(unsigned char)msg->msg_data[4];
curr_frame_id = (int)(event_data->frame_count*offset/event_data->duration); int int_part = ((unsigned char)msg->msg_data[1]<<24)|((unsigned char)msg->msg_data[2]<<16)|((unsigned char)msg->msg_data[3]<<8)|(unsigned char)msg->msg_data[4];
Debug(1, "Got SEEK command, to %d (new current frame id: %d offset %.f)", int dec_part = ((unsigned char)msg->msg_data[5]<<24)|((unsigned char)msg->msg_data[6]<<16)|((unsigned char)msg->msg_data[7]<<8)|(unsigned char)msg->msg_data[8];
double offset = (double)int_part + (double)(dec_part / (double)1000000);
if ( offset < 0.0 ) {
Warning("Invalid offset, not seeking");
break;
}
curr_frame_id = (int)(event_data->frame_count*offset/event_data->duration)+1;
curr_stream_time = event_data->frames[curr_frame_id-1].timestamp;
Debug(1, "Got SEEK command, to %f (new current frame id: %d offset %f)",
offset, curr_frame_id, event_data->frames[curr_frame_id-1].offset); offset, curr_frame_id, event_data->frames[curr_frame_id-1].offset);
send_frame = true; send_frame = true;
break; break;
@ -903,6 +912,7 @@ void EventStream::runStream() {
bool in_event = true; bool in_event = true;
double time_to_event = 0; double time_to_event = 0;
if ( replay_rate > 0 ) { if ( replay_rate > 0 ) {
// As we are playing, curr_stream_time starts at first frame timestamp and increases so it should only be greater if event data has been loaded for the next event.
time_to_event = event_data->frames[0].timestamp - curr_stream_time; time_to_event = event_data->frames[0].timestamp - curr_stream_time;
if ( time_to_event > 0 ) if ( time_to_event > 0 )
in_event = false; in_event = false;