Print Audio Types Example for C++

HRESULT PrintAudioType(IltmsAudioType* audiotype) 
{ 
   HRESULT hr; 
 
   // print the audio type properties to stdout 
   _tprintf(_T("--- Audio Type ---\n\n")); 
 
   { 
      CComBSTR v; 
      hr = audiotype->get_FriendlyName(&v); 
      if(FAILED(hr)) 
         goto error; 
      _tprintf(_T("FriendlyName = \"%s\"\n"), (LPCTSTR) CString(v)); 
 
   } 
   { 
      long v; 
      hr = audiotype->get_BitRate(&v); 
      if(FAILED(hr)) 
         goto error; 
      _tprintf(_T("Bit Rate = %ld\n"), v); 
 
   } 
   { 
      long v; 
      hr = audiotype->get_SampleRate(&v); 
      if(FAILED(hr)) 
         goto error; 
      _tprintf(_T("Sample Rate = %ld\n"), v); 
 
   } 
   { 
      long v; 
      hr = audiotype->get_Channels(&v); 
      if(FAILED(hr)) 
         goto error; 
      _tprintf(_T("Channels = %ld\n"), v); 
 
   } 
   { 
      VARIANT_BOOL v; 
      hr = audiotype->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 PrintAudioTypes(IltmsAudioTypes* audiotypes) 
{ 
   HRESULT hr; 
 
   // print the audio types to stdout 
   _tprintf(_T("--- Audio Types ---\n\n")); 
 
   long count; 
 
   hr = audiotypes->get_Count(&count); 
   for(long index = 0; index < count; index++) 
   { 
      CComPtr<IltmsAudioType> audiotype; 
      hr = audiotypes->Item(index, &audiotype); 
      if(FAILED(hr)) 
         goto error; 
      hr = PrintAudioType(audiotype); 
      if(FAILED(hr)) 
         goto error; 
   } 
error: 
   _tprintf(_T("\n")); 
   return hr; 
} 
 
HRESULT PrintLiveStreamAudioTypes(IltmsLiveStream* stream) 
{ 
   HRESULT hr; 
 
   // print the stream audio types to stdout 
   _tprintf(_T("--- Live Stream Audio Types ---\n\n")); 
 
 
   { 
      CComPtr<IltmsAudioTypes> audiotypes; 
      hr = stream->get_AudioTypes(&audiotypes); 
      if(FAILED(hr)) 
         goto error; 
      hr = PrintAudioTypes(audiotypes); 
      if(FAILED(hr)) 
         goto error; 
 
   } 
 
error: 
   _tprintf(_T("\n")); 
   return hr; 
} 
 
HRESULT PrintAvailableAudioTypes(IltmsServer* server) 
{ 
   HRESULT hr; 
   CComPtr<IltmsLiveStreams> streams; 
   CComPtr<IltmsLiveStream> stream; 
 
   // create live stream just to enumerate the audio types 
   hr = server->GetLiveStreams(&streams); 
   if(FAILED(hr)) 
      goto error; 
 
   hr = streams->CreateLiveStream(&stream); 
   if(FAILED(hr)) 
      goto error; 
 
   hr = PrintLiveStreamAudioTypes(stream); 
   if(FAILED(hr)) 
      goto error; 
error: 
   return hr; 
} 
Help Version 20.0.2019.3.12
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2019 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Media Streaming C API Help