Example #1
0
VOID CModel::Release(){

	MODELMESH* pMesh = meshes;

	for(DWORD i=0; i < numMeshes; i++){
		// SAFE_DELETE( pMesh->vertices );
		// SAFE_DELETE( pMesh->indices );
		SAFE_ARRAYDELETE( pMesh->vertices );
		SAFE_ARRAYDELETE( pMesh->indices );
		//if( pMesh->vertices ) delete [] pMesh->vertices
	}
}
HRESULT TvideoCodecLibavcodecDxva::findDXVA1DecoderConfiguration(IAMVideoAccelerator* pAMVideoAccelerator, const GUID* guidDecoder, DDPIXELFORMAT* pPixelFormat)
{
    HRESULT        hr            = E_FAIL;
    DWORD          dwFormats     = 0;
    DDPIXELFORMAT* pPixelFormats = NULL;


    pAMVideoAccelerator->GetUncompFormatsSupported(guidDecoder, &dwFormats, NULL);
    if (dwFormats > 0) {
        // Find the valid render target formats for this decoder GUID.
        pPixelFormats = new DDPIXELFORMAT[dwFormats];
        hr = pAMVideoAccelerator->GetUncompFormatsSupported(guidDecoder, &dwFormats, pPixelFormats);
        if (SUCCEEDED(hr)) {
            // Look for a format that matches our output format.
            for (DWORD iFormat = 0; iFormat < dwFormats; iFormat++) {
                if (pPixelFormats[iFormat].dwFourCC == MAKEFOURCC('N', 'V', '1', '2')) {
                    memcpy(pPixelFormat, &pPixelFormats[iFormat], sizeof(DDPIXELFORMAT));
                    SAFE_ARRAYDELETE(pPixelFormats)
                    return S_OK;
                }
            }

            SAFE_ARRAYDELETE(pPixelFormats);
            hr = E_FAIL;
        }
//------------------------------------------------------------------------------
// Name: CStreamData::~CStreamData()
// Desc: Destructor.
//------------------------------------------------------------------------------
CStreamData::~CStreamData()
{
    if( m_ptrMediaArray )
    {
        for( DWORD i = 0; i < m_dwStreamCount; i++ )
        {
			if( m_ptrMediaArray[i] )
			{
				delete[] (BYTE*)m_ptrMediaArray[i];
			}
        }
    }

    SAFE_ARRAYDELETE( m_ptrMediaArray );
	SAFE_ARRAYDELETE( m_ptrStreamNumArray );
	SAFE_ARRAYDELETE( m_ptrStreamBufferWindow );
	SAFE_ARRAYDELETE( m_pfVBRStream );
}
Example #4
0
HRESULT ConvertMBtoWC( LPCTSTR ptszInString, __out LPWSTR *ppwszOutString )
{
    if( ptszInString == NULL || ppwszOutString == NULL )
    {
        return( E_INVALIDARG );
    }

    HRESULT hr          = S_OK;
    int     nSizeCount  = 0;

    *ppwszOutString     = NULL;

    do
    {
        //
        // Get the memory reqd for this string
        //
        nSizeCount = MultiByteToWideChar( CP_ACP, 0, ptszInString, -1, NULL, 0 );
        if( 0 ==  nSizeCount )
        {
            hr = HRESULT_FROM_WIN32( GetLastError() );
            break;
        }

        *ppwszOutString = new WCHAR[ nSizeCount ];
        if( NULL == *ppwszOutString )
        {
            hr = HRESULT_FROM_WIN32( GetLastError() );
            break;
        }

        if( 0 == MultiByteToWideChar( CP_ACP, 0, ptszInString, -1, *ppwszOutString, nSizeCount ) )
        {
            hr = HRESULT_FROM_WIN32( GetLastError() );
            break;
        }
    }
    while( FALSE );
    
    if( FAILED( hr ) )
    {
        SAFE_ARRAYDELETE( *ppwszOutString );
        _tprintf( _T( "Internal error ( hr=0x%08x )\n" ), hr );
    }

    return( hr );
}
Example #5
0
///////////////////////////////////////////////////////////////////////////////
// Convert a TCHAR string to WCHAR string. 
// Caller must release the memory of pwszOutput by calling delete[] pwszOutput.
///////////////////////////////////////////////////////////////////////////////
HRESULT ConvertTCharToWChar( LPCTSTR ptszInput, __out LPWSTR * pwszOutput )
{
    int cchOutput = 0;
    
    if( NULL == ptszInput || NULL == pwszOutput )
    {
        return( E_INVALIDARG );
    }

    //
    // Get output buffer size
    //
#ifdef UNICODE
    cchOutput = wcslen( ptszInput ) + 1;
#else //UNICODE
    cchOutput = MultiByteToWideChar( CP_ACP, 0, ptszInput, -1, NULL, 0 );
    if( 0 == cchOutput )
    {
        return( HRESULT_FROM_WIN32( GetLastError() ) );
    }
#endif // UNICODE

    *pwszOutput = new WCHAR[ cchOutput ];
    if( NULL == *pwszOutput)
    {
        return( E_OUTOFMEMORY );
    }

#ifdef UNICODE
    wcsncpy_s( *pwszOutput, cchOutput, ptszInput, cchOutput - 1 );
#else //UNICODE
    if( 0 == MultiByteToWideChar( CP_ACP, 0, ptszInput, -1, *pwszOutput, cchOutput ) )
    {
        SAFE_ARRAYDELETE( *pwszOutput );
        return( HRESULT_FROM_WIN32( GetLastError() ) );
    }        
#endif // UNICODE

    return( S_OK );
}
Example #6
0
AABBTreePoly::~AABBTreePoly()
{
	SAFE_ARRAYDELETE(points_);
	SAFE_ARRAYDELETE(leafs_);
}
Example #7
0
//------------------------------------------------------------------------------
// Name: ShowAttributes()
// Desc: Display all attributes for the specified stream,
//       using IWMHeaderInfo.
//------------------------------------------------------------------------------
HRESULT ShowAttributes( __in LPWSTR pwszInFile, WORD wStreamNum )
{
    HRESULT             hr                  = S_OK;

    IWMMetadataEditor   * pEditor           = NULL;
    IWMHeaderInfo*      pHeaderInfo         = NULL;

    WCHAR               * pwszAttribName    = NULL;
    WORD                wAttribNameLen      = 0;
    WMT_ATTR_DATATYPE   wAttribType;
    BYTE                * pbAttribValue     = NULL;
    WORD                wAttribValueLen     = 0;

    do
    {
        hr = EditorOpenFile( pwszInFile, &pEditor, &pHeaderInfo, NULL );
        if(FAILED( hr ) )
        {
            break;
        }

        WORD wAttributeCount = 0;

        hr = pHeaderInfo->GetAttributeCount( wStreamNum, &wAttributeCount );
        if(FAILED( hr ) )
        {
            _tprintf( _T( "GetAttributeCount failed for stream = %d ( hr=0x%08x ).\n" ), 
                wStreamNum, hr );
            break;
        }

        PrintListHeader();

        for( WORD wAttribIndex = 0; wAttribIndex < wAttributeCount; wAttribIndex++ )
        {
            SAFE_ARRAYDELETE( pwszAttribName );
            SAFE_ARRAYDELETE( pbAttribValue );

            hr = pHeaderInfo->GetAttributeByIndex( wAttribIndex,
                                                   &wStreamNum,
                                                   pwszAttribName,
                                                   &wAttribNameLen,
                                                   &wAttribType,
                                                   pbAttribValue,
                                                   &wAttribValueLen );
            if( FAILED( hr ) )
            {
                _tprintf( _T( "GetAttributeByIndex failed for index = %d ( hr=0x%08x ).\n" ), 
                    wAttribIndex, hr );
                break;
            }

            pwszAttribName = new WCHAR[ wAttribNameLen ];
            if( NULL == pwszAttribName )
            {
                hr = E_OUTOFMEMORY;
                break;
            }

            pbAttribValue = new BYTE[ wAttribValueLen ];
            if( NULL == pbAttribValue )
            {
                hr = E_OUTOFMEMORY;
                break;
            }

            hr = pHeaderInfo->GetAttributeByIndex( wAttribIndex,
                                                   &wStreamNum,
                                                   pwszAttribName,
                                                   &wAttribNameLen,
                                                   &wAttribType,
                                                   pbAttribValue,
                                                   &wAttribValueLen );
            if( FAILED( hr ) )
            {
                _tprintf( _T( "GetAttributeByIndex failed for index = %d ( hr=0x%08x ).\n" ), 
                    wAttribIndex, hr );
                break;
            }

            hr = PrintAttribute( wAttribIndex, 
                                 wStreamNum, 
                                 pwszAttribName, 
                                 wAttribType, 
                                 0, 
                                 pbAttribValue, 
                                 wAttribValueLen );
            if( FAILED( hr ) )
            {
                break;
            }
        }
        
        hr = pEditor->Close();
        if( FAILED( hr ) )
        {
            _tprintf( _T( "Could not close the file %ws ( hr=0x%08x ).\n" ), pwszInFile, hr );
            break;
        }
    }
    while( FALSE );
    
    SAFE_RELEASE( pHeaderInfo );
    SAFE_RELEASE( pEditor );

    SAFE_ARRAYDELETE( pwszAttribName );
    SAFE_ARRAYDELETE( pbAttribValue );

    return( hr );
}
int __cdecl _tmain( int argc, TCHAR* argv[] )
{
    DWORD   dwPortNum       = 8080;     // Default port number.
    TCHAR*  ptszFileName    = NULL;     // File to broadcast.
    TCHAR*  ptszServerURL   = NULL;     // URL on the server, for push distribution
    int     nMaxClient  = 10;           // Maximum number of clients that can connect.
    HRESULT hr = S_OK;
	printf("Encoder build at %s %s\n",__DATE__,__TIME__);
    // Loop through the command-line arguments. On failure, display the correct
    // usage and exit.
    for( int i = 1; i < argc; i ++ )
    {
        if( 0 == _tcsicmp( argv[i], _T( "-p" ) ) )
        {
            i++;
            
            if( i == argc )
            {
                Usage();
                return( E_INVALIDARG );
            }
            
            int retval = _stscanf( argv[i], _T( "%d" ), &dwPortNum );
            if( retval == 0 )
            {
                Usage();
                return( E_INVALIDARG );
            }
            continue;
            
        }
        
        if( 0 == _tcsicmp( argv[i], _T( "-i" ) ) )
        {
            i++;
            
            if( i == argc )
            {
                Usage();
                return( E_INVALIDARG );
            }
            
            ptszFileName = argv[i];
            continue;
        }
        
        if( 0 == _tcsicmp( argv[i] , _T( "-c" ) ) )
        {
            i++;
            
            if(i == argc)
            {
                Usage();
                return ( E_INVALIDARG );
            }
            
            int retval = _stscanf( argv[i], _T( "%d" ), &nMaxClient );
            if( 0 == retval )
            {
                Usage();
                return( E_INVALIDARG );
            }
            continue;
        }

        if( 0 == _tcsicmp( argv[i], _T( "-s" ) ) )
        {
            i++;
            
            if( i == argc )
            {
                Usage();
                return( E_INVALIDARG );
            }
            
            ptszServerURL = argv[i];
            continue;
        }
    }
    
    if( NULL == ptszFileName )
    {
        Usage();
        return( E_INVALIDARG );
    }

    CNetWrite netWriter;  // Helper object that broadcasts the file.
     
    WCHAR *pwszFile = NULL;
    WCHAR *pwszServerURL = NULL;

    // Declare a dummy 'do' loop. On failure, we can break from the loop.
    do
    {
        // Convert the file name to a wide-character string.
        hr = ConvertTCharToWChar( ptszFileName, &pwszFile );
        if( FAILED( hr ) )
            break;

        
        // The server URL is optional, so it might be NULL.
        if( ptszServerURL != NULL )
        {
            // Convert the server URL to wide-character string.
            hr = ConvertTCharToWChar( ptszServerURL, &pwszServerURL);
            if( FAILED( hr ) )
                break;
        }

        // Initialize our helper object.
        hr = netWriter.Init();
        if( FAILED( hr ) )
        {
            break;
        }

//		netWriter.setCW( 0xff, 0x10ee, 135, 220, 1);
        // Configure the helper object with the port number, file name, maximum
        // number of clients, and server URL.		
        hr = netWriter.Configure(dwPortNum, pwszFile, nMaxClient, pwszServerURL);
        if( FAILED( hr ) )
        {
            break;
        }

        // Write all of the samples to the network.
        hr = netWriter.WritetoNet();
        if(FAILED(hr))
        {
            break;
        }

    }
    while(FALSE);  // Go through the dummy loop one time only.
    
    // Free memory. 
    SAFE_ARRAYDELETE( pwszFile );
    SAFE_ARRAYDELETE( pwszServerURL );
    
    return hr;
}
//------------------------------------------------------------------------------
// Name: CLicenseViewer::ShowRights()
// Desc: Show DRM rights properties.
//------------------------------------------------------------------------------
HRESULT CLicenseViewer::ShowRights()
{
    HRESULT                 hr = S_OK;
    DWORD                   dwPropertyIndex;
    WMT_ATTR_DATATYPE       wmtType;
    BOOL                    fBoolProperty;
    WORD                    cbLength;
    WM_LICENSE_STATE_DATA   LicenseStateData;
    WCHAR                   wszTemp[500];
    LPCWSTR                 wszPropertyName;
    const DRM_Properties*   pCurrentProperty;
    LPBYTE                  pbProperty = NULL;
    DWORD                   dwStateIndex;
    
    //
    // Validate current state
    //
    if ( !m_pIWMDRMReader )
    {
        _tprintf( _T( "ShowRights: m_pIWMDRMReader is NULL." ) );
        return E_FAIL;
    }
    
    _tprintf( _T( "ShowRights 0x%08lX\n" ), hr );

    //
    // Print the boolean properties
    //
    _tprintf( _T( "  Basic rights information:\n" ) );

    for ( dwPropertyIndex = 0; dwPropertyIndex < NUM_BOOL_PROPERTIES; dwPropertyIndex++ )
    {
        pCurrentProperty = &(g_BoolProperties[ dwPropertyIndex ]);
        
        //
        // Get the next property from the DRM reader
        //
        wszPropertyName = pCurrentProperty->pwszName;
        cbLength = sizeof( BOOL );
        assert( m_pIWMDRMReader );
        assert( pCurrentProperty );
    	hr = m_pIWMDRMReader->GetDRMProperty( wszPropertyName, &wmtType, (BYTE *)&fBoolProperty, &cbLength );
        if ( FAILED( hr ) )
        {
            _tprintf( _T( "    Couldn't get value for property %ws (hr = 0x%08lX)\n" ), wszPropertyName, hr );
            hr = S_OK; // Reset the HRESULT, since it was "handled"
        }
        else
        {
            //
            // Check to make sure the property is the expected type and size
            //
            if ( wmtType != pCurrentProperty->wmtExpectedType )
            {
                _tprintf( _T( "    Invalid returned property type\n" ) );
                continue;
            }

            if ( sizeof( BOOL ) != cbLength )
            {
                _tprintf( _T( "    Invalid returned property length\n" ) );
                continue;
            }
            
            //
            // Print the value of the property
            //
            _tprintf( _T( "    %ws: %Ls\n" ), wszPropertyName, fBoolProperty ? _T( "Yes" ) : _T( "No" ) );
        }
    }

    //
    // Get the license state properties
    //
    _tprintf( _T( "  Content rights information:\n" ) );

    for( dwPropertyIndex = 0; dwPropertyIndex < NUM_LICENSE_PROPERTIES; dwPropertyIndex++ )
    {
        pCurrentProperty = &(g_LicenseProperties[ dwPropertyIndex ]);

        //
        // Get property from DRM reader
        //        
        cbLength = pCurrentProperty->cbExpectedLength;
        assert( m_pIWMDRMReader );
        assert( pCurrentProperty );
    	hr = m_pIWMDRMReader->GetDRMProperty( pCurrentProperty->pwszName, &wmtType, (BYTE *)&LicenseStateData, &cbLength );
        if ( FAILED( hr ) )
        {
            _tprintf( _T( "    Couldn't get value for property %ws (hr = 0x%08lX)\n" ), pCurrentProperty->pwszName, hr );
            hr = S_OK; // Reset the HRESULT, since it was "handled"
        }
        else
        {
            //
            // Check that the property type and size are the expected values
            //
            if ( wmtType != pCurrentProperty->wmtExpectedType )
            {
                _tprintf( _T( "  Invalid returned property type\n" ) );
                continue;
            }

            if ( cbLength != pCurrentProperty->cbExpectedLength )
            {
                _tprintf( _T( "  Invalid returned property length\n" ) );
                continue;
            }
            
            //
            // Print each license state
            //
            _tprintf( _T( "    %ws:\n" ), pCurrentProperty->pwszName );
            for( dwStateIndex = 0; dwStateIndex < LicenseStateData.dwNumStates; dwStateIndex++ )
            {
                hr = PrintLicenseStateData( _T("      "), &(LicenseStateData.stateData[ dwStateIndex ]) );
                if ( FAILED( hr ) )
                {
                    break;
                }
            }
            if ( FAILED( hr ) )
            {
                break;
            }
        }
    }

    //
    // Test the Header properties
    //
    _tprintf( _T( "  Header Properies:\n" ) );

    for( dwPropertyIndex = 0; dwPropertyIndex < NUM_HEADER_PROPERTIES; dwPropertyIndex++ )
    {
        pCurrentProperty = &(g_HeaderProperties[ dwPropertyIndex ]);
        
        //
        // Get the property from the DRM reader
        //
        cbLength = sizeof( wszTemp );
        assert( m_pIWMDRMReader );
        assert( pCurrentProperty );
    	hr = m_pIWMDRMReader->GetDRMProperty( pCurrentProperty->pwszName, &wmtType, (BYTE *)&wszTemp[ 0 ], &cbLength );
        if ( FAILED( hr ) )
        {
            _tprintf( _T( "    Couldn't get value for property %ws (hr = 0x%08lX)\n" ), pCurrentProperty->pwszName, hr );
            hr = S_OK; // Reset the HRESULT, since it was "handled"
        }
        else
        {
            //
            // Check that the type returned is the expected type
            //
            if ( wmtType != pCurrentProperty->wmtExpectedType )
            {
                _tprintf( _T( "    Invalid returned property type\n" ) );
                continue;
            }
            
            //
            // Print the value of the property
            //
            _tprintf( _T( "    %ws: %ws\n" ), pCurrentProperty->pwszName, wszTemp );
        }
    }
    
    SAFE_ARRAYDELETE( pbProperty );

    return( hr );
}