Last active
October 26, 2015 22:54
-
-
Save RSully/ff40878b9b1311f20c49 to your computer and use it in GitHub Desktop.
Sample code for libCEC initialization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// main.cpp | |
// Test libCEC | |
// | |
// Created by Ryan Sullivan on 10/26/15. | |
// Copyright © 2015 Ryan Sullivan. All rights reserved. | |
// | |
#import <iostream> | |
#import <cec.h> | |
#import <list> | |
using namespace CEC; | |
int main(int argc, const char * argv[]) { | |
libcec_configuration *config; | |
ICECCallbacks *callbacks; | |
ICECAdapter *adapter; | |
config = new libcec_configuration(); | |
config->Clear(); | |
snprintf(config->strDeviceName, 13, "mac-cec-test"); | |
config->clientVersion = LIBCEC_VERSION_CURRENT; | |
config->bActivateSource = 0; | |
config->deviceTypes.Add(CEC_DEVICE_TYPE_RECORDING_DEVICE); | |
callbacks = new ICECCallbacks(); | |
callbacks->Clear(); | |
config->callbacks = callbacks; | |
adapter = (ICECAdapter*)CECInitialise(config); | |
adapter->InitVideoStandalone(); | |
int count = 10; | |
cec_adapter_descriptor *adapterList = (cec_adapter_descriptor*)malloc(count * sizeof(cec_adapter_descriptor)); | |
int real_count; | |
real_count = adapter->DetectAdapters(adapterList, count); | |
if (real_count > count) { | |
count = real_count; | |
adapterList = (cec_adapter_descriptor*)realloc(adapterList, count * sizeof(cec_adapter_descriptor)); | |
real_count = adapter->DetectAdapters(adapterList, count); | |
} | |
std::list<cec_adapter_descriptor> adapters; | |
for (int i = 0; i < real_count; i++) { | |
printf("found: %s\n", adapterList[i].strComPath); | |
adapters.push_back(adapterList[i]); | |
} | |
free(adapterList); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment