Print Capture Devices Example for C++

HRESULT PrintDevice(LPCTSTR title, IltmsDevice* device) 
{ 
   HRESULT hr; 
   // print the device's properties 
   _tprintf(_T("--- %s Device ---\n\n"), title); 
   { 
      CComBSTR v; 
      hr = device->get_Name(&v); 
      if(FAILED(hr)) 
         goto error; 
      _tprintf(_T("Name = \"%s\"\n"), (LPCTSTR) CString(v)); 
   } 
   { 
      CComBSTR v; 
      hr = device->get_FriendlyName(&v); 
      if(FAILED(hr)) 
         goto error; 
      _tprintf(_T("FriendlyName = \"%s\"\n"), (LPCTSTR) CString(v)); 
   } 
   { 
      VARIANT_BOOL v; 
      hr = device->get_Selected(&v); 
      if(FAILED(hr)) 
         goto error; 
      _tprintf(_T("Selected = %s\n"), (v == VARIANT_TRUE) ? _T("true") : _T("false")); 
   } 
error: 
   _tprintf(_T("\n")); 
   return hr; 
} 
HRESULT PrintDevices(LPCTSTR title, IltmsDevices* devices) 
{ 
   HRESULT hr; 
   long count; 
   _tprintf(_T("--- %s Devices ---\n\n"), title); 
   hr = devices->Refresh(); 
   if(FAILED(hr)) 
      goto error; 
   hr = devices->get_Count(&count); 
   if(FAILED(hr)) 
      goto error; 
   for(long index = 0; index < count; index++) 
   { 
      CComPtr device; 
      hr = devices->Item(index, &device); 
      if(FAILED(hr)) 
         goto error; 
      hr = PrintDevice(title, device); 
      if(FAILED(hr)) 
         goto error; 
   } 
error: 
   _tprintf(_T("\n")); 
   return hr; 
} 
HRESULT PrintLiveStreamDevices(IltmsLiveStream* stream) 
{ 
   HRESULT hr; 
   // print the capture devices to stdout 
   _tprintf(_T("--- Live Stream Devices ---\n\n")); 
   { 
      CComPtr devices; 
      hr = stream->get_VideoDevices(&devices); 
      if(FAILED(hr)) 
         goto error; 
      hr = PrintDevices(_T("Video"), devices); 
      if(FAILED(hr)) 
         goto error; 
   } 
   { 
      CComPtr devices; 
      hr = stream->get_AudioDevices(&devices); 
      if(FAILED(hr)) 
         goto error; 
      hr = PrintDevices(_T("Audio"), devices); 
      if(FAILED(hr)) 
         goto error; 
   } 
error: 
   _tprintf(_T("\n")); 
   return hr; 
} 
HRESULT PrintCaptureDevices(IltmsServer* server) 
{ 
   HRESULT hr; 
   CComPtr streams; 
   CComPtr stream; 
   // create live stream just to enumerate the devices 
   hr = server->GetLiveStreams(&streams); 
   if(FAILED(hr)) 
      goto error; 
   hr = streams->CreateLiveStream(&stream); 
   if(FAILED(hr)) 
      goto error; 
   hr = PrintLiveStreamDevices(stream); 
   if(FAILED(hr)) 
      goto error; 
error: 
   return hr; 
} 

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Media Streaming C API Help