static MMAL_STATUS_T mmalplay_event_handle(MMAL_CONNECTION_T *connection, MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer) { MMAL_STATUS_T status = MMAL_SUCCESS; LOG_INFO("%s(%p) received event %4.4s (%i bytes)", port->name, port, (char *)&buffer->cmd, (int)buffer->length); if (buffer->cmd == MMAL_EVENT_FORMAT_CHANGED && port->type == MMAL_PORT_TYPE_OUTPUT) { MMAL_EVENT_FORMAT_CHANGED_T *event = mmal_event_format_changed_get(buffer); if (event) { LOG_INFO("----------Port format changed----------"); log_format(port->format, port); LOG_INFO("-----------------to---------------------"); log_format(event->format, 0); LOG_INFO(" buffers num (opt %i, min %i), size (opt %i, min: %i)", event->buffer_num_recommended, event->buffer_num_min, event->buffer_size_recommended, event->buffer_size_min); LOG_INFO("----------------------------------------"); } status = mmal_connection_event_format_changed(connection, buffer); } mmal_buffer_header_release(buffer); return status; }
static void init_everything(void) { log_init("rtpengine"); log_format(rtpe_config.log_format); recording_fs_init(rtpe_config.spooldir, rtpe_config.rec_method, rtpe_config.rec_format); rtpe_ssl_init(); #if !GLIB_CHECK_VERSION(2,32,0) g_thread_init(NULL); #endif #if !(GLIB_CHECK_VERSION(2,36,0)) g_type_init(); #endif signals(); resources(); sdp_init(); dtls_init(); ice_init(); crypto_init_main(); interfaces_init(&rtpe_config.interfaces); iptables_init(); control_ng_init(); if (call_interfaces_init()) abort(); statistics_init(); codeclib_init(0); media_player_init(); }
gboolean _test_suite_run(TestContext *self, TestSuite *suite, TestCase *test) { gint i; gboolean res = TRUE; g_test_context_current = self; _test_run_hooks(TEST_HOOK_BEFORE_SUITE, suite); if (test) { res = TEST_PASSED == _test_case_run_single_test(self, test); } else { for (i = 0; i < suite->m_tests->len; i++) res &= TEST_PASSED == _test_case_run_single_test(self, (TestCase *)g_ptr_array_index(suite->m_tests, i)); } log_format(res ? LOG_DEBUG : LOG_WARNING, "Test suite run complete", msg_tag_str("suite", suite->m_name), msg_tag_bool("result", res), NULL); _test_run_hooks(TEST_HOOK_AFTER_SUITE, suite, res); return res; }
int console_receive(MasterIpcThread* ipcThread, Master* M, ChildProcess* proc, int sourceId, IpcPacket* packet) { ExceptionScope exScope; Console* volatile console = NULL; int volatile ret = false; int ex; exception_begin_try(B(ipcThread), &exScope); switch ((ex = exception_try(B(ipcThread)))) { case Try: ret = console_do_receive(ipcThread, M, proc, sourceId, packet, &console); break; default: if (console) console_destroy(console); log_format(B(ipcThread), LogError, "[console_receive] Error (%i): %s", ex, string_data(exception_message(B(ipcThread)))); exception_handled(B(ipcThread)); break; } exception_end_try(B(ipcThread)); return ret; }
void log_print_init(const char *appname) { if (!appname) appname = "<unknown>"; log_format(LOG_DEFAULT_CONF, NULL, LOG_NOTICE, "%s Build #%lu %s %s", appname, log_build, __DATE__, __TIME__); }
void log_debug(const char* message, ...) { if (!debugflag) return; va_list args; va_start(args, message); log_format("debug", message, args); va_end(args); }
void log_info(const char* message, ...) { if (!printjson) return; va_list args; va_start(args, message); log_format("info", message, args); va_end(args); }
static int parse_argv(int argc, char *argv[]) { enum { ARG_VERSION = 0x100, ARG_LOG_LEVEL, ARG_LOG_TIME, }; static const struct option options[] = { { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, ARG_VERSION }, { "log-level", required_argument, NULL, ARG_LOG_LEVEL }, { "log-time", no_argument, NULL, ARG_LOG_TIME }, {} }; int c; while ((c = getopt_long(argc, argv, "h", options, NULL)) >= 0) { switch (c) { case 'h': return help(); case ARG_VERSION: puts(PACKAGE_STRING); return 0; case ARG_LOG_LEVEL: log_max_sev = atoi(optarg); break; case ARG_LOG_TIME: log_init_time(); break; case '?': return -EINVAL; } } if (optind < argc) { log_error("unparsed remaining arguments starting with: %s", argv[optind]); return -EINVAL; } log_format(LOG_DEFAULT_BASE, NULL, LOG_INFO, "miracled - revision %s %s %s", "some-rev-TODO-xyz", __DATE__, __TIME__); return 1; }
void zc_mgr_init(MasterIpcThread* ipcThread, ZoneClusterMgr* mgr, lua_State* L) { mgr->maxZonesPerCluster = EQP_ZONE_CLUSTER_DEFAULT_ZONES_PER_PROCESS; mgr->nextZoneClusterPort = EQP_ZONE_CLUSTER_PORT_RANGE_START; mgr->activeZoneClusters = array_create_type(B(ipcThread), ZoneCluster*); mgr->zoneClustersBySourceId = array_create_type(B(ipcThread), ZoneClusterBySourceId); mgr->zoneReservations = array_create_type(B(ipcThread), ZoneReservation); mgr->zoneShortNameMap = zone_short_name_map_create(B(ipcThread)); mgr->ipcThread = ipcThread; if (lua_sys_run_file_no_throw(B(ipcThread), L, ZONE_CLUSTER_CONFIG, 1)) { if (!lua_isfunction(L, -1)) { log_format(B(ipcThread), LogLua, "[zc_mgr_init] Expected config script '" ZONE_CLUSTER_CONFIG "' to return a function; aborting zone cluster initialization"); lua_pop(L, 1); return; } lua_pushlightuserdata(L, mgr); lua_sys_call_no_throw(B(ipcThread), L, 1, 0); } }
static MMAL_STATUS_T mmalplay_setup_container_reader(MMALPLAY_T *ctx, MMAL_COMPONENT_T *reader, const char *uri) { MMAL_PARAMETER_SEEK_T seek = {{MMAL_PARAMETER_SEEK, sizeof(MMAL_PARAMETER_SEEK_T)},0,0}; MMAL_PARAMETER_STRING_T *param = 0; unsigned int param_size, track_audio, track_video; MMAL_STATUS_T status = MMAL_EINVAL; uint32_t encoding; size_t uri_len; if(!reader->output_num) { LOG_ERROR("%s doesn't have output ports", reader->name); goto error; } /* Open the given URI */ uri_len = strlen(uri); param_size = sizeof(MMAL_PARAMETER_STRING_T) + uri_len; param = malloc(param_size); if(!param) { LOG_ERROR("out of memory"); status = MMAL_ENOMEM; goto error; } memset(param, 0, param_size); param->hdr.id = MMAL_PARAMETER_URI; param->hdr.size = param_size; vcos_safe_strcpy(param->str, uri, uri_len + 1, 0); status = mmal_port_parameter_set(reader->control, ¶m->hdr); if(status != MMAL_SUCCESS && status != MMAL_ENOSYS) { LOG_ERROR("%s could not open file %s", reader->name, uri); goto error; } status = MMAL_SUCCESS; /* Look for a video track */ for(track_video = 0; track_video < reader->output_num; track_video++) if(reader->output[track_video]->format->type == MMAL_ES_TYPE_VIDEO) break; if(track_video != reader->output_num) { ctx->reader_video = reader->output[track_video]; /* Try to detect still images */ encoding = ctx->reader_video->format->encoding; if (encoding == MMAL_ENCODING_JPEG || encoding == MMAL_ENCODING_GIF || encoding == MMAL_ENCODING_PNG || encoding == MMAL_ENCODING_PPM || encoding == MMAL_ENCODING_TGA || encoding == MMAL_ENCODING_BMP) ctx->is_still_image = 1; } /* Look for an audio track */ for(track_audio = 0; track_audio < reader->output_num; track_audio++) if(reader->output[track_audio]->format->type == MMAL_ES_TYPE_AUDIO) break; if(track_audio != reader->output_num) ctx->reader_audio = reader->output[track_audio]; if(track_video == reader->output_num && track_audio == reader->output_num) { LOG_ERROR("no track to decode"); status = MMAL_EINVAL; goto error; } LOG_INFO("----Reader input port format-----"); if(track_video != reader->output_num) log_format(reader->output[track_video]->format, 0); if(track_audio != reader->output_num) log_format(reader->output[track_audio]->format, 0); if(ctx->options.seeking) { LOG_DEBUG("seek to %fs", ctx->options.seeking); seek.offset = ctx->options.seeking * INT64_C(1000000); status = mmal_port_parameter_set(reader->control, &seek.hdr); if(status != MMAL_SUCCESS) LOG_ERROR("failed to seek to %fs", ctx->options.seeking); } error: if(param) free(param); return status; }
static MMAL_STATUS_T mmalplay_connection_create(MMALPLAY_T *ctx, MMAL_PORT_T *out, MMAL_PORT_T *in, uint32_t flags) { MMAL_CONNECTION_T **connection = &ctx->connection[ctx->connection_num]; uint32_t encoding_override = MMAL_ENCODING_UNKNOWN; MMAL_RECT_T *rect_override = NULL; MMAL_BOOL_T format_override = MMAL_FALSE; MMAL_STATUS_T status; if (ctx->connection_num >= MMAL_COUNTOF(ctx->connection)) return MMAL_ENOMEM; /* Globally enable tunnelling if requested by the user */ flags |= ctx->options.tunnelling ? MMAL_CONNECTION_FLAG_TUNNELLING : 0; /* Apply any override to the format specified by the user */ if (out == ctx->video_out_port) { encoding_override = ctx->options.output_format; rect_override = &ctx->options.output_rect; } else if (out == ctx->converter_out_port) { encoding_override = ctx->options.render_format; rect_override = &ctx->options.render_rect; } if (encoding_override != MMAL_ENCODING_UNKNOWN && encoding_override != out->format->encoding) { out->format->encoding = encoding_override; format_override = MMAL_TRUE; } if (rect_override && rect_override->width && rect_override->height) { out->format->es->video.crop = *rect_override; out->format->es->video.width = rect_override->width; out->format->es->video.height = rect_override->height; format_override = MMAL_TRUE; } if (format_override) { status = mmal_port_format_commit(out); if (status != MMAL_SUCCESS) { LOG_ERROR("cannot override format on output port %s", out->name); return status; } } /* Create the actual connection */ status = mmal_connection_create(connection, out, in, flags); if (status != MMAL_SUCCESS) { LOG_ERROR("cannot create connection"); return status; } /* Set our connection callback */ (*connection)->callback = mmalplay_connection_cb; (*connection)->user_data = (void *)ctx; log_format(out->format, out); log_format(in->format, in); ctx->connection_num++; return MMAL_SUCCESS; }
void log_str(char* string, unsigned long ref) { log_format("string: \"%s\"; return address 0x%08X\n", string, ref); }
void main(void) { long lxsize; LogEntry loginfo; int status; char buf[200]; /* File system setup and partitioning */ fs_ext = fs_get_flash_lx(); if (fs_ext == 0) { printf("No flash available!\n"); exit(1); } /* * Get the size of the entire flash with the given sector size */ lxsize = fs_get_lx_size(fs_ext, 1, MY_LS_SHIFT); /* * Partition the filesystem - always give 1/8 to the backup partition, as we * have room to spare. */ backup_ext = fs_setup(fs_ext, MY_LS_SHIFT, 0, NULL, FS_PARTITION_FRACTION, 0x2000, MY_LS_SHIFT, 0, NULL); if (backup_ext == 0) { printf("Could not create backup extent!\n"); exit(2); } lxsize = fs_get_lx_size(fs_ext, 1, MY_LS_SHIFT); lxsize = fs_get_lx_size(backup_ext, 1, MY_LS_SHIFT); if (fs_init(0, 0) != 0) { printf("Filesystem failed to initialize!\n"); exit(3); } #ifdef FORMAT if (lx_format(fs_ext, 0) != 0) { printf("Filesystem failed to format!\n"); exit(4); } if (lx_format(backup_ext, 0) != 0) { printf("Backup area failed to format!\n"); exit(5); } #endif fs_set_lx(fs_ext, fs_ext); /* * Reset all logs if requested. */ #ifdef RESET_ALL_LOGS log_open(LOG_DEST_ALL, 1); #endif /* * This call is necessary to initialize target communications * beween the DeviceMate and the target processor. */ targetproc_init(); /* * Initialize the TCP/IP stack and the web server. */ sock_init(); http_init(); /* * The following improves interactive performance of the web server. */ tcp_reserveport(80); /* * Print out previous log entries */ if (!log_seek(LOG_DEST_FS2, 0)) { printf("Scanning previous log entries, oldest first...\n"); for (;;) { if (log_next(LOG_DEST_FS2, &loginfo) < 0) break; printf("%s\n", log_format(&loginfo, buf, sizeof(buf), 1)); } printf("End of messages.\n"); } /* * Log an initial entry. */ #define LOG_TEST_STRING "~~~{ Started test run. }~~~" status = log_put(LOG_MAKEPRI(2,LOG_INFO), 0, LOG_TEST_STRING, strlen(LOG_TEST_STRING)); if (status != 0) { printf("Failed to add 1st message: %d\n", status); } /* * Drive the target communications and the web server continuously. * This is all that is necessary as the main part of the program. */ for (;;) { targetproc_tick(); http_handler(); } }
int main() { LogEntry loginfo; int status; char buf[200]; #ifdef LOG_USE_FS2 #define DEST_IN_USE LOG_DEST_FS2 printf("Initializing file system. Please wait...\n"); status = fs_init(0,0); if (status) { printf("Could not initialize filesystem, error number %d\n", errno); exit(2); } printf("...done. Using LX#%d for logging\n", (int)LOG_FS2_DATALX(0)); #else #define DEST_IN_USE LOG_DEST_XMEM #endif #ifdef RESET_ALL_LOGS log_open(LOG_DEST_ALL, 1); #endif targetproc_init(); reprint: #ifdef READ_BACKWARDS if (!log_seek(DEST_IN_USE, 1)) { printf("Scanning previous log entries, most recent first...\n"); for (;;) { if (log_prev(DEST_IN_USE, &loginfo) < 0) break; printf("%s\n", log_format(&loginfo, buf, sizeof(buf), 1)); } printf("End of messages.\n"); } #else if (!log_seek(DEST_IN_USE, 0)) { printf("Scanning previous log entries, oldest first...\n"); for (;;) { if (log_next(DEST_IN_USE, &loginfo) < 0) break; printf("%s\n", log_format(&loginfo, buf, sizeof(buf), 1)); } printf("End of messages.\n"); } #endif #define LOG_TEST_STRING "~~~{ Started test run. }~~~" status = log_put(LOG_MAKEPRI(2,LOG_INFO), 0, LOG_TEST_STRING, strlen(LOG_TEST_STRING)); if (status != 0) printf("Failed to add 1st message: %d\n", status); for (;;) { targetproc_tick(); if (kbhit()) { gets(buf); // ignore it goto reprint; } } }
void log_error(const char* message, ...) { va_list args; va_start(args, message); log_format("error", message, args); va_end(args); }