LEADTOOLS Multimedia API Help > Programming with LEADTOOLS Multimedia > C++ Code > IltmmConvert::SetClosedCaptioningTargetFile Example for C++ |
// This function does the following: // 1) Sets a closed captioning target file and saves it in SRT format. // 2) Retrieves the file and its flag and makes sure it is properly set. // 3) Sets a closed captioning target file and saves it in TEXT format. // 4) Retrieves the file and its flag and makes sure it is properly set.
#define MAKE_MEDIA_PATH(pFileName) (TEXT("C:\\LEADTOOLS 18\\Media\\")TEXT(pFileName)) void TestSetClosedCaptioningTargetFile(IltmmConvert *pConvert) { HRESULT hr = S_OK; BSTR bstrTargetFileSRT = NULL; BSTR bstrTargetFileTEXT = NULL; BSTR bstrTargetFile = NULL; long Flags = 0; bstrTargetFileSRT = SysAllocString(MAKE_MEDIA_PATH("ClosedCaptioning.srt")); bstrTargetFileTEXT = SysAllocString(MAKE_MEDIA_PATH("ClosedCaptioning.txt")); // Set the closed captioning target file to ClosedCaptioning.srt and save it in SRT format. hr = pConvert->SetClosedCaptioningTargetFile(bstrTargetFileSRT, 0); ASSERT( hr == S_OK); bstrTargetFile = NULL; hr = pConvert->GetClosedCaptioningTargetFile(&bstrTargetFile, &Flags); if((hr == S_OK) && (VarBstrCmp(bstrTargetFile, bstrTargetFileSRT, NORM_IGNORECASE | LOCALE_USER_DEFAULT, 0) == static_cast<HRESULT>(VARCMP_EQ)) && (0==Flags) ) MessageBox(NULL, TEXT("The Closed Captioning Target File was set properly!"), TEXT("SUCCESS"), MB_OK); else MessageBox(NULL, TEXT("The Closed Captioning Target File was NOT set properly!"), TEXT("FAILURE"), MB_OK); // free the bstr SysFreeString(bstrTargetFile); // Set the closed captioning target file to ClosedCaptioning.txt and save it in TEXT format. hr = pConvert->SetClosedCaptioningTargetFile(bstrTargetFileTEXT, ltmmClosedCaptioning_Text); ASSERT( hr == S_OK); bstrTargetFile = NULL; hr = pConvert->GetClosedCaptioningTargetFile(&bstrTargetFile, &Flags); if((hr == S_OK) && (VarBstrCmp(bstrTargetFile, bstrTargetFileTEXT, NORM_IGNORECASE | LOCALE_USER_DEFAULT, 0) == static_cast<HRESULT>(VARCMP_EQ)) && (ltmmClosedCaptioning_Text==Flags) ) MessageBox(NULL, TEXT("The Closed Captioning Target File was set properly!"), TEXT("SUCCESS"), MB_OK); else MessageBox(NULL, TEXT("The Closed Captioning Target File was NOT set properly!"), TEXT("FAILURE"), MB_OK); // free the bstrs SysFreeString(bstrTargetFile); SysFreeString(bstrTargetFileSRT); SysFreeString(bstrTargetFileTEXT); }