Changeset 15

Show
Ignore:
Timestamp:
10/01/04 15:09:00 (18 years ago)
Author:
wagi
Message:

Removed sigc++ code, using instead boost library.
Print information on screen when doing bus scan.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/freebob/configure.ac

    r14 r15  
    2323AM_INIT_AUTOMAKE 
    2424AM_MAINTAINER_MODE 
    25 AC_CONFIG_SRCDIR([src/freebob.cpp]) 
     25AC_CONFIG_SRCDIR([src/main.cpp]) 
    2626AC_CONFIG_HEADER([config.h]) 
    2727AC_GNU_SOURCE 
     28AC_LANG(C++) 
    2829 
    2930maintainer_mode=${enable_maintainer_mode-no} 
     
    8586 
    8687# Checks for library functions. 
    87 PKG_CHECK_MODULES(LIBSIGC, sigc++-2.0 >= 2.0.3) 
    8888PKG_CHECK_MODULES(LIBRAW1394, libraw1394 >= 0.10) 
    8989PKG_CHECK_MODULES(LIBIEC61883, libiec61883 >= 0.1.0) 
     90AC_CHECK_HEADER(boost/signals.hpp, , [ 
     91        AC_MSG_ERROR([cannot find boost headers. Make sure boost (http://www.boost.org) is installed; if the headers are in a non-standard location, set the CPPFLAGS environment variable to contain -I<headerdir>])]) 
     92AC_HAVE_LIBRARY(boost_signals, , [ 
     93        AC_MSG_ERROR([cannot find boost libraries. Make sure boost (http://www.boost.org) is installed; if the libraries are in a non-standard location, set the LDFLAGS environment variable to contain -L<librarydir>])]) 
     94 
    9095 
    9196AC_SUBST([LIBSIGC_CFLAGS]) 
     
    109114  Source directory:     $srcdir 
    110115  Installation prefix:  $prefix 
    111   C compiler:           $CC $XTRA_CFLAGS $WARN_CFLAGS $CFLAGS 
    112116  C++ compiler:         $CXX $XTRA_CXXFLAGS $WARN_CXXFLAGS $CXXFLAGS 
    113117]) 
  • trunk/freebob/src/cmhandler.cpp

    r14 r15  
    3232CMHandler::~CMHandler() 
    3333{ 
     34    if ( m_pIeee1394Service ) { 
     35        m_pIeee1394Service->shutdown(); 
     36    } 
     37    m_pInstance = 0; 
    3438} 
    3539 
     
    5458} 
    5559 
     60void 
     61CMHandler::shutdown() 
     62{ 
     63    delete this; 
     64} 
     65 
    5666CMHandler* 
    5767CMHandler::instance() 
  • trunk/freebob/src/cmhandler.h

    r14 r15  
    3333 
    3434    FBReturnCodes initialize(); 
     35    void shutdown(); 
    3536 
    3637    static CMHandler* instance(); 
  • trunk/freebob/src/ieee1394service.cpp

    r14 r15  
    2020 
    2121#include <errno.h> 
     22#include <libavc1394/avc1394.h> 
     23#include <libavc1394/avc1394_vcr.h> 
    2224#include "ieee1394service.h" 
    2325#include "debugmodule.h" 
     
    3638{ 
    3739    stopRHThread(); 
    38     if ( !m_handle ) { 
     40 
     41    if ( m_rhHandle ) { 
     42        raw1394_destroy_handle( m_rhHandle ); 
     43        m_rhHandle = 0; 
     44    } 
     45 
     46    if ( m_handle ) { 
    3947        raw1394_destroy_handle( m_handle ); 
    4048        m_handle = 0; 
    4149    } 
     50 
     51    m_pInstance = 0; 
    4252} 
    4353 
     
    4656{ 
    4757    if ( !m_bInitialised ) { 
     58        m_rhHandle = raw1394_new_handle(); 
    4859        m_handle = raw1394_new_handle(); 
    49         if ( !m_handle ) { 
     60        if ( !m_rhHandle || !m_handle ) { 
    5061            if ( !errno ) { 
    5162                fprintf( stderr,  "libraw1394 not compatible.\n" ); 
     
    6071        // to be able to retrieve the instance in the pure C bus reset 
    6172        // call back function. 
    62         raw1394_set_userdata( m_handle,  this ); 
     73        raw1394_set_userdata( m_rhHandle,  this ); 
     74 
     75        if ( raw1394_set_port( m_rhHandle,  m_iPort ) < 0 ) { 
     76            perror( "Could not set port" ); 
     77            return eFBRC_Setting1394PortFailed; 
     78        } 
    6379 
    6480        if ( raw1394_set_port( m_handle,  m_iPort ) < 0 ) { 
     
    6783        } 
    6884 
    69         raw1394_set_bus_reset_handler( m_handle,  this->resetHandler ); 
     85        raw1394_set_bus_reset_handler( m_rhHandle,  this->resetHandler ); 
    7086 
    7187        startRHThread(); 
     
    7793} 
    7894 
     95void 
     96Ieee1394Service::shutdown() 
     97{ 
     98    delete this; 
     99} 
     100 
    79101Ieee1394Service* 
    80102Ieee1394Service::instance() 
     
    89111Ieee1394Service::discoveryDevices() 
    90112{ 
     113    //scan bus 
     114    int iNodeCount = raw1394_get_nodecount( m_handle ); 
     115    for ( int iNodeId = 0; iNodeId < iNodeCount; ++iNodeId ) { 
     116        rom1394_directory romDir; 
     117        rom1394_get_directory( m_handle, iNodeId, &romDir ); 
     118        printRomDirectory( iNodeId, &romDir ); 
     119 
     120        switch (rom1394_get_node_type( &romDir )) { 
     121        case ROM1394_NODE_TYPE_UNKNOWN: 
     122            debugPrint (DEBUG_LEVEL_INFO, 
     123                        "Node %d has node type UNKNOWN\n", iNodeId); 
     124            break; 
     125        case ROM1394_NODE_TYPE_DC: 
     126            debugPrint (DEBUG_LEVEL_INFO, 
     127                        "Node %d has node type DC\n", iNodeId); 
     128            break; 
     129        case ROM1394_NODE_TYPE_AVC: 
     130            debugPrint (DEBUG_LEVEL_INFO, 
     131                        "Node %d has node type AVC\n", iNodeId); 
     132            printAvcUnitInfo( iNodeId ); 
     133 
     134            if ( avc1394_check_subunit_type( m_handle, iNodeId, 
     135                                             AVC1394_SUBUNIT_TYPE_AUDIO ) ) { 
     136                // XXX 
     137                // create avcDevice which discovers itself :) 
     138            } 
     139            break; 
     140        case ROM1394_NODE_TYPE_SBP2: 
     141            debugPrint( DEBUG_LEVEL_INFO, 
     142                        "Node %d has node type SBP2\n", iNodeId); 
     143            break; 
     144        case ROM1394_NODE_TYPE_CPU: 
     145            debugPrint( DEBUG_LEVEL_INFO, 
     146                        "Node %d has node type CPU\n", iNodeId); 
     147            break; 
     148        default: 
     149            debugPrint( DEBUG_LEVEL_INFO, 
     150                        "No matching node type found for node %d\n", iNodeId); 
     151        } 
     152    } 
    91153    return eFBRC_Success; 
     154} 
     155 
     156void 
     157Ieee1394Service::printAvcUnitInfo( int iNodeId ) 
     158{ 
     159    printf( "AVC: video monitor?......%s\n", 
     160            avc1394_check_subunit_type( m_handle, iNodeId, 
     161                                        AVC1394_SUBUNIT_TYPE_VIDEO_MONITOR ) ? 
     162            "yes":"no" ); 
     163    printf( "AVC: audio?..............%s\n", 
     164            avc1394_check_subunit_type( m_handle, iNodeId, 
     165                                        AVC1394_SUBUNIT_TYPE_AUDIO ) ? 
     166            "yes":"no" ); 
     167    printf( "AVC; printer?............%s\n", 
     168            avc1394_check_subunit_type( m_handle, iNodeId, 
     169                                        AVC1394_SUBUNIT_TYPE_PRINTER ) ? 
     170            "yes":"no" ); 
     171    printf( "AVC: disk recorder?......%s\n", 
     172            avc1394_check_subunit_type( m_handle, iNodeId, 
     173                                        AVC1394_SUBUNIT_TYPE_DISC_RECORDER ) ? 
     174            "yes":"no" ); 
     175    printf( "AVC: video recorder?.....%s\n", 
     176            avc1394_check_subunit_type( m_handle, iNodeId, 
     177                                        AVC1394_SUBUNIT_TYPE_TAPE_RECORDER ) ? 
     178            "yes":"no" ); 
     179    printf( "AVC: vcr?................%s\n", 
     180            avc1394_check_subunit_type( m_handle, iNodeId, 
     181                                        AVC1394_SUBUNIT_TYPE_VCR ) ? 
     182            "yes":"no" ); 
     183    printf( "AVC: tuner?..............%s\n", 
     184            avc1394_check_subunit_type( m_handle, iNodeId, 
     185                                        AVC1394_SUBUNIT_TYPE_TUNER ) ? 
     186            "yes":"no" ); 
     187    printf( "AVC: CA?.................%s\n", 
     188            avc1394_check_subunit_type( m_handle, iNodeId, 
     189                                        AVC1394_SUBUNIT_TYPE_CA ) ? 
     190            "yes":"no" ); 
     191    printf( "AVC: video camera?.......%s\n", 
     192            avc1394_check_subunit_type( m_handle, iNodeId, 
     193                                        AVC1394_SUBUNIT_TYPE_VIDEO_CAMERA ) ? 
     194            "yes":"no" ); 
     195    printf( "AVC: panel?..............%s\n", 
     196            avc1394_check_subunit_type(m_handle, iNodeId, 
     197                                        AVC1394_SUBUNIT_TYPE_PANEL ) ? 
     198            "yes":"no" ); 
     199    printf( "AVC: camera storage?.....%s\n", 
     200            avc1394_check_subunit_type( m_handle, iNodeId, 
     201                                        AVC1394_SUBUNIT_TYPE_CAMERA_STORAGE ) ? 
     202            "yes":"no" ); 
     203    printf( "AVC: bulletin board?.....%s\n", 
     204            avc1394_check_subunit_type( m_handle, iNodeId, 
     205                                        AVC1394_SUBUNIT_TYPE_BULLETIN_BOARD ) ? 
     206            "yes":"no" ); 
     207    printf( "AVC: vendor specificr?...%s\n", 
     208            avc1394_check_subunit_type( m_handle, iNodeId, 
     209                                        AVC1394_SUBUNIT_TYPE_VENDOR_UNIQUE ) ? 
     210            "yes":"no" ); 
     211    printf( "AVC: extended?...........%s\n", 
     212            avc1394_check_subunit_type( m_handle, iNodeId, 
     213                                        AVC1394_SUBUNIT_TYPE_EXTENDED ) ? 
     214            "yes":"no" ); 
     215    printf( "AVC: unit?...............%s\n", 
     216            avc1394_check_subunit_type( m_handle, iNodeId, 
     217                                        AVC1394_SUBUNIT_TYPE_UNIT ) ? 
     218            "yes":"no" ); 
     219} 
     220 
     221void 
     222Ieee1394Service::printRomDirectory( int iNodeId,  rom1394_directory* pRomDir ) 
     223{ 
     224    int iBusInfoBlockLength 
     225        = rom1394_get_bus_info_block_length( m_handle,  iNodeId ); 
     226    int iBusId = rom1394_get_bus_id( m_handle,  iNodeId ); 
     227    octlet_t oGuid = rom1394_get_guid( m_handle, iNodeId ); 
     228    rom1394_bus_options busOptions; 
     229    rom1394_get_bus_options( m_handle, iNodeId, &busOptions ); 
     230 
     231    printf ( "\nNode %d: \n", iNodeId); 
     232    printf ( "-------------------------------------------------\n"); 
     233    printf ("bus info block length = %d\n", iBusInfoBlockLength); 
     234    printf ("bus id = 0x%08x\n", iBusId); 
     235    printf ("bus options:\n"); 
     236    printf ("    isochronous resource manager capable: %d\n", busOptions.irmc); 
     237    printf ("    cycle master capable                : %d\n", busOptions.cmc); 
     238    printf ("    isochronous capable                 : %d\n", busOptions.isc); 
     239    printf ("    bus manager capable                 : %d\n", busOptions.bmc); 
     240    printf ("    cycle master clock accuracy         : %d ppm\n", busOptions.cyc_clk_acc); 
     241    printf ("    maximum asynchronous record size    : %d bytes\n", busOptions.max_rec); 
     242    printf ("GUID: 0x%08x%08x\n", (quadlet_t) (oGuid>>32), 
     243            (quadlet_t) (oGuid & 0xffffffff)); 
     244    printf ("directory:\n"); 
     245    printf ("    node capabilities    : 0x%08x\n", pRomDir->node_capabilities); 
     246    printf ("    vendor id            : 0x%08x\n", pRomDir->vendor_id); 
     247    printf ("    unit spec id         : 0x%08x\n", pRomDir->unit_spec_id); 
     248    printf ("    unit software version: 0x%08x\n", pRomDir->unit_sw_version); 
     249    printf ("    model id             : 0x%08x\n", pRomDir->model_id); 
     250    printf ("    textual leaves       : %s\n",     pRomDir->label); 
    92251} 
    93252 
     
    140299 
    141300    while (true) { 
    142         raw1394_loop_iterate (pIeee1394Service->m_handle); 
     301        raw1394_loop_iterate (pIeee1394Service->m_rhHandle); 
    143302        pthread_testcancel (); 
    144303    } 
  • trunk/freebob/src/ieee1394service.h

    r14 r15  
    2323#include <libraw1394/raw1394.h> 
    2424#include <libavc1394/rom1394.h> 
    25 #include <sigc++/sigc++.h
     25#include <boost/signals.hpp
    2626 
    2727#include "freebob.h" 
    2828 
    29 typedef unsigned int GenerationT; 
     29/* XXX: add those to avc1394.h */ 
     30#define AVC1394_SUBUNIT_TYPE_AUDIO (1 <<19)  
     31#define AVC1394_SUBUNIT_TYPE_PRINTER (2 <<19)  
     32#define AVC1394_SUBUNIT_TYPE_CA (6 <<19)  
     33#define AVC1394_SUBUNIT_TYPE_PANEL (9 <<19)  
     34#define AVC1394_SUBUNIT_TYPE_BULLETIN_BOARD (0xA <<19)  
     35#define AVC1394_SUBUNIT_TYPE_CAMERA_STORAGE (0xB <<19)  
    3036 
    3137class Ieee1394Service { 
     
    3541 
    3642    FBReturnCodes initialize(); 
     43    void shutdown(); 
    3744 
    3845    static Ieee1394Service* instance(); 
     
    4451     * If the count is increased a bus reset has occurred. 
    4552     */ 
    46     sigc::signal<void,GenerationT>sigGenerationCount; 
     53    boost::signal<void (unsigned int)>sigGenerationCount; 
    4754 
    4855 protected: 
     
    5360    void stopRHThread(); 
    5461    static void* rHThread( void* arg ); 
     62 
     63    void printAvcUnitInfo( int iNodeId ); 
     64    void printRomDirectory( int iNodeId,  rom1394_directory* pRomDir ); 
    5565 private: 
    5666    static Ieee1394Service* m_pInstance; 
    5767    raw1394handle_t m_handle; 
     68    raw1394handle_t m_rhHandle; 
    5869    int m_iPort; 
    5970    bool m_bInitialised; 
  • trunk/freebob/src/streamprocess.cpp

    r14 r15  
    5555    printf( "\n" ); 
    5656 
     57    m_pCMHandler->shutdown(); 
    5758}