$NetBSD: patch-vdevicev4l_C,v 1.1.1.1 2010/02/02 02:01:54 phonohawk Exp $

--- cinelerra/vdevicev4l.C.orig	2010-02-01 08:26:23.000000000 +0000
+++ cinelerra/vdevicev4l.C
@@ -25,6 +25,7 @@
 #undef _LARGEFILE_SOURCE
 #undef _LARGEFILE64_SOURCE
 
+#include "config.h"
 
 #include "assets.h"
 #include "bcsignals.h"
@@ -108,6 +109,7 @@ int VDeviceV4L::close_v4l()
 
 int VDeviceV4L::unmap_v4l_shmem()
 {
+#if defined(HAVE_LINUX_VIDEODEV_H)
 	if(capture_buffer)
 	{
 		if(shared_memory)
@@ -116,9 +118,11 @@ int VDeviceV4L::unmap_v4l_shmem()
 			delete capture_buffer;
 		capture_buffer = 0;
 	}
+#endif
 	return 0;
 }
 
+#if defined(HAVE_LINUX_VIDEODEV_H)
 int VDeviceV4L::v4l_init()
 {
 	int i;
@@ -179,11 +183,20 @@ int VDeviceV4L::v4l_init()
 	got_first_frame = 0;
 	return 0;
 }
+#else
+int VDeviceV4L::v4l_init() {
+    fprintf(stderr, "VDeviceV4L::v4l_init (Warning: unavailble feature on this platform)\n");
+    input_fd = 0;
+    return 0;
+}
+#endif
 
 void VDeviceV4L::v4l1_start_capture()
 {
+#if defined(HAVE_LINUX_VIDEODEV_H)
 	for(int i = 0; i < MIN(capture_params.frames, device->in_config->capture_length); i++)
 		capture_frame(i);
+#endif
 }
 
 
@@ -195,6 +208,7 @@ void VDeviceV4L::v4l1_start_capture()
 
 int VDeviceV4L::v4l1_get_inputs()
 {
+#if defined(HAVE_LINUX_VIDEODEV_H)
 	struct video_channel channel_struct;
 	int i = 0, done = 0;
 	char *new_source;
@@ -215,6 +229,7 @@ int VDeviceV4L::v4l1_get_inputs()
 		}
 		i++;
 	}
+#endif
 	return 0;
 }
 
@@ -227,6 +242,7 @@ int VDeviceV4L::set_mute(int muted)
 
 int VDeviceV4L::v4l1_set_mute(int muted)
 {
+#if defined(HAVE_LINUX_VIDEODEV_H)
 	struct video_audio audio;
 
     if(ioctl(input_fd, VIDIOCGAUDIO, &audio))
@@ -244,6 +260,7 @@ int VDeviceV4L::v4l1_set_mute(int muted)
     if(ioctl(input_fd, VIDIOCSAUDIO, &audio) < 0)
 		perror("VDeviceV4L::ioctl VIDIOCSAUDIO");
 	return 0;
+#endif
 }
 
 
@@ -288,6 +305,7 @@ int VDeviceV4L::get_best_colormodel(Asse
 	return result;
 }
 
+#if defined(HAVE_LINUX_VIDEODEV_H)
 unsigned long VDeviceV4L::translate_colormodel(int colormodel)
 {
 	unsigned long result = 0;
@@ -303,12 +321,18 @@ unsigned long VDeviceV4L::translate_colo
 //printf("VDeviceV4L::translate_colormodel %d\n", result);
 	return result;
 }
+#else
+unsigned long VDeviceV4L::translate_colormodel(int) {
+    return 0;
+}
+#endif
 
 int VDeviceV4L::set_channel(Channel *channel)
 {
 	return v4l1_set_channel(channel);
 }
 
+#if defined(HAVE_LINUX_VIDEODEV_H)
 int VDeviceV4L::v4l1_set_channel(Channel *channel)
 {
 	struct video_channel channel_struct;
@@ -352,7 +376,13 @@ int VDeviceV4L::v4l1_set_channel(Channel
 //	set_mute(0);
 	return 0;
 }
+#else
+int VDeviceV4L::v4l1_set_channel(Channel*) {
+    return 0;
+}
+#endif
 
+#if defined(HAVE_LINUX_VIDEODEV_H)
 int VDeviceV4L::v4l1_get_norm(int norm)
 {
 	switch(norm)
@@ -363,13 +393,18 @@ int VDeviceV4L::v4l1_get_norm(int norm)
 	}
 	return 0;
 }
