816 | | AvDevice::getConfigurationId() |
---|
817 | | { |
---|
818 | | // create a unique configuration id. |
---|
819 | | // this implementation should do the trick but it is done in a very |
---|
820 | | // rough way. some cleanup and improvements have to be done for the |
---|
821 | | // 'final' version. |
---|
822 | | |
---|
823 | | int id = 0; |
---|
824 | | // get sample rate |
---|
825 | | { |
---|
826 | | ExtendedStreamFormatCmd extStreamFormatCmd( *m_p1394Service ); |
---|
827 | | UnitPlugAddress unitPlugAddress( UnitPlugAddress::ePT_PCR, |
---|
828 | | m_nodeId ); |
---|
829 | | extStreamFormatCmd.setPlugAddress( PlugAddress( PlugAddress::ePD_Input, |
---|
830 | | PlugAddress::ePAM_Unit, |
---|
831 | | unitPlugAddress ) ); |
---|
832 | | |
---|
833 | | extStreamFormatCmd.setNodeId( m_nodeId ); |
---|
834 | | extStreamFormatCmd.setCommandType( AVCCommand::eCT_Status ); |
---|
835 | | extStreamFormatCmd.setVerbose( true ); |
---|
836 | | |
---|
837 | | if ( !extStreamFormatCmd.fire() ) { |
---|
838 | | debugError( "getConfigurationId: stream format command failed\n" ); |
---|
839 | | return false; |
---|
840 | | } |
---|
841 | | |
---|
842 | | FormatInformation* formatInfo = |
---|
843 | | extStreamFormatCmd.getFormatInformation(); |
---|
844 | | FormatInformationStreamsCompound* compoundStream |
---|
845 | | = dynamic_cast< FormatInformationStreamsCompound* > ( |
---|
846 | | formatInfo->m_streams ); |
---|
847 | | if ( compoundStream ) { |
---|
848 | | //debugOutput( DEBUG_LEVEL_VERBOSE, |
---|
849 | | printf("getConfigurationId: sampling frequency %d\n", |
---|
850 | | compoundStream->m_samplingFrequency ); |
---|
851 | | id |= compoundStream->m_samplingFrequency; |
---|
852 | | } |
---|
853 | | } |
---|
854 | | |
---|
855 | | // get number of channels input plug |
---|
856 | | // |
---|
857 | | // in theory we don't need this information. sample rate + sync mode should |
---|
858 | | // ge enough. though to be on the safe side let's us this information as well. |
---|
859 | | // yeah and the number of channels for the output plug should also be added. |
---|
860 | | { |
---|
861 | | ExtendedPlugInfoCmd extPlugInfoCmd( *m_p1394Service ); |
---|
862 | | UnitPlugAddress unitPlugAddress( UnitPlugAddress::ePT_PCR, |
---|
863 | | m_nodeId ); |
---|
864 | | extPlugInfoCmd.setPlugAddress( PlugAddress( PlugAddress::ePD_Input, |
---|
| 816 | AvDevice::getConfigurationIdSampleRate() |
---|
| 817 | { |
---|
| 818 | ExtendedStreamFormatCmd extStreamFormatCmd( *m_p1394Service ); |
---|
| 819 | UnitPlugAddress unitPlugAddress( UnitPlugAddress::ePT_PCR, |
---|
| 820 | m_nodeId ); |
---|
| 821 | extStreamFormatCmd.setPlugAddress( PlugAddress( PlugAddress::ePD_Input, |
---|
867 | | extPlugInfoCmd.setNodeId( m_nodeId ); |
---|
868 | | extPlugInfoCmd.setCommandType( AVCCommand::eCT_Status ); |
---|
869 | | extPlugInfoCmd.setVerbose( true ); |
---|
870 | | ExtendedPlugInfoInfoType extendedPlugInfoInfoType( |
---|
871 | | ExtendedPlugInfoInfoType::eIT_NoOfChannels ); |
---|
872 | | extendedPlugInfoInfoType.initialize(); |
---|
873 | | extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); |
---|
874 | | |
---|
875 | | if ( !extPlugInfoCmd.fire() ) { |
---|
876 | | debugError( "getConfigurationId: number of channels command failed\n" ); |
---|
877 | | return false; |
---|
878 | | } |
---|
879 | | |
---|
880 | | ExtendedPlugInfoInfoType* infoType = extPlugInfoCmd.getInfoType(); |
---|
881 | | if ( infoType |
---|
882 | | && infoType->m_plugNrOfChns ) |
---|
883 | | { |
---|
884 | | printf( "getConfigurationId: number of channels %d\n", |
---|
885 | | infoType->m_plugNrOfChns->m_nrOfChannels ); |
---|
886 | | id |= infoType->m_plugNrOfChns->m_nrOfChannels << 8; |
---|
887 | | } |
---|
888 | | } |
---|
889 | | |
---|
890 | | // sync mode: get plug id/type of signal source for sync plug |
---|
891 | | { |
---|
892 | | SignalSourceCmd signalSourceCmd( *m_p1394Service ); |
---|
893 | | SignalUnitAddress signalUnitAddr; |
---|
894 | | signalUnitAddr.m_plugId = 0x01; |
---|
895 | | signalSourceCmd.setSignalDestination( signalUnitAddr ); |
---|
896 | | signalSourceCmd.setNodeId( m_nodeId ); |
---|
897 | | signalSourceCmd.setSubunitType( AVCCommand::eST_Unit ); |
---|
898 | | signalSourceCmd.setSubunitId( 0xff ); |
---|
899 | | |
---|
900 | | signalSourceCmd.setCommandType( AVCCommand::eCT_Status ); |
---|
901 | | |
---|
902 | | if ( !signalSourceCmd.fire() ) { |
---|
903 | | debugError( "getConfigurationId: number of channels command failed\n" ); |
---|
904 | | return false; |
---|
905 | | } |
---|
906 | | |
---|
907 | | SignalAddress* pSyncPlugSignalAddress = signalSourceCmd.getSignalSource(); |
---|
908 | | SignalUnitAddress* pSyncPlugUnitAddress |
---|
909 | | = dynamic_cast<SignalUnitAddress*>( pSyncPlugSignalAddress ); |
---|
910 | | if ( pSyncPlugUnitAddress ) { |
---|
911 | | printf( "getConfigurationId: sync plug (unit) 0x%04x\n", |
---|
912 | | pSyncPlugUnitAddress->m_plugId ); |
---|
913 | | } |
---|
914 | | |
---|
915 | | SignalSubunitAddress* pSyncPlugSubunitAddress |
---|
916 | | = dynamic_cast<SignalSubunitAddress*>( pSyncPlugSignalAddress ); |
---|
917 | | if ( pSyncPlugSubunitAddress ) { |
---|
918 | | printf( "getConfigurationId: sync plug 0x%04x\n", |
---|
| 824 | |
---|
| 825 | extStreamFormatCmd.setNodeId( m_nodeId ); |
---|
| 826 | extStreamFormatCmd.setCommandType( AVCCommand::eCT_Status ); |
---|
| 827 | extStreamFormatCmd.setVerbose( true ); |
---|
| 828 | |
---|
| 829 | if ( !extStreamFormatCmd.fire() ) { |
---|
| 830 | debugError( "Stream format command failed\n" ); |
---|
| 831 | return false; |
---|
| 832 | } |
---|
| 833 | |
---|
| 834 | FormatInformation* formatInfo = |
---|
| 835 | extStreamFormatCmd.getFormatInformation(); |
---|
| 836 | FormatInformationStreamsCompound* compoundStream |
---|
| 837 | = dynamic_cast< FormatInformationStreamsCompound* > ( |
---|
| 838 | formatInfo->m_streams ); |
---|
| 839 | if ( compoundStream ) { |
---|
| 840 | debugOutput(DEBUG_LEVEL_VERBOSE, "Sample rate 0x%02x\n", |
---|
| 841 | compoundStream->m_samplingFrequency ); |
---|
| 842 | return compoundStream->m_samplingFrequency; |
---|
| 843 | } |
---|
| 844 | |
---|
| 845 | debugError( "Could not retrieve sample rate\n" ); |
---|
| 846 | return 0; |
---|
| 847 | } |
---|
| 848 | |
---|
| 849 | int |
---|
| 850 | AvDevice::getConfigurationIdNumberOfChannel( PlugAddress::EPlugDirection ePlugDirection ) |
---|
| 851 | { |
---|
| 852 | ExtendedPlugInfoCmd extPlugInfoCmd( *m_p1394Service ); |
---|
| 853 | UnitPlugAddress unitPlugAddress( UnitPlugAddress::ePT_PCR, |
---|
| 854 | m_nodeId ); |
---|
| 855 | extPlugInfoCmd.setPlugAddress( PlugAddress( ePlugDirection, |
---|
| 856 | PlugAddress::ePAM_Unit, |
---|
| 857 | unitPlugAddress ) ); |
---|
| 858 | extPlugInfoCmd.setNodeId( m_nodeId ); |
---|
| 859 | extPlugInfoCmd.setCommandType( AVCCommand::eCT_Status ); |
---|
| 860 | extPlugInfoCmd.setVerbose( true ); |
---|
| 861 | ExtendedPlugInfoInfoType extendedPlugInfoInfoType( |
---|
| 862 | ExtendedPlugInfoInfoType::eIT_NoOfChannels ); |
---|
| 863 | extendedPlugInfoInfoType.initialize(); |
---|
| 864 | extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); |
---|
| 865 | |
---|
| 866 | if ( !extPlugInfoCmd.fire() ) { |
---|
| 867 | debugError( "Number of channels command failed\n" ); |
---|
| 868 | return false; |
---|
| 869 | } |
---|
| 870 | |
---|
| 871 | ExtendedPlugInfoInfoType* infoType = extPlugInfoCmd.getInfoType(); |
---|
| 872 | if ( infoType |
---|
| 873 | && infoType->m_plugNrOfChns ) |
---|
| 874 | { |
---|
| 875 | debugOutput(DEBUG_LEVEL_VERBOSE, "Number of channels 0x%02x\n", |
---|
| 876 | infoType->m_plugNrOfChns->m_nrOfChannels ); |
---|
| 877 | return infoType->m_plugNrOfChns->m_nrOfChannels; |
---|
| 878 | } |
---|
| 879 | |
---|
| 880 | debugError( "Could not retrieve number of channels\n" ); |
---|
| 881 | return 0; |
---|
| 882 | } |
---|
| 883 | |
---|
| 884 | int |
---|
| 885 | AvDevice::getConfigurationIdSyncMode() |
---|
| 886 | { |
---|
| 887 | SignalSourceCmd signalSourceCmd( *m_p1394Service ); |
---|
| 888 | SignalUnitAddress signalUnitAddr; |
---|
| 889 | signalUnitAddr.m_plugId = 0x01; |
---|
| 890 | signalSourceCmd.setSignalDestination( signalUnitAddr ); |
---|
| 891 | signalSourceCmd.setNodeId( m_nodeId ); |
---|
| 892 | signalSourceCmd.setSubunitType( AVCCommand::eST_Unit ); |
---|
| 893 | signalSourceCmd.setSubunitId( 0xff ); |
---|
| 894 | |
---|
| 895 | signalSourceCmd.setCommandType( AVCCommand::eCT_Status ); |
---|
| 896 | |
---|
| 897 | if ( !signalSourceCmd.fire() ) { |
---|
| 898 | debugError( "Number of channels command failed\n" ); |
---|
| 899 | return false; |
---|
| 900 | } |
---|
| 901 | |
---|
| 902 | SignalAddress* pSyncPlugSignalAddress = signalSourceCmd.getSignalSource(); |
---|
| 903 | SignalSubunitAddress* pSyncPlugSubunitAddress |
---|
| 904 | = dynamic_cast<SignalSubunitAddress*>( pSyncPlugSignalAddress ); |
---|
| 905 | if ( pSyncPlugSubunitAddress ) { |
---|
| 906 | debugOutput(DEBUG_LEVEL_VERBOSE, "Sync mode 0x%02x\n", |
---|