]> git.vomp.tv Git - vompclient.git/blob - recinfo.cc
More compiler warning fixes
[vompclient.git] / recinfo.cc
1 /*
2     Copyright 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 */
20
21 #include "recinfo.h"
22 #include "log.h"
23
24 RecInfo::RecInfo()
25 {
26   timerStart = 0;
27   timerEnd = 0;
28   resumePoint = 0;
29   summary = NULL;
30
31   numComponents = 0;
32   streams = NULL;
33   types = NULL;
34   languages = NULL;
35   descriptions = NULL;
36
37   title = NULL;
38 }
39
40 RecInfo::~RecInfo()
41 {
42   Log::getInstance()->log("RecInfo", Log::CRAZY, "Deleting recinfo: %lu, %s", numComponents, summary);
43
44   if (summary) delete[] summary;
45
46   for (ULONG i = 0; i < numComponents; i++)
47   {
48     Log::getInstance()->log("RecInfo", Log::CRAZY, "i: %lu, languages[i]=%p:%s", i, languages[i], languages[i]);
49     Log::getInstance()->log("RecInfo", Log::CRAZY, "i: %lu, descripti[i]=%p:%s", i, descriptions[i], descriptions[i]);
50     if (languages[i]) delete[] (languages[i]);
51     if (descriptions[i]) delete[] (descriptions[i]);
52   }
53
54   if (numComponents)
55   {
56     delete[] languages;
57     delete[] descriptions;
58
59     delete[] streams;
60     delete[] types;
61   }
62
63   if (title) delete [] title;
64
65   timerStart = 0;
66   timerEnd = 0;
67   resumePoint = 0;
68   summary = NULL;
69
70   numComponents = 0;
71   streams = NULL;
72   types = NULL;
73   languages = NULL;
74   descriptions = NULL;
75 }
76
77 void RecInfo::setNumComponents(ULONG tnumComponents)
78 {
79   numComponents = tnumComponents;
80   languages = new char*[numComponents];
81   descriptions = new char*[numComponents];
82   streams = new UCHAR[numComponents];
83   types = new UCHAR[numComponents];
84 }
85
86 void RecInfo::addComponent(ULONG componentNum, UCHAR tstream, UCHAR ttype, char* tlanguage, char* tdescription)
87 {
88   if (componentNum >= numComponents) return;
89   streams[componentNum] = tstream;
90   types[componentNum] = ttype;
91   languages[componentNum] = tlanguage;
92   descriptions[componentNum] = tdescription;
93 }
94
95 void RecInfo::print()
96 {
97   Log* logger = Log::getInstance();
98
99   logger->log("RecInfo", Log::DEBUG, "timerStart %lu", timerStart);
100   logger->log("RecInfo", Log::DEBUG, "timerEnd %lu", timerEnd);
101   logger->log("RecInfo", Log::DEBUG, "resumePoint %lu", resumePoint);
102   logger->log("RecInfo", Log::DEBUG, "Summary: %s", summary);
103   logger->log("RecInfo", Log::DEBUG, "numComponents: %lu", numComponents);
104
105   for (ULONG i = 0; i < numComponents; i++)
106   {
107     logger->log("RecInfo", Log::DEBUG, "streams[%lu]: %u", i, streams[i]);
108     logger->log("RecInfo", Log::DEBUG, "types[%lu]: %u", i, types[i]);
109     logger->log("RecInfo", Log::DEBUG, "languages[%lu]: %s", i, languages[i]);
110     logger->log("RecInfo", Log::DEBUG, "descriptions[%lu]: %s", i, descriptions[i]);
111   }
112 }
113
114 bool RecInfo::hasNoVideo()
115 {
116   // If no info (numComponents == 0) assume there is video
117   if (!numComponents) return false;
118
119   // video = 1, audio = 2
120
121   for (ULONG i = 0; i < numComponents; i++)
122     if (streams[i] == 1) return false;
123
124   return true;
125 }