Decoding of DVD

zhaozj2021-02-08  405

This is something long ago, if you have inaccurate, please I forgive

DVD decoding

This section mainly includes interface descriptions used by DirectShow property settings and specific DVDs and extended decodes, and there is also a decoder that supports universal DirectShow filter interfaces and their pin attribute descriptions.

This section mainly includes the following topics:

l decoder volume control

l Windows supported DVD area code transformation

as well as:

l DVD Karaoke Properties Settings

l DVD copy protection property settings

l DVD sub-graph properties settings

l pin attribute settings

l ikspropertyset interface

l iVideoFrameStep interface (hardware decoder is dedicated)

l ivpconfig interface (hardware decoder is dedicated)

1, volume control

The application manages volume control via the ibasicaudio interface, and the iBasicaudio interface is managed by KsProxy, so in order to cause these commands to cause the decoder, you must add some registration keys in the KSPPROPSetId_Wave property setting. Let's create these new driver registration keys:

HKLM / SYSTEM /

CurrentControlSet / Control

DeviceClasses

(Decoder GUID, EG 2721AE ....)

(PNP ID, EG ##? # Vdgendev # ...)

#Global

Device Parameters

CLSID REG_SZ {17cca ...}

FriendlyName Reg_sz WDM DVD Driver

Interfaces <--- Create this key

{B9F8AC3E-0F71-11D2-B72C-00c04fb6bd3d} <- Also Create this key, it is not a value)

MediaInterfaces

{B9F8AC3E-0F71-11D2-B72C-00c04fb6bd3d} <- CREATE THIS Key

(Default) Reg_sz 'Ksproxy ibasicaudio handler' <- set this value

Iid Reg_SZ 56 A8 68 B3 0A D4 11 CE B0 3A 00 20 AF 0B A7 70 <- Create this String Value

Realize volume control, the driver must support kspropsetid_wave and ksproperty.id = ksproperty_wave_volume. This attribute is controlled by the driver via the IKSPROPERTYSET :: GET and IKSPROPERTYSET :: SET method. Left, right audio control The volume size is the linear value of 0x0000 to 0xFFFF.

2, DVD area code transformation

This paragraph explains the working process of selecting the DVD area code under Windows9x and Windows 2000. First, the source of three DVD area code information is described. Subsequently describe how PC vendors set the system to initialize the DVD area code, and then explain how DVD navigation determines the matching of the area by driving, decoder, and disc, and finally reveals the application and decoding How can developers to achieve the correct DVD area code.

2.1, Source of DVD District Code Information

The DVD area code has three sources, which determines the Windows DVD player area.

The DVD title Most DVD titles are marked as specific area code. Some headings can only be played in a certain area, but others can play in many areas, and some can play in all regions. DVD-ROM drives have two DVD-ROM drives: RPC 1 and RPC 2. The RPC 1 driver does not have built-in hardware support area management, so for these drives, you need to manage the number of information changes by Windows, and can only change once; and RPC 2 drivers put these management in hardware, so these The area of ​​the driver can be changed 5 times. DVD decoders Some DVD decoders, regardless of hardware or software, are set to specific area code services. Normally, the user cannot change the area set by the decoder itself. 2.2 How to set up the initialization area code in Windows98 and Windows 2000

This problem is mainly responsible for the DVD driver producer, and they will choose a suitable area before the DVD driver is shipped. In Windows 98, the manufacturer can determine the DVD drive default area code by setting the registration key value hkey_local_machine / software / microsoft / windows / current / version / default DVD area code (binary). This value determines the preferred decoder for DVD decoding in Windows. If this value is set before the system DVD play is played, the Windows component automatically selects the decoder for DVD playback.

If the manufacturer sets the default area code in the registry, then play a disc (including the default area DVD driver) of different zone code, the user will be prompted to change the required area code. If the vendor does not specify the default area, Windows will select an operating system-based code, time zone, and other factors. If the first disc is a multi-zone disc, Windows will also look for the minimum number of minimum code. If you can't find the matching area, the selected area is the area that is the smallest number of minimum number of square codes.

