コード例 #1
0
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;
    }
}
コード例 #2
0
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);
}
コード例 #3
0
ファイル: test_self_view.c プロジェクト: altname/openwebrtc
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);
}
コード例 #4
0
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);
    }
}
コード例 #5
0
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);
}
コード例 #6
0
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;
    }
}