case 12:
processConfigLoad(data, packetLength);
break;
+ case 13:
+ processReScanRecording(data, packetLength);
+ break;
}
free(buffer);
}
}
+void MVPClient::processReScanRecording(unsigned char* data, int length)
+{
+ ULLONG retval = 0;
+
+ if (!rp)
+ {
+ log->log("Client", Log::DEBUG, "Rescan recording called when no recording being played!");
+ }
+ else
+ {
+ rp->scan();
+ retval = rp->getTotalLength();
+ }
+
+ unsigned char sendBuffer[12];
+ *(unsigned long*)&sendBuffer[0] = htonl(8);
+ *(ULLONG*)&sendBuffer[4] = htonll(retval);
+
+ tcp.sendPacket(sendBuffer, 12);
+ log->log("Client", Log::DEBUG, "Rescan recording, wrote new length to client");
+}
+
void MVPClient::processGetChannelSchedule(unsigned char* data, int length)
{
ULONG channelNumber = ntohl(*(ULLONG*)data);
void processGetBlock(unsigned char* data, int length);
void processStopStreaming(unsigned char* data, int length);
void processStartStreamingRecording(unsigned char* data, int length);
+ void processReScanRecording(unsigned char* data, int length);
void processGetChannelSchedule(unsigned char* data, int length);
void processConfigSave(unsigned char* data, int length);
void processConfigLoad(unsigned char* data, int length);
RecPlayer::RecPlayer(cRecording* rec)
{
+ log = Log::getInstance();
file = NULL;
- totalLength = 0;
+ fileOpen = 0;
lastPosition = 0;
- log = Log::getInstance();
recording = rec;
+ for(int i = 1; i < 1000; i++) segments[i] = NULL;
// FIXME find out max file path / name lengths
+ scan();
+}
+
+void RecPlayer::scan()
+{
+ if (file) fclose(file);
+ totalLength = 0;
+ fileOpen = 0;
+
+ int i = 1;
+ while(segments[i++]) delete segments[i];
char fileName[2048];
- for(int i = 1; i < 1001; i++)
+ for(i = 1; i < 1000; i++)
{
- snprintf(fileName, 2047, "%s/%03i.vdr", rec->FileName(), i);
+ snprintf(fileName, 2047, "%s/%03i.vdr", recording->FileName(), i);
log->log("RecPlayer", Log::DEBUG, "FILENAME: %s", fileName);
file = fopen(fileName, "r");
- if (file)
- {
- segments[i] = new Segment();
- segments[i]->start = totalLength;
-
- fseek(file, 0, SEEK_END);
- totalLength += ftell(file);
- log->log("RecPlayer", Log::DEBUG, "File %i found, totalLength now %llu", i, totalLength);
- segments[i]->end = totalLength;
- fclose(file);
- }
- else
- {
- segments[i] = NULL;
- break;
- }
+ if (!file) break;
+
+ segments[i] = new Segment();
+ segments[i]->start = totalLength;
+ fseek(file, 0, SEEK_END);
+ totalLength += ftell(file);
+ log->log("RecPlayer", Log::DEBUG, "File %i found, totalLength now %llu", i, totalLength);
+ segments[i]->end = totalLength;
+ fclose(file);
}
- openFile(1);
+
+ file = NULL;
}
RecPlayer::~RecPlayer()