Name: libmm-camcorder
Summary: Camera and recorder library
-Version: 0.10.268
+Version: 0.10.269
Release: 0
Group: Multimedia/Libraries
License: Apache-2.0
void _mmcamcorder_element_release_noti(gpointer data, GObject *where_the_object_was);
gboolean _mmcamcorder_add_elements_to_bin(GstBin *bin, GList *element_list);
gboolean _mmcamcorder_link_elements(GList *element_list);
+GstCaps *_mmcamcorder_get_video_caps(MMHandleType handle, MMPixelFormatType format, int width, int height, int fps, int rotate);
/* Message */
#ifdef _MMCAMCORDER_ENABLE_IDLE_MESSAGE_CALLBACK
int fps_auto = 0;
unsigned int caps_fourcc = 0;
gboolean do_set_caps = FALSE;
- char fourcc_string[sizeof(fourcc) + 1];
- gchar *caps_str = NULL;
-#ifdef _MMCAMCORDER_PRODUCT_TV
- gint maxwidth = 0;
- gint maxheight = 0;
- int display_surface_type = MM_DISPLAY_SURFACE_NULL;
-#endif /* _MMCAMCORDER_PRODUCT_TV */
-
GstCaps *caps = NULL;
mmf_camcorder_t *hcamcorder = NULL;
if (!do_set_caps)
return TRUE;
- switch (sc->info_image->preview_format) {
- case MM_PIXEL_FORMAT_ENCODED_H264:
-#ifdef _MMCAMCORDER_PRODUCT_TV
- mm_camcorder_get_attributes(handle, NULL,
- MMCAM_DISPLAY_SURFACE, &display_surface_type,
- NULL);
- if (display_surface_type != MM_DISPLAY_SURFACE_NULL &&
- __mmcamcorder_find_max_resolution(handle, &maxwidth, &maxheight) == false) {
- MMCAM_LOG_ERROR("can not find max resolution limitation");
- return false;
- } else if (display_surface_type == MM_DISPLAY_SURFACE_NULL) {
- maxwidth = set_width;
- maxheight = set_height;
- }
-#endif /* _MMCAMCORDER_PRODUCT_TV */
- caps = gst_caps_new_simple("video/x-h264",
- "width", G_TYPE_INT, set_width,
- "height", G_TYPE_INT, set_height,
- "framerate", GST_TYPE_FRACTION, fps, 1,
- "stream-format", G_TYPE_STRING, "byte-stream",
-#ifdef _MMCAMCORDER_PRODUCT_TV
- "maxwidth", G_TYPE_INT, maxwidth,
- "maxheight", G_TYPE_INT, maxheight,
- "alignment", G_TYPE_STRING, "au",
-#endif /* _MMCAMCORDER_PRODUCT_TV */
- NULL);
- break;
- case MM_PIXEL_FORMAT_ENCODED_MJPEG:
-#ifdef _MMCAMCORDER_PRODUCT_TV
- caps = gst_caps_new_simple("video/x-jpeg",
-#else
- caps = gst_caps_new_simple("image/jpeg",
-#endif
- "width", G_TYPE_INT, set_width,
- "height", G_TYPE_INT, set_height,
- "framerate", GST_TYPE_FRACTION, fps, 1,
- NULL);
- break;
- case MM_PIXEL_FORMAT_ENCODED_VP8:
- caps = gst_caps_new_simple("video/x-vp8",
- "width", G_TYPE_INT, set_width,
- "height", G_TYPE_INT, set_height,
- "framerate", GST_TYPE_FRACTION, fps, 1,
- NULL);
- break;
- case MM_PIXEL_FORMAT_ENCODED_VP9:
- caps = gst_caps_new_simple("video/x-vp9",
- "width", G_TYPE_INT, set_width,
- "height", G_TYPE_INT, set_height,
- "framerate", GST_TYPE_FRACTION, fps, 1,
- NULL);
- break;
- break;
- default:
- memcpy(fourcc_string, (char*)&fourcc, sizeof(fourcc));
- fourcc_string[sizeof(fourcc)] = '\0';
- caps = gst_caps_new_simple("video/x-raw",
- "format", G_TYPE_STRING, fourcc_string,
- "width", G_TYPE_INT, set_width,
- "height", G_TYPE_INT, set_height,
- "framerate", GST_TYPE_FRACTION, fps, 1,
- "rotate", G_TYPE_INT, set_rotate,
- NULL);
- break;
- }
-
+ caps = _mmcamcorder_get_video_caps(handle,
+ sc->info_image->preview_format, set_width, set_height, fps, set_rotate);
if (!caps) {
MMCAM_LOG_ERROR("There are no caps");
return FALSE;
}
- caps_str = gst_caps_to_string(caps);
- MMCAM_LOG_INFO("vidoesrc new caps set [%s]", caps_str);
- g_free(caps_str);
-
MMCAMCORDER_G_OBJECT_SET_POINTER(sc->element[_MMCAMCORDER_VIDEOSRC_FILT].gst, "caps", caps);
gst_caps_unref(caps);
int width = 0;
int height = 0;
int fps = 0;
- gchar *caps_string = NULL;
GstCaps *caps = NULL;
GList *element_list = NULL;
_MMCamcorderSubContext *sc = NULL;
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_EXT_SINK].gst, "enable-last-sample", FALSE);
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_EXT_SINK].gst, "signal-handoffs", TRUE);
- caps = gst_caps_new_simple("video/x-h264",
- "width", G_TYPE_INT, width,
- "height", G_TYPE_INT, height,
- "framerate", GST_TYPE_FRACTION, fps, 1,
- NULL);
+ caps = _mmcamcorder_get_video_caps((MMHandleType)hcamcorder,
+ hcamcorder->extra_preview.format[0].pixel_format,
+ width, height, fps, -1);
if (!caps) {
MMCAM_LOG_ERROR("caps for extra preview failed");
err = MM_ERROR_CAMCORDER_GST_LINK;
goto pipeline_creation_error;
}
- caps_string = gst_caps_to_string(caps);
- if (caps_string) {
- MMCAM_LOG_INFO("set caps for capture[%s]", caps_string);
- g_free(caps_string);
- caps_string = NULL;
- }
-
MMCAMCORDER_G_OBJECT_SET_POINTER(sc->element[_MMCAMCORDER_VIDEOSRC_EXT_FILT].gst, "caps", caps);
gst_caps_unref(caps);
return TRUE;
}
+GstCaps *_mmcamcorder_get_video_caps(MMHandleType handle, MMPixelFormatType format, int width, int height, int fps, int rotate)
+{
+ int codec_type = MM_IMAGE_CODEC_JPEG;
+ guint32 fourcc = 0;
+ char fourcc_string[sizeof(guint32) + 1];
+#ifdef _MMCAMCORDER_PRODUCT_TV
+ int maxwidth = 0;
+ int maxheight = 0;
+ int display_surface_type = MM_DISPLAY_SURFACE_NULL;
+#endif /* _MMCAMCORDER_PRODUCT_TV */
+ gchar *caps_string = NULL;
+ GstCaps *caps = NULL;;
+ mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
+
+ switch (format) {
+ case MM_PIXEL_FORMAT_ENCODED_H264:
+#ifdef _MMCAMCORDER_PRODUCT_TV
+ mm_camcorder_get_attributes(handle, NULL,
+ MMCAM_DISPLAY_SURFACE, &display_surface_type,
+ NULL);
+ if (display_surface_type != MM_DISPLAY_SURFACE_NULL &&
+ __mmcamcorder_find_max_resolution(handle, &maxwidth, &maxheight) == false) {
+ MMCAM_LOG_ERROR("can not find max resolution limitation");
+ return false;
+ } else if (display_surface_type == MM_DISPLAY_SURFACE_NULL) {
+ maxwidth = width;
+ maxheight = height;
+ }
+#endif /* _MMCAMCORDER_PRODUCT_TV */
+ caps = gst_caps_new_simple("video/x-h264",
+ "stream-format", G_TYPE_STRING, "byte-stream",
+#ifdef _MMCAMCORDER_PRODUCT_TV
+ "maxwidth", G_TYPE_INT, maxwidth,
+ "maxheight", G_TYPE_INT, maxheight,
+ "alignment", G_TYPE_STRING, "au",
+#endif /* _MMCAMCORDER_PRODUCT_TV */
+ NULL);
+ break;
+ case MM_PIXEL_FORMAT_ENCODED_MJPEG:
+#ifdef _MMCAMCORDER_PRODUCT_TV
+ caps = gst_caps_new_empty_simple("video/x-jpeg");
+#else
+ caps = gst_caps_new_empty_simple("image/jpeg");
+#endif
+ break;
+ case MM_PIXEL_FORMAT_ENCODED_VP8:
+ caps = gst_caps_new_empty_simple("video/x-vp8");
+ break;
+ case MM_PIXEL_FORMAT_ENCODED_VP9:
+ caps = gst_caps_new_empty_simple("video/x-vp9");
+ break;
+ default:
+ mm_camcorder_get_attributes(handle, NULL,
+ MMCAM_IMAGE_ENCODER, &codec_type,
+ NULL);
+
+ fourcc = (guint32)_mmcamcorder_get_fourcc(format, codec_type, hcamcorder->use_zero_copy_format);
+ snprintf(fourcc_string, sizeof(fourcc_string), "%"GST_FOURCC_FORMAT, GST_FOURCC_ARGS(fourcc));
+ caps = gst_caps_new_simple("video/x-raw",
+ "format", G_TYPE_STRING, fourcc_string,
+ NULL);
+ break;
+ }
+
+ gst_caps_set_simple(caps,
+ "width", G_TYPE_INT, width,
+ "height", G_TYPE_INT, height,
+ NULL);
+
+ if (fps > 0) {
+ gst_caps_set_simple(caps,
+ "framerate", GST_TYPE_FRACTION, fps, 1,
+ NULL);
+ }
+
+ if (rotate >= 0) {
+ gst_caps_set_simple(caps,
+ "rotate", G_TYPE_INT, rotate,
+ NULL);
+ }
+
+ caps_string = gst_caps_to_string(caps);
+ MMCAM_LOG_INFO("caps[%s]", caps_string);
+ g_free(caps_string);
+
+ return caps;
+}
+
gboolean _mmcamcorder_resize_frame(unsigned char *src_data, unsigned int src_width, unsigned int src_height, unsigned int src_length, int src_format,
unsigned char **dst_data, unsigned int *dst_width, unsigned int *dst_height, size_t *dst_length)
{