+ /* If we got an offer and we have no webrtcbin, we need to parse the SDP,
+ * get the payload types, then start the pipeline */
+ if (!webrtc1 && our_id) {
+ guint medias_len, formats_len;
+ guint opus_pt = 0, vp8_pt = 0;
+
+ gst_println ("Parsing offer to find payload types");
+
+ medias_len = gst_sdp_message_medias_len (sdp);
+ for (int i = 0; i < medias_len; i++) {
+ const GstSDPMedia *media = gst_sdp_message_get_media (sdp, i);
+ formats_len = gst_sdp_media_formats_len (media);
+ for (int j = 0; j < formats_len; j++) {
+ guint pt;
+ GstCaps *caps;
+ GstStructure *s;
+ const char *fmt, *encoding_name;
+
+ fmt = gst_sdp_media_get_format (media, j);
+ if (g_strcmp0 (fmt, "webrtc-datachannel") == 0)
+ continue;
+ pt = atoi (fmt);
+ caps = gst_sdp_media_get_caps_from_media (media, pt);
+ s = gst_caps_get_structure (caps, 0);
+ encoding_name = gst_structure_get_string (s, "encoding-name");
+ if (vp8_pt == 0 && g_strcmp0 (encoding_name, "VP8") == 0)
+ vp8_pt = pt;
+ if (opus_pt == 0 && g_strcmp0 (encoding_name, "OPUS") == 0)
+ opus_pt = pt;
+ }
+ }
+
+ g_assert_cmpint (opus_pt, !=, 0);
+ g_assert_cmpint (vp8_pt, !=, 0);
+
+ gst_println ("Starting pipeline with opus pt: %u vp8 pt: %u", opus_pt,
+ vp8_pt);
+
+ if (!start_pipeline (FALSE, opus_pt, vp8_pt)) {
+ cleanup_and_quit_loop ("ERROR: failed to start pipeline",
+ PEER_CALL_ERROR);
+ }
+ }
+