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() { GMainContext *ctx = g_main_context_default(); GMainLoop *loop = g_main_loop_new(ctx, FALSE); owr_init_with_main_context(ctx); owr_get_capture_sources(OWR_MEDIA_TYPE_AUDIO|OWR_MEDIA_TYPE_VIDEO, got_sources, NULL); g_main_loop_run(loop); return 0; }
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() { GMainContext *ctx = g_main_context_default(); GMainLoop *loop = g_main_loop_new(ctx, FALSE); /* PREPARE FOR RECEIVING */ OwrPayload *receive_payload; owr_init_with_main_context(ctx); 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"); recv_session_audio = owr_media_session_new(FALSE); recv_session_video = owr_media_session_new(FALSE); send_session_audio = owr_media_session_new(TRUE); send_session_video = owr_media_session_new(TRUE); g_signal_connect(recv_session_audio, "on-new-candidate", G_CALLBACK(got_candidate), send_session_audio); g_signal_connect(recv_session_video, "on-new-candidate", G_CALLBACK(got_candidate), send_session_video); g_signal_connect(send_session_audio, "on-new-candidate", G_CALLBACK(got_candidate), recv_session_audio); g_signal_connect(send_session_video, "on-new-candidate", G_CALLBACK(got_candidate), recv_session_video); // 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); g_object_unref(receive_payload); owr_transport_agent_add_session(recv_transport_agent, OWR_SESSION(recv_session_video)); // 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); g_object_unref(receive_payload); owr_transport_agent_add_session(recv_transport_agent, OWR_SESSION(recv_session_audio)); /* PREPARE FOR SENDING */ owr_get_capture_sources(OWR_MEDIA_TYPE_AUDIO|OWR_MEDIA_TYPE_VIDEO, got_sources, NULL); g_timeout_add_seconds(5, (GSourceFunc)dump_cb, NULL); g_main_loop_run(loop); return 0; }
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; }