gstbasecamerasrc.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * GStreamer
  3. * Copyright (C) 2010 Texas Instruments, Inc
  4. * Copyright (C) 2011 Thiago Santos <thiago.sousa.santos@collabora.com>
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Library General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Library General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Library General Public
  17. * License along with this library; if not, write to the
  18. * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
  19. * Boston, MA 02110-1301, USA.
  20. */
  21. #ifndef __GST_BASE_CAMERA_SRC_H__
  22. #define __GST_BASE_CAMERA_SRC_H__
  23. #ifndef GST_USE_UNSTABLE_API
  24. #warning "GstBaseCameraSrc is unstable API and may change in future."
  25. #warning "You can define GST_USE_UNSTABLE_API to avoid this warning."
  26. #endif
  27. #include <gst/gst.h>
  28. #include <gst/gstbin.h>
  29. #include "gstcamerabin-enum.h"
  30. #include "gstcamerabinpreview.h"
  31. G_BEGIN_DECLS
  32. #define GST_TYPE_BASE_CAMERA_SRC \
  33. (gst_base_camera_src_get_type())
  34. #define GST_BASE_CAMERA_SRC(obj) \
  35. (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_BASE_CAMERA_SRC,GstBaseCameraSrc))
  36. #define GST_BASE_CAMERA_SRC_GET_CLASS(obj) \
  37. (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_BASE_CAMERA_SRC, GstBaseCameraSrcClass))
  38. #define GST_BASE_CAMERA_SRC_CLASS(klass) \
  39. (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_BASE_CAMERA_SRC,GstBaseCameraSrcClass))
  40. #define GST_IS_BASE_CAMERA_SRC(obj) \
  41. (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BASE_CAMERA_SRC))
  42. #define GST_IS_BASE_CAMERA_SRC_CLASS(klass) \
  43. (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_CAMERA_SRC))
  44. #define GST_BASE_CAMERA_SRC_CAST(obj) \
  45. ((GstBaseCameraSrc *) (obj))
  46. GType gst_base_camera_src_get_type (void);
  47. typedef struct _GstBaseCameraSrc GstBaseCameraSrc;
  48. typedef struct _GstBaseCameraSrcClass GstBaseCameraSrcClass;
  49. #define GST_BASE_CAMERA_SRC_VIEWFINDER_PAD_NAME "vfsrc"
  50. #define GST_BASE_CAMERA_SRC_IMAGE_PAD_NAME "imgsrc"
  51. #define GST_BASE_CAMERA_SRC_VIDEO_PAD_NAME "vidsrc"
  52. #define GST_BASE_CAMERA_SRC_PREVIEW_MESSAGE_NAME "preview-image"
  53. /**
  54. * GstBaseCameraSrc:
  55. */
  56. struct _GstBaseCameraSrc
  57. {
  58. GstBin parent;
  59. GstCameraBinMode mode;
  60. gboolean auto_start;
  61. gboolean capturing;
  62. GMutex capturing_mutex;
  63. /* Preview convert pipeline */
  64. GstCaps *preview_caps;
  65. gboolean post_preview;
  66. GstElement *preview_filter;
  67. GstCameraBinPreviewPipelineData *preview_pipeline;
  68. /* Resolution of the buffers configured to camerabin */
  69. gint width;
  70. gint height;
  71. gfloat zoom;
  72. gfloat max_zoom;
  73. gpointer _gst_reserved[GST_PADDING_LARGE];
  74. };
  75. /**
  76. * GstBaseCameraSrcClass:
  77. * @construct_pipeline: construct pipeline
  78. * @setup_pipeline: configure pipeline for the chosen settings
  79. * @set_zoom: set the zoom
  80. * @set_mode: set the mode
  81. */
  82. struct _GstBaseCameraSrcClass
  83. {
  84. GstBinClass parent;
  85. /* Construct pipeline. (called in GST_STATE_CHANGE_NULL_TO_READY) Optional. */
  86. gboolean (*construct_pipeline) (GstBaseCameraSrc *self);
  87. /* (called in GST_STATE_CHANGE_READY_TO_PAUSED). Optional. */
  88. gboolean (*setup_pipeline) (GstBaseCameraSrc *self);
  89. /* Set the zoom. If set, called when changing 'zoom' property. Optional. */
  90. void (*set_zoom) (GstBaseCameraSrc *self, gfloat zoom);
  91. /* Set the mode. If set, called when changing 'mode' property. Optional. */
  92. gboolean (*set_mode) (GstBaseCameraSrc *self,
  93. GstCameraBinMode mode);
  94. /* Set preview caps. If set, called called when setting new 'preview-caps'. Optional. */
  95. gboolean (*set_preview) (GstBaseCameraSrc *self,
  96. GstCaps *preview_caps);
  97. /* Called by the handler for 'start-capture'. Mandatory. */
  98. gboolean (*start_capture) (GstBaseCameraSrc * src);
  99. /* Called by the handler for 'stop-capture'. Mandatory. */
  100. void (*stop_capture) (GstBaseCameraSrc * src);
  101. gpointer _gst_reserved[GST_PADDING_LARGE];
  102. };
  103. #define MIN_ZOOM 1.0f
  104. #define MAX_ZOOM 10.0f
  105. #define ZOOM_1X MIN_ZOOM
  106. gboolean gst_base_camera_src_set_mode (GstBaseCameraSrc *self, GstCameraBinMode mode);
  107. void gst_base_camera_src_setup_zoom (GstBaseCameraSrc * self);
  108. void gst_base_camera_src_setup_preview (GstBaseCameraSrc * self, GstCaps * preview_caps);
  109. void gst_base_camera_src_finish_capture (GstBaseCameraSrc *self);
  110. void gst_base_camera_src_post_preview (GstBaseCameraSrc *self, GstSample * sample);
  111. // XXX add methods to get/set img capture and vid capture caps..
  112. G_END_DECLS
  113. #endif /* __GST_BASE_CAMERA_SRC_H__ */