Build the development environment of DirectShow vc6.0

Source: Internet
Author: User

Today, we will use DirectShow as an audio collection program. The first problem encountered in the results is the establishment of the development environment, which requires several steps to prepare.

1) download the SDK that supports DirectShow

2) configure the include and Lib directories in the SDK to vc6.0 (generally, the SDK will be configured during installation)

3) compile the project provided by samples in the SDK and obtain the strmbasd. Lib winmm. Lib library file. This file must be referenced in the newly created DirectShow project.

 

Step 1: In order to develop the DirectShow program, I once thought about using vc6.0 or vs2005. As long as one of the two is successfully configured, I will use it because I am not concerned about the development environment.

I have downloaded and installed two sdks provided by Microsoft. One is windows. server.2003.platform. SDK. feb.2003.edition-quantum, and the other is dxsdk_aug08. The two were not configured successfully until later, so I skipped it here. If I didn't configure them successfully, it doesn't mean other people cannot configure them.

I finally downloaded the successfully configured SDK, Which is dx9sdk. You can search for "directx9.0b SDK summer 2003" in Baidu to find and download the SDK. After installation, this directory is available: <SDK root>/samples/C ++/DirectShow/baseclasses

Next, go to step 2.

Step 2: Open vc6.0

Tools-> options-> Directories
Include-add <SDK root>/include
Lib-add <SDK root>/lib
-Add the <SDK root>/samples/C ++/DirectShow/baseclasses/debug // directory that will appear after step 3.

Step 3: for the compilation of <SDK root>/samples/C ++/DirectShow/baseclasses, I want to refer to the previous article on the Internet that I am very grateful:

Start of conversion:

 

I am also a beginner. If any of the following articles is incorrect, please leave a message. Thank you!

[1] Make sure that your host has installed the VS 2005 and DirectX 9.0b sdks. The dx9.0 SDK will not be written. Find it online! (My dx9.0 is installed in the root directory of the D Drive)

[2] compile baseclasses. sln under the samplesc ++ directshowbaseclasses directory to get two library files (strbase. lib and strmbase. Lib ). The following describes how to modify compilation errors, which are not described in many articles. I wrote it by myself. Sorry!

Go to the DirectShow installation directory, find samplesc ++ directshowbaseclasses, and double-click baseclasses. sln to open the solution. First, you will see the conversion Wizard of Visual Studio. You don't need to worry about it, just click Next to finish.

Click F5 to debug and run it. You will see the following errors (at least this is the result when I compile it ):

