/* Log information on all statically configured streams. * (Dynamically configured streams are logged by SRP.) */ void openavbEndPtLogAllStaticStreams(void) { bool hdrDone = FALSE; if(x_cfg.noSrp) { clientStream_t **lpp; for(lpp = &x_streamList; *lpp != NULL; lpp = &(*lpp)->next) { if ((*lpp)->clientHandle != AVB_ENDPOINT_HANDLE_INVALID) { if (!hdrDone) { AVB_LOG_INFO("Statically Configured Streams:"); AVB_LOG_INFO(" | SR | Destination | ----Max Frame(s)--- |"); AVB_LOG_INFO(" Role | Stream Id | Class | Address | Size | Per Interval |"); hdrDone = TRUE; } if ((*lpp)->role == clientTalker) { AVB_LOGF_INFO(" Talker | %02x:%02x:%02x:%02x:%02x:%02x - %4d | %c | %02x:%02x:%02x:%02x:%02x:%02x | %4u | %2u |", (*lpp)->streamID.addr[0], (*lpp)->streamID.addr[1], (*lpp)->streamID.addr[2], (*lpp)->streamID.addr[3], (*lpp)->streamID.addr[4], (*lpp)->streamID.addr[5], (*lpp)->streamID.uniqueID, AVB_CLASS_LABEL((*lpp)->srClass), (*lpp)->destAddr[0], (*lpp)->destAddr[1], (*lpp)->destAddr[2], (*lpp)->destAddr[3], (*lpp)->destAddr[4], (*lpp)->destAddr[5], (*lpp)->tSpec.maxFrameSize, (*lpp)->tSpec.maxIntervalFrames ); } else if ((*lpp)->role == clientListener) { AVB_LOGF_INFO(" Listener | %02x:%02x:%02x:%02x:%02x:%02x - %4d | - | --:--:--:--:--:-- | -- | -- |", (*lpp)->streamID.addr[0], (*lpp)->streamID.addr[1], (*lpp)->streamID.addr[2], (*lpp)->streamID.addr[3], (*lpp)->streamID.addr[4], (*lpp)->streamID.addr[5], (*lpp)->streamID.uniqueID ); } } } } }
static void* avdeccServerThread(void *arg) { AVB_TRACE_ENTRY(AVB_TRACE_AVDECC); while (avdeccRunning) { if (!openavbAvdeccInitialize()) { AVB_LOG_ERROR("Failed to initialize AVDECC"); break; } AVB_LOG_DEBUG("AVDECC Initialized"); if (!openavbAvdeccStart()) { AVB_LOG_ERROR("Failed to start AVDECC"); openavbAvdeccStop(); break; } if (!openavbAvdeccMsgServerOpen()) { AVB_LOG_ERROR("Failed to start AVDECC Server"); openavbAvdeccStop(); break; } else { AVB_LOG_INFO("AVDECC Started"); avdeccInitSucceeded = TRUE; // Wait until AVDECC is finished. while (avdeccRunning) { openavbAvdeccMsgSrvrService(); } openavbAvdeccMsgServerClose(); } // Stop AVDECC AVB_LOG_DEBUG("AVDECC Stopping"); openavbAvdeccStop(); AVB_LOG_INFO("AVDECC Stopped"); } // Shutdown AVDECC openavbAvdeccCleanup(); avdeccRunning = FALSE; AVB_TRACE_EXIT(AVB_TRACE_AVDECC); return NULL; }
bool openavbAVDECCStopTalker(openavb_aem_descriptor_stream_io_t *pDescriptorStreamOutput, U16 configIdx, openavb_acmp_TalkerStreamInfo_t *pTalkerStreamInfo) { AVB_TRACE_ENTRY(AVB_TRACE_AVDECC); // Sanity tests. if (!pDescriptorStreamOutput) { AVB_LOG_ERROR("openavbAVDECCStopTalker Invalid descriptor"); AVB_TRACE_EXIT(AVB_TRACE_AVDECC); return FALSE; } if (!pTalkerStreamInfo) { AVB_LOG_ERROR("openavbAVDECCStopTalker Invalid streaminfo"); AVB_TRACE_EXIT(AVB_TRACE_AVDECC); return FALSE; } if (!pDescriptorStreamOutput->stream) { AVB_LOG_ERROR("openavbAVDECCStopTalker Invalid StreamInput descriptor stream"); AVB_TRACE_EXIT(AVB_TRACE_AVDECC); return FALSE; } if (!pDescriptorStreamOutput->stream->client) { AVB_LOG_ERROR("openavbAVDECCStopTalker Invalid stream client pointer"); AVB_TRACE_EXIT(AVB_TRACE_AVDECC); return FALSE; } // Don't request if already stopped. if (pDescriptorStreamOutput->stream->client->lastReportedState == OPENAVB_AVDECC_MSG_STOPPED) { AVB_LOG_INFO("Talker state change to Stopped ignored, as Talker already Stopped"); AVB_TRACE_EXIT(AVB_TRACE_AVDECC); return TRUE; } // Send the request to the client. if (!openavbAvdeccMsgSrvrChangeRequest(pDescriptorStreamOutput->stream->client->avdeccMsgHandle, OPENAVB_AVDECC_MSG_STOPPED)) { AVB_LOG_ERROR("Error requesting Talker change to Stopped"); AVB_TRACE_EXIT(AVB_TRACE_AVDECC); return FALSE; } AVB_LOG_INFO("Talker state change to Stopped requested"); AVB_TRACE_EXIT(AVB_TRACE_AVDECC); return TRUE; }
bool openavbAVDECCRunListener(openavb_aem_descriptor_stream_io_t *pDescriptorStreamInput, U16 configIdx, openavb_acmp_ListenerStreamInfo_t *pListenerStreamInfo) { AVB_TRACE_ENTRY(AVB_TRACE_AVDECC); // Sanity tests. if (!pDescriptorStreamInput) { AVB_LOG_ERROR("openavbAVDECCRunListener Invalid descriptor"); AVB_TRACE_EXIT(AVB_TRACE_AVDECC); return FALSE; } if (!pListenerStreamInfo) { AVB_LOG_ERROR("openavbAVDECCRunListener Invalid streaminfo"); AVB_TRACE_EXIT(AVB_TRACE_AVDECC); return FALSE; } if (!pDescriptorStreamInput->stream) { AVB_LOG_ERROR("openavbAVDECCRunListener Invalid StreamInput descriptor stream"); AVB_TRACE_EXIT(AVB_TRACE_AVDECC); return FALSE; } if (!pDescriptorStreamInput->stream->client) { AVB_LOG_ERROR("openavbAVDECCRunListener Invalid stream client pointer"); AVB_TRACE_EXIT(AVB_TRACE_AVDECC); return FALSE; } // Send the Stream ID to the client. // The client will stop a running Listener if the settings differ from its current values. if (!openavbAvdeccMsgSrvrListenerStreamID(pDescriptorStreamInput->stream->client->avdeccMsgHandle, ((pListenerStreamInfo->flags & OPENAVB_ACMP_FLAG_CLASS_B) != 0 ? SR_CLASS_B : SR_CLASS_A), pListenerStreamInfo->stream_id, /* The first 6 bytes of the steam_id are the source MAC Address */ (((U16) pListenerStreamInfo->stream_id[6]) << 8 | (U16) pListenerStreamInfo->stream_id[7]), pListenerStreamInfo->stream_dest_mac, pListenerStreamInfo->stream_vlan_id)) { AVB_LOG_ERROR("Error send Stream ID to Listener"); AVB_TRACE_EXIT(AVB_TRACE_AVDECC); return FALSE; } // Tell the client to start running. if (!openavbAvdeccMsgSrvrChangeRequest(pDescriptorStreamInput->stream->client->avdeccMsgHandle, OPENAVB_AVDECC_MSG_RUNNING)) { AVB_LOG_ERROR("Error requesting Listener change to Running"); AVB_TRACE_EXIT(AVB_TRACE_AVDECC); return FALSE; } AVB_LOG_INFO("Listener state change to Running requested"); AVB_TRACE_EXIT(AVB_TRACE_AVDECC); return TRUE; }
/*********************************************** * Signal handler - used to respond to signals. * Allows graceful cleanup. */ static void openavbTLSigHandler(int signal) { AVB_TRACE_ENTRY(AVB_TRACE_HOST); if (signal == SIGINT) { AVB_LOG_INFO("Host shutting down"); bRunning = FALSE; } else if (signal == SIGUSR1) { AVB_LOG_DEBUG("Waking up streaming thread"); } else { AVB_LOG_ERROR("Unexpected signal"); } AVB_TRACE_EXIT(AVB_TRACE_HOST); }
void stopAvdecc() { AVB_TRACE_ENTRY(AVB_TRACE_AVDECC); avdeccRunning = FALSE; pthread_join(avdeccServerHandle, NULL); AVB_LOG_INFO("Shutting down"); // Free the INI file items. while (streamList) { openavb_tl_data_cfg_t * del = streamList; streamList = streamList->next; free(del); } AVB_TRACE_EXIT(AVB_TRACE_AVDECC); }
/*********************************************** * Signal handler - used to respond to signals. * Allows graceful cleanup. */ static void openavbAvdeccSigHandler(int signal) { AVB_TRACE_ENTRY(AVB_TRACE_HOST); if (signal == SIGINT || signal == SIGTERM) { if (avdeccRunning) { AVB_LOG_INFO("AVDECC shutting down"); avdeccRunning = FALSE; } else { // Force shutdown exit(2); } } else { AVB_LOG_ERROR("Unexpected signal"); } AVB_TRACE_EXIT(AVB_TRACE_HOST); }
bool openavbAVDECCRunTalker(openavb_aem_descriptor_stream_io_t *pDescriptorStreamOutput, U16 configIdx, openavb_acmp_TalkerStreamInfo_t *pTalkerStreamInfo) { AVB_TRACE_ENTRY(AVB_TRACE_AVDECC); // Sanity tests. if (!pDescriptorStreamOutput) { AVB_LOG_ERROR("openavbAVDECCRunTalker Invalid descriptor"); AVB_TRACE_EXIT(AVB_TRACE_AVDECC); return FALSE; } if (!pTalkerStreamInfo) { AVB_LOG_ERROR("openavbAVDECCRunTalker Invalid streaminfo"); AVB_TRACE_EXIT(AVB_TRACE_AVDECC); return FALSE; } if (!pDescriptorStreamOutput->stream) { AVB_LOG_ERROR("openavbAVDECCRunTalker Invalid StreamInput descriptor stream"); AVB_TRACE_EXIT(AVB_TRACE_AVDECC); return FALSE; } if (!pDescriptorStreamOutput->stream->client) { AVB_LOG_ERROR("openavbAVDECCRunTalker Invalid stream client pointer"); AVB_TRACE_EXIT(AVB_TRACE_AVDECC); return FALSE; } // Tell the client to start running. // Note that that Talker may already be running; this call ensures that it really is. if (!openavbAvdeccMsgSrvrChangeRequest(pDescriptorStreamOutput->stream->client->avdeccMsgHandle, OPENAVB_AVDECC_MSG_RUNNING)) { AVB_LOG_ERROR("Error requesting Talker change to Running"); AVB_TRACE_EXIT(AVB_TRACE_AVDECC); return FALSE; } AVB_LOG_INFO("Talker state change to Running requested"); AVB_TRACE_EXIT(AVB_TRACE_AVDECC); return TRUE; }
static gboolean bus_message(GstBus *bus, GstMessage *message, void *pv) { switch (GST_MESSAGE_TYPE(message)) { case GST_MESSAGE_ERROR: { GError *err = NULL; gchar *dbg_info = NULL; gst_message_parse_error(message, &err, &dbg_info); AVB_LOGF_ERROR("GStreamer ERROR message from element %s: %s", GST_OBJECT_NAME(message->src), err->message); AVB_LOGF_ERROR("Additional info: %s\n", (dbg_info) ? dbg_info : "none"); g_error_free(err); g_free(dbg_info); break; } case GST_MESSAGE_WARNING: { GError *err = NULL; gchar *dbg_info = NULL; gst_message_parse_warning(message, &err, &dbg_info); AVB_LOGF_WARNING("GStreamer WARNING message from element %s: %s", GST_OBJECT_NAME(message->src), err->message); AVB_LOGF_WARNING("Additional info: %s\n", (dbg_info) ? dbg_info : "none"); g_error_free(err); g_free(dbg_info); break; } case GST_MESSAGE_INFO: { GError *err = NULL; gchar *dbg_info = NULL; gst_message_parse_info(message, &err, &dbg_info); AVB_LOGF_ERROR("GStreamer INFO message from element %s: %s", GST_OBJECT_NAME(message->src), err->message); AVB_LOGF_ERROR("Additional info: %s\n", (dbg_info) ? dbg_info : "none"); g_error_free(err); g_free(dbg_info); break; } case GST_MESSAGE_STATE_CHANGED: { GstState old_state, new_state; gst_message_parse_state_changed(message, &old_state, &new_state, NULL); AVB_LOGF_DEBUG("Element %s changed state from %s to %s", GST_OBJECT_NAME(message->src), gst_element_state_get_name(old_state), gst_element_state_get_name(new_state)); break; } case GST_MESSAGE_STREAM_STATUS: { // not so valuable break; } case GST_MESSAGE_EOS: AVB_LOG_INFO("EOS received"); break; default: AVB_LOGF_INFO("GStreamer '%s' message from element %s", gst_message_type_get_name(GST_MESSAGE_TYPE(message)), GST_OBJECT_NAME(message->src)); break; } return TRUE; }
void openavbAVDECCPauseStream(openavb_aem_descriptor_stream_io_t *pDescriptor, bool bPause) { AVB_TRACE_ENTRY(AVB_TRACE_AVDECC); // Sanity test. if (!pDescriptor) { AVB_LOG_ERROR("openavbAVDECCPauseStream Invalid descriptor"); AVB_TRACE_EXIT(AVB_TRACE_AVDECC); return; } if (!pDescriptor->stream) { AVB_LOG_ERROR("openavbAVDECCPauseStream Invalid StreamInput descriptor stream"); AVB_TRACE_EXIT(AVB_TRACE_AVDECC); return; } if (!pDescriptor->stream->client) { AVB_LOG_ERROR("openavbAVDECCPauseStream Invalid stream client pointer"); AVB_TRACE_EXIT(AVB_TRACE_AVDECC); return; } if (pDescriptor->descriptor_type == OPENAVB_AEM_DESCRIPTOR_STREAM_INPUT) { if (bPause) { // If the client is not running (or already paused), ignore this command. if (pDescriptor->stream->client->lastReportedState != OPENAVB_AVDECC_MSG_RUNNING) { AVB_LOG_DEBUG("Listener state change to pause ignored, as Listener not running"); AVB_TRACE_EXIT(AVB_TRACE_AVDECC); return; } // Send the request to the client. if (!openavbAvdeccMsgSrvrChangeRequest(pDescriptor->stream->client->avdeccMsgHandle, OPENAVB_AVDECC_MSG_PAUSED)) { AVB_LOG_ERROR("Error requesting Listener change to Paused"); AVB_TRACE_EXIT(AVB_TRACE_AVDECC); return; } AVB_LOG_INFO("Listener state change from Running to Paused requested"); } else { // If the client is not paused, ignore this command. if (pDescriptor->stream->client->lastReportedState != OPENAVB_AVDECC_MSG_PAUSED) { AVB_LOG_DEBUG("Listener state change to pause ignored, as Listener not paused"); AVB_TRACE_EXIT(AVB_TRACE_AVDECC); return; } // Send the request to the client. if (!openavbAvdeccMsgSrvrChangeRequest(pDescriptor->stream->client->avdeccMsgHandle, OPENAVB_AVDECC_MSG_RUNNING)) { AVB_LOG_ERROR("Error requesting Listener change to Running"); AVB_TRACE_EXIT(AVB_TRACE_AVDECC); return; } AVB_LOG_INFO("Listener state change from Paused to Running requested"); } } else if (pDescriptor->descriptor_type == OPENAVB_AEM_DESCRIPTOR_STREAM_OUTPUT) { if (bPause) { // If the client is not running (or already paused), ignore this command. if (pDescriptor->stream->client->lastReportedState != OPENAVB_AVDECC_MSG_RUNNING) { AVB_LOG_DEBUG("Talker state change to pause ignored, as Talker not running"); AVB_TRACE_EXIT(AVB_TRACE_AVDECC); return; } // Send the request to the client. if (!openavbAvdeccMsgSrvrChangeRequest(pDescriptor->stream->client->avdeccMsgHandle, OPENAVB_AVDECC_MSG_PAUSED)) { AVB_LOG_ERROR("Error requesting Talker change to Paused"); AVB_TRACE_EXIT(AVB_TRACE_AVDECC); return; } AVB_LOG_INFO("Talker state change from Running to Paused requested"); } else { // If the client is not paused, ignore this command. if (pDescriptor->stream->client->lastReportedState != OPENAVB_AVDECC_MSG_PAUSED) { AVB_LOG_DEBUG("Talker state change to pause ignored, as Talker not paused"); AVB_TRACE_EXIT(AVB_TRACE_AVDECC); return; } // Send the request to the client. if (!openavbAvdeccMsgSrvrChangeRequest(pDescriptor->stream->client->avdeccMsgHandle, OPENAVB_AVDECC_MSG_RUNNING)) { AVB_LOG_ERROR("Error requesting Talker change to Running"); AVB_TRACE_EXIT(AVB_TRACE_AVDECC); return; } AVB_LOG_INFO("Talker state change from Paused to Running requested"); } } else { AVB_LOG_ERROR("openavbAVDECCPauseStream unsupported descriptor"); } AVB_TRACE_EXIT(AVB_TRACE_AVDECC); }