1 |
/* avmusicstatusdescriptor.cpp |
---|
2 |
* Copyright (C) 2004 by Pieter Palmers |
---|
3 |
* |
---|
4 |
* This file is part of FreeBob. |
---|
5 |
* |
---|
6 |
* FreeBob 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 |
* FreeBob is distributed in the hope that it will be useful, |
---|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
13 |
* GNU General Public License for more details. |
---|
14 |
* |
---|
15 |
* You should have received a copy of the GNU General Public License |
---|
16 |
* along with FreeBob; if not, write to the Free Software |
---|
17 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
---|
18 |
* MA 02111-1307 USA. |
---|
19 |
*/ |
---|
20 |
|
---|
21 |
#include "avdevice.h" |
---|
22 |
#include "avdescriptor.h" |
---|
23 |
#include "avmusicidentifierdescriptor.h" |
---|
24 |
#include "avmusicstatusdescriptor.h" |
---|
25 |
#include "avinfoblock.h" |
---|
26 |
#include "avgeneralmusicstatusinfoblock.h" |
---|
27 |
#include "avnameinfoblock.h" |
---|
28 |
#include "avaudioinfoblock.h" |
---|
29 |
#include "avmidiinfoblock.h" |
---|
30 |
#include "avaudiosyncinfoblock.h" |
---|
31 |
#include "avsourcepluginfoblock.h" |
---|
32 |
#include "avoutputplugstatusinfoblock.h" |
---|
33 |
|
---|
34 |
AvMusicStatusDescriptor::AvMusicStatusDescriptor(AvDevice *parent) : AvDescriptor(parent, AVC1394_SUBUNIT_TYPE_MUSIC | AVC1394_SUBUNIT_ID_0,0x80) { |
---|
35 |
|
---|
36 |
} |
---|
37 |
|
---|
38 |
AvMusicStatusDescriptor::~AvMusicStatusDescriptor() { |
---|
39 |
|
---|
40 |
} |
---|
41 |
|
---|
42 |
void AvMusicStatusDescriptor::printCapabilities() { |
---|
43 |
if (!(this->AvDescriptor::isPresent())) { |
---|
44 |
fprintf(stderr,"AvMusicStatusDescriptor: Descriptor not present!\n"); |
---|
45 |
return; |
---|
46 |
} |
---|
47 |
|
---|
48 |
if (!(this->AvDescriptor::isOpen())) { |
---|
49 |
debugPrint (DEBUG_LEVEL_INFO, "AvMusicStatusDescriptor: Opening descriptor...\n"); |
---|
50 |
this->AvDescriptor::OpenReadOnly(); |
---|
51 |
if (!(this->AvDescriptor::isOpen()) ) { |
---|
52 |
fprintf(stderr,"AvMusicStatusDescriptor: Failed!\n"); |
---|
53 |
bValid=false; |
---|
54 |
return; |
---|
55 |
} |
---|
56 |
} |
---|
57 |
|
---|
58 |
if (!(this->AvDescriptor::isLoaded())) { |
---|
59 |
debugPrint (DEBUG_LEVEL_INFO, "AvMusicStatusDescriptor: Loading descriptor...\n"); |
---|
60 |
this->AvDescriptor::Load(); |
---|
61 |
if (!(this->AvDescriptor::isLoaded())) { |
---|
62 |
fprintf(stderr,"AvMusicStatusDescriptor: Failed!\n"); |
---|
63 |
bValid=false; |
---|
64 |
return; |
---|
65 |
} |
---|
66 |
} |
---|
67 |
|
---|
68 |
unsigned int offset=0; // update offset when beginning at a new table in the specs for easy reading |
---|
69 |
cGeneralMusicInfoBlock=NULL; |
---|
70 |
cOutputPlugStatusInfoBlock=NULL; |
---|
71 |
|
---|
72 |
debugPrint (DEBUG_LEVEL_INFO, "AvMusicStatusDescriptor: Creating AvGeneralMusicStatusInfoBlock... (offset=0x%04X)\n",offset); |
---|
73 |
cGeneralMusicInfoBlock=new AvGeneralMusicInfoBlock(this,offset); |
---|
74 |
if (!(cGeneralMusicInfoBlock) || !(cGeneralMusicInfoBlock->isValid())) { |
---|
75 |
debugPrint (DEBUG_LEVEL_INFO, "AvMusicStatusDescriptor: AvGeneralMusicStatusInfoBlock not found!\n"); |
---|
76 |
bValid=false; |
---|
77 |
return; |
---|
78 |
} |
---|
79 |
debugPrint (DEBUG_LEVEL_INFO, "AvMusicStatusDescriptor: AvGeneralMusicStatusInfoBlock found: length=0x%04X\n",cGeneralMusicInfoBlock->getLength()); |
---|
80 |
|
---|
81 |
offset += cGeneralMusicInfoBlock->getLength()+2; |
---|
82 |
|
---|
83 |
|
---|
84 |
debugPrint (DEBUG_LEVEL_INFO, "AvMusicStatusDescriptor: Creating AvOutputPlugStatusInfoBlock... (offset=0x%04X)\n",offset); |
---|
85 |
cOutputPlugStatusInfoBlock=new AvOutputPlugStatusInfoBlock(this,offset); |
---|
86 |
if (!(cOutputPlugStatusInfoBlock) || !(cOutputPlugStatusInfoBlock->isValid())) { |
---|
87 |
debugPrint (DEBUG_LEVEL_INFO, "AvMusicStatusDescriptor: AvOutputPlugStatusInfoBlock not found!\n"); |
---|
88 |
bValid=false; |
---|
89 |
return; |
---|
90 |
} |
---|
91 |
debugPrint (DEBUG_LEVEL_INFO, "AvMusicStatusDescriptor: AvOutputPlugStatusInfoBlock found: length=0x%04X\n",cOutputPlugStatusInfoBlock->getLength()); |
---|
92 |
|
---|
93 |
offset += cOutputPlugStatusInfoBlock->getLength()+2; |
---|
94 |
|
---|
95 |
// start parsing the optional infoblock(s) |
---|
96 |
AvInfoBlock *tmpInfoBlock = NULL; |
---|
97 |
debugPrint (DEBUG_LEVEL_INFO, "AvMusicStatusDescriptor: Parsing optional infoblocks...\n"); |
---|
98 |
|
---|
99 |
while (offset < getLength()) { |
---|
100 |
debugPrint (DEBUG_LEVEL_INFO, "AvMusicStatusDescriptor: Optional block found...\n"); |
---|
101 |
tmpInfoBlock = new AvInfoBlock(this,offset); |
---|
102 |
if (tmpInfoBlock && tmpInfoBlock->isValid()) { |
---|
103 |
debugPrint (DEBUG_LEVEL_INFO, "AvMusicStatusDescriptor: Optional block of type 0x%04X with length 0x%04X found\n",tmpInfoBlock->getType(), tmpInfoBlock->getLength()); |
---|
104 |
|
---|
105 |
offset += tmpInfoBlock->getLength()+2; |
---|
106 |
} else { |
---|
107 |
debugPrint (DEBUG_LEVEL_INFO, "AvMusicStatusDescriptor: error parsing optional infoblock\n"); |
---|
108 |
bValid=false; |
---|
109 |
return; |
---|
110 |
} |
---|
111 |
|
---|
112 |
} |
---|
113 |
|
---|
114 |
|
---|
115 |
} |
---|