Changeset 74
- Timestamp:
- 03/07/05 14:40:49 (19 years ago)
- Files:
-
- trunk/freebob/src/avdevice.cpp (modified) (2 diffs)
- trunk/freebob/src/avdevice.h (modified) (3 diffs)
- trunk/freebob/src/cmhandler.cpp (modified) (5 diffs)
- trunk/freebob/src/cmhandler.h (modified) (1 diff)
- trunk/freebob/src/freebob.h (modified) (2 diffs)
- trunk/freebob/src/ieee1394service.cpp (modified) (1 diff)
- trunk/freebob/src/main.cpp (modified) (4 diffs)
- trunk/freebob/src/Makefile.am (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/freebob/src/avdevice.cpp
r60 r74 64 64 { 65 65 switch ( state ) { 66 case e ScanAndCreate:66 case eDeviceDiscovery: 67 67 if ( initialize() == eFBRC_Success ) { 68 // Initiate connection 69 asyncCall( CMHandler::instance(), 70 &CMHandler::createConnection, 71 this ); 68 debugPrint( DEBUG_LEVEL_INFO, "Device discovery successful\n" ); 69 72 70 // Put ourself to sleep until a something happends 73 71 sleepCall( this, &AvDevice::execute, eCheckState ); 74 72 } else { 75 asyncCall( CMHandler::instance(), 76 &CMHandler::destroyConnection, 77 this ); 73 debugError( "Device discovry failed\n" ); 74 78 75 asyncCall( this, &AvDevice::execute, eDestroy ); 79 76 } … … 499 496 } 500 497 } 498 499 FBReturnCodes 500 AvDevice::addConnectionsToXml( xmlNodePtr root ) 501 { 502 for ( unsigned int i = 0; 503 i < getNbIsoSourcePlugs(); 504 ++i ) 505 { 506 507 } 508 509 xmlNodePtr node = xmlNewChild( root, 0, BAD_CAST "ConnectionSet", 0 ); 510 if ( !node ) { 511 debugError( "Couldn't create connection set node\n" ); 512 return eFBRC_CreatingXMLDocFailed; 513 } 514 515 return eFBRC_Success; 516 } trunk/freebob/src/avdevice.h
r60 r74 25 25 #include "debugmodule.h" 26 26 27 #include <libxml/tree.h> 28 27 29 #include <vector> 28 30 using std::vector; … … 34 36 public: 35 37 enum EStates { 36 e ScanAndCreate= 0,37 eCheckState = 1, // put this instance to the sleep queue38 eDestroy = 238 eDeviceDiscovery = 0, 39 eCheckState = 1, // put this instance to the sleep queue 40 eDestroy = 2 39 41 }; 40 42 … … 71 73 // getSourcePlugConnection(); 72 74 void printConnections(); 75 FBReturnCodes addConnectionsToXml( xmlNodePtr root ); 73 76 74 77 unsigned char getNbAsyncSourcePlugs() trunk/freebob/src/cmhandler.cpp
r71 r74 23 23 #include "avdevice.h" 24 24 #include "ipchandler.h" 25 #include "avdevicepool.h" 26 27 #include <libxml/parser.h> 28 #include <libxml/tree.h> 25 29 26 30 CMHandler* CMHandler::m_pInstance = 0; … … 39 43 if ( m_pIPCHandler ) { 40 44 m_pIPCHandler->shutdown(); 41 } 45 } 42 46 m_pInstance = 0; 43 47 } … … 58 62 return eStatus; 59 63 } 60 64 61 65 m_pIPCHandler = IPCHandler::instance(); 62 66 if ( !m_pIPCHandler ) { … … 64 68 return eFBRC_InitializeCMHandlerFailed; 65 69 } 66 70 67 71 eStatus = m_pIPCHandler->initialize(); 68 72 if ( eStatus != eFBRC_Success ) { 69 73 debugError( "Initialising of IPC handler failed.\n" ); 70 74 return eStatus; 71 } 72 75 } 76 73 77 eStatus = m_pIPCHandler->start(); 74 78 if ( eStatus != eFBRC_Success ) { 75 79 debugError( "Start of IPC handler failed.\n" ); 76 80 return eStatus; 77 } 78 81 } 82 79 83 m_bInitialised = true; 80 84 } … … 97 101 } 98 102 99 FBReturnCodes 100 CMHandler::createConnection( AvDevice* avDevice ) 103 104 char* 105 CMHandler::getXmlConnectionInfo( octlet_t oGuid ) 101 106 { 102 103 // First start with the play direction. 104 unsigned int iNoOfIPCR = avDevice->getNbIsoDestinationPlugs(); 105 106 if ( iNoOfIPCR == 0 ) { 107 debugError( "No iPCR found\n" ); 108 return eFBRC_NoOfIPCRNotCorrect; 107 AvDevice* pAvDevice = AvDevicePool::instance()->getAvDevice( oGuid ); 108 if ( !pAvDevice ) { 109 debugError( "No AV device found with given GUID 0x%08x%08x\n", 110 (quadlet_t) (oGuid>>32), 111 (quadlet_t) (oGuid & 0xffffffff) ); 112 return 0; 109 113 } 110 114 111 // BeBob devices have two iPCR 112 // iPCR 0: IsoStream/AudioInput 113 // iPCR 1: Synch/SynchInput 114 115 if ( iNoOfIPCR != 2 ) { 116 debugError( "Not correct number iPCR founds on target. " 117 "Expected 2, found %d\n", iNoOfIPCR ); 118 return eFBRC_NoOfIPCRNotCorrect; 115 xmlDocPtr doc = xmlNewDoc( BAD_CAST "1.0" ); 116 if ( !doc ) { 117 debugError( "Couldn't create new xml doc\n" ); 118 return 0; 119 119 } 120 120 121 // Create external connection 121 xmlNodePtr rootNode = xmlNewNode( 0, BAD_CAST "FreeBobConnectionInfo" ); 122 if ( !rootNode ) { 123 debugError( "Couldn't create root node\n" ); 124 xmlFreeDoc( doc ); 125 xmlCleanupParser(); 126 return 0; 127 } 128 xmlDocSetRootElement( doc, rootNode ); 122 129 123 124 125 // Internal connection are not configureable on BeBob device... gladly 126 127 128 129 // Second configure record direction. 130 unsigned int iNoOfOPCR = avDevice->getNbIsoSourcePlugs(); 131 132 if ( iNoOfOPCR == 0 ) { 133 debugError( "No oPCR found\n" ); 134 return eFBRC_NoOfOPCRNotCorrect; 130 if ( !xmlNewChild( rootNode, 131 0, 132 BAD_CAST "Comment", 133 BAD_CAST "Connection Information for XXX configuration" ) ) { 134 debugError( "Couldn't create comment node\n" ); 135 xmlFreeDoc( doc ); 136 xmlCleanupParser(); 137 return 0; 135 138 } 136 139 137 // BeBob devices have two iPCR 138 // oPCR 0: IsoStream/Output 139 // oPCR 1: Synch/SynchOut 140 141 if ( iNoOfOPCR != 2 ) { 142 debugError( "Not correct number oPCR founds on target. " 143 "Expected 2, found %d\n", iNoOfOPCR ); 144 return eFBRC_NoOfOPCRNotCorrect; 140 FBReturnCodes eStatus = pAvDevice->addConnectionsToXml( rootNode ); 141 if ( eStatus != eFBRC_Success ) { 142 debugError( "Could not add connection information to XML document\n" ); 143 xmlFreeDoc( doc ); 144 xmlCleanupParser(); 145 return 0; 145 146 } 146 147 148 // Dump xml document to stdout 149 xmlSaveFormatFileEnc( "-", doc, "UTF-8", 1 ); 147 150 148 debugPrint( DEBUG_LEVEL_INFO, "Connection established\n" ); 149 return eFBRC_Success; 151 // Cleanup 152 xmlFreeDoc( doc ); 153 xmlCleanupParser(); 154 155 return 0; 150 156 } 151 152 FBReturnCodes153 CMHandler::destroyConnection( AvDevice* avDevice )154 {155 156 return eFBRC_Success;157 }trunk/freebob/src/cmhandler.h
r71 r74 36 36 37 37 static CMHandler* instance(); 38 FBReturnCodes createConnection( AvDevice* avDevice );39 FBReturnCodes destroyConnection( AvDevice* avDevice );40 38 39 char* getXmlConnectionInfo( octlet_t oGuid ); 41 40 private: 42 41 CMHandler(); trunk/freebob/src/freebob.h
r71 r74 38 38 eFBRC_CreatingIPCServerFailed = -10, 39 39 eFBRC_IPCServerInvalid = -11, 40 eFBRC_CreatingXMLDocFailed = -12, 40 41 } FBReturnCodes; 41 42 … … 44 45 { 45 46 char* args[1]; // LISTEN_TIME 46 int silent, verbose ;47 int silent, verbose, xml; 47 48 }; 48 49 trunk/freebob/src/ieee1394service.cpp
r57 r74 176 176 177 177 asyncCall( pAvDevice, &AvDevice::execute, 178 AvDevice::e ScanAndCreate);178 AvDevice::eDeviceDiscovery ); 179 179 180 180 // XXX Pieter's test code. trunk/freebob/src/main.cpp
r53 r74 42 42 {"quiet", 'q', 0, 0, "Don't produce any output" }, 43 43 {"silent", 's', 0, OPTION_ALIAS }, 44 {"xml", 'x', 0, 0, "XML document generation test"}, 44 45 { 0 } 45 46 }; … … 59 60 case 'v': 60 61 arguments->verbose = 1; 62 break; 63 case 'x': 64 arguments->xml = 1; 61 65 break; 62 66 case ARGP_KEY_ARG: … … 93 97 arguments.silent = 0; 94 98 arguments.verbose = 0; 99 arguments.xml = 0; 95 100 96 101 // Parse our arguments; every option seen by `parse_opt' will … … 107 112 setGlobalDebugLevel( DEBUG_LEVEL_ALL ); 108 113 114 if ( arguments.xml ) { 115 CMHandler::instance()->getXmlConnectionInfo(0); 116 return 0; 117 } 118 109 119 StreamProcess* pStreamProcess = new StreamProcess(); 110 120 pStreamProcess->run( timeToListen ); trunk/freebob/src/Makefile.am
r71 r74 18 18 19 19 INCLUDES = \ 20 $(LIBSIGC_CFLAGS) $(LIBRAW1394_CFLAGS) $(LIBIEC61883_CFLAGS) $(LIBAVC_CFLAGS) $(LIBLO_CFLAGS) 20 $(LIBSIGC_CFLAGS) $(LIBRAW1394_CFLAGS) $(LIBIEC61883_CFLAGS) $(LIBAVC_CFLAGS) $(LIBLO_CFLAGS) $(LIBXML_CFLAGS) 21 21 22 22 bin_PROGRAMS = freebob … … 79 79 80 80 freebob_LDFLAGS = \ 81 $(LIBSIGC_LIBS) $(LIBRAW1394_LIBS) $(LIBIEC61883_LIBS) $(LIBAVC_LIBS) $(LIBLO_LIBS) 81 $(LIBSIGC_LIBS) $(LIBRAW1394_LIBS) $(LIBIEC61883_LIBS) $(LIBAVC_LIBS) $(LIBLO_LIBS) $(LIBXML_LIBS)