static void got_sources(GList *sources, gpointer user_data) { OwrMediaSource *source = NULL; static gboolean have_video = FALSE, have_audio = FALSE; g_assert(sources); while (sources && (source = sources->data)) { OwrMediaType media_type; OwrSourceType source_type; g_assert(OWR_IS_MEDIA_SOURCE(source)); g_object_get(source, "type", &source_type, "media-type", &media_type, NULL); if (!disable_video && !have_video && media_type == OWR_MEDIA_TYPE_VIDEO && source_type == OWR_SOURCE_TYPE_CAPTURE) { OwrVideoRenderer *renderer; OwrPayload *payload; have_video = TRUE; payload = owr_video_payload_new(OWR_CODEC_TYPE_VP8, 103, 90000, TRUE, FALSE); g_object_set(payload, "width", 1280, "height", 720, "framerate", 30.0, NULL); g_object_set(payload, "rtx-payload-type", 123, NULL); owr_media_session_set_send_payload(send_session_video, payload); owr_media_session_set_send_source(send_session_video, source); owr_transport_agent_add_session(send_transport_agent, OWR_SESSION(send_session_video)); g_print("Displaying self-view\n"); renderer = owr_video_renderer_new(NULL); g_assert(renderer); g_object_set(renderer, "width", 1280, "height", 720, "max-framerate", 30.0, NULL); owr_media_renderer_set_source(OWR_MEDIA_RENDERER(renderer), source); video_renderer = OWR_MEDIA_RENDERER(renderer); video_source = g_object_ref(source); } else if (!disable_audio && !have_audio && media_type == OWR_MEDIA_TYPE_AUDIO && source_type == OWR_SOURCE_TYPE_CAPTURE) { OwrPayload *payload; have_audio = TRUE; payload = owr_audio_payload_new(OWR_CODEC_TYPE_OPUS, 100, 48000, 1); owr_media_session_set_send_payload(send_session_audio, payload); owr_media_session_set_send_source(send_session_audio, source); owr_transport_agent_add_session(send_transport_agent, OWR_SESSION(send_session_audio)); audio_source = g_object_ref(source); } if ((disable_video || have_video) && (disable_audio || have_audio)) break; sources = sources->next; } }
OwrSession* new_session() { Debug("new session"); OwrMediaSession *session = owr_media_session_new(TRUE); g_signal_connect(session, "on-new-candidate", G_CALLBACK(got_candidate), NULL); g_signal_connect(session, "on-candidate-gathering-done", G_CALLBACK(candidate_gathering_done_go), NULL); g_signal_connect(session, "notify::dtls-certificate", G_CALLBACK(got_dtls_certificate), NULL); if (local_sources != NULL && local_sources->data != NULL) { Debug("setting local source"); owr_media_session_set_send_source(session, OWR_MEDIA_SOURCE(local_sources->data)); } // TODO make the specs (payload:120, encoding VP8, clock: 9000) mutable. OwrPayload *payload = owr_video_payload_new(OWR_CODEC_TYPE_VP8, 120, 90000, TRUE, TRUE); owr_media_session_set_send_payload(session, payload); // Add session to the transport. owr_transport_agent_add_session(transport_agent, OWR_SESSION(session)); return OWR_SESSION(session); }
static void got_sources(GList *sources, gpointer user_data) { OwrMediaSource *source = NULL; static gboolean have_video = FALSE, have_audio = FALSE; g_assert(sources); while (sources && (source = sources->data)) { OwrMediaType media_type; OwrSourceType source_type; g_assert(OWR_IS_MEDIA_SOURCE(source)); g_object_get(source, "type", &source_type, "media-type", &media_type, NULL); if (remote_addr) { owr_transport_agent_add_helper_server(send_transport_agent, OWR_HELPER_SERVER_TYPE_STUN, "stun.services.mozilla.com", 3478, NULL, NULL); owr_transport_agent_add_helper_server(recv_transport_agent, OWR_HELPER_SERVER_TYPE_STUN, "stun.services.mozilla.com", 3478, NULL, NULL); } if (!disable_video && !have_video && media_type == OWR_MEDIA_TYPE_VIDEO) { OwrVideoRenderer *renderer; OwrPayload *payload; have_video = TRUE; owr_bus_add_message_origin(bus, OWR_MESSAGE_ORIGIN(source)); payload = owr_video_payload_new(OWR_CODEC_TYPE_VP8, 103, 90000, TRUE, FALSE); g_object_set(payload, "width", 640, "height", 480, "framerate", 30.0, NULL); g_object_set(payload, "rtx-payload-type", 123, NULL); if (adaptation) g_object_set(payload, "adaptation", TRUE, NULL); owr_media_session_set_send_payload(send_session_video, payload); owr_media_session_set_send_source(send_session_video, source); owr_transport_agent_add_session(recv_transport_agent, OWR_SESSION(recv_session_video)); owr_transport_agent_add_session(send_transport_agent, OWR_SESSION(send_session_video)); g_print("Displaying self-view\n"); renderer = owr_video_renderer_new(NULL); g_assert(renderer); owr_bus_add_message_origin(bus, OWR_MESSAGE_ORIGIN(renderer)); g_object_set(renderer, "width", 640, "height", 480, "max-framerate", 30.0, NULL); owr_media_renderer_set_source(OWR_MEDIA_RENDERER(renderer), source); video_renderer = OWR_MEDIA_RENDERER(renderer); video_source = g_object_ref(source); } else if (!disable_audio && !have_audio && media_type == OWR_MEDIA_TYPE_AUDIO) { OwrPayload *payload; have_audio = TRUE; owr_bus_add_message_origin(bus, OWR_MESSAGE_ORIGIN(source)); payload = owr_audio_payload_new(OWR_CODEC_TYPE_OPUS, 100, 48000, 1); owr_media_session_set_send_payload(send_session_audio, payload); owr_media_session_set_send_source(send_session_audio, source); owr_transport_agent_add_session(recv_transport_agent, OWR_SESSION(recv_session_audio)); owr_transport_agent_add_session(send_transport_agent, OWR_SESSION(send_session_audio)); audio_source = g_object_ref(source); } if ((disable_video || have_video) && (disable_audio || have_audio)) break; sources = sources->next; } }