Microsoft DirectX 8.1 (C++) |
While a DV tape is playing or is in record-pause mode, you can retrieve the SMPTE timecode or the absolute track number. To do this, call the IAMTimecodeReader::GetTimecode method. This method takes a pointer to a TIMECODE_SAMPLE structure, which describes the timecode. Before calling the method, initialize the dwFlags member of the structure. Use the value ED_DEVCAP_TIMECODE_READ to retrieve the timecode or the value ED_DEVCAP_ATN_READ to retrieve the absolute track number.
The timecode member of the TIMECODE_SAMPLE structure is a TIMECODE structure. When the method returns, the dwFrames member of the TIMECODE structure contains the timecode or track number. For timecode, the hours, minutes, seconds, and frames are packed into a DWORD as binary coded decimal (BCD) values, with the format hhmmssff. Use bitmasks to extract the individual values.
The following example retrieves the timecode and track number. The functions DisplayTimecode and DisplayTrackNum are assumed to be application-defined functions that display the information.
if (MyDevCap.bHasTimecode)
{
TIMECODE_SAMPLE TimecodeSample;
TimecodeSample.timecode.dwFrames = 0;
char szBuf[32];
TimecodeSample.dwFlags = ED_DEVCAP_TIMECODE_READ;
if (hr = MyDevCap.pTimecode->GetTimecode(&TimecodeSample), SUCCEEDED(hr))
{
wsprintf(szBuf, "TIMECODE %.2x : %.2x : %.2x : %.2x",
(TimecodeSample.timecode.dwFrames & 0xFF000000) >> 24,
(TimecodeSample.timecode.dwFrames & 0x00FF0000) >> 16,
(TimecodeSample.timecode.dwFrames & 0x0000FF00) >> 8,
(TimecodeSample.timecode.dwFrames & 0x000000FF));
DisplayTimecode(szBuf);
}
TimecodeSample.dwFlags = ED_DEVCAP_ATN_READ;
if (hr = MyDevCap.pTimecode->GetTimecode(&TimecodeSample), SUCCEEDED(hr))
{
wsprintf(szBuf, "%d", TimecodeSample.timecode.dwFrames);
DisplayTrackNum(szBuf);
}
}