1 |
/* avc_generic.cpp |
---|
2 |
* Copyright (C) 2005 by Daniel Wagner |
---|
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 "avc_generic.h" |
---|
22 |
#include "serialize.h" |
---|
23 |
#include "ieee1394service.h" |
---|
24 |
|
---|
25 |
AVCCommand::AVCCommand( Ieee1394Service* ieee1394service, |
---|
26 |
opcode_t opcode ) |
---|
27 |
: m_1394Service( ieee1394service ) |
---|
28 |
, m_nodeId( 0 ) |
---|
29 |
, m_ctype( eCT_Unknown ) |
---|
30 |
, m_subunit( 0xff ) |
---|
31 |
, m_opcode( opcode ) |
---|
32 |
, m_eResponse( eR_Unknown ) |
---|
33 |
, m_verbose( false ) |
---|
34 |
{ |
---|
35 |
} |
---|
36 |
|
---|
37 |
bool |
---|
38 |
AVCCommand::serialize( IOSSerialize& se ) |
---|
39 |
{ |
---|
40 |
se.write( m_ctype, "AVCCommand ctype" ); |
---|
41 |
se.write( m_subunit, "AVCCommand subunit" ); |
---|
42 |
se.write( m_opcode, "AVCCommand opcode" ); |
---|
43 |
return true; |
---|
44 |
} |
---|
45 |
|
---|
46 |
bool |
---|
47 |
AVCCommand::deserialize( IISDeserialize& de ) |
---|
48 |
{ |
---|
49 |
de.read( &m_ctype ); |
---|
50 |
de.read( &m_subunit ); |
---|
51 |
de.read( &m_opcode ); |
---|
52 |
return true; |
---|
53 |
} |
---|
54 |
|
---|
55 |
bool |
---|
56 |
AVCCommand::setCommandType( ECommandType commandType ) |
---|
57 |
{ |
---|
58 |
m_ctype = commandType; |
---|
59 |
m_commandType = commandType; |
---|
60 |
return true; |
---|
61 |
} |
---|
62 |
|
---|
63 |
AVCCommand::ECommandType |
---|
64 |
AVCCommand::getCommandType() |
---|
65 |
{ |
---|
66 |
return m_commandType; |
---|
67 |
} |
---|
68 |
|
---|
69 |
AVCCommand::EResponse |
---|
70 |
AVCCommand::getResponse() |
---|
71 |
{ |
---|
72 |
return m_eResponse; |
---|
73 |
} |
---|
74 |
|
---|
75 |
bool |
---|
76 |
AVCCommand::parseResponse( byte_t response ) |
---|
77 |
{ |
---|
78 |
m_eResponse = static_cast<EResponse>( response ); |
---|
79 |
return true; |
---|
80 |
} |
---|
81 |
|
---|
82 |
bool |
---|
83 |
AVCCommand::setSubunitType(ESubunitType subunitType) |
---|
84 |
{ |
---|
85 |
byte_t subT = subunitType; |
---|
86 |
|
---|
87 |
m_subunit = ( subT << 3 ) | ( m_subunit & 0x7 ); |
---|
88 |
return true; |
---|
89 |
} |
---|
90 |
|
---|
91 |
bool |
---|
92 |
AVCCommand::setNodeId( fb_nodeid_t nodeId ) |
---|
93 |
{ |
---|
94 |
m_nodeId = nodeId; |
---|
95 |
return true; |
---|
96 |
} |
---|
97 |
|
---|
98 |
bool |
---|
99 |
AVCCommand::setSubunitId(subunit_id_t subunitId) |
---|
100 |
{ |
---|
101 |
m_subunit = ( subunitId & 0x7 ) | ( m_subunit & 0xf8 ); |
---|
102 |
return true; |
---|
103 |
} |
---|
104 |
|
---|
105 |
AVCCommand::ESubunitType |
---|
106 |
AVCCommand::getSubunitType() |
---|
107 |
{ |
---|
108 |
return static_cast<ESubunitType>( ( m_subunit >> 3 ) ); |
---|
109 |
} |
---|
110 |
|
---|
111 |
subunit_id_t |
---|
112 |
AVCCommand::getSubunitId() |
---|
113 |
{ |
---|
114 |
return m_subunit & 0x7; |
---|
115 |
} |
---|
116 |
|
---|
117 |
bool |
---|
118 |
AVCCommand::setVerbose( bool enable ) |
---|
119 |
{ |
---|
120 |
m_verbose = enable; |
---|
121 |
return true; |
---|
122 |
} |
---|
123 |
|
---|
124 |
bool |
---|
125 |
AVCCommand::isVerbose() |
---|
126 |
{ |
---|
127 |
return m_verbose; |
---|
128 |
} |
---|
129 |
|
---|
130 |
|
---|
131 |
const char* subunitTypeStrings[] = |
---|
132 |
{ |
---|
133 |
"Monitor", |
---|
134 |
"Audio", |
---|
135 |
"Printer", |
---|
136 |
"Disc recorder", |
---|
137 |
"Tape recorder/VCR", |
---|
138 |
"Tuner", |
---|
139 |
"CA", |
---|
140 |
"Video camera", |
---|
141 |
"unknown", |
---|
142 |
"Panel", |
---|
143 |
"Bulletin board", |
---|
144 |
"Camera storage", |
---|
145 |
"Music", |
---|
146 |
}; |
---|
147 |
|
---|
148 |
const char* |
---|
149 |
subunitTypeToString( subunit_type_t subunitType ) |
---|
150 |
{ |
---|
151 |
if ( subunitType > sizeof( subunitTypeStrings ) ) { |
---|
152 |
return "unknown"; |
---|
153 |
} else { |
---|
154 |
return subunitTypeStrings[subunitType]; |
---|
155 |
} |
---|
156 |
} |
---|