Index: /trunk/freebob/configure.ac =================================================================== --- /trunk/freebob/configure.ac (revision 14) +++ /trunk/freebob/configure.ac (revision 15) @@ -23,7 +23,8 @@ AM_INIT_AUTOMAKE AM_MAINTAINER_MODE -AC_CONFIG_SRCDIR([src/freebob.cpp]) +AC_CONFIG_SRCDIR([src/main.cpp]) AC_CONFIG_HEADER([config.h]) AC_GNU_SOURCE +AC_LANG(C++) maintainer_mode=${enable_maintainer_mode-no} @@ -85,7 +86,11 @@ # Checks for library functions. -PKG_CHECK_MODULES(LIBSIGC, sigc++-2.0 >= 2.0.3) PKG_CHECK_MODULES(LIBRAW1394, libraw1394 >= 0.10) PKG_CHECK_MODULES(LIBIEC61883, libiec61883 >= 0.1.0) +AC_CHECK_HEADER(boost/signals.hpp, , [ + 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])]) +AC_HAVE_LIBRARY(boost_signals, , [ + 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])]) + AC_SUBST([LIBSIGC_CFLAGS]) @@ -109,5 +114,4 @@ Source directory: $srcdir Installation prefix: $prefix - C compiler: $CC $XTRA_CFLAGS $WARN_CFLAGS $CFLAGS C++ compiler: $CXX $XTRA_CXXFLAGS $WARN_CXXFLAGS $CXXFLAGS ]) Index: /trunk/freebob/src/ieee1394service.h =================================================================== --- /trunk/freebob/src/ieee1394service.h (revision 14) +++ /trunk/freebob/src/ieee1394service.h (revision 15) @@ -23,9 +23,15 @@ #include #include -#include +#include #include "freebob.h" -typedef unsigned int GenerationT; +/* XXX: add those to avc1394.h */ +#define AVC1394_SUBUNIT_TYPE_AUDIO (1 <<19) +#define AVC1394_SUBUNIT_TYPE_PRINTER (2 <<19) +#define AVC1394_SUBUNIT_TYPE_CA (6 <<19) +#define AVC1394_SUBUNIT_TYPE_PANEL (9 <<19) +#define AVC1394_SUBUNIT_TYPE_BULLETIN_BOARD (0xA <<19) +#define AVC1394_SUBUNIT_TYPE_CAMERA_STORAGE (0xB <<19) class Ieee1394Service { @@ -35,4 +41,5 @@ FBReturnCodes initialize(); + void shutdown(); static Ieee1394Service* instance(); @@ -44,5 +51,5 @@ * If the count is increased a bus reset has occurred. */ - sigc::signalsigGenerationCount; + boost::signalsigGenerationCount; protected: @@ -53,7 +60,11 @@ void stopRHThread(); static void* rHThread( void* arg ); + + void printAvcUnitInfo( int iNodeId ); + void printRomDirectory( int iNodeId, rom1394_directory* pRomDir ); private: static Ieee1394Service* m_pInstance; raw1394handle_t m_handle; + raw1394handle_t m_rhHandle; int m_iPort; bool m_bInitialised; Index: /trunk/freebob/src/cmhandler.h =================================================================== --- /trunk/freebob/src/cmhandler.h (revision 14) +++ /trunk/freebob/src/cmhandler.h (revision 15) @@ -33,4 +33,5 @@ FBReturnCodes initialize(); + void shutdown(); static CMHandler* instance(); Index: /trunk/freebob/src/ieee1394service.cpp =================================================================== --- /trunk/freebob/src/ieee1394service.cpp (revision 14) +++ /trunk/freebob/src/ieee1394service.cpp (revision 15) @@ -20,4 +20,6 @@ #include +#include +#include #include "ieee1394service.h" #include "debugmodule.h" @@ -36,8 +38,16 @@ { stopRHThread(); - if ( !m_handle ) { + + if ( m_rhHandle ) { + raw1394_destroy_handle( m_rhHandle ); + m_rhHandle = 0; + } + + if ( m_handle ) { raw1394_destroy_handle( m_handle ); m_handle = 0; } + + m_pInstance = 0; } @@ -46,6 +56,7 @@ { if ( !m_bInitialised ) { + m_rhHandle = raw1394_new_handle(); m_handle = raw1394_new_handle(); - if ( !m_handle ) { + if ( !m_rhHandle || !m_handle ) { if ( !errno ) { fprintf( stderr, "libraw1394 not compatible.\n" ); @@ -60,5 +71,10 @@ // to be able to retrieve the instance in the pure C bus reset // call back function. - raw1394_set_userdata( m_handle, this ); + raw1394_set_userdata( m_rhHandle, this ); + + if ( raw1394_set_port( m_rhHandle, m_iPort ) < 0 ) { + perror( "Could not set port" ); + return eFBRC_Setting1394PortFailed; + } if ( raw1394_set_port( m_handle, m_iPort ) < 0 ) { @@ -67,5 +83,5 @@ } - raw1394_set_bus_reset_handler( m_handle, this->resetHandler ); + raw1394_set_bus_reset_handler( m_rhHandle, this->resetHandler ); startRHThread(); @@ -77,4 +93,10 @@ } +void +Ieee1394Service::shutdown() +{ + delete this; +} + Ieee1394Service* Ieee1394Service::instance() @@ -89,5 +111,142 @@ Ieee1394Service::discoveryDevices() { + //scan bus + int iNodeCount = raw1394_get_nodecount( m_handle ); + for ( int iNodeId = 0; iNodeId < iNodeCount; ++iNodeId ) { + rom1394_directory romDir; + rom1394_get_directory( m_handle, iNodeId, &romDir ); + printRomDirectory( iNodeId, &romDir ); + + switch (rom1394_get_node_type( &romDir )) { + case ROM1394_NODE_TYPE_UNKNOWN: + debugPrint (DEBUG_LEVEL_INFO, + "Node %d has node type UNKNOWN\n", iNodeId); + break; + case ROM1394_NODE_TYPE_DC: + debugPrint (DEBUG_LEVEL_INFO, + "Node %d has node type DC\n", iNodeId); + break; + case ROM1394_NODE_TYPE_AVC: + debugPrint (DEBUG_LEVEL_INFO, + "Node %d has node type AVC\n", iNodeId); + printAvcUnitInfo( iNodeId ); + + if ( avc1394_check_subunit_type( m_handle, iNodeId, + AVC1394_SUBUNIT_TYPE_AUDIO ) ) { + // XXX + // create avcDevice which discovers itself :) + } + break; + case ROM1394_NODE_TYPE_SBP2: + debugPrint( DEBUG_LEVEL_INFO, + "Node %d has node type SBP2\n", iNodeId); + break; + case ROM1394_NODE_TYPE_CPU: + debugPrint( DEBUG_LEVEL_INFO, + "Node %d has node type CPU\n", iNodeId); + break; + default: + debugPrint( DEBUG_LEVEL_INFO, + "No matching node type found for node %d\n", iNodeId); + } + } return eFBRC_Success; +} + +void +Ieee1394Service::printAvcUnitInfo( int iNodeId ) +{ + printf( "AVC: video monitor?......%s\n", + avc1394_check_subunit_type( m_handle, iNodeId, + AVC1394_SUBUNIT_TYPE_VIDEO_MONITOR ) ? + "yes":"no" ); + printf( "AVC: audio?..............%s\n", + avc1394_check_subunit_type( m_handle, iNodeId, + AVC1394_SUBUNIT_TYPE_AUDIO ) ? + "yes":"no" ); + printf( "AVC; printer?............%s\n", + avc1394_check_subunit_type( m_handle, iNodeId, + AVC1394_SUBUNIT_TYPE_PRINTER ) ? + "yes":"no" ); + printf( "AVC: disk recorder?......%s\n", + avc1394_check_subunit_type( m_handle, iNodeId, + AVC1394_SUBUNIT_TYPE_DISC_RECORDER ) ? + "yes":"no" ); + printf( "AVC: video recorder?.....%s\n", + avc1394_check_subunit_type( m_handle, iNodeId, + AVC1394_SUBUNIT_TYPE_TAPE_RECORDER ) ? + "yes":"no" ); + printf( "AVC: vcr?................%s\n", + avc1394_check_subunit_type( m_handle, iNodeId, + AVC1394_SUBUNIT_TYPE_VCR ) ? + "yes":"no" ); + printf( "AVC: tuner?..............%s\n", + avc1394_check_subunit_type( m_handle, iNodeId, + AVC1394_SUBUNIT_TYPE_TUNER ) ? + "yes":"no" ); + printf( "AVC: CA?.................%s\n", + avc1394_check_subunit_type( m_handle, iNodeId, + AVC1394_SUBUNIT_TYPE_CA ) ? + "yes":"no" ); + printf( "AVC: video camera?.......%s\n", + avc1394_check_subunit_type( m_handle, iNodeId, + AVC1394_SUBUNIT_TYPE_VIDEO_CAMERA ) ? + "yes":"no" ); + printf( "AVC: panel?..............%s\n", + avc1394_check_subunit_type(m_handle, iNodeId, + AVC1394_SUBUNIT_TYPE_PANEL ) ? + "yes":"no" ); + printf( "AVC: camera storage?.....%s\n", + avc1394_check_subunit_type( m_handle, iNodeId, + AVC1394_SUBUNIT_TYPE_CAMERA_STORAGE ) ? + "yes":"no" ); + printf( "AVC: bulletin board?.....%s\n", + avc1394_check_subunit_type( m_handle, iNodeId, + AVC1394_SUBUNIT_TYPE_BULLETIN_BOARD ) ? + "yes":"no" ); + printf( "AVC: vendor specificr?...%s\n", + avc1394_check_subunit_type( m_handle, iNodeId, + AVC1394_SUBUNIT_TYPE_VENDOR_UNIQUE ) ? + "yes":"no" ); + printf( "AVC: extended?...........%s\n", + avc1394_check_subunit_type( m_handle, iNodeId, + AVC1394_SUBUNIT_TYPE_EXTENDED ) ? + "yes":"no" ); + printf( "AVC: unit?...............%s\n", + avc1394_check_subunit_type( m_handle, iNodeId, + AVC1394_SUBUNIT_TYPE_UNIT ) ? + "yes":"no" ); +} + +void +Ieee1394Service::printRomDirectory( int iNodeId, rom1394_directory* pRomDir ) +{ + int iBusInfoBlockLength + = rom1394_get_bus_info_block_length( m_handle, iNodeId ); + int iBusId = rom1394_get_bus_id( m_handle, iNodeId ); + octlet_t oGuid = rom1394_get_guid( m_handle, iNodeId ); + rom1394_bus_options busOptions; + rom1394_get_bus_options( m_handle, iNodeId, &busOptions ); + + printf ( "\nNode %d: \n", iNodeId); + printf ( "-------------------------------------------------\n"); + printf ("bus info block length = %d\n", iBusInfoBlockLength); + printf ("bus id = 0x%08x\n", iBusId); + printf ("bus options:\n"); + printf (" isochronous resource manager capable: %d\n", busOptions.irmc); + printf (" cycle master capable : %d\n", busOptions.cmc); + printf (" isochronous capable : %d\n", busOptions.isc); + printf (" bus manager capable : %d\n", busOptions.bmc); + printf (" cycle master clock accuracy : %d ppm\n", busOptions.cyc_clk_acc); + printf (" maximum asynchronous record size : %d bytes\n", busOptions.max_rec); + printf ("GUID: 0x%08x%08x\n", (quadlet_t) (oGuid>>32), + (quadlet_t) (oGuid & 0xffffffff)); + printf ("directory:\n"); + printf (" node capabilities : 0x%08x\n", pRomDir->node_capabilities); + printf (" vendor id : 0x%08x\n", pRomDir->vendor_id); + printf (" unit spec id : 0x%08x\n", pRomDir->unit_spec_id); + printf (" unit software version: 0x%08x\n", pRomDir->unit_sw_version); + printf (" model id : 0x%08x\n", pRomDir->model_id); + printf (" textual leaves : %s\n", pRomDir->label); } @@ -140,5 +299,5 @@ while (true) { - raw1394_loop_iterate (pIeee1394Service->m_handle); + raw1394_loop_iterate (pIeee1394Service->m_rhHandle); pthread_testcancel (); } Index: /trunk/freebob/src/streamprocess.cpp =================================================================== --- /trunk/freebob/src/streamprocess.cpp (revision 14) +++ /trunk/freebob/src/streamprocess.cpp (revision 15) @@ -55,3 +55,4 @@ printf( "\n" ); + m_pCMHandler->shutdown(); } Index: /trunk/freebob/src/cmhandler.cpp =================================================================== --- /trunk/freebob/src/cmhandler.cpp (revision 14) +++ /trunk/freebob/src/cmhandler.cpp (revision 15) @@ -32,4 +32,8 @@ CMHandler::~CMHandler() { + if ( m_pIeee1394Service ) { + m_pIeee1394Service->shutdown(); + } + m_pInstance = 0; } @@ -54,4 +58,10 @@ } +void +CMHandler::shutdown() +{ + delete this; +} + CMHandler* CMHandler::instance()