diff options
Diffstat (limited to 'software/octdeviceapi/oct6100api/oct6100_api/oct6100_channel.c')
-rw-r--r-- | software/octdeviceapi/oct6100api/oct6100_api/oct6100_channel.c | 129 |
1 files changed, 118 insertions, 11 deletions
diff --git a/software/octdeviceapi/oct6100api/oct6100_api/oct6100_channel.c b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_channel.c index 162dfa6..463f077 100644 --- a/software/octdeviceapi/oct6100api/oct6100_api/oct6100_channel.c +++ b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_channel.c @@ -2,7 +2,7 @@ File: oct6100_channel.c - Copyright (c) 2001-2007 Octasic Inc. + Copyright (c) 2001-2008 Octasic Inc. Description: @@ -23,9 +23,9 @@ You should have received a copy of the GNU General Public License along with the OCT6100 GPL API; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -$Octasic_Release: OCT612xAPI-01.00-PR49 $ +$Octasic_Release: OCT612xAPI-01.01.01 $ -$Octasic_Revision: 492 $ +$Octasic_Revision: 494 $ \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ @@ -4931,35 +4931,130 @@ UINT32 Oct6100ApiModifyChannelStructs( { UINT32 ulCompType = 0; UINT16 usTempTsiMemIndex; - UINT16 usDecoderMemIndex; - UINT16 usEncoderMemIndex; + UINT16 usDecoderMemIndex = cOCT6100_INVALID_INDEX; + UINT16 usEncoderMemIndex = cOCT6100_INVALID_INDEX; + UINT16 usConversionMemIndex; UINT32 ulPcmLaw; UINT16 usPhasingIndex; BOOL fModifyAdpcmMem = TRUE; /*==============================================================================*/ - /* Reprogram the Decoder memory.*/ + /* Clear off the decoder and encoder memory if the direction changes, */ + /* or if the port is disabled (basically, as required). */ - if ( pChanEntry->CodecConfig.byDecoderPort == cOCT6100_CHANNEL_PORT_RIN ) + /* Only clear the conversion memory if the decoder or encoder port has changed. */ + if ( ( pChanEntry->CodecConfig.byDecoderPort != cOCT6100_NO_DECODING ) + && ( pChanEntry->CodecConfig.byDecoderPort != (UINT8)( f_pChannelOpen->CodecConfig.ulDecoderPort & 0xFF ) ) ) + { + /* Default is there is no conversion index. */ + usConversionMemIndex = cOCT6100_INVALID_INDEX; + + /* Find the old decoder port, to clear it. */ + if ( pChanEntry->CodecConfig.byDecoderPort == cOCT6100_CHANNEL_PORT_RIN ) + usConversionMemIndex = pChanEntry->usRinRoutConversionMemIndex; + else if ( pChanEntry->CodecConfig.byDecoderPort == cOCT6100_CHANNEL_PORT_SIN ) + usConversionMemIndex = pChanEntry->usSinSoutConversionMemIndex; + + /* If the conversion memory index is valid. */ + if ( usConversionMemIndex != cOCT6100_INVALID_INDEX ) + { + ulResult = Oct6100ApiClearConversionMemory( f_pApiInstance, + usConversionMemIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Flag the entry as deactivated.*/ + if ( pChanEntry->CodecConfig.byDecoderPort == cOCT6100_CHANNEL_PORT_RIN ) + { + *f_pfRinRoutCodecActive = FALSE; + } + else + { + *f_pfSinSoutCodecActive = FALSE; + } + } + } + + /* Now with the encoder.. */ + if ( ( pChanEntry->CodecConfig.byEncoderPort != cOCT6100_NO_ENCODING ) + && ( pChanEntry->CodecConfig.byEncoderPort != (UINT8)( f_pChannelOpen->CodecConfig.ulEncoderPort & 0xFF ) ) ) + { + /* Default is there is no conversion index. */ + usConversionMemIndex = cOCT6100_INVALID_INDEX; + + /* Find the old encoder port, to clear it. */ + if ( pChanEntry->CodecConfig.byEncoderPort == cOCT6100_CHANNEL_PORT_ROUT ) + usConversionMemIndex = pChanEntry->usRinRoutConversionMemIndex; + else if ( pChanEntry->CodecConfig.byEncoderPort == cOCT6100_CHANNEL_PORT_SOUT ) + usConversionMemIndex = pChanEntry->usSinSoutConversionMemIndex; + + /* If the conversion memory index is valid. */ + if ( usConversionMemIndex != cOCT6100_INVALID_INDEX ) + { + ulResult = Oct6100ApiClearConversionMemory( f_pApiInstance, + usConversionMemIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Flag the entry as deactivated.*/ + if ( pChanEntry->CodecConfig.byEncoderPort == cOCT6100_CHANNEL_PORT_ROUT ) + { + *f_pfRinRoutCodecActive = FALSE; + } + else + { + *f_pfSinSoutCodecActive = FALSE; + } + } + } + + /*==============================================================================*/ + + + + /*==============================================================================*/ + /* Reprogram the Decoder memory with the new requested configuration. */ + + /* Select the conversion index according to the port to be used for decoding. */ + /* NOTE: At this point, the configuration can request the decoder to be disabled, thus this */ + /* case must be handled correctly. */ + if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN ) { usDecoderMemIndex = pChanEntry->usRinRoutConversionMemIndex; } - else + else if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN ) { usDecoderMemIndex = pChanEntry->usSinSoutConversionMemIndex; } + else /* if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_NO_DECODING ) */ + { + /* No decoding requested. The conversion memory does not */ + /* have to be modified, it was cleared above. */ + usDecoderMemIndex = cOCT6100_INVALID_INDEX; + } - if ( pChanEntry->CodecConfig.byEncoderPort == cOCT6100_CHANNEL_PORT_ROUT ) + /* Select the conversion index according to the port to be used for encoding. */ + /* NOTE: At this point, the configuration can request the encoder to be disabled, thus this */ + /* case must be handled correctly. */ + if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT ) { usEncoderMemIndex = pChanEntry->usRinRoutConversionMemIndex; } - else + else if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT ) { usEncoderMemIndex = pChanEntry->usSinSoutConversionMemIndex; } + else /* if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_NO_DECODING ) */ + { + /* No encoding requested. The conversion memory does not */ + /* have to be modified, it was cleared above. */ + usEncoderMemIndex = cOCT6100_INVALID_INDEX; + } + /* If the decoder must be programmed. */ if ( usDecoderMemIndex != cOCT6100_INVALID_INDEX ) { + /* Program conversion memory according to decoding rate selected by user. */ switch( f_pChannelOpen->CodecConfig.ulDecodingRate ) { case cOCT6100_G711_64KBPS: @@ -5099,6 +5194,9 @@ UINT32 Oct6100ApiModifyChannelStructs( } } + /* Save the new decoder port for future references. */ + pChanEntry->CodecConfig.byDecoderPort = (UINT8)( f_pChannelOpen->CodecConfig.ulDecoderPort & 0xFF ); + /*==============================================================================*/ @@ -5109,7 +5207,6 @@ UINT32 Oct6100ApiModifyChannelStructs( if ( usEncoderMemIndex != cOCT6100_INVALID_INDEX ) { - fModifyAdpcmMem = TRUE; /* Set the chariot memory based on the selected port.*/ @@ -5270,6 +5367,9 @@ UINT32 Oct6100ApiModifyChannelStructs( } } + /* Save the new encoder port for future references. */ + pChanEntry->CodecConfig.byEncoderPort = (UINT8)( f_pChannelOpen->CodecConfig.ulEncoderPort & 0xFF ); + /*==============================================================================*/ } @@ -10933,6 +11033,9 @@ UINT32 Oct6100ApiCheckChannelCreateBiDirParams( /* Check the specific state of the channel.*/ if ( pFirstChanEntry->fRinRoutCodecActive == TRUE && pFirstChanEntry->CodecConfig.byEncoderPort != cOCT6100_CHANNEL_PORT_ROUT) return cOCT6100_ERR_CHANNEL_CODEC_ACTIVATED; + /* Law conversion is not permitted on the Rin-Rout path. */ + if ( pFirstChanEntry->TdmConfig.byRinPcmLaw != pFirstChanEntry->TdmConfig.byRoutPcmLaw ) + return cOCT6100_ERR_CHANNEL_CODEC_ACTIVATED; if ( pFirstChanEntry->fSinSoutCodecActive == TRUE && pFirstChanEntry->CodecConfig.byEncoderPort != cOCT6100_CHANNEL_PORT_SOUT) return cOCT6100_ERR_CHANNEL_CODEC_ACTIVATED; if ( pFirstChanEntry->fBiDirChannel == TRUE ) @@ -10979,6 +11082,10 @@ UINT32 Oct6100ApiCheckChannelCreateBiDirParams( /* Check the specific state of the channel.*/ if ( pSecondChanEntry->fRinRoutCodecActive == TRUE && pSecondChanEntry->CodecConfig.byEncoderPort != cOCT6100_CHANNEL_PORT_ROUT) return cOCT6100_ERR_CHANNEL_CODEC_ACTIVATED; + /* Law conversion is not permitted on the Rin-Rout path. */ + if ( pSecondChanEntry->TdmConfig.byRinPcmLaw != pSecondChanEntry->TdmConfig.byRoutPcmLaw ) + return cOCT6100_ERR_CHANNEL_CODEC_ACTIVATED; + if ( pSecondChanEntry->fSinSoutCodecActive == TRUE && pSecondChanEntry->CodecConfig.byEncoderPort != cOCT6100_CHANNEL_PORT_SOUT) { |