#include <gphoto2/gphoto2-abilities-list.h>
#include <gphoto2/gphoto2-port.h>
#include <gphoto2/gphoto2-widget.h>
#include <gphoto2/gphoto2-filesys.h>
#include <gphoto2/gphoto2-result.h>
Go to the source code of this file.
Data Structures | |
struct | CameraText |
CameraText structure used in various functions. More... | |
struct | CameraFilePath |
A structure created by the capture operation. More... | |
struct | _CameraFunctions |
Various camera specific functions. More... | |
struct | _Camera |
Some cameras need 'keep-alive-messages'. | |
typedef int(* | CameraTimeoutFunc )(Camera *camera, GPContext *context) |
typedef unsigned int(* | CameraTimeoutStartFunc )(Camera *camera, unsigned int timeout, CameraTimeoutFunc func, void *data) |
typedef void(* | CameraTimeoutStopFunc )(Camera *camera, unsigned int id, void *data) |
void | gp_camera_set_timeout_funcs (Camera *camera, CameraTimeoutStartFunc start_func, CameraTimeoutStopFunc stop_func, void *data) |
int | gp_camera_start_timeout (Camera *camera, unsigned int timeout, CameraTimeoutFunc func) |
void | gp_camera_stop_timeout (Camera *camera, unsigned int id) |
Typedefs | |
typedef struct _Camera | Camera |
Object representing a camera attached to the system. | |
typedef int(* | CameraPrePostFunc )(Camera *camera, GPContext *context) |
typedef struct _CameraFunctions | CameraFunctions |
typedef GPPort | CameraPort |
typedef GPPortInfo | CameraPortInfo |
typedef struct _CameraPrivateLibrary | CameraPrivateLibrary |
typedef struct _CameraPrivateCore | CameraPrivateCore |
Camera object member functions | |
These functions must be implemented by a camlib and the camlib's camera_init() function will add them to a Camera object. | |
typedef int(* | CameraExitFunc )(Camera *camera, GPContext *context) |
The camera exit function. | |
typedef int(* | CameraGetConfigFunc )(Camera *camera, CameraWidget **widget, GPContext *context) |
Get a configuration tree for the camera and its driver. | |
typedef int(* | CameraSetConfigFunc )(Camera *camera, CameraWidget *widget, GPContext *context) |
Set the configuration in the camera. | |
typedef int(* | CameraCaptureFunc )(Camera *camera, CameraCaptureType type, CameraFilePath *path, GPContext *context) |
typedef int(* | CameraCapturePreviewFunc )(Camera *camera, CameraFile *file, GPContext *context) |
typedef int(* | CameraSummaryFunc )(Camera *camera, CameraText *text, GPContext *context) |
typedef int(* | CameraManualFunc )(Camera *camera, CameraText *text, GPContext *context) |
typedef int(* | CameraAboutFunc )(Camera *camera, CameraText *text, GPContext *context) |
typedef int(* | CameraWaitForEvent )(Camera *camera, int timeout, CameraEventType *eventtype, void **eventdata, GPContext *context) |
Enumerations | |
enum | CameraCaptureType { GP_CAPTURE_IMAGE, GP_CAPTURE_MOVIE, GP_CAPTURE_SOUND } |
Type of the capture to do. More... | |
enum | CameraEventType { GP_EVENT_UNKNOWN, GP_EVENT_TIMEOUT, GP_EVENT_FILE_ADDED, GP_EVENT_FOLDER_ADDED, GP_EVENT_CAPTURE_COMPLETE } |
Specify what event we received from the camera. More... | |
Functions | |
int | gp_camera_new (Camera **camera) |
Preparing initialization | |
int | gp_camera_set_abilities (Camera *camera, CameraAbilities abilities) |
Sets the camera abilities. | |
int | gp_camera_get_abilities (Camera *camera, CameraAbilities *abilities) |
int | gp_camera_set_port_info (Camera *camera, GPPortInfo info) |
int | gp_camera_get_port_info (Camera *camera, GPPortInfo *info) |
camera speed | |
You normally don't use that. If you do, you prevent the camera driver from selecting the optimal speed. | |
int | gp_camera_set_port_speed (Camera *camera, int speed) |
int | gp_camera_get_port_speed (Camera *camera) |
Initialization | |
int | gp_camera_init (Camera *camera, GPContext *context) |
int | gp_camera_exit (Camera *camera, GPContext *context) |
Operations on cameras | |
int | gp_camera_ref (Camera *camera) |
int | gp_camera_unref (Camera *camera) |
int | gp_camera_free (Camera *camera) |
int | gp_camera_get_config (Camera *camera, CameraWidget **window, GPContext *context) |
int | gp_camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) |
int | gp_camera_get_summary (Camera *camera, CameraText *summary, GPContext *context) |
int | gp_camera_get_manual (Camera *camera, CameraText *manual, GPContext *context) |
int | gp_camera_get_about (Camera *camera, CameraText *about, GPContext *context) |
int | gp_camera_capture (Camera *camera, CameraCaptureType type, CameraFilePath *path, GPContext *context) |
int | gp_camera_capture_preview (Camera *camera, CameraFile *file, GPContext *context) |
int | gp_camera_wait_for_event (Camera *camera, int timeout, CameraEventType *eventtype, void **eventdata, GPContext *context) |
int | gp_camera_get_storageinfo (Camera *camera, CameraStorageInformation **, int *, GPContext *context) |
Gets information on the camera attached storage. | |
Operations on folders | |
int | gp_camera_folder_list_files (Camera *camera, const char *folder, CameraList *list, GPContext *context) |
int | gp_camera_folder_list_folders (Camera *camera, const char *folder, CameraList *list, GPContext *context) |
int | gp_camera_folder_delete_all (Camera *camera, const char *folder, GPContext *context) |
int | gp_camera_folder_put_file (Camera *camera, const char *folder, CameraFile *file, GPContext *context) |
int | gp_camera_folder_make_dir (Camera *camera, const char *folder, const char *name, GPContext *context) |
int | gp_camera_folder_remove_dir (Camera *camera, const char *folder, const char *name, GPContext *context) |
Operations on files | |
int | gp_camera_file_get_info (Camera *camera, const char *folder, const char *file, CameraFileInfo *info, GPContext *context) |
int | gp_camera_file_set_info (Camera *camera, const char *folder, const char *file, CameraFileInfo info, GPContext *context) |
int | gp_camera_file_get (Camera *camera, const char *folder, const char *file, CameraFileType type, CameraFile *camera_file, GPContext *context) |
int | gp_camera_file_delete (Camera *camera, const char *folder, const char *file, GPContext *context) |
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
typedef struct _Camera Camera |
Object representing a camera attached to the system.
A Camera object represents a specific instance of a (physical of virtual) camera attached to the system.
The abilities of this type of camera are stored in a CameraAbility object.
The details of the Camera object are internal.
typedef int(* CameraExitFunc)(Camera *camera, GPContext *context) |
The camera exit function.
camera | the current camera | |
context | a GPContext |
The driver does not need to close the GPPort, this is done by libgphoto2 itself.
Implement this function if you need to any of this stuff, otherwise leave it out.
typedef int(* CameraGetConfigFunc)(Camera *camera, CameraWidget **widget, GPContext *context) |
Get a configuration tree for the camera and its driver.
camera | the current camera | |
widget | pointer to store the toplevel widget of the tree | |
context | the active GPContext |
If you do not have configuration ability, there is no need to specify this function.
typedef int(* CameraPrePostFunc)(Camera *camera, GPContext *context) |
For example, you would probably set the speed to the highest one right before downloading an image, and reset it to the default speed afterwards so that other programs will not be affected by this speed change.
typedef int(* CameraSetConfigFunc)(Camera *camera, CameraWidget *widget, GPContext *context) |
Set the configuration in the camera.
camera | the current camera | |
widget | the configuration widget tree that was changed | |
context | the active GPContext |
enum CameraCaptureType |
Type of the capture to do.
Specifies the type of capture the user wants to do with the gp_camera_capture() function.
enum CameraEventType |
Specify what event we received from the camera.
Used by gp_camera_wait_for_event() to specify what event happened on the camera. This functionality is still in development and might change.
int gp_camera_capture | ( | Camera * | camera, | |
CameraCaptureType | type, | |||
CameraFilePath * | path, | |||
GPContext * | context | |||
) |
Captures an image, movie, or sound clip depending on the given type
.
camera | a Camera | |
type | a CameraCaptureType | |
path | a CameraFilePath | |
context | a GPContext |
path
. The file can then be downloaded using gp_camera_file_get.
References GP_ERROR_NOT_SUPPORTED, and GP_OK.
int gp_camera_capture_preview | ( | Camera * | camera, | |
CameraFile * | file, | |||
GPContext * | context | |||
) |
Captures a preview that won't be stored on the camera but returned in supplied file.
camera | a Camera | |
file | a CameraFile | |
context | a GPContext |
References GP_ERROR_NOT_SUPPORTED, gp_file_clean(), and GP_OK.
Close connection to camera.
It is recommended that you call this function when you currently don't need the camera. The camera will get reinitialized by gp_camera_init() automatically if you try to access the camera again.
References gp_camera_stop_timeout(), gp_filesystem_reset(), gp_log(), GP_LOG_DEBUG, GP_OK, gp_port_close(), and gp_port_open().
Referenced by gp_camera_free(), gp_camera_set_abilities(), and gp_camera_set_port_speed().
int gp_camera_file_delete | ( | Camera * | camera, | |
const char * | folder, | |||
const char * | file, | |||
GPContext * | context | |||
) |
Deletes the file from folder
.
References gp_filesystem_delete_file(), gp_log(), GP_LOG_DEBUG, and GP_OK.
int gp_camera_file_get | ( | Camera * | camera, | |
const char * | folder, | |||
const char * | file, | |||
CameraFileType | type, | |||
CameraFile * | camera_file, | |||
GPContext * | context | |||
) |
Retrieves a file from the Camera.
camera | a Camera | |
folder | a folder | |
file | the name of a file | |
type | the CameraFileType | |
camera_file | a CameraFile | |
context | a GPContext |
References GP_ERROR_DIRECTORY_NOT_FOUND, GP_ERROR_FILE_NOT_FOUND, gp_file_clean(), gp_filesystem_get_file(), gp_log(), GP_LOG_DEBUG, and GP_OK.
Referenced by gp_camera_file_get_info().
int gp_camera_file_get_info | ( | Camera * | camera, | |
const char * | folder, | |||
const char * | file, | |||
CameraFileInfo * | info, | |||
GPContext * | context | |||
) |
Retrieves information about a file.
References _CameraFileInfoPreview::fields, _CameraFileInfoFile::fields, _CameraFileInfo::file, gp_camera_file_get(), GP_ERROR_NOT_SUPPORTED, gp_file_get_data_and_size(), gp_file_get_mime_type(), GP_FILE_INFO_NAME, GP_FILE_INFO_NONE, GP_FILE_INFO_SIZE, GP_FILE_INFO_TYPE, gp_file_new(), GP_FILE_TYPE_PREVIEW, gp_file_unref(), gp_filesystem_get_info(), gp_log(), GP_LOG_DEBUG, GP_OK, _CameraFileInfoFile::name, _CameraFileInfo::preview, _CameraFileInfoPreview::size, and _CameraFileInfoPreview::type.
int gp_camera_file_set_info | ( | Camera * | camera, | |
const char * | folder, | |||
const char * | file, | |||
CameraFileInfo | info, | |||
GPContext * | context | |||
) |
Sets some file properties like name or permissions.
camera | a Camera | |
folder | a folder | |
file | the name of a file | |
info | the CameraFileInfo | |
context | a GPContext |
References gp_filesystem_set_info(), and GP_OK.
Deletes all files in a given folder
.
References gp_filesystem_delete_all(), gp_log(), GP_LOG_DEBUG, and GP_OK.
int gp_camera_folder_list_files | ( | Camera * | camera, | |
const char * | folder, | |||
CameraList * | list, | |||
GPContext * | context | |||
) |
Lists the files in supplied folder
.
camera | a Camera | |
folder | a folder | |
list | a CameraList | |
context | a GPContext |
References gp_filesystem_list_files(), gp_list_reset(), gp_list_sort(), gp_log(), GP_LOG_DEBUG, and GP_OK.
int gp_camera_folder_list_folders | ( | Camera * | camera, | |
const char * | folder, | |||
CameraList * | list, | |||
GPContext * | context | |||
) |
Lists the folders in supplied folder
.
camera | a Camera | |
folder | a folder | |
list | a CameraList | |
context | a GPContext |
References gp_filesystem_list_folders(), gp_list_reset(), gp_list_sort(), gp_log(), GP_LOG_DEBUG, and GP_OK.
int gp_camera_folder_make_dir | ( | Camera * | camera, | |
const char * | folder, | |||
const char * | name, | |||
GPContext * | context | |||
) |
Creates a new directory called name
in the given folder
.
camera | a Camera | |
folder | the location where to create the new directory | |
name | the name of the directory to be created | |
context | a GPContext |
References gp_filesystem_make_dir(), and GP_OK.
int gp_camera_folder_put_file | ( | Camera * | camera, | |
const char * | folder, | |||
CameraFile * | file, | |||
GPContext * | context | |||
) |
Uploads a file into given folder
.
camera | a Camera | |
folder | a folder | |
file | a CameraFile | |
context | a GPContext |
References gp_filesystem_put_file(), gp_log(), GP_LOG_DEBUG, and GP_OK.
int gp_camera_folder_remove_dir | ( | Camera * | camera, | |
const char * | folder, | |||
const char * | name, | |||
GPContext * | context | |||
) |
Removes an (empty) directory called name
from the given folder
.
camera | a Camera | |
folder | the folder from which to remove the directory | |
name | the name of the directory to be removed | |
context | a GPContext |
References gp_filesystem_remove_dir(), and GP_OK.
int gp_camera_free | ( | Camera * | camera | ) |
Free the camera
.
camera | a Camera |
References gp_camera_exit(), gp_filesystem_free(), gp_log(), GP_LOG_DEBUG, GP_OK, and gp_port_free().
Referenced by gp_camera_new(), and gp_camera_unref().
int gp_camera_get_abilities | ( | Camera * | camera, | |
CameraAbilities * | abilities | |||
) |
int gp_camera_get_about | ( | Camera * | camera, | |
CameraText * | about, | |||
GPContext * | context | |||
) |
Retrieves information about the camera driver.
camera | a Camera | |
about | a CameraText | |
context | a GPContext |
References GP_ERROR_NOT_SUPPORTED, and GP_OK.
int gp_camera_get_config | ( | Camera * | camera, | |
CameraWidget ** | window, | |||
GPContext * | context | |||
) |
Retrieve a configuration window
for the camera
.
camera | a Camera | |
window | a CameraWidget | |
context | a GPContext |
window
can be used for construction of a configuration dialog.
References GP_ERROR_NOT_SUPPORTED, and GP_OK.
int gp_camera_get_manual | ( | Camera * | camera, | |
CameraText * | manual, | |||
GPContext * | context | |||
) |
Retrieves the manual
for given camera
.
camera | a Camera | |
manual | a CameraText | |
context | a GPContext |
References GP_ERROR_NOT_SUPPORTED, and GP_OK.
int gp_camera_get_port_speed | ( | Camera * | camera | ) |
Retrieve the current speed.
camera | a Camera |
int gp_camera_get_storageinfo | ( | Camera * | camera, | |
CameraStorageInformation ** | sifs, | |||
int * | nrofsifs, | |||
GPContext * | context | |||
) |
Gets information on the camera attached storage.
camera | a Camera | |
sifs | Pointer to receive a pointer to/array of storage info items | |
nrofsifs | Pointer to receive number of array entries | |
context | a GPContext |
The variable pointed to by nrofsifs will be set to the number of elements in that array.
It is the caller's responsibility to free the memory of the array.
References gp_filesystem_get_storageinfo(), and GP_OK.
int gp_camera_get_summary | ( | Camera * | camera, | |
CameraText * | summary, | |||
GPContext * | context | |||
) |
Retrieves a camera summary.
camera | a Camera | |
summary | a CameraText | |
context | a GPContext |
References GP_ERROR_NOT_SUPPORTED, and GP_OK.
Initiate a connection to the camera
.
camera
should be set up using gp_camera_set_port_path or gp_camera_set_port_name and gp_camera_set_abilities. If that has been omitted, gphoto2 tries to autodetect any cameras and chooses the first one if any cameras are found. It is generally a good idea to call gp_camera_exit after transactions have been completed in order to give other applications the chance to access the camera, too.
References gp_abilities_list_detect(), gp_abilities_list_free(), gp_abilities_list_get_abilities(), gp_abilities_list_load(), gp_abilities_list_lookup_model(), gp_abilities_list_new(), gp_camera_set_abilities(), GP_ERROR_FILE_NOT_FOUND, GP_ERROR_LIBRARY, GP_ERROR_MODEL_NOT_FOUND, GP_ERROR_UNKNOWN_PORT, gp_list_count(), gp_list_free(), gp_list_get_name(), gp_list_get_value(), gp_list_new(), gp_log(), GP_LOG_DEBUG, GP_OK, gp_port_close(), gp_port_get_info(), gp_port_info_list_free(), gp_port_info_list_get_info(), gp_port_info_list_load(), gp_port_info_list_lookup_path(), gp_port_info_list_new(), GP_PORT_NONE, gp_port_open(), GP_PORT_USB, gp_port_usb_find_device(), gp_port_usb_find_device_by_class(), _GPPortInfo::name, _GPPortInfo::path, and _GPPortInfo::type.
int gp_camera_new | ( | Camera ** | camera | ) |
Create a new camera device.
Allocates the memory for a Camera.
camera | the Camera object to initialize. |
References gp_camera_free(), GP_ERROR_NO_MEMORY, gp_filesystem_new(), GP_OK, and gp_port_new().
int gp_camera_ref | ( | Camera * | camera | ) |
int gp_camera_set_abilities | ( | Camera * | camera, | |
CameraAbilities | abilities | |||
) |
Sets the camera abilities.
camera | a Camera | |
abilities | the CameraAbilities to be set |
abilities
, you tell gphoto2 what model the camera
is and what camera driver should be used for accessing the camera
. You can get abilities
by calling gp_abilities_list_get_abilities.
References gp_camera_exit(), gp_log(), GP_LOG_DEBUG, GP_OK, and CameraAbilities::model.
Referenced by gp_camera_init().
int gp_camera_set_config | ( | Camera * | camera, | |
CameraWidget * | window, | |||
GPContext * | context | |||
) |
Sets the configuration.
camera | a Camera | |
window | a CameraWidget | |
context | a GPContext |
window
is retrieved using gp_camera_get_config and passed to this function in order to adjust the settings on the camera.
References GP_ERROR_NOT_SUPPORTED, and GP_OK.
int gp_camera_set_port_speed | ( | Camera * | camera, | |
int | speed | |||
) |
Set the camera speed.
camera | a Camera | |
speed | the speed |
References gp_camera_exit(), GP_ERROR_BAD_PARAMETERS, gp_log(), GP_LOG_ERROR, GP_OK, gp_port_get_settings(), GP_PORT_SERIAL, gp_port_set_settings(), _GPPortSettings::serial, and _GPPortSettingsSerial::speed.
void gp_camera_set_timeout_funcs | ( | Camera * | camera, | |
CameraTimeoutStartFunc | start_func, | |||
CameraTimeoutStopFunc | stop_func, | |||
void * | data | |||
) |
camera | a Camera | |
start_func | ||
stop_func | ||
data |
int gp_camera_start_timeout | ( | Camera * | camera, | |
unsigned int | timeout, | |||
CameraTimeoutFunc | func | |||
) |
camera | a Camera | |
timeout | number of seconds that should pass between each call to func | |
func | the function that should be called each timeout seconds |
References GP_ERROR_BAD_PARAMETERS, GP_ERROR_NO_MEMORY, and GP_ERROR_NOT_SUPPORTED.
void gp_camera_stop_timeout | ( | Camera * | camera, | |
unsigned int | id | |||
) |
Stop periodic calls to keepalive function.
camera | a Camera | |
id | the id of the background process previously returned by gp_camera_start_timeout |
Referenced by gp_camera_exit().
int gp_camera_unref | ( | Camera * | camera | ) |
Decrements the reference count of a Camera.
camera | a Camera |
camera
will be freed automatically.
References gp_camera_free(), GP_ERROR, gp_log(), GP_LOG_ERROR, and GP_OK.
int gp_camera_wait_for_event | ( | Camera * | camera, | |
int | timeout, | |||
CameraEventType * | eventtype, | |||
void ** | eventdata, | |||
GPContext * | context | |||
) |
Wait for an event from the camera.
camera | a Camera | |
timeout | amount of time to wait in 1/1000 seconds | |
eventtype | received CameraEventType [out] | |
eventdata | received event specific data [out] | |
context | a GPContext |
References GP_ERROR_NOT_SUPPORTED, and GP_OK.