]> git.vomp.tv Git - vompclient-marten.git/blob - recinfo.cc
Fix bug in demuxer widescreen signaling
[vompclient-marten.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
38 RecInfo::~RecInfo()
39 {
40   Log::getInstance()->log("RecInfo", Log::CRAZY, "Deleting recinfo: %lu, %s", numComponents, summary);
41
42   if (summary) delete[] summary;
43
44   for (ULONG i = 0; i < numComponents; i++)
45   {
46     Log::getInstance()->log("RecInfo", Log::CRAZY, "i: %lu, languages[i]=%p:%s", i, languages[i], languages[i]);
47     Log::getInstance()->log("RecInfo", Log::CRAZY, "i: %lu, descripti[i]=%p:%s", i, descriptions[i], descriptions[i]);
48     if (languages[i]) delete[] (languages[i]);
49     if (descriptions[i]) delete[] (descriptions[i]);
50   }
51
52   if (numComponents)
53   {
54     delete[] languages;
55     delete[] descriptions;
56
57     delete[] streams;
58     delete[] types;
59   }
60
61   timerStart = 0;
62   timerEnd = 0;
63   resumePoint = 0;
64   summary = NULL;
65
66   numComponents = 0;
67   streams = NULL;
68   types = NULL;
69   languages = NULL;
70   descriptions = NULL;
71 }
72
73 void RecInfo::setNumComponents(ULONG tnumComponents)
74 {
75   numComponents = tnumComponents;
76   languages = new char*[numComponents];
77   descriptions = new char*[numComponents];
78   streams = new UCHAR[numComponents];
79   types = new UCHAR[numComponents];
80 }
81
82 void RecInfo::addComponent(ULONG componentNum, UCHAR tstream, UCHAR ttype, char* tlanguage, char* tdescription)
83 {
84   if (componentNum >= numComponents) return;
85   streams[componentNum] = tstream;
86   types[componentNum] = ttype;
87   languages[componentNum] = tlanguage;
88   descriptions[componentNum] = tdescription;
89 }
90
91 void RecInfo::print()
92 {
93   Log* logger = Log::getInstance();
94
95   logger->log("RecInfo", Log::DEBUG, "timerStart %lu", timerStart);
96   logger->log("RecInfo", Log::DEBUG, "timerEnd %lu", timerEnd);
97   logger->log("RecInfo", Log::DEBUG, "resumePoint %lu", resumePoint);
98   logger->log("RecInfo", Log::DEBUG, "Summary: %s", summary);
99   logger->log("RecInfo", Log::DEBUG, "numComponents: %lu", numComponents);
100
101   for (ULONG i = 0; i < numComponents; i++)
102   {
103     logger->log("RecInfo", Log::DEBUG, "streams[%lu]: %u", i, streams[i]);
104     logger->log("RecInfo", Log::DEBUG, "types[%lu]: %u", i, types[i]);
105     logger->log("RecInfo", Log::DEBUG, "languages[%lu]: %s", i, languages[i]);
106     logger->log("RecInfo", Log::DEBUG, "descriptions[%lu]: %s", i, descriptions[i]);
107   }
108 }
109
110 bool RecInfo::hasNoVideo()
111 {
112   // If no info (numComponents == 0) assume there is video
113   if (!numComponents) return false;
114
115   // video = 1, audio = 2
116
117   for (ULONG i = 0; i < numComponents; i++)
118     if (streams[i] == 1) return false;
119
120   return true;
121 }