If the manufacturer does not set a zone code, the first time the Windows 98 operating system basic components will be selected, and the language, time zone and the driver are selected for this area. The manufacturer sets the area code as "all adaptation". If the manufacturer does not have these processing, it is best to choose the recommended area code.

Under Windows 2000, the default DVD area code selects the machine-based settings. If there is a disc in the drive, Windows 2000 usually uses the same area code as the default and disc to set the initialization area code, so the DVD drive manufacturer can do anything without initializing the DVD drive under Windows 2000.

For the drive of RPC1, if there is no DVD disc in the drive when Windows starts, the default area will be created based on the local machine; if there is a disc in the drive, then the driver is selected as the default area code, that is, the drive The area code of the disc may be used to initialize the area of ​​the drive. In case the default value is incorrect, then the user also has the right to change the area code.

For the RPC2 driver, if the drive is not set to the drive when it is handled, the driver will be sampled in the above method, but there are discs in the drive. (RPC1 can be selected from the area without requiring the disc in the drive.) Once the RPC2 driver is set, then it cannot be changed by reinstalling the Windows or uninstall the operating system.

3, Microsoft's DVD navigation

When playing a DVD disc while playing a DVD disc, Microsoft's DVD navigation uses the following method to determine the area match: DVD navigation to obtain the area code of the disc, the driver area, and the decoder. If the disc field code is in all regions, the DVD navigation will play unconditional; if the disc is not a full area code, the DVD navigation detects whether the decoder has a preset area code; if the decoder contains the area code and discs The disk code does not match, then the DVD navigation returns an error message to indicate that the current DVD is configured to play the disc; if the decoder area is the same as the disc zone code, the DVD navigation will continue to detect whether the driver area is with the disc. The DVD navigates the DVD navigation. Different, the DVD navigation calls the code to change the area of ​​the drive; if the number of times the change is allowed to be exhausted, the changed area is considered to fail and will not be played. 4, the development of DVD area code change

In the Windows 9x system, when the DVD navigation detects the necessary area code changes to the drive, use the DVDRGN.EXE request drive to change the section. Other components of the application and operating system are mounted to the target system. The demonstration method is as follows:

In Windows 2000, DVD navigation calls the property page of the DVD-ROM drive device in the device management. When the area is required to be changed, the property page is generated by the DVDPlay.exe application. The user interface of this property page is very similar to DVDRGN.EXE, which can be identified by operating system.

For the RPC1 drive, the Windows operating system part management section changes; and the RPC2 driver maintains the area code setting in its hardware. In the RPC2 drive, when the number of times allowed to change, the driver invoking section will fail, The area code change component of the operating system will give the user these conditions and results.

5, install components that support Windows change area code

Application developers can use DVD area code to change support, and change in the DVD application. Here is two different methods for processing this problem.

5.1, Windows 9X

Under the Windows 9x platform, the area code changes the application DVDRGN.exe, and is installed only after the hardware decoding and the WDM MINI driver are installed, and the standard INF file is used.

For software decoders, you can insert the following lines in the INF file. (This is a method of loading DVDRGN.EXE to the target system installed)

[Version]

Signature = $ chicago $

Layoutfile = layout.inf

[DestinationDIRS]

DVDRGNCOPY = 25; Windows

DefaultDestDir = 25; Windows

[DefaultInstall]

CopyFiles = DVDRGNCOPY

[DVDRGNCOPY]

DVDRGN.EXE

5.2, Windows 2000

Under the Windows 2000 system, the component provides support for DVD area code in the storprop.dll file under the system32 under the Windows directory. This DLL is installed by default, without additional steps to confirm its validity.

6, join the integrated area code change support in the application

The following code provides software developers with code that is added to DVD area code in the DVD application:

/

// ChangeDVDREGION: Function to Change The DVD Drive Region.

//

// Parameters:

// in: hwnd - window handle of the application

// That Calls this function

