DVD Source C++

void CConvertDlg::SetDVDSettings()

{

   // Create the converter object
  IltmmConvert* pConvert;
  IUnknown* punk;
  IltmmDVDSource* pDVDSource;
  HRESULT hr = CoCreateInstance(CLSID_ltmmConvert, NULL, CLSCTX_INPROC_SERVER, IID_IltmmConvert, (void**) &pConvert);
  if(FAILED(hr))

   {

      AfxMessageBox(_T("Can't instantiate convert library"));
     return;

   }

   // Force the DVD source to be used
  pConvert->put_UseDVDSource(VARIANT_TRUE);

   // Set the source DVD image A set of files that contain all of the video and audio content for a DVD, organized with a table of contents (optional). See also: Title, Chapter, ISO Image An ISO image (.iso) is a disk image of a file system. It includes data files that are contained in the ISO image along with filesystem metadata. ISO images are an alternative to physical media for distribution of a "DVD" over the Internet. Most operating systems allow ISO images images to be "played" as if they were physical discs. See also: DVD Image..
  pConvert->put_SourceFile(L"C:\\DVDImage\\VIDEO_TS\\VIDEO_TS.IFO");
  pConvert->put_TargetFile(L"C:\\DVDImage.avi");


  // Get the DVD source interface
  pConvert->GetSubObject(ltmmConvert_Object_SourceFilter, &punk);
  if (punk)

   {   

      punk->QueryInterface(IID_IltmmDVDSource, (void**)&pDVDSource);
     if (pDVDSource)

      {

         IltmmDVDTitle *pTitle;
        long lCount;
        long lVal;
        VARIANT_BOOL vbVal;
        double dVal;
        BSTR strPlayList;

         // Select the main title The name for a group of related video files (called "Chapters") on your DVD. For example, for a DVD called "My Summer Vacation," you might have the titles "Water Skiing," "New Friends," and "Hiking." For each of those titles, you might have one or more different video files. in the disk
        pDVDSource->get_Selected(&lVal);
        if (lVal != ltmmDVDSource_Main_Selected)
           pDVDSource->put_Selected(ltmmDVDSource_Main_Selected);

         // Get the disc duration
        pDVDSource->get_TotalDuration(&dVal);
        // Do something with the value

         // Get the selected title duration
        pDVDSource->get_SelectedDuration(&dVal);
        // Do something with the value

         // Get the play list settings
        pDVDSource->get_PlayList(&strPlayList);
        // You can save this to a file and restore the settings later

         // Restore the playlist settings
        pDVDSource->put_PlayList(strPlayList);

         // Free the string
        SysFreeString(strPlayList);

         // Get the title count in the disc
        pDVDSource->get_TitleCount(&lCount);
        for (int i = 0; i < lCount; i++)
        {

            // Get the title interface
           pDVDSource->GetTitle(i, &pTitle);
           if (pTitle)
           {              
              // Get the X aspect
              pTitle->get_AspectX(&lVal);
              // Do something with the value

               // Get the Y aspect
              pTitle->get_AspectY(&lVal);
              // Do something with the value

               // Determine whether the title is in film mode or camera mode
              pTitle->get_IsFilmMode(&vbVal);
              // Do something with the value

               // Determine whether there is user data in line 21, field 1
              pTitle->get_Line21Field1InGOP(&vbVal);
              // Do something with the value

               // Determine whether there is user data in line 21, field 2
              pTitle->get_Line21Field2InGOP(&vbVal);
              // Do something with the value


              // Get the compression
              pTitle->get_Compression(&lVal);
              // Do something with the value

               // Get the X source resolution
              pTitle->get_SourceResolutionX(&lVal);
              // Do something with the value


              // Get the Y source resolution
              pTitle->get_SourceResolutionY(&lVal);
              // Do something with the value

               // Get the Frame Height
              pTitle->get_FrameHeight(&lVal);
              // Do something with the value
              // Get the Frame Rate

               pTitle->get_FrameRate(&lVal);
              // Do something with the value

               // Determine whether the source is letter boxed
              pTitle->get_IsSourceLetterboxed(&vbVal);
              // Do something with the value

               // Determine whether the picture can be shown as letterbox
              pTitle->get_LetterboxPermitted(&vbVal);
              // Do something with the value

               // Determine whether the picture can be shown as pan-scan
              pTitle->get_PanscanPermitted(&vbVal);
              // Do something with the value

               // Get the title duration
              pTitle->get_TotalDuration(&dVal);
              // Do something with the value


              // Select all title chapters
              pTitle->get_Selected(&lVal);
              if (lVal != ltmmDVDSource_Selected)
                 pTitle->put_Selected(ltmmDVDSource_Selected);

               // Get the selected chapter The name for each individual video file on a DVD. For example, under the title "Water Skiing", you might have the chapters "My first try," "My first wreck," and "My first jump."'s duration
              pTitle->get_SelectedDuration(&dVal);
              // Do something with the value

               // Get the audio stream The portion of the file holding the audio data. The audio data might be compressed to save disk space. The data has to be decompressed using an audio decompressor oftware component which decompresses audio. It must be designed to work with ACM or DirectShow . Note that different compression methods require different decompressors. There is no universal decompressor capable of decoding all compressed streams. before you can play (hear) it. count of the title
              pTitle->get_AudioStreamCount(&lVal);
              if (lVal > 0)

               {
                 // Select the first audio stream
                 pTitle->get_SelectedAudioStream(&lVal);
                 if (lVal == -1)
                    pTitle->put_SelectedAudioStream(0);
                 // Get the first audio stream
                 IltmmDVDAudioStream* pAudioStream;
                 pTitle->GetAudioStream(0, &pAudioStream);
                 if (pAudioStream)
                 {
                    // Select the audio stream
                    pAudioStream->get_Selected(&vbVal);
                    if (vbVal == VARIANT_FALSE)
                       pAudioStream->put_Selected(VARIANT_TRUE);
                    // Get the application mode
                    pAudioStream->get_AppMode(&lVal);
                    // Do something with the value
                    // Get the application mode data
                    pAudioStream->get_AppModeData(&lVal);
                    // Do something with the value
                    // Get the audio format
                    pAudioStream->get_AudioFormat(&lVal);
                    // Do something with the value
                    // Get the number of channels
                    pAudioStream->get_Channels(&lVal);
                    // Do something with the value
                    // Get the frequency
                    pAudioStream->get_Frequency(&lVal);
                    // Do something with the value
                    // Get the language
                    pAudioStream->get_Language(&lVal);
                    // Do something with the value
                    // Get the language extension
                    pAudioStream->get_LanguageExtension(&lVal);
                    // Do something with the value
                    // Get the quantization
                    pAudioStream->get_Quantization(&lVal);
                    // Do something with the value

            

                     // Free the pointer
                    pAudioStream->Release();
                 }
              }

               // Get the subpicture stream count
              pTitle->get_SubpictureStreamCount(&lVal);
              if (lVal > 0)
              {
                 // Select the first subpicture stream
                 pTitle->get_SelectedSubpictureStream(&lVal);
                 if (lVal == -1)
                    pTitle->put_SelectedSubpictureStream(0);
                 // Get the first subpicture stream
                 IltmmDVDSubpictureStream* pSubpictureStream;
                 pTitle->GetSubpictureStream(0, &pSubpictureStream);
                 if (pSubpictureStream)
                 {

                     // Select the subpicture stream
                    pSubpictureStream->get_Selected(&vbVal);
                    if (vbVal == VARIANT_FALSE)
                       pSubpictureStream->put_Selected(VARIANT_TRUE);
                    // Get the coding mode
                    pSubpictureStream->get_CodingMode(&lVal);
                    // Do something with the value
                    // Get the langauge
                    pSubpictureStream->get_Language(&lVal);
                    // Do something with the value
                    // Get the language extension
                    pSubpictureStream->get_LanguageExtension(&lVal);
                    // Do something with the value
                    // Get the type
                    pSubpictureStream->get_Type(&lVal);
                    // Do something with the value
                    // Free the pointer
                    pSubpictureStream->Release();
                 }
              }
              // Get the chapter count
              pTitle->get_ChapterCount(&lVal);
              if (lVal > 0)
              {
                 // Get the first chapter
                 IltmmDVDChapter* pChapter;
                 pTitle->GetChapter(0, &pChapter);
                 // Get the chapter duration
                 pChapter->get_Duration(&dVal);
                 // Determine whether the chapter is selected
                 pChapter->get_Selected(&vbVal);
                 if (vbVal == VARIANT_FALSE)
                    pChapter->put_Selected(VARIANT_TRUE);
                 // Free the pointer
                 pChapter->Release();
              }
              pTitle->Release();
           }
        }
        pDVDSource->Release();
     }
     punk->Release();
  }

}