1 /* 2 * GStreamer 3 * Copyright (C) 2013-2015 Jan Schmidt <jan@centricular.com> 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * and/or sell copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be included in 13 * all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 * DEALINGS IN THE SOFTWARE. 22 * 23 * Alternatively, the contents of this file may be used under the 24 * GNU Lesser General Public License Version 2.1 (the "LGPL"), in 25 * which case the following provisions apply instead of the ones 26 * mentioned above: 27 * 28 * This library is free software; you can redistribute it and/or 29 * modify it under the terms of the GNU Library General Public 30 * License as published by the Free Software Foundation; either 31 * version 2 of the License, or (at your option) any later version. 32 * 33 * This library is distributed in the hope that it will be useful, 34 * but WITHOUT ANY WARRANTY; without even the implied warranty of 35 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 36 * Library General Public License for more details. 37 * 38 * You should have received a copy of the GNU Library General Public 39 * License along with this library; if not, write to the 40 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 41 * Boston, MA 02111-1307, USA. 42 */ 43 44 #ifndef __RASPICAPTURE_H__ 45 #define __RASPICAPTURE_H__ 46 47 #include <glib.h> 48 #include <inttypes.h> 49 50 #include "interface/mmal/mmal_common.h" 51 #include "interface/mmal/mmal_types.h" 52 #include "interface/mmal/mmal_parameters_camera.h" 53 #include "interface/mmal/mmal_component.h" 54 #include "RaspiCamControl.h" 55 #include "RaspiPreview.h" 56 57 #define RPICAMSRC_MAX_FPS 1000 58 59 GST_DEBUG_CATEGORY_EXTERN (gst_rpi_cam_src_debug); 60 #define GST_CAT_DEFAULT gst_rpi_cam_src_debug 61 62 #undef fprintf 63 #define fprintf(f,...) GST_LOG(__VA_ARGS__) 64 #undef vcos_log_error 65 #define vcos_log_error GST_ERROR 66 #undef vcos_log_warn 67 #define vcos_log_warn GST_WARNING 68 69 #define GST_FLOW_ERROR_TIMEOUT GST_FLOW_CUSTOM_ERROR 70 #define GST_FLOW_KEEP_ACCUMULATING GST_FLOW_CUSTOM_SUCCESS 71 72 G_BEGIN_DECLS 73 74 typedef enum 75 { 76 PROP_CHANGE_ENCODING = (1 << 0), /* BITRATE or QUANT or KEY Interval, intra refresh */ 77 PROP_CHANGE_PREVIEW = (1 << 1), /* Preview opacity or fullscreen */ 78 PROP_CHANGE_COLOURBALANCE = (1 << 2), 79 PROP_CHANGE_SENSOR_SETTINGS = (1 << 3), /* ISO, EXPOSURE, SHUTTER, DRC, Sensor Mode */ 80 PROP_CHANGE_VIDEO_STABILISATION = (1 << 4), 81 PROP_CHANGE_AWB = (1 << 5), 82 PROP_CHANGE_IMAGE_COLOUR_EFFECT = (1 << 6), 83 PROP_CHANGE_ORIENTATION = (1 << 7), 84 PROP_CHANGE_ROI = (1 << 8), 85 PROP_CHANGE_ANNOTATION = (1 << 9) 86 } RpiPropChangeFlags; 87 88 /** Structure containing all state information for the current run 89 */ 90 typedef struct 91 { 92 RpiPropChangeFlags change_flags; 93 94 int verbose; /// !0 if want detailed run information 95 96 int timeout; /// Time taken before frame is grabbed and app then shuts down. Units are milliseconds 97 int width; /// Requested width of image 98 int height; /// requested height of image 99 int bitrate; /// Requested bitrate 100 int fps_n; /// Requested frame rate (fps) numerator 101 int fps_d; /// Requested frame rate (fps) denominator 102 int intraperiod; /// Intra-refresh period (key frame rate) 103 int quantisationParameter; /// Quantisation parameter - quality. Set bitrate 0 and set this for variable bitrate 104 int bInlineHeaders; /// Insert inline headers to stream (SPS, PPS) 105 int demoMode; /// Run app in demo mode 106 int demoInterval; /// Interval between camera settings changes 107 int immutableInput; /// Flag to specify whether encoder works in place or creates a new buffer. Result is preview can display either 108 /// the camera output or the encoder output (with compression artifacts) 109 int profile; /// H264 profile to use for encoding 110 RASPIPREVIEW_PARAMETERS preview_parameters; /// Preview setup parameters 111 RASPICAM_CAMERA_PARAMETERS camera_parameters; /// Camera setup parameters 112 113 int inlineMotionVectors; /// Encoder outputs inline Motion Vectors 114 115 int cameraNum; /// Camera number 116 int settings; /// Request settings from the camera 117 int sensor_mode; /// Sensor mode. 0=auto. Check docs/forum for modes selected by other values. 118 int intra_refresh_type; /// What intra refresh type to use. -1 to not set. 119 120 MMAL_FOURCC_T encoding; // Which encoding to use 121 122 int jpegQuality; 123 int jpegRestartInterval; 124 125 int useSTC; 126 } RASPIVID_CONFIG; 127 128 typedef struct RASPIVID_STATE_T RASPIVID_STATE; 129 130 void raspicapture_init(void); 131 void raspicapture_default_config(RASPIVID_CONFIG *config); 132 RASPIVID_STATE *raspi_capture_setup(RASPIVID_CONFIG *config); 133 gboolean raspi_capture_start(RASPIVID_STATE *state); 134 void raspi_capture_update_config (RASPIVID_STATE *state, 135 RASPIVID_CONFIG *config, gboolean dynamic); 136 GstFlowReturn raspi_capture_fill_buffer(RASPIVID_STATE *state, GstBuffer **buf, 137 GstClock *clock, GstClockTime base_time); 138 void raspi_capture_stop(RASPIVID_STATE *state); 139 void raspi_capture_free(RASPIVID_STATE *state); 140 gboolean raspi_capture_request_i_frame(RASPIVID_STATE *state); 141 142 G_END_DECLS 143 144 #endif 145