Changeset 86
- Timestamp:
- 04/02/05 04:13:31 (19 years ago)
- Files:
-
- trunk/freebob/src/avdevice.cpp (modified) (4 diffs)
- trunk/freebob/src/avdevice.h (modified) (3 diffs)
- trunk/freebob/src/ipchandler.cpp (modified) (5 diffs)
- trunk/freebob/src/ipchandler.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/freebob/src/avdevice.cpp
r85 r86 619 619 } 620 620 621 std::string AvDevice::getPlugChannelName(unsigned int direction, unsigned int plug, unsigned int channel) { 622 quadlet_t request[6]; 623 quadlet_t *response; 624 std::string str; 625 626 request[0] = AVC1394_CTYPE_STATUS 627 | AVC1394_SUBUNIT_TYPE_UNIT 628 | AVC1394_SUBUNIT_ID_IGNORE 629 | AVC1394_COMMAND_PLUG_INFO 630 | 0xC0; 631 632 request[1]=0x00000000 | ((direction &0xFF)<<24) | (plug & 0xFF); 633 request[2]=0xFF040000 | ((channel & 0xFF) << 8); 634 635 response = Ieee1394Service::instance()->avcExecuteTransaction(m_iNodeId, request, 3, 3); 636 637 if ( response ) { 638 unsigned namelen=response[3]&0xFF; 639 char *buff=NULL; 640 641 buff=new char[namelen+1]; 642 if (!buff) { 643 debugError( "Could not allocate memory for temporary name buffer\n" ); 644 return str; 645 } 646 647 if(!strncpy(buff, (const char *)(response+3), namelen)) { 648 buff[0]=0; 649 debugError( "Could not copy name\n" ); 650 str=""; 651 } else { 652 buff[namelen]=0; 653 str=buff; 654 } 655 delete buff; 656 } 657 658 return str; 659 } 660 661 621 662 #define FREEBOB_DIRTY_XML_CHILD_ADD(XparentX,XnodeX,XvalueX) if ( !xmlNewChild( XparentX, 0, BAD_CAST XnodeX, BAD_CAST XvalueX ) ) { debugError( "Couldn't create " XnodeX "node\n" ); return eFBRC_CreatingXMLDocFailed; } 622 663 … … 625 666 { 626 667 char tmpbuff[256]; 668 std::string name; 627 669 628 670 // At this point only plug 0 is used by the firmware for audio i/o … … 732 774 FREEBOB_DIRTY_XML_CHILD_ADD(stream, "DestinationPort",tmpbuff); 733 775 734 sprintf(tmpbuff,"playback_%d_%d",i,j); 735 FREEBOB_DIRTY_XML_CHILD_ADD(stream, "Name",tmpbuff); 776 name=getInputPlugChannelName(plug, clusterInfo->getPosition(j)+1); 777 xmlChar *enc_name=xmlEncodeEntitiesReentrant(root->doc, BAD_CAST name.c_str()); 778 FREEBOB_DIRTY_XML_CHILD_ADD(stream, "Name",enc_name); 779 xmlFree(enc_name); 736 780 } 737 781 } … … 819 863 FREEBOB_DIRTY_XML_CHILD_ADD(stream, "DestinationPort",tmpbuff); 820 864 821 sprintf(tmpbuff,"playback_%d_%d",i,j); 822 FREEBOB_DIRTY_XML_CHILD_ADD(stream, "Name",tmpbuff); 865 name=getOutputPlugChannelName(plug, clusterInfo->getPosition(j)+1); 866 867 xmlChar *enc_name=xmlEncodeEntitiesReentrant(root->doc, BAD_CAST name.c_str()); 868 FREEBOB_DIRTY_XML_CHILD_ADD(stream, "Name",enc_name); 869 xmlFree(enc_name); 823 870 } 824 871 } trunk/freebob/src/avdevice.h
r85 r86 61 61 { return m_configRom.getModelName(); } 62 62 63 64 63 std::string getInputPlugChannelName(unsigned int plug, unsigned int channel) 64 { return getPlugChannelName(0x00,plug,channel); } 65 std::string getOutputPlugChannelName(unsigned int plug, unsigned int channel) 66 { return getPlugChannelName(0x01,plug,channel); } 67 65 68 void execute( EStates state ); 66 69 … … 85 88 void test(); 86 89 FBReturnCodes addConnectionsToXml( xmlNodePtr root ); 87 90 88 91 unsigned char getNbAsyncSourcePlugs() 89 92 { return m_iNbAsyncSourcePlugs; } … … 99 102 { return m_iNbExtDestinationPlugs; } 100 103 101 protected: 104 105 protected: 102 106 AvDeviceSubunit *getSubunit(unsigned char type, unsigned char id); 103 107 104 108 FBReturnCodes create1394RawHandle(); 105 109 FBReturnCodes enumerateSubUnits(); 106 110 111 std::string getPlugChannelName(unsigned int direction, unsigned int plug, unsigned int channel); 112 107 113 private: 108 114 ConfigRom m_configRom; trunk/freebob/src/ipchandler.cpp
r80 r86 28 28 #include <fcntl.h> 29 29 #include <stdlib.h> 30 #include <libavc1394/avc1394.h> 31 #include <libavc1394/avc1394_vcr.h> 30 32 31 33 #include "debugmodule.h" … … 34 36 #include "avdevicepool.h" 35 37 #include "cmhandler.h" 38 #include "ieee1394service.h" 36 39 37 40 IPCHandler* IPCHandler::m_pInstance = 0; … … 62 65 63 66 return handler->requestHandler(path, types,argv, argc, msg); 67 } 68 69 int request_handler_debug(const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data) { 70 IPCHandler *handler=(IPCHandler *)user_data; 71 72 if (!user_data) { 73 printf("user_data not valid\n"); 74 return -1; 75 } 76 77 return handler->requestHandlerDebug(path, types,argv, argc, msg); 64 78 } 65 79 … … 102 116 103 117 lo_server_thread_add_method(m_serverThread, "/freebob/request", "s", request_handler, (void *)this); 118 lo_server_thread_add_method(m_serverThread, "/freebob/debug", "s", request_handler_debug, (void *)this); 119 lo_server_thread_add_method(m_serverThread, "/freebob/debug", "sii", request_handler_debug, (void *)this); 120 lo_server_thread_add_method(m_serverThread, "/freebob/debug", "si", request_handler_debug, (void *)this); 104 121 105 122 return eFBRC_Success; … … 197 214 return 0; 198 215 } 216 217 int 218 IPCHandler::requestHandlerDebug(const char *path, 219 const char *types, 220 lo_arg **argv, 221 int argc, 222 lo_message msg) 223 { 224 lo_address src=lo_message_get_source ( msg ); 225 226 debugPrint(DEBUG_LEVEL_IPC,"request from %s port %s (%s)\n", lo_address_get_hostname(src), lo_address_get_port(src), lo_address_get_url ( src ) ); 227 debugPrint(DEBUG_LEVEL_IPC,"to path: <%s>\n", path); 228 229 if(argc >= 1) { 230 if(strcasecmp(&argv[0]->s,"AvDevice.test")==0) { 231 if ( AvDevicePool::instance()->m_avDevices.size() ) { 232 AvDevice* pAvDevice 233 = AvDevicePool::instance()->m_avDevices.front(); 234 235 if ( pAvDevice ) { 236 pAvDevice->test(); 237 } 238 } 239 } else if((strcasecmp(&argv[0]->s,"setDebugLevel")==0) && argc==2) { 240 241 setDebugLevel(argv[1]->i); 242 243 } else if((strcasecmp(&argv[0]->s,"plugInfo")==0) && argc==3) { 244 quadlet_t request[6]; 245 quadlet_t *response; 246 247 if ( AvDevicePool::instance()->m_avDevices.size() ) { 248 AvDevice* pAvDevice 249 = AvDevicePool::instance()->m_avDevices.front(); 250 251 if ( pAvDevice ) { 252 request[0] = AVC1394_CTYPE_STATUS 253 | AVC1394_SUBUNIT_TYPE_UNIT 254 | AVC1394_SUBUNIT_ID_IGNORE 255 | AVC1394_COMMAND_PLUG_INFO 256 | 0xC0; 257 request[1]=argv[1]->i; 258 request[2]=argv[2]->i; 259 260 response = Ieee1394Service::instance()->avcExecuteTransaction(pAvDevice->getNodeId(), request, 3, 20); 261 262 if ( response ) { 263 hexDump( (unsigned char *)response, 20 *sizeof(quadlet_t)); 264 265 } 266 } 267 } 268 269 270 } 271 272 } 273 return 0; 274 } trunk/freebob/src/ipchandler.h
r71 r86 43 43 int genericHandler(const char *path, const char *types, lo_arg **argv, int argc, lo_message msg); 44 44 int requestHandler(const char *path, const char *types, lo_arg **argv, int argc, lo_message msg); 45 int requestHandlerDebug(const char *path, const char *types, lo_arg **argv, int argc, lo_message msg); 45 46 46 47 private: