break;
}
+ log->log("Client", Log::DEBUG, "SwitchOp");
switch(opcode)
{
case 1:
case 16:
result = processPositionFromFrameNumber(data, packetLength);
break;
+ case 17:
+ result = processFrameNumberFromPosition(data, packetLength);
+ break;
+ case 18:
+ result = processMoveRecording(data, packetLength);
+ break;
}
free(buffer);
return 1;
}
+int MVPClient::processMoveRecording(UCHAR* data, int length)
+{
+ log->log("Client", Log::DEBUG, "Process move recording");
+ char* fileName = (char*)data;
+ char* newPath = NULL;
+
+ for (int k = 0; k < length; k++)
+ {
+ if (data[k] == '\0')
+ {
+ newPath = (char*)&data[k+1];
+ break;
+ }
+ }
+ log->log("Client", Log::DEBUG, "newPath=%s", newPath);
+ if (!newPath) return 0;
+
+ cRecordings Recordings;
+ Recordings.Load(); // probably have to do this
+
+ cRecording* recording = Recordings.GetByName((char*)fileName);
+
+ log->log("Client", Log::DEBUG, "recording pointer %p", recording);
+
+ if (recording)
+ {
+ log->log("Client", Log::DEBUG, "moving recording: %s", recording->Name());
+
+ cRecordControl *rc = cRecordControls::GetRecordControl(recording->FileName());
+ if (!rc)
+ {
+ if (1)
+ {
+
+ sendULONG(1);
+ }
+ else
+ {
+ sendULONG(2);
+ }
+ }
+ else
+ {
+ sendULONG(3);
+ }
+ }
+ else
+ {
+ sendULONG(4);
+ }
+
+ return 1;
+}
+
int MVPClient::processGetSummary(UCHAR* data, int length)
{
// data is a pointer to the fileName string
return 1;
}
+int MVPClient::processFrameNumberFromPosition(UCHAR* data, int length)
+{
+ ULONG retval = 0;
+
+ ULLONG position = ntohll(*(ULLONG*)data);
+ data += 8;
+
+ if (!rp)
+ {
+ log->log("Client", Log::DEBUG, "Rescan recording called when no recording being played!");
+ }
+ else
+ {
+ retval = rp->frameNumberFromPosition(position);
+ }
+
+ UCHAR sendBuffer[8];
+ *(ULONG*)&sendBuffer[0] = htonl(4);
+ *(ULONG*)&sendBuffer[4] = htonl(retval);
+
+ tcp.sendPacket(sendBuffer, 8);
+ log->log("Client", Log::DEBUG, "Wrote frameNumFromPos reply to client");
+ return 1;
+}
+
int MVPClient::processGetChannelSchedule(UCHAR* data, int length)
{
ULONG channelNumber = ntohl(*(ULONG*)data);
int processLogin(UCHAR* buffer, int length);
int processGetRecordingsList(UCHAR* data, int length);
int processDeleteRecording(UCHAR* data, int length);
+ int processMoveRecording(UCHAR* data, int length);
int processGetSummary(UCHAR* data, int length);
int processGetChannelsList(UCHAR* data, int length);
int processStartStreamingChannel(UCHAR* data, int length);
int processGetTimers(UCHAR* data, int length);
int processSetTimer(UCHAR* data, int length);
int processPositionFromFrameNumber(UCHAR* data, int length);
+ int processFrameNumberFromPosition(UCHAR* data, int length);
cChannel* channelFromNumber(ULONG channelNumber);
void writeResumeData();
return position;
}
+
+ULONG RecPlayer::frameNumberFromPosition(ULLONG position)
+{
+ if (!indexFile) return 0;
+
+ uchar segmentNumber;
+ for(segmentNumber = 1; segmentNumber < 255; segmentNumber++)
+ {
+ if ((position >= segments[segmentNumber]->start) && (position < segments[segmentNumber]->end)) break;
+ // position is in this block
+ }
+ ULONG askposition = position - segments[segmentNumber]->start;
+ return indexFile->Get((int)segmentNumber, askposition);
+
+}