1 |
/* avoutputplugstatusinfoblock.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 |
|
---|
22 |
#include <string.h> |
---|
23 |
#include <errno.h> |
---|
24 |
#include <libavc1394/avc1394.h> |
---|
25 |
#include <libavc1394/avc1394_vcr.h> |
---|
26 |
#include "debugmodule.h" |
---|
27 |
|
---|
28 |
#include "avdescriptor.h" |
---|
29 |
#include "avinfoblock.h" |
---|
30 |
#include "avnameinfoblock.h" |
---|
31 |
#include "avoutputplugstatusinfoblock.h" |
---|
32 |
|
---|
33 |
AvOutputPlugStatusInfoBlock::AvOutputPlugStatusInfoBlock(AvDescriptor *parent, int address) : AvInfoBlock(parent,address) { |
---|
34 |
// do some more valid checks |
---|
35 |
if (getType() != 0x8101) { |
---|
36 |
bValid=false; |
---|
37 |
} |
---|
38 |
|
---|
39 |
unsigned int next_block_position=address+7; |
---|
40 |
unsigned int nb_sourceplugs=readByte(6); |
---|
41 |
AvSourcePlugInfoBlock *tmpAvSourcePlugInfoBlock=NULL; |
---|
42 |
|
---|
43 |
debugPrint(DEBUG_LEVEL_INFO,"AvOutputPlugStatusInfoBlock: Creating... length=0x%04X\n",getLength()); |
---|
44 |
debugPrint(DEBUG_LEVEL_INFO,"AvOutputPlugStatusInfoBlock: Number of source plugs=%d\n",nb_sourceplugs); |
---|
45 |
|
---|
46 |
if (nb_sourceplugs>0) { |
---|
47 |
for (unsigned int i=0;i<nb_sourceplugs;i++) { |
---|
48 |
debugPrint(DEBUG_LEVEL_INFO,"AvOutputPlugStatusInfoBlock: source plug=%d\n",i); |
---|
49 |
tmpAvSourcePlugInfoBlock=new AvSourcePlugInfoBlock(parent, next_block_position); |
---|
50 |
|
---|
51 |
if (tmpAvSourcePlugInfoBlock && (tmpAvSourcePlugInfoBlock->isValid())) { |
---|
52 |
//debugPrint(DEBUG_LEVEL_INFO,"AvOutputPlugStatusInfoBlock: source plug type=0x%04X\n",tmpAvSourcePlugInfoBlock->getType()); |
---|
53 |
next_block_position+=tmpAvSourcePlugInfoBlock->getLength()+2; // the 2 is due to the fact that the length of the length field of the infoblock isn't accounted for; |
---|
54 |
|
---|
55 |
// add to child list |
---|
56 |
cSourcePlugs.push_back(tmpAvSourcePlugInfoBlock); |
---|
57 |
|
---|
58 |
tmpAvSourcePlugInfoBlock->printContents(); |
---|
59 |
|
---|
60 |
} else { |
---|
61 |
debugPrint(DEBUG_LEVEL_INFO,"AvOutputPlugStatusInfoBlock: Invalid block... parse error!\n"); |
---|
62 |
bValid=false; |
---|
63 |
break; // what to do now? |
---|
64 |
} |
---|
65 |
|
---|
66 |
} |
---|
67 |
} |
---|
68 |
|
---|
69 |
debugPrint(DEBUG_LEVEL_INFO,"AvOutputPlugStatusInfoBlock: Created\n"); |
---|
70 |
|
---|
71 |
} |
---|
72 |
|
---|
73 |
AvOutputPlugStatusInfoBlock::~AvOutputPlugStatusInfoBlock() { |
---|
74 |
vector<AvSourcePlugInfoBlock *>::iterator it; |
---|
75 |
for( it = cSourcePlugs.begin(); it != cSourcePlugs.end(); it++ ) { |
---|
76 |
delete *it; |
---|
77 |
} |
---|
78 |
|
---|
79 |
} |
---|
80 |
|
---|
81 |
unsigned int AvOutputPlugStatusInfoBlock::getNbSourcePlugs() { |
---|
82 |
if(isValid()) { |
---|
83 |
return readByte(6); |
---|
84 |
} else { |
---|
85 |
return 0; |
---|
86 |
} |
---|
87 |
} |
---|