]> git.vomp.tv Git - vompclient.git/blob - recording.cc
Update for windows
[vompclient.git] / recording.cc
1 /*
2     Copyright 2004-2005 Chris Tallon
3
4     This file is part of VOMP.
5
6     VOMP is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     VOMP is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with VOMP; if not, write to the Free Software
18     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 */
20
21 #include "recording.h"
22
23 Recording* Recording::recInfoFor = NULL;
24 RecInfo* Recording::recInfo = NULL;
25
26 Recording::Recording()
27 {
28   start = 0;
29   progName = NULL;
30   fileName = NULL;
31   index = -1;
32 }
33
34 Recording::~Recording()
35 {
36   if (progName) { delete[] progName; progName = NULL; }
37   if (fileName) { delete[] fileName; fileName = NULL; }
38   index = -1; // just in case
39 }
40
41 ULONG Recording::getStartTime() const
42 {
43   return start;
44 }
45
46 char* Recording::getProgName() const
47 {
48   return progName;
49 }
50
51 char* Recording::getFileName() const
52 {
53   return fileName;
54 }
55
56 void Recording::setStartTime(ULONG tstartTime)
57 {
58   start = tstartTime;
59 }
60
61 void Recording::setProgName(char* tProgName)
62 {
63   if (progName) delete[] progName;
64
65   progName = new char[strlen(tProgName) + 1];
66   if (progName) strcpy(progName, tProgName);
67 }
68
69 void Recording::setFileName(char* tFileName)
70 {
71   if (fileName) delete[] fileName;
72
73   fileName = new char[strlen(tFileName) + 1];
74   if (fileName) strcpy(fileName, tFileName);
75 }
76
77 void Recording::loadRecInfo()
78 {
79   if (recInfoFor == this) return; // it already is loaded
80
81   if (recInfo) delete recInfo;
82   recInfoFor = this;
83   recInfo = VDR::getInstance()->getRecInfo(fileName);
84   Log::getInstance()->log("Recording", Log::DEBUG, "Recording has loaded recInfo %p", recInfo);
85 }
86
87 void Recording::dropRecInfo()
88 {
89   if (recInfo) delete recInfo;
90   recInfo = NULL;
91   recInfoFor = NULL;
92 }
93
94 bool Recording::isRadio()
95 {
96   VDR* vdr = VDR::getInstance();
97   if (!vdr) return false;
98
99   ULONG lengthFrames = 0;
100   ULLONG lengthBytes = vdr->streamRecording(getFileName(), &lengthFrames);
101   if (!lengthBytes || !lengthFrames) return false;
102
103   UINT thisRead;
104   UCHAR* buffer = vdr->getBlock(0ULL, 10000U, &thisRead);
105   if (!buffer) return false;
106
107   if (!thisRead)
108   {
109     free(buffer);
110     return false;
111   }
112
113   bool hasVideo = Demuxer::scanForVideo(buffer, thisRead);
114
115   free(buffer);
116
117   // FIXME
118   vdr->stopStreaming();
119   Log::getInstance()->log("Recording", Log::DEBUG, "Recording has messed about and worked out radio = %u", !hasVideo);
120
121
122   if (!hasVideo) return true;
123   return false;
124 }
125