The DVDSample Startup Sequence (Windows CE 5.0)
This topic provides a high-level summary of the tasks that DVDSample performs prior to entering its main message loop. The tasks are presented here in a flattened list even though they execute in several nested steps in the source code.
For a graphical representation of how the object classes in DVDSample relate to one another see Architectural Overview of DVDSample.
Instantiating CApp
After loading the necessary header files, the application begins by instantiating a CApp object. This object is DVDSample. It contains all of the logic for the entire application. Upon instantiation, the application object instantiates objects from two other classes, CParentLevels and CDVDLanguages.
The parental level and language objects are simple helper objects that provide DVDSample with easy access to information from the DVD-Video standard.
Entering WinMain
The first task performed in WinMain is a call to CApp::SetAppValues. This assigns the application's window handle to a global variable and it identifies the name of the application.
The second task is the initialization of the CApp object. This is the entry point to the majority of DVDSample's startup activities. It is where the application window is created and both the CAppState object and the CDvdCore object are instantiated and initialized.
Instantiating CAppState
The CAppState object maintains a record of the various playback parameters associated with DVDSample's user interface. It exposes an internal callback interface, IDVDCallback, which is used to provide notification for playback events that require updates to the DVDSample control panel.
DVDSample's control panel graphics resources are loaded into memory when the CAppState object is initialized. Once the graphics for the buttons are loaded, all of the fonts and font properties are loaded.
This font data is used in the portions of the control panel that show textual information such as the title and chapter numbers and the playback status messages.
After the CAppState object is created, execution returns to the CApp::InitInstance method and DVDSample menus are created for the application window's command bar. At this point, the command bar is only created in memory. It is not yet visible in the window.
The CDVDCore object is instantiated after the menu bars are created.
Instantiating CDvdCore
The CDvdCore object provides the link between the data coming directly from the DVD drive and the user interface elements of the application.
CDvdCore object is initialized immediately after it is instantiated. The initialization process involves three distinct steps: obtaining DVD-Video API interface pointers, instantiating additional internal objects, and creating a thread to monitor the DVD drive.
The steps that DVDSample uses to obtain the DVD-Video API interface in CDvdCore::InitDVDInterfaces pointers are very similar to the process described in Fundamental DVD-Video API Interfaces. First the DVDData and DVDNavigationManager objects are created and then the IDVDROM, IDVDVideoVolume, IDVDNavigationManager, and IDVDUserOperation pointers are obtained.
Initializing the CDvdCore object next involves instantiating and initializing three key internal objects in the CDvdCore::InitInternalObjects method. The first object that is instantiated in this method is from the CDVDSampleEventSink class.
This object's Connect method identifies the CDVDSampleEventSink methods as the implementations of the IDVDNavDataStatusSink and IDVDNavigatorSink interfaces. This established the link between the DVD-Video API and DVDSample.
The second internal object is from the CDevMon class. This object is used to monitor the DVD drive and send notifications when the drive is or is not ready for playback.
Upon initialization, the CDevMon object searches the system to find a handle to the DVD drive. It also creates a new thread and identifies the CDevMon::ThreadProc as the starting point for the thread's execution. Within CDevMon::ThreadProc, processing is suspended until a window becomes available to receive the thread's messages.
When the window does become available, the thread begins listening on the system's device manager notification queue. Whenever a notification is received from the DVD drive, a call to CDevMon::Notify communicates the drive readiness state back to the monitoring thread's window.
Execution on the main thread continues while CDevMon::ThreadProc is determining the status of the DVD drive on the monitoring thread. The third internal object to instantiated by the CDvdCore object is from the CDvdVideo class.
The CDvdVideo object uses DirectDraw to manage the primary display surface and the overlay display surface for DVD playback in a window. DVDSample will play back to a window on the device's desktop if the device's hardware will allow it, for more information see Setting up DirectDraw in DVDSample.
With the last of the internal objects created, execution returns to the method that initialized the CDvdCore object. While the monitoring thread is already running in the background, the infrastructure needed to complete the event sinks supported by the monitoring thread is created with the CDvdCore::InitMessageSink method.
This method creates a window that the CDvdCore object uses for DVD playback. This window is set to receive messages from the DVD Video API through the CDVDSampleEventSink object and messages about the state of the DVD drive from the CDevMon object. This window may be made visible later on, depending on the video capabilities of the Windows CE device.
The final step of initializing the CDvdCore object is to set the aspect ratio of the display through a call to the CDvdCore::SetPlaybackOptions method.
The Final Steps
Once all of the objects needed to run DVDSample are created only a few tasks remain. To finish the process of initializing the CApp object, the title of the control panel window is defined and the control panel is made visible to the user. Execution then returns to the remaining part of WinMain where the accelerator tables for DVDSample are loaded into memory.
DVDSample then enters its message loop.
See Also
Architectural Overview of DVDSample | The DVDSample Control Panel | Fundamental DVD-Video API Interfaces | IDVDROM | IDVDVideoVolume | IDVDNavigationManager | IDVDUserOperation | IDVDNavDataStatusSink | IDVDNavigatorSink | Examining the DVDSample Sample Application
Send Feedback on this topic to the authors