root/branches/streaming-rework/src/libavc/avc_generic.h

Revision 439, 4.3 kB (checked in by pieterpalmers, 16 years ago)

- some work on the AVC mixer & control stuff

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /* avc_generic.h
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 #ifndef AVCGeneric_h
22 #define AVCGeneric_h
23
24 #include "avc_definitions.h"
25 #include "debugmodule/debugmodule.h"
26
27 #include "../fbtypes.h"
28
29 #include <libavc1394/avc1394.h>
30
31 class IOSSerialize;
32 class IISDeserialize;
33 class Ieee1394Service;
34
35 const int fcpFrameMaxLength = 512;
36 typedef unsigned char fcp_frame_t[fcpFrameMaxLength];
37
38 class IBusData {
39 public:
40     IBusData() {}
41     virtual ~IBusData() {}
42
43     virtual bool serialize( IOSSerialize& se ) = 0;
44     virtual bool deserialize( IISDeserialize& de ) = 0;
45
46     virtual IBusData* clone() const = 0;
47    
48 protected:
49     DECLARE_DEBUG_MODULE;
50 };
51
52 class AVCCommand
53 {
54 public:
55     enum EResponse {
56         eR_Unknown        = 0,
57         eR_NotImplemented = AVC1394_RESP_NOT_IMPLEMENTED,
58         eR_Accepted       = AVC1394_RESP_ACCEPTED,
59         eR_Rejected       = AVC1394_RESP_REJECTED,
60         eR_InTransition   = AVC1394_RESP_IN_TRANSITION,
61         eR_Implemented    = AVC1394_RESP_IMPLEMENTED,
62         eR_Changed        = AVC1394_RESP_CHANGED,
63         eR_Interim        = AVC1394_RESP_INTERIM,
64     };
65
66     enum ECommandType {
67         eCT_Control         = AVC1394_CTYP_CONTROL,
68         eCT_Status          = AVC1394_CTYP_STATUS,
69         eCT_SpecificInquiry = AVC1394_CTYP_SPECIFIC_INQUIRY,
70         eCT_Notify          = AVC1394_CTYP_NOTIFY,
71         eCT_GeneralInquiry  = AVC1394_CTYP_GENERAL_INQUIRY,
72         eCT_Unknown         = 0xff,
73     };
74
75     enum ESubunitType {
76         eST_Monitor       = AVC1394_SUBUNIT_VIDEO_MONITOR,
77         eST_Audio         = AVC1394_SUBUNIT_AUDIO,
78         eST_Printer       = AVC1394_SUBUNIT_PRINTER,
79         eST_Disc          = AVC1394_SUBUNIT_DISC_RECORDER,
80         eST_VCR           = AVC1394_SUBUNIT_VCR,
81         eST_Tuner         = AVC1394_SUBUNIT_TUNER,
82         eST_CA            = AVC1394_SUBUNIT_CA,
83         eST_Camera        = AVC1394_SUBUNIT_VIDEO_CAMERA,
84         eST_Panel         = AVC1394_SUBUNIT_PANEL,
85         eST_BulltinBoard  = AVC1394_SUBUNIT_BULLETIN_BOARD,
86         eST_CameraStorage = AVC1394_SUBUNIT_CAMERA_STORAGE,
87         eST_Music         = AVC1394_SUBUNIT_MUSIC,
88         eST_VendorUnique  = AVC1394_SUBUNIT_VENDOR_UNIQUE,
89         eST_Reserved      = AVC1394_SUBUNIT_RESERVED,
90         eST_Extended      = AVC1394_SUBUNIT_EXTENDED,
91         eST_Unit          = AVC1394_SUBUNIT_UNIT,
92     };
93
94     virtual bool serialize( IOSSerialize& se );
95     virtual bool deserialize( IISDeserialize& de );
96
97     virtual bool setCommandType( ECommandType commandType );
98     virtual bool fire();
99
100     EResponse getResponse();
101
102     bool setNodeId( fb_nodeid_t nodeId );
103     bool setSubunitType( ESubunitType subunitType );
104     bool setSubunitId( subunit_id_t subunitId );
105
106     ESubunitType getSubunitType();
107     subunit_id_t getSubunitId();
108
109     bool setVerbose( int verboseLevel );
110     int getVerboseLevel();
111    
112     virtual const char* getCmdName() const = 0;
113
114     // workaround
115     static void setSleepAfterAVCCommand( int time );
116 protected:
117     void showFcpFrame( const unsigned char* buf,
118                        unsigned short frameSize ) const;
119
120 protected:
121     AVCCommand( Ieee1394Service& ieee1394service, opcode_t opcode );
122     virtual ~AVCCommand() {}
123
124     ECommandType getCommandType();
125
126     Ieee1394Service* m_p1394Service;
127     fb_nodeid_t      m_nodeId;
128
129     fcp_frame_t      m_fcpFrame;
130
131 private:
132     ctype_t      m_ctype;
133     subunit_t    m_subunit;
134     opcode_t     m_opcode;
135     EResponse    m_eResponse;
136     ECommandType m_commandType;
137     static int   m_time;
138    
139     DECLARE_DEBUG_MODULE;
140 };
141
142
143 const char* subunitTypeToString( subunit_type_t subunitType );
144 const char* responseToString( AVCCommand::EResponse eResponse );
145
146 #endif // AVCGeneric_h
Note: See TracBrowser for help on using the browser.