6
#include <tnt/httperror.h>
7
#include <tnt/httpheader.h>
8
#include <vdr/recording.h>
9
#include "tntfeatures.h"
14
using namespace vdrlive;
16
off_t RecSize(cRecording const * recording)
18
cFileName recFile(recording->FileName(), false, false);
20
for (cUnbufferedFile *recData = recFile.Open(); recData; recData = recFile.NextFile()) {
22
if (0 == stat(recFile.Name(), &buf)) {
23
recSize += buf.st_size;
24
// dsyslog("LIVE: size of recording part %s is %ld", recFile.Name(), buf.st_size);
27
esyslog("LIVE: can't determine size of %s", recFile.Name());
30
// dsyslog("LIVE: total size of %s is %ld", recording->FileName(), recSize);
38
<%session scope="global">
39
bool logged_in(false);
42
//if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html");
44
cRecording const * recording = LiveRecordingsManager()->GetByMd5Hash(recid);
46
reply.setContentType("video/mpeg");
47
reply.setKeepAliveHeader();
48
reply.setContentLengthHeader(RecSize(recording));
49
reply.setDirectMode();
51
cFileName recFile(recording->FileName(), false, false);
52
// dsyslog("LIVE: start send video data.");
53
for (cUnbufferedFile *recData = recFile.Open(); recData; recData = recFile.NextFile()) {
54
char buffer[KILOBYTE(16)];
55
ssize_t bytesRead = 0;
56
// dsyslog("LIVE: send file %s", recFile->Name());
57
while (0 < (bytesRead = recData->Read(buffer, sizeof(buffer)))) {
58
// dsyslog("LIVE: copy %zd bytes", bytesRead);
59
reply.out().write(buffer, bytesRead);
63
#if TNT_WATCHDOG_SILENCE
64
request.touch(); // retrigger the watchdog.
67
// dsyslog("LIVE: bytesRead = %zd", bytesRead);
69
return HTTP_PARTIAL_CONTENT;
72
// dsyslog("LIVE: finished send video data.");
73
reply.out() << std::flush;