bool openavbTLAVDECCRunTalker(tl_handle_t handle, U16 configIdx, U16 descriptorType, U16 descriptorIdx, void *pVoidTalkerStreamInfo) { AVB_TRACE_ENTRY(AVB_TRACE_TL); if (!handle) { AVB_LOG_ERROR("Invalid handle."); AVB_TRACE_EXIT(AVB_TRACE_TL); return FALSE; } tl_state_t *pTLState = (tl_state_t *)handle; if (pTLState->cfg.intf_cb.intf_avdecc_init_cb) { pTLState->cfg.intf_cb.intf_avdecc_init_cb(pTLState->pMediaQ, configIdx, descriptorType, descriptorIdx); } if (pTLState->cfg.map_cb.map_avdecc_init_cb) { pTLState->cfg.map_cb.map_avdecc_init_cb(pTLState->pMediaQ, configIdx, descriptorType, descriptorIdx); } if (!openavbTLIsRunning(handle)) { openavbTLRun(handle); } AVB_TRACE_EXIT(AVB_TRACE_TL); return TRUE; }
bool openavbTLAVDECCRunListener(tl_handle_t handle, U16 configIdx, U16 descriptorType, U16 descriptorIdx, void *pVoidListenerStreamInfo) { AVB_TRACE_ENTRY(AVB_TRACE_TL); if (!handle) { AVB_LOG_ERROR("Invalid handle."); AVB_TRACE_EXIT(AVB_TRACE_TL); return FALSE; } if (!pVoidListenerStreamInfo) { AVB_LOG_ERROR("Invalid argument"); AVB_TRACE_EXIT(AVB_TRACE_TL); return FALSE; } openavb_acmp_ListenerStreamInfo_t *pListenerStreamInfo = pVoidListenerStreamInfo; tl_state_t *pTLState = (tl_state_t *)handle; memcpy(pTLState->cfg.dest_addr.mac->ether_addr_octet, pListenerStreamInfo->stream_dest_mac, ETH_ALEN); memcpy(pTLState->cfg.stream_addr.mac->ether_addr_octet, pListenerStreamInfo->stream_id, ETH_ALEN); U8 *pStreamUID = pListenerStreamInfo->stream_id + 6; // pTLState->cfg.stream_uid = ntohs(*(U16 *)(pStreamUID)); U16 align16; memcpy(&align16, (U16 *)(pStreamUID), sizeof(U16)); pTLState->cfg.stream_uid = ntohs(align16); if (pTLState->cfg.intf_cb.intf_avdecc_init_cb) { pTLState->cfg.intf_cb.intf_avdecc_init_cb(pTLState->pMediaQ, configIdx, descriptorType, descriptorIdx); } if (pTLState->cfg.map_cb.map_avdecc_init_cb) { pTLState->cfg.map_cb.map_avdecc_init_cb(pTLState->pMediaQ, configIdx, descriptorType, descriptorIdx); } openavbTLRun(handle); AVB_TRACE_EXIT(AVB_TRACE_TL); return TRUE; }
/********************************************** * main */ int main(int argc, char *argv[]) { AVB_TRACE_ENTRY(AVB_TRACE_HOST); int iniIdx = 0; char *programName; char *optIfnameGlobal = NULL; programName = strrchr(argv[0], '/'); programName = programName ? programName + 1 : argv[0]; if (argc < 2) { openavbTlHostUsage(programName); exit(-1); } tl_handle_t *tlHandleList = NULL; int i1; // Process command line bool optDone = FALSE; while (!optDone) { int opt = getopt(argc, argv, "hI:"); if (opt != EOF) { switch (opt) { case 'I': optIfnameGlobal = strdup(optarg); break; case 'h': default: openavbTlHostUsage(programName); exit(-1); } } else { optDone = TRUE; } } osalAVBInitialize(optIfnameGlobal); iniIdx = optind; U32 tlCount = argc - iniIdx; if (!openavbTLInitialize(tlCount)) { AVB_LOG_ERROR("Unable to initialize talker listener library"); osalAVBFinalize(); exit(-1); } // Setup signal handler // We catch SIGINT and shutdown cleanly bool err; struct sigaction sa; sa.sa_handler = openavbTLSigHandler; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; err = sigaction(SIGINT, &sa, NULL); if (err) { AVB_LOG_ERROR("Failed to setup SIGINT handler"); osalAVBFinalize(); exit(-1); } err = sigaction(SIGUSR1, &sa, NULL); if (err) { AVB_LOG_ERROR("Failed to setup SIGUSR1 handler"); osalAVBFinalize(); exit(-1); } registerStaticMapModule(openavbMapPipeInitialize); registerStaticMapModule(openavbMapAVTPAudioInitialize); registerStaticMapModule(openavbMapCtrlInitialize); registerStaticMapModule(openavbMapH264Initialize); registerStaticMapModule(openavbMapMjpegInitialize); registerStaticMapModule(openavbMapMpeg2tsInitialize); registerStaticMapModule(openavbMapNullInitialize); registerStaticMapModule(openavbMapUncmpAudioInitialize); registerStaticIntfModule(openavbIntfEchoInitialize); registerStaticIntfModule(openavbIntfCtrlInitialize); registerStaticIntfModule(openavbIntfLoggerInitialize); registerStaticIntfModule(openavbIntfNullInitialize); registerStaticIntfModule(openavbIntfToneGenInitialize); registerStaticIntfModule(openavbIntfViewerInitialize); registerStaticIntfModule(openavbIntfAlsaInitialize); registerStaticIntfModule(openavbIntfMjpegGstInitialize); registerStaticIntfModule(openavbIntfMpeg2tsFileInitialize); registerStaticIntfModule(openavbIntfMpeg2tsGstInitialize); registerStaticIntfModule(openavbIntfWavFileInitialize); registerStaticIntfModule(openavbIntfH264RtpGstInitialize); tlHandleList = calloc(1, sizeof(tl_handle_t) * tlCount); // Open all streams for (i1 = 0; i1 < tlCount; i1++) { tlHandleList[i1] = openavbTLOpen(); } // Parse ini and configure all streams for (i1 = 0; i1 < tlCount; i1++) { openavb_tl_cfg_t cfg; openavb_tl_cfg_name_value_t NVCfg; char iniFile[1024]; snprintf(iniFile, sizeof(iniFile), "%s", argv[i1 + iniIdx]); if (optIfnameGlobal && !strcasestr(iniFile, ",ifname=")) { snprintf(iniFile + strlen(iniFile), sizeof(iniFile), ",ifname=%s", optIfnameGlobal); } openavbTLInitCfg(&cfg); memset(&NVCfg, 0, sizeof(NVCfg)); if (!openavbTLReadIniFileOsal(tlHandleList[i1], iniFile, &cfg, &NVCfg)) { AVB_LOGF_ERROR("Error reading ini file: %s\n", argv[i1 + 1]); osalAVBFinalize(); exit(-1); } if (!openavbTLConfigure(tlHandleList[i1], &cfg, &NVCfg)) { AVB_LOGF_ERROR("Error configuring: %s\n", argv[i1 + 1]); osalAVBFinalize(); exit(-1); } int i2; for (i2 = 0; i2 < NVCfg.nLibCfgItems; i2++) { free(NVCfg.libCfgNames[i2]); free(NVCfg.libCfgValues[i2]); } } #ifdef AVB_FEATURE_GSTREAMER // If we're supporting the interface modules which use GStreamer, // initialize GStreamer here to avoid errors. gst_init(0, NULL); #endif for (i1 = 0; i1 < tlCount; i1++) { openavbTLRun(tlHandleList[i1]); } while (bRunning) { sleep(1); } for (i1 = 0; i1 < tlCount; i1++) { openavbTLStop(tlHandleList[i1]); } for (i1 = 0; i1 < tlCount; i1++) { openavbTLClose(tlHandleList[i1]); } openavbTLCleanup(); #ifdef AVB_FEATURE_GSTREAMER // If we're supporting the interface modules which use GStreamer, // De-initialize GStreamer to clean up resources. gst_deinit(); #endif osalAVBFinalize(); AVB_TRACE_EXIT(AVB_TRACE_HOST); exit(0); }