UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
ProfileCallback Class Reference
Inheritance diagram for ProfileCallback:
Inheritance graph
Collaboration diagram for ProfileCallback:
Collaboration graph

Public Member Functions

 ProfileCallback (IDeckLinkProfile *requestedProfile)
 
virtual ~ProfileCallback ()
 
ULONG STDMETHODCALLTYPE AddRef () override
 
HRESULT ProfileActivated (IDeckLinkProfile *activatedProfile) override
 
HRESULT ProfileChanging (IDeckLinkProfile *profileToBeActivated, BMD_BOOL streamsWillBeForcedToStop) override
 
HRESULT STDMETHODCALLTYPE QueryInterface (REFIID iid, LPVOID *ppv) override
 
ULONG STDMETHODCALLTYPE Release () override
 
bool WaitForProfileActivation (void)
 

Private Attributes

std::condition_variable m_profileActivatedCondition
 
std::mutex m_profileActivatedMutex
 
int m_refCount = 1
 
IDeckLinkProfile * m_requestedProfile
 
bool m_requestedProfileActivated = false
 

Detailed Description

Definition at line 335 of file blackmagic_common.cpp.

Constructor & Destructor Documentation

◆ ProfileCallback()

ProfileCallback::ProfileCallback ( IDeckLinkProfile * requestedProfile)
inline

Definition at line 338 of file blackmagic_common.cpp.

338 : m_requestedProfile(requestedProfile) {
339 m_requestedProfile->AddRef();
340 }
IDeckLinkProfile * m_requestedProfile

References m_requestedProfile.

◆ ~ProfileCallback()

virtual ProfileCallback::~ProfileCallback ( )
inlinevirtual

Definition at line 384 of file blackmagic_common.cpp.

384 {
385 m_requestedProfile->Release();
386 }

References m_requestedProfile.

Member Function Documentation

◆ AddRef()

ULONG STDMETHODCALLTYPE ProfileCallback::AddRef ( )
inlineoverride

Definition at line 356 of file blackmagic_common.cpp.

356{ return ++m_refCount; }

References m_refCount.

◆ ProfileActivated()

HRESULT ProfileCallback::ProfileActivated ( IDeckLinkProfile * activatedProfile)
inlineoverride

Definition at line 343 of file blackmagic_common.cpp.

343 {
344 {
345 std::lock_guard<std::mutex> lock(m_profileActivatedMutex);
347 }
348 m_profileActivatedCondition.notify_one();
349 return S_OK;
350 }
std::condition_variable m_profileActivatedCondition
std::mutex m_profileActivatedMutex

References m_profileActivatedCondition, m_profileActivatedMutex, and m_requestedProfileActivated.

◆ ProfileChanging()

HRESULT ProfileCallback::ProfileChanging ( IDeckLinkProfile * profileToBeActivated,
BMD_BOOL streamsWillBeForcedToStop )
inlineoverride

Definition at line 342 of file blackmagic_common.cpp.

342{ return S_OK; }

◆ QueryInterface()

HRESULT STDMETHODCALLTYPE ProfileCallback::QueryInterface ( REFIID iid,
LPVOID * ppv )
inlineoverride

Definition at line 351 of file blackmagic_common.cpp.

352 {
353 *ppv = nullptr;
354 return E_NOINTERFACE;
355 }

◆ Release()

ULONG STDMETHODCALLTYPE ProfileCallback::Release ( )
inlineoverride

Definition at line 357 of file blackmagic_common.cpp.

357 {
358 ULONG refCount = --m_refCount;
359 if (refCount == 0)
360 delete this;
361
362 return refCount;
363 }

References m_refCount.

◆ WaitForProfileActivation()

bool ProfileCallback::WaitForProfileActivation ( void )
inline

Definition at line 365 of file blackmagic_common.cpp.

365 {
366 BMD_BOOL isActiveProfile = BMD_FALSE;
367 const char *profileName = kDeviceProfiles.find(GetDeckLinkProfileID(m_requestedProfile)) != kDeviceProfiles.end() ?
369 if ((m_requestedProfile->IsActive(&isActiveProfile) == S_OK) && isActiveProfile) {
370 LOG(LOG_LEVEL_INFO) << "[DeckLink] Profile " << profileName << " already active.\n";
371 return true;
372 }
373
374 LOG(LOG_LEVEL_INFO) << "[DeckLink] Waiting for profile activation... (this may take few seconds)\n";
375 std::unique_lock<std::mutex> lock(m_profileActivatedMutex);
376 bool ret = m_profileActivatedCondition.wait_for(lock, std::chrono::seconds{5}, [&]{ return m_requestedProfileActivated; });
377 if (ret) {
378 LOG(LOG_LEVEL_NOTICE) << "[DeckLink] Profile " << profileName << " activated succesfully.\n";
379 } else {
380 LOG(LOG_LEVEL_ERROR) << "[DeckLink] Profile " << profileName << " activation timeouted!\n";
381 }
382 return ret;
383 }
static const map< BMDProfileID, pair< const char *, const char * > > kDeviceProfiles
static BMDProfileID GetDeckLinkProfileID(IDeckLinkProfile *profile)
#define BMD_BOOL
#define BMD_FALSE
#define LOG_LEVEL_NOTICE
information that may be interesting
Definition debug.h:61
#define LOG_LEVEL_INFO
normal reporting
Definition debug.h:62
#define LOG_LEVEL_ERROR
general errors
Definition debug.h:59
#define LOG(level)
Definition debug.h:313

References BMD_BOOL, BMD_FALSE, GetDeckLinkProfileID(), kDeviceProfiles, LOG, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_NOTICE, m_profileActivatedCondition, m_profileActivatedMutex, m_requestedProfile, and m_requestedProfileActivated.

Referenced by decklink_set_profile().

Here is the call graph for this function:

Member Data Documentation

◆ m_profileActivatedCondition

std::condition_variable ProfileCallback::m_profileActivatedCondition
private

Definition at line 391 of file blackmagic_common.cpp.

Referenced by ProfileActivated(), and WaitForProfileActivation().

◆ m_profileActivatedMutex

std::mutex ProfileCallback::m_profileActivatedMutex
private

Definition at line 392 of file blackmagic_common.cpp.

Referenced by ProfileActivated(), and WaitForProfileActivation().

◆ m_refCount

int ProfileCallback::m_refCount = 1
private

Definition at line 390 of file blackmagic_common.cpp.

Referenced by AddRef(), and Release().

◆ m_requestedProfile

IDeckLinkProfile* ProfileCallback::m_requestedProfile
private

◆ m_requestedProfileActivated

bool ProfileCallback::m_requestedProfileActivated = false
private

Definition at line 393 of file blackmagic_common.cpp.

Referenced by ProfileActivated(), and WaitForProfileActivation().


The documentation for this class was generated from the following file: