33 #include <dc1394/dc1394.h>
34 #elif HAVE_LIBDC1394_1
35 #include <libraw1394/raw1394.h>
36 #include <libdc1394/dc1394_control.h>
38 #define DC1394_VIDEO_MODE_320x240_YUV422 MODE_320x240_YUV422
39 #define DC1394_VIDEO_MODE_640x480_YUV411 MODE_640x480_YUV411
40 #define DC1394_VIDEO_MODE_640x480_YUV422 MODE_640x480_YUV422
41 #define DC1394_FRAMERATE_1_875 FRAMERATE_1_875
42 #define DC1394_FRAMERATE_3_75 FRAMERATE_3_75
43 #define DC1394_FRAMERATE_7_5 FRAMERATE_7_5
44 #define DC1394_FRAMERATE_15 FRAMERATE_15
45 #define DC1394_FRAMERATE_30 FRAMERATE_30
46 #define DC1394_FRAMERATE_60 FRAMERATE_60
47 #define DC1394_FRAMERATE_120 FRAMERATE_120
48 #define DC1394_FRAMERATE_240 FRAMERATE_240
56 raw1394handle_t handle;
57 dc1394_cameracapture camera;
59 #elif HAVE_LIBDC1394_2
61 dc1394camera_t *camera;
62 dc1394video_frame_t *frame;
89 { 1875, DC1394_FRAMERATE_1_875 },
90 { 3750, DC1394_FRAMERATE_3_75 },
91 { 7500, DC1394_FRAMERATE_7_5 },
92 { 15000, DC1394_FRAMERATE_15 },
93 { 30000, DC1394_FRAMERATE_30 },
94 { 60000, DC1394_FRAMERATE_60 },
95 {120000, DC1394_FRAMERATE_120 },
96 {240000, DC1394_FRAMERATE_240 },
100 #define OFFSET(x) offsetof(dc1394_data, x)
101 #define DEC AV_OPT_FLAG_DECODING_PARAM
198 nodeid_t* camera_nodes;
207 dc1394->handle = dc1394_create_handle(0);
208 if (!dc1394->handle) {
212 camera_nodes = dc1394_get_camera_nodes(dc1394->handle, &res, 1);
213 if (!camera_nodes || camera_nodes[dc1394->channel] == DC1394_NO_CAMERA) {
214 av_log(c,
AV_LOG_ERROR,
"There's no IIDC camera on the channel %d\n", dc1394->channel);
217 res = dc1394_dma_setup_capture(dc1394->handle, camera_nodes[dc1394->channel],
219 FORMAT_VGA_NONCOMPRESSED,
225 dc1394_free_camera_nodes(camera_nodes);
226 if (res != DC1394_SUCCESS) {
231 res = dc1394_start_iso_transmission(dc1394->handle, dc1394->camera.node);
232 if (res != DC1394_SUCCESS) {
240 dc1394_dma_unlisten(dc1394->handle, &dc1394->camera);
241 dc1394_dma_release_camera(dc1394->handle, &dc1394->camera);
243 dc1394_destroy_handle(dc1394->handle);
255 if (dc1394_dma_done_with_buffer(&dc1394->camera) != DC1394_SUCCESS)
259 res = dc1394_dma_single_capture(&dc1394->camera);
261 if (res == DC1394_SUCCESS) {
262 dc1394->
packet.
data = (uint8_t *)(dc1394->camera.capture_buffer);
279 dc1394_stop_iso_transmission(dc1394->handle, dc1394->camera.node);
280 dc1394_dma_unlisten(dc1394->handle, &dc1394->camera);
281 dc1394_dma_release_camera(dc1394->handle, &dc1394->camera);
282 dc1394_destroy_handle(dc1394->handle);
287 #elif HAVE_LIBDC1394_2
291 dc1394camera_list_t *list;
300 dc1394->d = dc1394_new();
301 dc1394_camera_enumerate (dc1394->d, &list);
302 if ( !list || list->num == 0) {
308 dc1394->camera = dc1394_camera_new (dc1394->d, list->ids[0].guid);
314 dc1394_camera_free_list (list);
317 if (dc1394->camera->bmode_capable>0) {
318 dc1394_video_set_operation_mode(dc1394->camera, DC1394_OPERATION_MODE_1394B);
319 i = DC1394_ISO_SPEED_800;
321 i = DC1394_ISO_SPEED_400;
324 for (res = DC1394_FAILURE; i >= DC1394_ISO_SPEED_MIN && res != DC1394_SUCCESS; i--) {
325 res=dc1394_video_set_iso_speed(dc1394->camera, i);
327 if (res != DC1394_SUCCESS) {
332 if (dc1394_video_set_mode(dc1394->camera, fmt->
frame_size_id) != DC1394_SUCCESS) {
337 if (dc1394_video_set_framerate(dc1394->camera,fps->
frame_rate_id) != DC1394_SUCCESS) {
341 if (dc1394_capture_setup(dc1394->camera, 10, DC1394_CAPTURE_FLAGS_DEFAULT)!=DC1394_SUCCESS) {
346 if (dc1394_video_set_transmission(dc1394->camera, DC1394_ON) !=DC1394_SUCCESS) {
353 dc1394_capture_stop(dc1394->camera);
354 dc1394_video_set_transmission(dc1394->camera, DC1394_OFF);
355 dc1394_camera_free (dc1394->camera);
357 dc1394_free(dc1394->d);
368 if (dc1394_capture_enqueue(dc1394->camera, dc1394->frame) != DC1394_SUCCESS)
372 res = dc1394_capture_dequeue(dc1394->camera, DC1394_CAPTURE_POLICY_WAIT, &dc1394->frame);
373 if (res == DC1394_SUCCESS) {
374 dc1394->
packet.
data = (uint8_t *) dc1394->frame->image;
376 res = dc1394->frame->image_bytes;
391 dc1394_video_set_transmission(dc1394->camera, DC1394_OFF);
392 dc1394_capture_stop(dc1394->camera);
393 dc1394_camera_free(dc1394->camera);
394 dc1394_free(dc1394->d);
404 .read_packet = dc1394_v2_read_packet,
405 .read_close = dc1394_v2_close,
417 .read_packet = dc1394_v1_read_packet,
418 .read_close = dc1394_v1_close,
enum PixelFormat pix_fmt
Pixel format, see PIX_FMT_xxx.
int av_parse_video_rate(AVRational *rate, const char *arg)
Parse str and store the detected values in *rate.
int av_parse_video_size(int *width_ptr, int *height_ptr, const char *str)
Parse str and put in width_ptr and height_ptr the detected values.
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
int index
stream index in AVFormatContext
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
struct dc1394_frame_rate dc1394_frame_rates[]
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
char * framerate
Set by a private option.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3
static int read_header(FFV1Context *f)
int avpicture_get_size(enum PixelFormat pix_fmt, int width, int height)
Calculate the size in bytes that a picture of the given width and height would occupy if stored in th...
static int dc1394_read_common(AVFormatContext *c, AVFormatParameters *ap, struct dc1394_frame_format **select_fmt, struct dc1394_frame_rate **select_fps)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void av_log(void *avcl, int level, const char *fmt,...)
AVStream * avformat_new_stream(AVFormatContext *s, AVCodec *c)
Add a new stream to a media file.
int flags
A combination of AV_PKT_FLAG values.
AVCodecContext * codec
codec context
int bit_rate
the average bitrate
char filename[1024]
input or output filename
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
int width
picture width / height.
const char * av_get_pix_fmt_name(enum PixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
struct dc1394_data dc1394_data
char * pixel_format
Set by a private option.
enum AVMediaType codec_type
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const AVOption options[]
static const AVClass libdc1394_class
Describe the class of an AVClass context structure.
rational number numerator/denominator
int frame_rate
frames per 1000 seconds (fps * 1000)
char * video_size
String describing video size, set by a private option.
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
struct dc1394_frame_format dc1394_frame_formats[]
static int64_t video_size
void * priv_data
Format private data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
enum PixelFormat av_get_pix_fmt(const char *name)
Return the pixel format corresponding to name.