root/trunk/freebob/src/avmusicstatusdescriptor.cpp

Revision 38, 5.2 kB (checked in by pieterpalmers, 19 years ago)

- Added classes to parse the infoblocks new to the 1.1 version of the AV/C Music Subunit spec
- Implemented some prototype parsing in these classes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
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 #include "avroutingstatusinfoblock.h"
34
35 AvMusicStatusDescriptor::AvMusicStatusDescriptor(AvDevice *parent, unsigned char id) : AvDescriptor(parent, AVC1394_SUBUNIT_TYPE_MUSIC | (id << 16),0x80) {
36         if (!(this->AvDescriptor::isPresent())) {
37                 debugPrint(DEBUG_LEVEL_DESCRIPTOR,"AvMusicStatusDescriptor: Descriptor not present!\n");
38                 return;
39         }
40        
41         if (!(this->AvDescriptor::isOpen())) {
42                 debugPrint (DEBUG_LEVEL_DESCRIPTOR, "AvMusicStatusDescriptor: Opening descriptor...\n");
43                 this->AvDescriptor::OpenReadOnly();
44                 if (!(this->AvDescriptor::isOpen()) ) {
45                         debugPrint(DEBUG_LEVEL_DESCRIPTOR,"AvMusicStatusDescriptor:   Failed!\n");
46                         bValid=false;
47                         return;
48                 }
49         }
50        
51         if (!(this->AvDescriptor::isLoaded())) {
52                 debugPrint (DEBUG_LEVEL_DESCRIPTOR, "AvMusicStatusDescriptor: Loading descriptor...\n");
53                 this->AvDescriptor::Load();
54                 if (!(this->AvDescriptor::isLoaded())) {
55                         debugPrint(DEBUG_LEVEL_DESCRIPTOR,"AvMusicStatusDescriptor:   Failed!\n");
56                         bValid=false;
57                         return;
58                 }
59         }
60        
61         unsigned int offset=0; // update offset when beginning at a new table in the specs for easy reading
62         cGeneralMusicInfoBlock=NULL;
63         cOutputPlugStatusInfoBlock=NULL;
64        
65         debugPrint (DEBUG_LEVEL_DESCRIPTOR, "AvMusicStatusDescriptor: Creating AvGeneralMusicStatusInfoBlock... (offset=0x%04X)\n",offset);
66         cGeneralMusicInfoBlock=new AvGeneralMusicInfoBlock(this,offset);
67         if (!(cGeneralMusicInfoBlock) || !(cGeneralMusicInfoBlock->isValid())) {
68                 debugPrint (DEBUG_LEVEL_DESCRIPTOR, "AvMusicStatusDescriptor:  AvGeneralMusicStatusInfoBlock not found!\n");
69                 bValid=false;
70                 return;
71         }
72         debugPrint (DEBUG_LEVEL_DESCRIPTOR, "AvMusicStatusDescriptor:  AvGeneralMusicStatusInfoBlock found: length=0x%04X\n",cGeneralMusicInfoBlock->getLength());
73        
74         offset += cGeneralMusicInfoBlock->getLength()+2;
75        
76        
77         debugPrint (DEBUG_LEVEL_DESCRIPTOR, "AvMusicStatusDescriptor: Creating AvOutputPlugStatusInfoBlock... (offset=0x%04X)\n",offset);
78         cOutputPlugStatusInfoBlock=new AvOutputPlugStatusInfoBlock(this,offset);
79         if (!(cOutputPlugStatusInfoBlock) || !(cOutputPlugStatusInfoBlock->isValid())) {
80                 debugPrint (DEBUG_LEVEL_DESCRIPTOR, "AvMusicStatusDescriptor:  AvOutputPlugStatusInfoBlock not found!\n");
81                 bValid=false;
82                 return;
83         }
84         debugPrint (DEBUG_LEVEL_DESCRIPTOR, "AvMusicStatusDescriptor:  AvOutputPlugStatusInfoBlock found: length=0x%04X\n",cOutputPlugStatusInfoBlock->getLength());
85        
86         offset += cOutputPlugStatusInfoBlock->getLength()+2;
87        
88         debugPrint (DEBUG_LEVEL_DESCRIPTOR, "AvMusicStatusDescriptor: Creating AvRoutingStatusInfoBlock... (offset=0x%04X)\n",offset);
89         cRoutingStatusInfoBlock=new AvRoutingStatusInfoBlock(this,offset);
90         if (!(cRoutingStatusInfoBlock) || !(cRoutingStatusInfoBlock->isValid())) {
91                 debugPrint (DEBUG_LEVEL_DESCRIPTOR, "AvMusicStatusDescriptor:  AvRoutingStatusInfoBlock not found!\n");
92                 bValid=false;
93                 return;
94         }
95         debugPrint (DEBUG_LEVEL_DESCRIPTOR, "AvMusicStatusDescriptor:  AvRoutingStatusInfoBlock found: length=0x%04X\n",cRoutingStatusInfoBlock->getLength());
96        
97         offset += cRoutingStatusInfoBlock->getLength()+2;
98        
99         // start parsing the optional infoblock(s)
100         AvInfoBlock *tmpInfoBlock = NULL;
101         debugPrint (DEBUG_LEVEL_DESCRIPTOR, "AvMusicStatusDescriptor: Parsing optional infoblocks...\n");
102        
103         while (offset < getLength()) {
104                 debugPrint (DEBUG_LEVEL_DESCRIPTOR, "AvMusicStatusDescriptor:  Optional block found...\n");
105                 tmpInfoBlock = new AvInfoBlock(this,offset);
106                 if (tmpInfoBlock && tmpInfoBlock->isValid()) {
107                         debugPrint (DEBUG_LEVEL_DESCRIPTOR, "AvMusicStatusDescriptor:  Optional block of type 0x%04X with length 0x%04X found\n",tmpInfoBlock->getType(), tmpInfoBlock->getLength());
108                        
109                         offset += tmpInfoBlock->getLength()+2;
110                 } else {
111                         if (tmpInfoBlock) {
112                                 delete tmpInfoBlock;
113                                 tmpInfoBlock=NULL;
114                         }
115                         debugPrint (DEBUG_LEVEL_DESCRIPTOR, "AvMusicStatusDescriptor:  error parsing optional infoblock\n");
116                         bValid=false;
117                         return;
118                 }
119                
120         }
121
122 }
123
124 AvMusicStatusDescriptor::~AvMusicStatusDescriptor()  {
125         if (cGeneralMusicInfoBlock) delete cGeneralMusicInfoBlock;
126         if (cOutputPlugStatusInfoBlock) delete cOutputPlugStatusInfoBlock;
127 }
128
129 void AvMusicStatusDescriptor::printCapabilities() {
130        
131        
132 }
Note: See TracBrowser for help on using the browser.