+#else
+int VDeviceV4L::v4l1_get_norm(int) {
+    return 0;
+}
+#endif
 
 int VDeviceV4L::set_picture(PictureConfig *picture)
 {
 	v4l1_set_picture(picture);
 }
 
-
+#if defined(HAVE_LINUX_VIDEODEV_H)
 int VDeviceV4L::v4l1_set_picture(PictureConfig *picture)
 {
 	int brightness = (int)((float)picture->brightness / 100 * 32767 + 32768);
@@ -394,8 +429,13 @@ int VDeviceV4L::v4l1_set_picture(Picture
 		perror("VDeviceV4L::v4l1_set_picture VIDIOCGPICT");
 	return 0;
 }
+#else
+int VDeviceV4L::v4l1_set_picture(PictureConfig*) {
+    return 0;
+}
+#endif
 
-
+#if defined(HAVE_LINUX_VIDEODEV_H)
 int VDeviceV4L::capture_frame(int capture_frame_number)
 {
 	struct video_mmap params;
@@ -409,7 +449,13 @@ int VDeviceV4L::capture_frame(int captur
 		perror("VDeviceV4L::capture_frame VIDIOCMCAPTURE");
 	return 0;
 }
+#else
+int VDeviceV4L::capture_frame(int) {
+    return 0;
+}
+#endif
 
+#if defined(HAVE_LINUX_VIDEODEV_H)
 int VDeviceV4L::wait_v4l_frame()
 {
 //printf("VDeviceV4L::wait_v4l_frame 1 %d\n", capture_frame_number);
@@ -418,17 +464,29 @@ int VDeviceV4L::wait_v4l_frame()
 //printf("VDeviceV4L::wait_v4l_frame 2 %d\n", capture_frame_number);
 	return 0;
 }
+#else
+int VDeviceV4L::wait_v4l_frame() {
+    return 0;
+}
+#endif
 
+#if defined(HAVE_LINUX_VIDEODEV_H)
 int VDeviceV4L::read_v4l_frame(VFrame *frame)
 {
 	frame_to_vframe(frame, (unsigned char*)capture_buffer + capture_params.offsets[capture_frame_number]);
 	return 0;
 }
+#else
+int VDeviceV4L::read_v4l_frame(VFrame *) {
+    return 0;
+}
+#endif
 
 #ifndef MIN
 #define MIN(x, y) ((x) < (y) ? (x) : (y))
 #endif
 
+#if defined(HAVE_LINUX_VIDEODEV_H)
 int VDeviceV4L::frame_to_vframe(VFrame *frame, unsigned char *input)
 {
 	int inwidth, inheight;
@@ -525,9 +583,13 @@ int VDeviceV4L::frame_to_vframe(VFrame *
 	}
 	return 0;
 }
+#else
+int VDeviceV4L::frame_to_vframe(VFrame *, unsigned char *) {
+    return 0;
+}
+#endif
 
-
-
+#if defined(HAVE_LINUX_VIDEODEV_H)
 int VDeviceV4L::next_frame(int previous_frame)
 {
 	int result = previous_frame + 1;
@@ -535,7 +597,13 @@ int VDeviceV4L::next_frame(int previous_
 	if(result >= MIN(capture_params.frames, device->in_config->capture_length)) result = 0;
 	return result;
 }
+#else
+int VDeviceV4L::next_frame(int) {
+    return 0;
+}
+#endif
 
+#if defined(HAVE_LINUX_VIDEODEV_H)
 int VDeviceV4L::read_buffer(VFrame *frame)
 {
 	int result = 0;
@@ -561,7 +629,11 @@ SET_TRACE
 
 	return 0;
 }
-
+#else
+int VDeviceV4L::read_buffer(VFrame *) {
+    return 0;
+}
+#endif
 
 
 
