Page 1 of 1

GetReferenceClock utility?

PostPosted: Thu Jul 13, 2017 4:23 am
by John Willkie
Hello;
I'm making my way through coding a complete interface for DeckLink cards, including all the SDK trees.

I'm writing in C# (Visual Studio 2017), under Windows 10 Professional. I'm building the app as MTATHREAD ed and compiled in 64-bit mode.

The current problem I'm having is getting the GetHardwareReferenceClock() method to work.

Here's my reference code

long desiredTimeScale = 1;
long HardwareTime;
long timeInFrame;
long ticksPerFrame = 0;
if (dl != null)
{
dli = (IDeckLinkInput)dl;
dli.GetHardwareReferenceClock(desiredTimeScale, out HardwareTime, out timeInFrame, out ticksPerFrame);
}
I've tried many work-arounds and fixes, but each time, I get an "E_FAIL" HRESULT.

I have not hooked up the DeckLink SDI card to a SDI input source yet, nor an external reference.

The (badly written and badly executed, despite ok graphical design and layout) SDK says that GetHardwareReferenceClock() can be run while the card is inputting video. Simple question: will this method work when the card is not inputting video?

If the answer to that question is yes, I need help. If no, a few extra words in the SDK could have prevented me from going in circles for more than 24 hours ...

Re: GetReferenceClock utility?

PostPosted: Fri Jul 14, 2017 6:22 am
by Nicholas Gill
Hi John,

I can confirm that IDeckLinkInput::GetHardwareReferenceClock may only be called while video input is enabled:
2.5.4.16 IDeckLinkInput::GetHardwareReferenceClock method

The GetHardwareReferenceClock method returns a clock that is locked to the system clock. ... This method can be called while video input is enabled (see IDeckLinkInput::EnableVideoInput for details).
Suggestions on how this could be better conveyed are welcome.

In general, the early sections of the SDK manual exist to give high-level overviews of some common usage scenarios, while the remaining content serves primarily as an API reference.

Cheers,

-nick

Re: GetReferenceClock utility?

PostPosted: Fri Jul 14, 2017 5:29 pm
by John Willkie
Nick;

thanks for the information. As for how to improve the SDK language, it's very, very simple:

1. add "only" between "can" and "be" in the quoted sentence below, so that it will read "This method can be called while video input is enabled".

2. Delete the reference to "(see IDeckLinkInput::EnableVideoInput for details)." Because -- bad editing -- there are no details there.

Less simple: the structure in the SDK for GetHardwareReferenceClock() lists four objects: BMDTimeScale,
BMDTimeValue, BMDTimeValue, BMDTimeValue that 1) aren't defined in any way in any SDK documents and 2) are actually longs.

As a nit, I'd say that GetHardwareReferenceClock() is a misnomer; since this is constrained to actual incoming streams, it could be called an input stream reference clock to minimize confusion.

I had been cautioned by a colleague at a major test & measurement firm that the SDK was sub-optimal and riddled issues. Good technical writers and editors with domain expertise (media systems and programming) are hard to come by.

Re: GetReferenceClock utility?

PostPosted: Wed Jul 19, 2017 1:34 am
by Nicholas Gill
Hi John,

Thanks very much for the feedback.

"... can only be called.." does appear to be an improvement in conveying that the video input must be enabled - noted - however the reference to IDeckLinkInput::EnableVideoInput in that paragraph is pertinent as it provides a link to how video input can be enabled.

BMDTimeScale and BMDTimeValue are defined in "2.7.2 Time Representation", and are int64_t - the exact representation differs per platform (see "2.7 Common Data Types").

Just as a clarification for IDeckLinkInput::GetHardwareReferenceClock, an active video input is not required, but video input must be enabled, i.e. the input/output interface must be enabled in order to get the input/output hardware reference clock.

If you encounter any issues or have developer questions which are not addressed on the forum, please contact Blackmagic Design Developer Support (the email address is in the SDK manual, in section "1.2  Overview").

Sincerely,

-nick

Re: GetReferenceClock utility?

PostPosted: Wed Jul 19, 2017 2:54 am
by John Willkie
Nick;

I just rechecked, and BMDTimeScale is in the SDK, so I apologize for those. (I seem to have problems with Adobe's search function working correctly from time to time, and I hadn't rechecked this.

I did notice another obvious error: 10.9.3 pp. 52 lists the method GetBufferedAudioSampleFrameCount. When you look for the details on that one, there is none. The actual method is GetAvailableAudioSampleFrameCount. I've implemented that in code (but have yet to check in the real world) so I know that the latter is the appropriate method.

AudioSample is the appropriate term of art; there is no such thing (in the SDI space, anyway) for an AudioSampleFrame. Frame is a video word.

I've seen the email link in the SDK, and I have a card from a developer relations evangelist that I met behind the BMD display space at NAB.

Best;

John