1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355
|
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include <linux/types.h>
/* we don't want linux/time.h */
#define _LINUX_TIME_H 1
#include "videodev2.h"
#include <stdio.h>
#include "ivtv.h"
MODULE = Video::ivtv PACKAGE = Video::ivtv
void
getResolution(SV * self, IN int fd, OUTLIST int width, OUTLIST int height)
INIT:
struct v4l2_format vfmt;
CODE:
vfmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if (ioctl(fd, VIDIOC_G_FMT, &vfmt) < 0)
{
/* return an invalid case to signal an error occured */
width = height = -1;
}
else
{
width = vfmt.fmt.pix.width;
height = vfmt.fmt.pix.height;
}
int
setResolution(SV * self, int fd, int width, int height)
INIT:
struct v4l2_format vfmt;
/* make sure we have valid input values. */
if (width < 0 || width > 720)
{
XSRETURN_UNDEF;
}
if (height < 0 || height > 576)
{
XSRETURN_UNDEF;
}
CODE:
vfmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; /* make sure the buf type is set for Video Capture! */
vfmt.fmt.pix.width = width;
vfmt.fmt.pix.height = height;
if (ioctl(fd, VIDIOC_S_FMT, &vfmt) < 0)
{
/* return an invalid case to signal an error occured */
RETVAL = 0;
}
else
{
RETVAL = 1;
}
OUTPUT:
RETVAL
int
getStandard(SV * self, int fd)
INIT:
v4l2_std_id n;
CODE:
if (ioctl(fd, VIDIOC_G_STD, &n) < 0)
{
RETVAL = 0;
}
else
{
RETVAL = n;
}
OUTPUT:
RETVAL
int
setStandard(SV * self, int fd, int standard)
CODE:
if (ioctl(fd, VIDIOC_S_STD, &standard) < 0)
{
RETVAL = 0;
}
else
{
RETVAL = 1;
}
OUTPUT:
RETVAL
void
enumerateStandard(SV * self, IN int fd, IN_OUTLIST int index, OUTLIST int std_id, OUTLIST char *name, OUTLIST int numerator, OUTLIST int denominator, OUTLIST int framelines)
INIT:
struct v4l2_standard vs;
if (index < 0)
{
XSRETURN_UNDEF;
}
CODE:
vs.index = index;
if (ioctl(fd, VIDIOC_ENUMSTD, &vs) < 0)
{
/* return an invalid case to signal an error occured */
index = -1;
name = "";
numerator = 0;
denominator = 0;
framelines = 0;
}
else
{
std_id = vs.id;
name = vs.name;
numerator = vs.frameperiod.numerator;
denominator = vs.frameperiod.denominator;
framelines = vs.framelines;
}
int
getFrequency(SV * self, int fd, int tuner)
INIT:
struct v4l2_frequency vf;
if (tuner < 0)
{
XSRETURN_UNDEF;
}
CODE:
vf.tuner = tuner;
if (ioctl(fd, VIDIOC_G_FREQUENCY, &vf) < 0)
{
RETVAL = -1;
}
else
{
RETVAL = vf.frequency;
}
OUTPUT:
RETVAL
int
setFrequency(SV * self, int fd, int tuner, int freq)
INIT:
struct v4l2_frequency vf;
if (tuner < 0)
{
XSRETURN_UNDEF;
}
if (freq < 0)
{
XSRETURN_UNDEF;
}
CODE:
vf.tuner = tuner;
vf.frequency = freq;
if (ioctl(fd, VIDIOC_S_FREQUENCY, &vf) < 0)
{
RETVAL = 0;
}
else
{
RETVAL = 1;
}
OUTPUT:
RETVAL
int
getInput(SV * self, int fd)
INIT:
int input;
CODE:
if (ioctl(fd, VIDIOC_G_INPUT, &input) < 0)
{
RETVAL = -1;
}
else
{
RETVAL = input;
}
OUTPUT:
RETVAL
int
setInput(SV * self, int fd, int input)
INIT:
if (input < 0)
{
XSRETURN_UNDEF;
}
CODE:
if (ioctl(fd, VIDIOC_S_INPUT, &input) < 0)
{
RETVAL = 0;
}
else
{
RETVAL = 1;
}
OUTPUT:
RETVAL
void
enumerateInput(SV * self, IN int fd, IN_OUTLIST int index, OUTLIST char *name, OUTLIST int type, OUTLIST int audioset, OUTLIST int tuner, OUTLIST int std, OUTLIST int status)
INIT:
struct v4l2_input vi;
if (index < 0)
{
XSRETURN_UNDEF;
}
CODE:
vi.index = index;
if (ioctl(fd, VIDIOC_ENUMINPUT, &vi) < 0)
{
/* return an invalid case to signal an error occured */
index = -1;
name = "";
type = 0;
audioset = 0;
tuner = 0;
std = 0;
status = 0;
}
else
{
name = vi.name;
type = vi.type;
audioset = vi.audioset;
tuner = vi.tuner;
std = vi.std;
status = vi.status;
}
void
getCodecInfo(SV * self, IN int fd, OUTLIST int aspect, OUTLIST int audio_bitmask, OUTLIST int bframes, OUTLIST int bitrate_mode, OUTLIST int bitrate, OUTLIST int bitrate_peak, OUTLIST int dnr_mode, OUTLIST int dnr_spatial, OUTLIST int dnr_temporal, OUTLIST int dnr_type, OUTLIST int framerate, OUTLIST int framespergop, OUTLIST int gop_closure, OUTLIST int pulldown, OUTLIST int stream_type)
INIT:
struct ivtv_ioctl_codec codec;
CODE:
if (ioctl(fd, IVTV_IOC_G_CODEC, &codec) < 0)
{
/* an error occured, hopefully this is returning an empty array. */
}
else
{
aspect = codec.aspect;
audio_bitmask = codec.audio_bitmask;
bframes = codec.bframes;
bitrate_mode = codec.bitrate_mode;
bitrate = codec.bitrate;
bitrate_peak = codec.bitrate_peak;
dnr_mode = codec.dnr_mode;
dnr_spatial = codec.dnr_spatial;
dnr_temporal = codec.dnr_temporal;
dnr_type = codec.dnr_type;
framerate = codec.framerate;
framespergop = codec.framespergop;
gop_closure = codec.gop_closure;
pulldown = codec.pulldown;
stream_type = codec.stream_type;
}
int
setCodecInfo(SV * self, int fd, int aspect, int audio_bitmask, int bframes, int bitrate_mode, int bitrate, int bitrate_peak, int dnr_mode, int dnr_spatial, int dnr_temporal, int dnr_type, int framerate, int framespergop, int gop_closure, int pulldown, int stream_type)
INIT:
struct ivtv_ioctl_codec codec;
/* make sure we have valid input values. */
CODE:
codec.aspect = aspect;
codec.audio_bitmask = audio_bitmask;
codec.bframes = bframes;
codec.bitrate_mode = bitrate_mode;
codec.bitrate = bitrate;
codec.bitrate_peak = bitrate_peak;
codec.dnr_mode = dnr_mode;
codec.dnr_spatial = dnr_spatial;
codec.dnr_temporal = dnr_temporal;
codec.dnr_type = dnr_type;
codec.framerate = framerate;
codec.framespergop = framespergop;
codec.gop_closure = gop_closure;
codec.pulldown = pulldown;
codec.stream_type = stream_type;
if (ioctl(fd, IVTV_IOC_S_CODEC, &codec) < 0)
{
/* return an invalid case to signal an error occured */
RETVAL = 0;
}
else
{
RETVAL = 1;
}
OUTPUT:
RETVAL
void
getCapabilities(SV * self, IN int fd, OUTLIST char *driver, OUTLIST char *card, OUTLIST char *bus_info, OUTLIST int version, OUTLIST int capabilities)
INIT:
struct v4l2_capability vcap;
CODE:
if (ioctl(fd, VIDIOC_QUERYCAP, &vcap) < 0)
{
/* an error occured, hopefully this is returning an empty array. */
}
else
{
driver = vcap.driver;
card = vcap.card;
bus_info = vcap.bus_info;
version = vcap.version;
capabilities = vcap.capabilities;
}
int
setEndGOP(SV * self, int fd, int end_gop)
INIT:
if (end_gop < 0 || end_gop > 1)
{
XSRETURN_UNDEF;
}
CODE:
if (ioctl(fd, IVTV_IOC_S_GOP_END, &end_gop) < 0)
{
RETVAL = 0;
}
else
{
RETVAL = 1;
}
OUTPUT:
RETVAL
int
stopEncoding(SV * self, int fd)
CODE:
if (ioctl(fd, VIDIOC_STREAMOFF) < 0)
{
RETVAL = 0;
}
else
{
RETVAL = 1;
}
OUTPUT:
RETVAL
|