// out: none.

//

// Returns:

// True: if The Drive Region Change Is Successful // False: IF Drive Region Change Fails (Probably Because

// No Drive Was Found With a Valid DVD-V DISC.

/

BOOL CHANGEDVDREGION (HWND HWND)

{

TypeDef Bool (HWND HWND, CHAR Driveletter);

Bool BREGIONCHANGED = FALSE

Tchar Szcmdline [MAX_PATH];

// First Find Out Which Drive Is A DVD Drive With a Valid DVD-V DISC.

Tchar Szdvddrive [4];

IF (! getDriveletter (szdvddrive))

{

Messagebox (hwnd,

Text ("NO DVD Drive Was Found with DVD-V Disc.")

Text ("/ NCANNOT CHANGE DVD Region of the Drive."),

Text ("Error"), MB_OK | MB_INFORMATION;

Return False;

}

// detect Which OS We are running on. For Windows NT, Use the storprop.dll,

// While for Windows 9x Use the dvdrgn.exe application to change the region.

OsversionInfo Ver;

Ver.dwosveionsInfosize = Sizeof (OsversionInfo);

GetVersionex (& VER);

IF (Ver_Platform_Win32_NT == Ver.dwplatformID)

{

// Windows NT Platform

Hinstance hinstdll;

DVDPLAUNCHER DVDPLAUNCHER;

Char szdvdrivea [4];

#ifdef unicode

Widechartomultibyte (0, 0, szdvddrive, -1,

Szdvddrivea, Sizeof (Szdvddrivea),

NULL, NULL);

#ELSE

STRCPY (SZDvddrivea, Szdvddrive);

#ENDIF // Unicode

GetSystemDirectory (Szcmdline, Max_Path);

LSTRCAT (Szcmdline, Text ("// storprop.dll"));

Hinstdll = loadingLibrary (szcmdline);

IF (hinstdll)

{

DvdppLauncher = (DVDPLAUNCHER) GetProcaddress (Hinstdll,

"DVDLAUNCHER");

IF (DVDPLAUNCHER)

{

BREGIONCHANGED = DVDPLAUNCHER (hwnd, szdvddrivea [0]);

}

Freelibrary (HinSTDLL);

}

} // End of Region Change Code for Windows NT PLATFORM

ELSE // Windows 9X Platform

{

// Get path of /Windows/dvdrgn.exe for Command Line StringgetWindowsDirectory (Szcmdline, Max_Path);

LSTRCAT (SZCMDline, Text ("// DVDRGN.EXE"));

// Add Only the Drive Letter As Command Line Parameter

LSTRNCAT (SZCMDline, Szdvddrive, 1);

// prepare to execute DVDRGN.EXE

Startupinfo Startupinfo;

PROCESS_INFORMATION Processinfo;

STARTUPINFO.CB = SizeOf (Startupinfo);

STARTUPINFO.DWFLAGS = startf_useshowwindow;

Startupinfo.wshowwindow = sw_shownormal;

STARTUPINFO.LPRESERVED = NULL;

STARTUPINFO.LPDESKTOP = NULL;

Startupinfo.lptitle = NULL;

Startupinfo.cbreserved2 = 0;

STARTUPINFO.LPRESERVED2 = NULL;

IF (CREATEPROCESS (CSModulenAme, Szcmdline,

Null, NULL, TRUE,

Normal_Priority_Class,

NULL, NULL, & Startupinfo, & ProcessInfo)

{

// Wait Until DVDRGN.EXE Finishes

WaitforsingleObject (ProcessInfo.hprocess, Infinite);

DWORD dwret = 1;

Bool Bret = getExitcodeProcess (ProcessInfo.hprocess,

& dwret);

// if the user change The Drive Region

// SuccessFully, The EXIT code of DVDRGN.EXE IS 0.

IF (Bret && 0 == DWRET)

{

BREGIONCHANGED = TRUE;

}

}

} // End of region Change Code for Windows 9X Platform

IF (BREGIONCHANGED) // if Region Changed SuccessFully

{

// delete old filter graph and create new filter graph

// via idvdgraphbuilder :: renderdvdvideovolume ().

}

Else // DVD Region Didn't Happen

{

Messagebox (hwnd,

Text ("DVD Drive Region Could Not Be Changd.")

Text ("Error"), MB_OK | MB_INFORMATION;

}

} // end function changevdregion

/

// getDriveletter: function to get the drive letter of the currently

// Active DVD Drive

// Parameters: // in: PDVDC - Pointer to IdvdControl Interface of

// DVDNAVIGATOR FILTER..

// out: pszdrive - The first DVD Drive That Is Found

// TO HAVE A VALID DVD-V DISC.

//

// Returns:

// True: if a DVD Drive Is Found (with Valid DISC)

// false: if no DVD Drive Was Found with Valid DVD-V DISC.

/

Bool getDriveletter (IDVDControl * pdvdc, tchar * pszdrive)

{

Char szpatha [MAX_PATH];

Tchar Szpath [MAX_PATH];

Ulong uLactualsize;

Pszdrive [0] = pszdrive [3] = 0;

// Get The Current Root Directory

IF (PDVDC -> Gtroot (Szpatha, Max_Path, & ULACTUALSIZE))

{

#ifdef unicode

MultibyToWideChar (CP_ACP, 0, Szpatha, 0, Szpath, Max_Path);

#ELSE

Lstrcpy (szpath, szpatha);

#ENDIF // Unicode

LSTRCPYN (Pszdrive, Szpath, 3);

IF (drive_cdrom == getDriveType (pszdrive)) // Could Be a DVD Drive

Return True;

}

// Now loop through all the valid drives to detect Which One

// is A DVD Drive with a Valid DVD-V DISC IN IT.

// Get All Valid Drives

DWORD DWLENG = getLogicalDrivestrings (max_path, szpath);

TCHAR * psztemp = szpath;

// Try All Drives One by one

For (DWORD DW = 0; DW

{

// Look Only for CD-ROM Drives That Has A Disc With Required (.IFO) Files

IF (drive_cdrom == getDriveType (psztemp))

{

Tchar Szdvdpath1 [MAX_PATH]

TCHAR SZDVDPATH2 [MAX_PATH];

Lstrcpyn (szdvdpath1, psztemp, 4);

LSTRCPYN (SZDVDPATH 2, PSZTEMP, 4);

LSTRCAT (SZDVDPath1, Text ("Video_TS // Video_TS.ifo"));

LSTRCAT (SZDVDPATH2, TEXT ("VIDEO_TS // VTS_01_0.ifo");

// if the .ifo files exist on this drive kilover ing? A valid DVD-V DISC

IF (DoesfileExist (Achdvdpath1) && Doesfileexist (Achdvdpath2))

{

LSTRCPYN (Pszdrive, PSZTEMP, 3);

Return True; // Return The First Drive That Has A Valid DVD-V DISC

}

}

PSZTEMP = 4;

}

Return False; // Didn't Find Any DVD Drive (with DVD-V Content)

} // End Function GetDriveletter

/

// DOESFILEXIST: Function to Determine if the given filename is an existing file.

//

// Parameters:

// in: pszfile - filename String to check for exec.

// out: none.

//

// Returns:

// true: if the specified file is found.

// false: if the specified file is not found.

/

Bool DoesfileExist (LPTSTR PSZFILE)

{

Handle Hfile = NULL;

// we don't want to pop up by 'we try to top up by ing Test

// if The Required File Is Available To Open for Read.

Uint UerrorMode = setErrorMode (SEM_FAILCRIRALRORS |

Sem_noopenfileerrorbox;

Hfile = Createfile (pszfile, generic_read,

File_share_read, null,

Open_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN,

NULL);

SetErrorMode (UerorMode); // restore error mode

IF (Invalid_Handle_Value == HFILE)

Return False;

CloseHandle (HFILE);

Return True;

} // end function doesfileexist