Implementing byte arrey data type of VAStruct for both ways. Now all set.

parent f881ae09
...@@ -77,11 +77,16 @@ PyObject* ConvertVAStructToPythonDict( const CVAStruct& oInStruct ) ...@@ -77,11 +77,16 @@ PyObject* ConvertVAStructToPythonDict( const CVAStruct& oInStruct )
} }
else if( oValue.IsData() ) else if( oValue.IsData() )
{ {
VA_EXCEPT_NOT_IMPLEMENTED; pNewValue = PyByteArray_FromStringAndSize( ( char* ) oValue.GetData(), oValue.GetDataSize() );
Py_INCREF( pNewValue );
} }
else if( oValue.IsSampleBuffer() ) else if( oValue.IsSampleBuffer() )
{ {
VA_EXCEPT_NOT_IMPLEMENTED; const CVASampleBuffer& oSampleBuffer( oValue );
pNewValue = PyList_New( oSampleBuffer.GetNumSamples() );
Py_INCREF( pNewValue );
for( int i = 0; i < oSampleBuffer.GetNumSamples(); i++ )
PyList_SetItem( pNewValue, i, PyFloat_FromDouble( oSampleBuffer.GetDataReadOnly()[ i ] ) );
} }
else else
{ {
...@@ -154,18 +159,17 @@ CVAStruct ConvertPythonDictToVAStruct( PyObject* pInDict ) ...@@ -154,18 +159,17 @@ CVAStruct ConvertPythonDictToVAStruct( PyObject* pInDict )
} }
else else
{ {
oBuffer.vfSamples[ n ] = PyFloat_AsDouble( pSample ); oBuffer.vfSamples[ n ] = float( PyFloat_AsDouble( pSample ) );
} }
} }
oReturn[ pcKeyName ] = oBuffer; oReturn[ pcKeyName ] = oBuffer;
} }
else if( PyByteArray_Check( pValue ) ) else if( PyBytes_Check( pValue ) )
{ {
// Data blob // Data blob
size_t iBytes = PyByteArray_Size( pValue ); size_t iBytes = PyBytes_Size( pValue );
char* pcData = PyByteArray_AsString( pValue ); char* pcData = PyBytes_AsString( pValue );
oReturn[ pcKeyName ] = CVAStructValue( pcData, iBytes ); oReturn[ pcKeyName ] = CVAStructValue( pcData, int( iBytes ) );
delete[] pcData;
} }
else else
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment