void got_sources(GList *sources, gpointer user_data) { OwrMediaSource *source; static gboolean have_video = FALSE, have_audio = FALSE; g_assert(sources); g_print("Got sources!\n"); if (have_video && have_audio) return; if (!have_video) { OwrVideoRenderer *renderer; source = pick_a_source(sources, OWR_MEDIA_TYPE_VIDEO, MANUAL_SOURCE_SELECTION); if (source) { have_video = TRUE; 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 = source; } } if (!have_audio) { OwrAudioRenderer *renderer; source = pick_a_source(sources, OWR_MEDIA_TYPE_AUDIO, MANUAL_SOURCE_SELECTION); if (source) { have_audio = TRUE; renderer = owr_audio_renderer_new(); g_assert(renderer); owr_media_renderer_set_source(OWR_MEDIA_RENDERER(renderer), source); audio_renderer = OWR_MEDIA_RENDERER(renderer); audio_source = source; } } g_timeout_add(5000, dump_pipeline, NULL); }
static void got_sources(GList *sources, gpointer user_data) { OwrMediaSource *source = NULL; static gboolean have_video = FALSE, have_audio = FALSE; g_assert(sources); g_print("Got sources!\n"); 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 (!have_video && media_type == OWR_MEDIA_TYPE_VIDEO && source_type == OWR_SOURCE_TYPE_CAPTURE) { OwrVideoRenderer *renderer; have_video = TRUE; 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 = source; } else if (!have_audio && media_type == OWR_MEDIA_TYPE_AUDIO && source_type == OWR_SOURCE_TYPE_CAPTURE) { OwrAudioRenderer *renderer; have_audio = TRUE; renderer = owr_audio_renderer_new(); g_assert(renderer); owr_media_renderer_set_source(OWR_MEDIA_RENDERER(renderer), source); audio_renderer = OWR_MEDIA_RENDERER(renderer); audio_source = source; } if (have_video && have_audio) break; sources = sources->next; } g_timeout_add(5000, dump_pipeline, NULL); }
static void got_remote_source(OwrMediaSession *session, OwrMediaSource *source, gpointer user_data) { gchar *name = NULL; OwrMediaRenderer *owr_renderer = NULL; OwrMediaType media_type; g_assert(!user_data); g_object_get(source, "media-type", &media_type, "name", &name, NULL); g_print("Got remote source: %s\n", name); if (media_type == OWR_MEDIA_TYPE_VIDEO) { OwrVideoRenderer *renderer; g_print("Creating video renderer\n"); renderer = owr_video_renderer_new(NULL); g_assert(renderer); g_print("Connecting source to video renderer\n"); owr_media_renderer_set_source(OWR_MEDIA_RENDERER(renderer), source); owr_renderer = OWR_MEDIA_RENDERER(renderer); } else if (media_type == OWR_MEDIA_TYPE_AUDIO) { OwrAudioRenderer *renderer; g_print("Creating audio renderer\n"); renderer = owr_audio_renderer_new(); g_assert(renderer); g_print("Connecting source to audio renderer\n"); owr_media_renderer_set_source(OWR_MEDIA_RENDERER(renderer), source); owr_renderer = OWR_MEDIA_RENDERER(renderer); } g_free(name); if (media_type == OWR_MEDIA_TYPE_VIDEO) { owr_media_source_dump_dot_file(source, "test_receive-got_remote_source-video-source", TRUE); owr_media_renderer_dump_dot_file(owr_renderer, "test_receive-got_remote_source-video-renderer", TRUE); } else { owr_media_source_dump_dot_file(source, "test_receive-got_remote_source-audio-source", TRUE); owr_media_renderer_dump_dot_file(owr_renderer, "test_receive-got_remote_source-audio-renderer", TRUE); } }
static void got_remote_source(OwrMediaSession *session, OwrMediaSource *source, gpointer user_data) { gchar *name = NULL; OwrMediaType media_type; g_assert(!user_data); g_object_get(source, "media-type", &media_type, "name", &name, NULL); g_print("Got remote source: %s\n", name); if (media_type == OWR_MEDIA_TYPE_VIDEO) { OwrVideoRenderer *renderer; g_print("Creating video renderer\n"); renderer = owr_video_renderer_new(NULL); g_assert(renderer); owr_bus_add_message_origin(bus, OWR_MESSAGE_ORIGIN(renderer)); g_print("Connecting source to video renderer\n"); owr_media_renderer_set_source(OWR_MEDIA_RENDERER(renderer), source); remote_video_renderer = OWR_MEDIA_RENDERER(renderer); } else if (media_type == OWR_MEDIA_TYPE_AUDIO) { OwrAudioRenderer *renderer; g_print("Creating audio renderer\n"); renderer = owr_audio_renderer_new(); g_assert(renderer); owr_bus_add_message_origin(bus, OWR_MESSAGE_ORIGIN(renderer)); g_print("Connecting source to audio renderer\n"); owr_media_renderer_set_source(OWR_MEDIA_RENDERER(renderer), source); remote_audio_renderer = OWR_MEDIA_RENDERER(renderer); } g_free(name); if (media_type == OWR_MEDIA_TYPE_VIDEO) remote_video_source = g_object_ref(source); else remote_audio_source = g_object_ref(source); }