int main() { guint64 start_time; guint64 end_time; start_time = g_get_monotonic_time(); g_log_set_handler(NULL, G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL, log_handler, NULL); /* This whole thing should be over within 1s */ g_thread_new("test-timeout-thread", timeout_thread_func, NULL); /* we're not running the mainloop, as the message bus should work without it */ owr_init(NULL); test_illegal_argument_warnings(); test_message_type_mask(); test_destruction(); test_mass_messaging(); test_refcounting(); end_time = g_get_monotonic_time(); g_print("\n *** Test successful! ***\n"); g_print("Duration: %.3fs\n\n", (end_time - start_time) / 1000000.0); return 0; }
/** * owr_init_with_main_context: * @main_context: a #GMainContext to be used in OpenWebRTC. * * Initializes the OpenWebRTC library with the given #GMainContext. When this * function is used the application is responsible for iterating the * #GMainContext. Either This function or owr_init() must be called before * doing anything else. */ void owr_init_with_main_context(GMainContext *main_context) { g_return_if_fail(!owr_initialized); g_return_if_fail(main_context); owr_main_context = main_context; owr_init(); }
int main() { owr_init(NULL); owr_get_capture_sources(OWR_MEDIA_TYPE_AUDIO|OWR_MEDIA_TYPE_VIDEO, got_sources, NULL); owr_run(); return 0; }
int main(int argc, char **argv) { GOptionContext *options; GError *error = NULL; gint success_count = 0; gint test_count = 0; options = g_option_context_new(NULL); g_option_context_add_main_entries(options, entries, NULL); if (!g_option_context_parse(options, &argc, &argv, &error)) { g_print("Failed to parse options: %s\n", error->message); return -2; } g_print("\n *** Starting data channel test ***\n\n"); owr_init(NULL); owr_run_in_background(); if (setup_transport_agents()) { success_count += run_prenegotiated_channel_test(TRUE); test_count++; success_count += run_requested_channel_test(TRUE); test_count++; success_count += run_requested_channel_test(FALSE); test_count++; success_count += run_prenegotiated_channel_test(FALSE); test_count++; g_print("\n%d / %d test were successful\n", success_count, test_count); g_print("Dumping transport agent pipelines!\n"); write_dot_file("test_data_channel-left-transport_agent", owr_transport_agent_get_dot_data(left_transport_agent), TRUE); write_dot_file("test_data_channel-right-transport_agent", owr_transport_agent_get_dot_data(right_transport_agent), TRUE); return test_count - success_count; } g_print("\n *** Failed initial setup ***\n\n"); return -1; }
int main(int argc, char **argv) { GOptionContext *options; GError *error = NULL; options = g_option_context_new(NULL); g_option_context_add_main_entries(options, entries, NULL); if (!g_option_context_parse(options, &argc, &argv, &error)) { g_print("Failed to parse options: %s\n", error->message); return 1; } if (disable_audio && disable_video) { g_print("Audio and video disabled. Nothing to do.\n"); return 0; } /* PREPARE FOR RECEIVING */ OwrPayload *receive_payload; owr_init(NULL); bus = owr_bus_new(); owr_bus_set_message_callback(bus, (OwrBusMessageCallback) bus_message_print_callback, message_origin_name_func, NULL); if (!print_messages) { g_object_set(bus, "message-type-mask", OWR_MESSAGE_TYPE_ERROR, NULL); } owr_bus_add_message_origin(bus, OWR_MESSAGE_ORIGIN(owr_window_registry_get())); recv_transport_agent = owr_transport_agent_new(FALSE); g_assert(OWR_IS_TRANSPORT_AGENT(recv_transport_agent)); owr_bus_add_message_origin(bus, OWR_MESSAGE_ORIGIN(recv_transport_agent)); owr_transport_agent_set_local_port_range(recv_transport_agent, 5120, 5127); if (!remote_addr) owr_transport_agent_add_local_address(recv_transport_agent, "127.0.0.1"); else if (local_addr) owr_transport_agent_add_local_address(recv_transport_agent, local_addr); // SEND send_transport_agent = owr_transport_agent_new(TRUE); g_assert(OWR_IS_TRANSPORT_AGENT(send_transport_agent)); owr_bus_add_message_origin(bus, OWR_MESSAGE_ORIGIN(send_transport_agent)); owr_transport_agent_set_local_port_range(send_transport_agent, 5120, 5129); if (!remote_addr) owr_transport_agent_add_local_address(send_transport_agent, "127.0.0.1"); if (!disable_video) { recv_session_video = owr_media_session_new(FALSE); owr_bus_add_message_origin(bus, OWR_MESSAGE_ORIGIN(recv_session_video)); send_session_video = owr_media_session_new(TRUE); owr_bus_add_message_origin(bus, OWR_MESSAGE_ORIGIN(send_session_video)); } if (!disable_audio) { recv_session_audio = owr_media_session_new(FALSE); owr_bus_add_message_origin(bus, OWR_MESSAGE_ORIGIN(recv_session_audio)); send_session_audio = owr_media_session_new(TRUE); owr_bus_add_message_origin(bus, OWR_MESSAGE_ORIGIN(send_session_audio)); } if (!disable_video) { g_signal_connect(recv_session_video, "on-new-candidate", G_CALLBACK(got_candidate), send_session_video); g_signal_connect(send_session_video, "on-new-candidate", G_CALLBACK(got_candidate), recv_session_video); if (remote_addr) { g_signal_connect(recv_session_video, "on-candidate-gathering-done", G_CALLBACK(gathering_done), send_session_video); g_signal_connect(send_session_video, "on-candidate-gathering-done", G_CALLBACK(gathering_done), recv_session_video); owr_session_set_local_port(OWR_SESSION(send_session_video), OWR_COMPONENT_TYPE_RTP, 5120); owr_session_set_local_port(OWR_SESSION(send_session_video), OWR_COMPONENT_TYPE_RTCP, 5121); owr_session_set_local_port(OWR_SESSION(recv_session_video), OWR_COMPONENT_TYPE_RTP, 5122); owr_session_set_local_port(OWR_SESSION(recv_session_video), OWR_COMPONENT_TYPE_RTCP, 5123); } } if (!disable_audio) { g_signal_connect(recv_session_audio, "on-new-candidate", G_CALLBACK(got_candidate), send_session_audio); g_signal_connect(send_session_audio, "on-new-candidate", G_CALLBACK(got_candidate), recv_session_audio); if (remote_addr) { g_signal_connect(recv_session_audio, "on-candidate-gathering-done", G_CALLBACK(gathering_done), send_session_audio); g_signal_connect(send_session_audio, "on-candidate-gathering-done", G_CALLBACK(gathering_done), recv_session_audio); owr_session_set_local_port(OWR_SESSION(send_session_audio), OWR_COMPONENT_TYPE_RTP, 5124); owr_session_set_local_port(OWR_SESSION(send_session_audio), OWR_COMPONENT_TYPE_RTCP, 5125); owr_session_set_local_port(OWR_SESSION(recv_session_audio), OWR_COMPONENT_TYPE_RTP, 5126); owr_session_set_local_port(OWR_SESSION(recv_session_audio), OWR_COMPONENT_TYPE_RTCP, 5127); } } // VIDEO if (!disable_video) { g_signal_connect(recv_session_video, "on-incoming-source", G_CALLBACK(got_remote_source), NULL); receive_payload = owr_video_payload_new(OWR_CODEC_TYPE_VP8, 103, 90000, TRUE, FALSE); g_object_set(receive_payload, "rtx-payload-type", 123, NULL); if (adaptation) g_object_set(receive_payload, "adaptation", TRUE, NULL); owr_media_session_add_receive_payload(recv_session_video, receive_payload); } // AUDIO if (!disable_audio) { g_signal_connect(recv_session_audio, "on-incoming-source", G_CALLBACK(got_remote_source), NULL); receive_payload = owr_audio_payload_new(OWR_CODEC_TYPE_OPUS, 100, 48000, 1); owr_media_session_add_receive_payload(recv_session_audio, receive_payload); } /* PREPARE FOR SENDING */ if (!uri) { owr_get_capture_sources( (!disable_video ? OWR_MEDIA_TYPE_VIDEO : 0) | (!disable_audio ? OWR_MEDIA_TYPE_AUDIO : 0), got_sources, NULL); } else { uri_source_agent = owr_uri_source_agent_new(uri); g_signal_connect(uri_source_agent, "on-new-source", G_CALLBACK(on_new_source), NULL); owr_uri_source_agent_play(uri_source_agent); } g_timeout_add_seconds(10, (GSourceFunc)dump_cb, NULL); owr_run(); g_free(remote_addr); g_free(uri); return 0; }
void init() { owr_init(NULL); owr_run_in_background(); owr_get_capture_sources(OWR_MEDIA_TYPE_AUDIO | OWR_MEDIA_TYPE_VIDEO, (OwrCaptureSourcesCallback)got_local_sources, NULL); }
int main(int argc, char **argv) { GOptionContext *options; GError *error = NULL; options = g_option_context_new(NULL); g_option_context_add_main_entries(options, entries, NULL); if (!g_option_context_parse(options, &argc, &argv, &error)) { g_print("Failed to parse options: %s\n", error->message); return 1; } if (disable_audio && disable_video) { g_print("Audio and video disabled. Nothing to do.\n"); return 0; } /* PREPARE FOR RECEIVING */ OwrPayload *receive_payload; owr_init(NULL); recv_transport_agent = owr_transport_agent_new(FALSE); g_assert(OWR_IS_TRANSPORT_AGENT(recv_transport_agent)); owr_transport_agent_set_local_port_range(recv_transport_agent, 5000, 5999); owr_transport_agent_add_local_address(recv_transport_agent, "127.0.0.1"); // SEND send_transport_agent = owr_transport_agent_new(TRUE); g_assert(OWR_IS_TRANSPORT_AGENT(send_transport_agent)); owr_transport_agent_set_local_port_range(send_transport_agent, 5000, 5999); owr_transport_agent_add_local_address(send_transport_agent, "127.0.0.1"); if (!disable_video) { recv_session_video = owr_media_session_new(FALSE); send_session_video = owr_media_session_new(TRUE); } if (!disable_audio) { recv_session_audio = owr_media_session_new(FALSE); send_session_audio = owr_media_session_new(TRUE); } if (!disable_video) { g_signal_connect(recv_session_video, "on-new-candidate", G_CALLBACK(got_candidate), send_session_video); g_signal_connect(send_session_video, "on-new-candidate", G_CALLBACK(got_candidate), recv_session_video); } if (!disable_audio) { g_signal_connect(recv_session_audio, "on-new-candidate", G_CALLBACK(got_candidate), send_session_audio); g_signal_connect(send_session_audio, "on-new-candidate", G_CALLBACK(got_candidate), recv_session_audio); } // VIDEO if (!disable_video) { g_signal_connect(recv_session_video, "on-incoming-source", G_CALLBACK(got_remote_source), NULL); receive_payload = owr_video_payload_new(OWR_CODEC_TYPE_VP8, 103, 90000, TRUE, FALSE); g_object_set(receive_payload, "rtx-payload-type", 123, NULL); owr_media_session_add_receive_payload(recv_session_video, receive_payload); owr_transport_agent_add_session(recv_transport_agent, OWR_SESSION(recv_session_video)); } // AUDIO if (!disable_audio) { g_signal_connect(recv_session_audio, "on-incoming-source", G_CALLBACK(got_remote_source), NULL); receive_payload = owr_audio_payload_new(OWR_CODEC_TYPE_OPUS, 100, 48000, 1); owr_media_session_add_receive_payload(recv_session_audio, receive_payload); owr_transport_agent_add_session(recv_transport_agent, OWR_SESSION(recv_session_audio)); } /* PREPARE FOR SENDING */ owr_get_capture_sources((!disable_video ? OWR_MEDIA_TYPE_VIDEO : 0) | (!disable_audio ? OWR_MEDIA_TYPE_AUDIO : 0), got_sources, NULL); g_timeout_add_seconds(10, (GSourceFunc)dump_cb, NULL); owr_run(); return 0; }