root/trunk/libffado/src/libavc/general/avc_vendor_dependent_cmd.cpp

Revision 618, 2.0 kB (checked in by ppalmers, 17 years ago)

move serialization routines to libutil such that they can be used for non-AVC stuff too (fireworks EFC)

Line 
1 /*
2  * Copyright (C) 2005-2007 by Pieter Palmers
3  *
4  * This file is part of FFADO
5  * FFADO = Free Firewire (pro-)audio drivers for linux
6  *
7  * FFADO is based upon FreeBoB
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License version 2.1, as published by the Free Software Foundation;
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21  * MA 02110-1301 USA
22  */
23
24 #include "avc_vendor_dependent_cmd.h"
25 #include "libutil/cmd_serialize.h"
26 #include "libieee1394/ieee1394service.h"
27
28 #include <netinet/in.h>
29 #include <iostream>
30
31 using namespace std;
32
33 #define AVC1394_CMD_VENDOR_DEPENDENT 0x00
34
35 namespace AVC {
36
37 VendorDependentCmd::VendorDependentCmd(Ieee1394Service& ieee1394service)
38     : AVCCommand( ieee1394service, AVC1394_CMD_VENDOR_DEPENDENT )
39 {
40 }
41
42 VendorDependentCmd::~VendorDependentCmd()
43 {
44 }
45
46 bool
47 VendorDependentCmd::serialize( Util::IOSSerialize& se )
48 {
49     bool result=true;
50     result &= AVCCommand::serialize( se );
51     byte_t tmp;
52     tmp=(m_companyId >> 16) & 0xFF;
53     result &= se.write(tmp,"VendorDependentCmd companyid[2]");
54     tmp=(m_companyId >> 8) & 0xFF;
55     result &= se.write(tmp,"VendorDependentCmd companyid[1]");
56     tmp=(m_companyId) & 0xFF;
57     result &= se.write(tmp,"VendorDependentCmd companyid[0]");
58     return result;
59 }
60
61 bool
62 VendorDependentCmd::deserialize( Util::IISDeserialize& de )
63 {
64     bool result=true;
65     result &= AVCCommand::deserialize( de );
66    
67     byte_t tmp[3];
68     result &= de.read(&tmp[2]);
69     result &= de.read(&tmp[1]);
70     result &= de.read(&tmp[0]);
71    
72     m_companyId = (tmp[2] << 16) | (tmp[1]<<8) | tmp[0];
73    
74     return result;
75 }
76
77 }
Note: See TracBrowser for help on using the browser.