caps = gst_pad_get_current_caps(pad);
structure = gst_caps_get_structure(caps, 0);
mime = gst_structure_get_name(structure);
-
caps_str = gst_caps_to_string(caps);
LOG_WARNING("%s", caps_str);
g_free(caps_str);
- if (__get_media_format_mimetype(mime, &mimetype) != WEBRTC_ERROR_NONE) {
- gst_caps_unref(caps);
- media_format_unref(format);
- return NULL;
- }
- gst_caps_unref(caps);
+ if (__get_media_format_mimetype(mime, &mimetype) != WEBRTC_ERROR_NONE)
+ goto error;
- LOG_INFO("mimetype[0x%x]", mimetype);
+ LOG_WARNING("media format mimetype[0x%x]", mimetype);
if (mimetype & MEDIA_FORMAT_VIDEO) {
+ gint width = 0;
+ gint height = 0;
+
ret = media_format_set_video_mime(format, mimetype);
if (ret != MEDIA_FORMAT_ERROR_NONE) {
LOG_ERROR("failed to media_format_set_video_mime()");
- media_format_unref(format);
- return NULL;
+ goto error;
+ }
+
+ /* FIXME: We also need to get width/height in case of H26x with not this way. */
+ gst_structure_get_int(structure, "width", &width);
+ gst_structure_get_int(structure, "height", &height);
+ if (width > 0 && height > 0) {
+ ret |= media_format_set_video_width(format, width);
+ ret |= media_format_set_video_height(format, height);
+ if (ret != MEDIA_FORMAT_ERROR_NONE) {
+ LOG_ERROR("failed to media_format_set_video_width/height()");
+ goto error;
+ }
}
} else if (mimetype & MEDIA_FORMAT_AUDIO) {
ret = media_format_set_audio_mime(format, mimetype);
if (ret != MEDIA_FORMAT_ERROR_NONE) {
LOG_ERROR("failed to media_format_set_audio_mime()");
- media_format_unref(format);
- return NULL;
+ goto error;
}
}
+ gst_caps_unref(caps);
return format;
+
+error:
+ gst_caps_unref(caps);
+ media_format_unref(format);
+ return NULL;
}
static int __media_packet_finalize_cb(media_packet_h packet, int error_code, void *user_data)