root/branches/streaming-rework/src/bounce/bounce_avdevice.h

Revision 424, 4.0 kB (checked in by pieterpalmers, 17 years ago)

- The library can now be started in 'slave mode', creating a BounceSlaveDevice?.

On a discovering node, this slave device is discovered as a BounceDevice?.
Streaming does not work yet, something wrong with the timestamps.

- Implemented the 'snoop mode', that allows a client to 'snoop' the streams

between another host and a device. It is only implemented for BeBoB devices.
The channel numbers and stream configuration are automatically detected.
Note that it currently relies on a rather hackish support for reading the
{i,o}PCR plugs by using private functions of libiec61883

- changed jack backend to support these two new features

Line 
1 /* bounce_avdevice.h
2  * Copyright (C) 2006 by Pieter Palmers
3  * Copyright (C) 2006 by Daniel Wagner
4  *
5  * This file is part of FreeBoB.
6  *
7  * FreeBoB is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  * FreeBoB is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with FreeBoB; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
19  * MA 02111-1307 USA.
20  */
21 #ifndef BOUNCEDEVICE_H
22 #define BOUNCEDEVICE_H
23
24 #include "debugmodule/debugmodule.h"
25 #include "libavc/avc_definitions.h"
26 #include "libavc/avc_extended_cmd_generic.h"
27 #include "libfreebob/xmlparser.h"
28
29 #include "libstreaming/AmdtpStreamProcessor.h"
30 #include "libstreaming/AmdtpPort.h"
31 #include "libstreaming/AmdtpPortInfo.h"
32
33 #include "libieee1394/ARMHandler.h"
34
35 #include "iavdevice.h"
36 #include "libfreebob/freebob_bounce.h"
37
38 #include <vector>
39
40 #define BOUNCE_REGISTER_BASE 0x0000FFFFE0000000ULL
41 #define BOUNCE_REGISTER_LENGTH (4*256)
42 #define BOUNCE_REGISTER_TX_ISOCHANNEL 0x10
43 #define BOUNCE_REGISTER_RX_ISOCHANNEL 0x14
44 #define BOUNCE_INVALID_OFFSET 0xFFFFF00000000000ULL
45
46 class ConfigRom;
47 class Ieee1394Service;
48
49 namespace Bounce {
50
51 // struct to define the supported devices
52 struct VendorModelEntry {
53     uint32_t vendor_id;
54     uint32_t model_id;
55     uint32_t unit_specifier_id;
56     char *vendor_name;
57     char *model_name;
58 };
59
60 class BounceDevice : public IAvDevice {
61 private:
62     class BounceNotifier;
63 public:
64     BounceDevice( std::auto_ptr<ConfigRom>( configRom ),
65                   Ieee1394Service& ieee1394Service,
66                   int nodeId,
67                   int verboseLevel );
68     virtual ~BounceDevice();
69
70     static bool probe( ConfigRom& configRom );
71     bool discover();
72     ConfigRom& getConfigRom() const;
73    
74     bool addXmlDescription( xmlNodePtr deviceNode );
75    
76     bool setSamplingFrequency( ESamplingFrequency samplingFrequency );
77     int getSamplingFrequency( );
78    
79     bool prepare();
80     bool lock();
81     bool unlock();
82
83     int getStreamCount();
84
85     Streaming::StreamProcessor *getStreamProcessorByIndex(int i);
86
87     bool startStreamByIndex(int i);
88     bool stopStreamByIndex(int i);
89    
90     void showDevice() const;
91     bool setId(unsigned int id);
92
93 protected:
94     std::auto_ptr<ConfigRom>( m_configRom );
95     Ieee1394Service* m_p1394Service;
96     int              m_nodeId;
97     int              m_verboseLevel;
98
99         std::string xmlDescription;
100
101     unsigned int m_samplerate;
102     struct VendorModelEntry* m_model;
103
104     // streaming stuff
105     typedef std::vector< Streaming::StreamProcessor * > StreamProcessorVector;
106     StreamProcessorVector m_receiveProcessors;
107     StreamProcessorVector m_transmitProcessors;
108
109     bool addPortsToProcessor(
110        Streaming::StreamProcessor *processor,
111        Streaming::Port::E_Direction direction);
112
113     DECLARE_DEBUG_MODULE;
114    
115 private: // generic helpers
116     int allocateIsoChannel(unsigned int packet_size);
117     bool deallocateIsoChannel(int channel);
118
119 protected: // I/O helpers
120     // quadlet read/write routines
121     bool readReg(fb_nodeaddr_t, fb_quadlet_t *);
122     bool writeReg(fb_nodeaddr_t, fb_quadlet_t);
123     bool readRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t);
124     bool writeRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t);
125    
126 private:
127     BounceNotifier *m_Notifier;
128     /**
129      * this class reacts on the ohter side writing to the
130      * hosts address space
131      */
132     #define BOUNCE_NOTIFIER_BASE_ADDRESS 0x0000FFFFE0000000ULL
133     #define BOUNCE_NOTIFIER_BLOCK_LENGTH 4
134     class BounceNotifier : public ARMHandler
135     {
136     public:
137         BounceNotifier(BounceDevice *, nodeaddr_t start);
138         virtual ~BounceNotifier();
139        
140     private:
141         BounceDevice *m_bouncedevice;
142     };
143 };
144
145 }
146
147 #endif
Note: See TracBrowser for help on using the browser.