Changeset 74

Show
Ignore:
Timestamp:
03/07/05 14:40:49 (19 years ago)
Author:
wagi
Message:

Started with XML document generation. For debugging puposes 'x' option added
to command line argument parser.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/freebob/src/avdevice.cpp

    r60 r74  
    6464{ 
    6565    switch ( state ) { 
    66     case eScanAndCreate
     66    case eDeviceDiscovery
    6767        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 
    7270            // Put ourself to sleep until a something happends 
    7371            sleepCall( this, &AvDevice::execute, eCheckState ); 
    7472        } else { 
    75             asyncCall( CMHandler::instance(), 
    76                        &CMHandler::destroyConnection, 
    77                        this ); 
     73            debugError( "Device discovry failed\n" ); 
     74 
    7875            asyncCall( this, &AvDevice::execute, eDestroy ); 
    7976        } 
     
    499496    } 
    500497} 
     498 
     499FBReturnCodes 
     500AvDevice::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  
    2525#include "debugmodule.h" 
    2626 
     27#include <libxml/tree.h> 
     28 
    2729#include <vector> 
    2830using std::vector; 
     
    3436 public: 
    3537    enum EStates { 
    36         eScanAndCreate = 0, 
    37         eCheckState    = 1,  // put this instance to the sleep queue 
    38         eDestroy       = 2 
     38        eDeviceDiscovery = 0, 
     39        eCheckState      = 1,  // put this instance to the sleep queue 
     40        eDestroy         = 2 
    3941    }; 
    4042 
     
    7173    //  getSourcePlugConnection(); 
    7274    void printConnections(); 
     75    FBReturnCodes addConnectionsToXml( xmlNodePtr root ); 
    7376             
    7477    unsigned char getNbAsyncSourcePlugs()  
  • trunk/freebob/src/cmhandler.cpp

    r71 r74  
    2323#include "avdevice.h" 
    2424#include "ipchandler.h" 
     25#include "avdevicepool.h" 
     26 
     27#include <libxml/parser.h> 
     28#include <libxml/tree.h> 
    2529 
    2630CMHandler* CMHandler::m_pInstance = 0; 
     
    3943    if ( m_pIPCHandler ) { 
    4044        m_pIPCHandler->shutdown(); 
    41     }     
     45    } 
    4246    m_pInstance = 0; 
    4347} 
     
    5862            return eStatus; 
    5963        } 
    60          
     64 
    6165        m_pIPCHandler = IPCHandler::instance(); 
    6266        if ( !m_pIPCHandler ) { 
     
    6468            return eFBRC_InitializeCMHandlerFailed; 
    6569        } 
    66          
     70 
    6771        eStatus = m_pIPCHandler->initialize(); 
    6872        if ( eStatus != eFBRC_Success ) { 
    6973            debugError( "Initialising of IPC handler failed.\n" ); 
    7074            return eStatus; 
    71         }       
    72          
     75        } 
     76 
    7377        eStatus = m_pIPCHandler->start(); 
    7478        if ( eStatus != eFBRC_Success ) { 
    7579            debugError( "Start of IPC handler failed.\n" ); 
    7680            return eStatus; 
    77         }       
    78          
     81        } 
     82 
    7983        m_bInitialised = true; 
    8084    } 
     
    97101} 
    98102 
    99 FBReturnCodes 
    100 CMHandler::createConnection( AvDevice* avDevice ) 
     103 
     104char* 
     105CMHandler::getXmlConnectionInfo( octlet_t oGuid ) 
    101106{ 
    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; 
    109113    } 
    110114 
    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; 
    119119    } 
    120120 
    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 ); 
    122129 
    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; 
    135138    } 
    136139 
    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; 
    145146    } 
    146147 
     148    // Dump xml document to stdout 
     149    xmlSaveFormatFileEnc( "-", doc, "UTF-8", 1 ); 
    147150 
    148     debugPrint( DEBUG_LEVEL_INFO, "Connection established\n" ); 
    149     return eFBRC_Success; 
     151    // Cleanup 
     152    xmlFreeDoc( doc ); 
     153    xmlCleanupParser(); 
     154 
     155    return 0; 
    150156} 
    151  
    152 FBReturnCodes 
    153 CMHandler::destroyConnection( AvDevice* avDevice ) 
    154 { 
    155  
    156     return eFBRC_Success; 
    157 } 
  • trunk/freebob/src/cmhandler.h

    r71 r74  
    3636 
    3737    static CMHandler* instance(); 
    38     FBReturnCodes createConnection( AvDevice* avDevice ); 
    39     FBReturnCodes destroyConnection( AvDevice* avDevice ); 
    4038 
     39    char* getXmlConnectionInfo( octlet_t oGuid ); 
    4140private: 
    4241    CMHandler(); 
  • trunk/freebob/src/freebob.h

    r71 r74  
    3838  eFBRC_CreatingIPCServerFailed      =  -10, 
    3939  eFBRC_IPCServerInvalid             =  -11, 
     40  eFBRC_CreatingXMLDocFailed         =  -12, 
    4041} FBReturnCodes; 
    4142 
     
    4445{ 
    4546    char* args[1];           // LISTEN_TIME 
    46     int silent, verbose
     47    int silent, verbose, xml
    4748}; 
    4849 
  • trunk/freebob/src/ieee1394service.cpp

    r57 r74  
    176176 
    177177                asyncCall( pAvDevice, &AvDevice::execute, 
    178                            AvDevice::eScanAndCreate ); 
     178                           AvDevice::eDeviceDiscovery ); 
    179179 
    180180                // XXX Pieter's test code. 
  • trunk/freebob/src/main.cpp

    r53 r74  
    4242    {"quiet",    'q', 0,      0,  "Don't produce any output" }, 
    4343    {"silent",   's', 0,      OPTION_ALIAS }, 
     44    {"xml",      'x', 0,      0,  "XML document generation test"}, 
    4445    { 0 } 
    4546}; 
     
    5960    case 'v': 
    6061        arguments->verbose = 1; 
     62        break; 
     63    case 'x': 
     64        arguments->xml = 1; 
    6165        break; 
    6266    case ARGP_KEY_ARG: 
     
    9397    arguments.silent = 0; 
    9498    arguments.verbose = 0; 
     99    arguments.xml = 0; 
    95100 
    96101    // Parse our arguments; every option seen by `parse_opt' will 
     
    107112    setGlobalDebugLevel( DEBUG_LEVEL_ALL ); 
    108113 
     114    if ( arguments.xml ) { 
     115        CMHandler::instance()->getXmlConnectionInfo(0); 
     116        return 0; 
     117    } 
     118 
    109119    StreamProcess* pStreamProcess = new StreamProcess(); 
    110120    pStreamProcess->run( timeToListen ); 
  • trunk/freebob/src/Makefile.am

    r71 r74  
    1818 
    1919INCLUDES = \ 
    20         $(LIBSIGC_CFLAGS) $(LIBRAW1394_CFLAGS) $(LIBIEC61883_CFLAGS) $(LIBAVC_CFLAGS) $(LIBLO_CFLAGS)  
     20        $(LIBSIGC_CFLAGS) $(LIBRAW1394_CFLAGS) $(LIBIEC61883_CFLAGS) $(LIBAVC_CFLAGS) $(LIBLO_CFLAGS) $(LIBXML_CFLAGS) 
    2121 
    2222bin_PROGRAMS = freebob 
     
    7979 
    8080freebob_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)