1> ------ build started: Project: baseclasses, configuration: Debug Unicode Win32 ------
1> compiling...
1> dllentry. cpp
1> D: Program filesmicrosoft Visual Studio 8vcplatformsdkincludewinnt. H (222): Error c2146: syntax error: Missing '; 'before identifier' pvoid64'
1> D: Program filesmicrosoft Visual Studio 8vcplatformsdkincludewinnt. H (222): Error c4430: Missing type specifier-int assumed. Note: C ++ does not support default-int
1> D: Program filesmicrosoft Visual Studio 8vcplatformsdkincludewinnt. H (5940): Error c2146: syntax error: Missing '; 'before identifier 'buffer'
1> D: Program filesmicrosoft Visual Studio 8vcplatformsdkincludewinnt. H (5940): Error c4430: Missing type specifier-int assumed. Note: C ++ does not support default-int
1> D: Program filesmicrosoft Visual Studio 8vcplatformsdkincludewinnt. H (5940): Error c4430: Missing type specifier-int assumed. Note: C ++ does not support default-int
1> D: dxsdksamplesc ++ directshowbaseclassesctlutil. H (278): Error c4430: Missing type specifier-int assumed. Note: C ++ does not support default-int
1> D: dxsdkincludeuuids. h: Warning c4819: The file contains a character that cannot be represented in the current Code Page (936). Save the file in unicode format to prevent data loss
1> build log was saved"File: // D: dxsdksamplescloud using directshowbaseclassesdebug_unicodebuildlog.htm"
1> baseclasses-6 error (s), 1 warning (s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========

No way. correct the error. (I have mentioned this in my online article, but I don't understand what it means !)

Double-click 1> D: Program filesmicrosoft Visual Studio 8vcplatformsdkincludewinnt. H (222): Error c2146: syntax error: Missing '; 'before identifier' pvoid64' to jump to the error location.

You will see the error statement: typedef void * pointer_64 pvoid64;

This definition is not supported in vs2005. Modify it to two statements:

# Define pointer_64 _ ptr64

Typedef void * pvoid;
Typedef void * pointer_64 pvoid64;

After debugging and running, one more error is found:

1> ------ build started: Project: baseclasses, configuration: Debug Unicode Win32 ------
1> compiling...
1> dllentry. cpp
1> D: dxsdksamplesc ++ directshowbaseclassesctlutil. H (278): Error c4430: Missing type specifier-int assumed. Note: C ++ does not support default-int
1> D: dxsdkincludeuuids. h: Warning c4819: The file contains a character that cannot be represented in the current Code Page (936). Save the file in unicode format to prevent data loss
1> build log was saved"File: // D: dxsdksamplescloud using directshowbaseclassesdebug_unicodebuildlog.htm"
1> baseclasses-1 error (s), 1 warning (s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========

Only change it! Double-click 1> D: dxsdksamplesc ++ directshowbaseclassesctlutil. H (278): Error c4430: Missing type specifier-int assumed. note: C ++ does not support default-int jump to the error location.

You will see the error statement operator = (long );

There is no returned value! Just add one to it and change it to: Long operator = (long );

Debug and run again, wow! More errors:

1> ------ build started: Project: baseclasses, configuration: Debug Unicode Win32 ------
1> compiling...
1> wxdebug. cpp
1>. wxdebug. cpp (534): Warning c4996: '_ vsnwprintf' was declared deprecated
1> D: Program filesmicrosoft Visual Studio 8vcincludestdio. H (450): See Declaration of '_ vsnwprintf'
1> message: 'This function or variable may be unsafe. consider using _ vsnwprintf_s instead. to disable deprecation, use _ crt_secure_no_deprecate. see _ disibledevent = "file: // D: dxsdksamplesc1_directshowbaseclassesdebug_unicodebuildlog.htm"> file: // D: Example"
1> baseclasses-10 error (s), 2 warning (s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========

If something is wrong, change it!Double-click 1>. wxdebug. cpp (567): Error c4430: Missing type specifier-int assumed. Note: C ++ does not support default-int to the error location.

You will see the error statement: static g_dwlastrefresh = 0;

Is there such a definition for static type variables? You have to give a type! Change it to: static DWORD g_dwlastrefresh = 0; why is the type specified as DWORD? Check the statements in the program to understand-ensure that the same type of variables are computed.

Debug and run again:

1> ------ build started: Project: baseclasses, configuration: Debug Unicode Win32 ------
1> compiling...
1> winutil. cpp
1>. winutil. cpp (2104): Error c2065: 'Count': Undeclared identifier
1>. winutil. cpp (2106): Error c2228: Left of '. pered' must have class/struct/Union
1>. winutil. cpp (2106): Error c2228: Left of '. pered' must have class/struct/Union
1>. winutil. cpp (2107): Error c2228: Left of '. pegreen' must have class/struct/Union
1>. winutil. cpp (2107): Error c2228: Left of '. pegreen' must have class/struct/Union
1>. winutil. cpp (2108): Error c2228: Left of '. peblu' must have class/struct/Union
1>. winutil. cpp (2108): Error c2228: Left of '. peblu' must have class/struct/Union
1>. winutil. cpp (2124): Error c2228: Left of '. peflags' must have class/struct/Union
1> outputq. cpp
1>. outputq. cpp (664): Error c2065: 'idone': Undeclared identifier
1> generating code...
1> build log was saved"File: // D: dxsdksamplescloud using directshowbaseclassesdebug_unicodebuildlog.htm"
1> baseclasses-9 error (s), 0 warning (s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========

An error is missing! Continue to work! Double-click 1>. winutil. cpp (2104): Error c2065: 'Count': Undeclared identifier to the error location.

You will see the error statement: For (COUNT = 0; count <result; count ++ ){

Count is not defined? See the preceding statements of this statement:

For (uint COUNT = 0; count <result; count ++ ){
If (systementries [count]. pered! = Pentry [count]. pered |
Systementries [count]. pegreen! = Pentry [count]. pegreen |
Systementries [count]. peblue! = Pentry [count]. peblue ){
Bidentitypalette = false;
}
}

// And likewise compare against the last ten entries

Result = getsystempaletteentries (HDC, palhistart, pallocount, systementries );

See it! Count is a variable defined in the loop body. After a loop is generated, "life" is over. So define it to the outside. Change the preceding statement:

Uint COUNT = 0;

For (COUNT = 0; count <result; count ++ ){
If (systementries [count]. pered! = Pentry [count]. pered |
Systementries [count]. pegreen! = Pentry [count]. pegreen |
Systementries [count]. peblue! = Pentry [count]. peblue ){
Bidentitypalette = false;
}
}

// And likewise compare against the last ten entries

Result = getsystempaletteentries (HDC, palhistart, pallocount, systementries );

Debug and run again:

1> ------ build started: Project: baseclasses, configuration: Debug Unicode Win32 ------
1> compiling...
1> winutil. cpp
1> outputq. cpp
1>. outputq. cpp (664): Error c2065: 'idone': Undeclared identifier
1> generating code...
1> build log was saved"File: // D: dxsdksamplescloud using directshowbaseclassesdebug_unicodebuildlog.htm"
1> baseclasses-1 error (s), 0 warning (s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========

Good! There is one error left! Change again,Double-click "1">. outputq. cpp (664): Error c2065: 'idone': Undeclared identifier
Jump to the error location.

You will see the error statement: * nsamplesprocessed = idone-ilost;

Idone is not defined? OK. Continue to read the preceding statements:

// Loop processing the samples in batches

Long ilost = 0;
For (long idone = 0;
Idone <nsamples | (m_nbatched! = 0 & m_bsendanyway );
){

//...

Similarly, place the idone definition outside the loop body and change it:

// Loop processing the samples in batches

Long ilost = 0;

Long idone = 0;
For (idone = 0;
Idone <nsamples | (m_nbatched! = 0 & m_bsendanyway );
){

//...

After the modification is complete, debug and run again:

1> ------ build started: Project: baseclasses, configuration: Debug Unicode Win32 ------
1> compiling...
1> outputq. cpp
1> creating library...
1> build log was saved"File: // D: dxsdksamplescloud using directshowbaseclassesdebug_unicodebuildlog.htm"
1> baseclasses-0 error (s), 0 warning (s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ========

I finally met succeeded! Are you calling it out?

 

The original address of the forwarding end is as follows: http://blog.chinaunix.net/u1/33950/showart_716130.html

The above example describes how to compile the required library file strmbasd. Lib, generate the library file according to the redirection method, and then go to the project-> setting-> link in vc6.0
Add strmbasd. Lib winmm. Lib

 

 

After completing the above preparations, You can compile our DirectShow program ~~~

A reference source code that can be used for testing

# Include <dshow. h>
# Include <streams. h>
# Include <stdio. h>

Void main (void)
{
Igraphbuilder * pgraph = NULL;
Imediacontrol * pcontrol = NULL;
Imediaevent * pevent = NULL;

// Initialize the com library.
Hresult hR = coinitialize (null );
If (failed (HR ))
{
Printf ("error-cocould not initialize com library ");
Return;
}

// Create the filter graph manager and query for interfaces.
HR = cocreateinstance (clsid_filtergraph, null, clsctx_inproc_server,
Iid_igraphbuilder, (void **) & pgraph );
If (failed (HR ))
{
Printf ("error-cocould not create the filter graph manager .");
Return;
}

HR = pgraph-> QueryInterface (iid_imediacontrol, (void **) & pcontrol );
HR = pgraph-> QueryInterface (iid_imediaevent, (void **) & pevent );

// Build the graph. Important: change this string to a file on your system.
// HR = pgraph-> renderfile (L "C: // example. Avi", null );
HR = pgraph-> renderfile (L "E: // dx90sdk // samples // media // chicken. wmv", null); // open a media file
If (succeeded (HR ))
{
// Run the graph.
HR = pcontrol-> Run ();
If (succeeded (HR ))
{
// Wait for completion.
Long evcode;
Pevent-> waitforcompletion (infinite, & evcode );

// Note: Do not use infinite in a real application, because it
// Can block indefinitely.
}
}
Pcontrol-> release ();
Pevent-> release ();
Pgraph-> release ();
Couninitialize ();
}

.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.