/usr/include/ptlib/videoio.h is in libpt-dev 2.10.11~dfsg-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 | /*
* videoio.h
*
* Classes to support streaming video input (grabbing) and output.
*
* Portable Windows Library
*
* Copyright (c) 1993-2000 Equivalence Pty. Ltd.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Portable Windows Library.
*
* The Initial Developer of the Original Code is Equivalence Pty. Ltd.
*
* Contributor(s): Mark Cooke (mpc@star.sr.bham.ac.uk)
*
* $Revision: 29328 $
* $Author: rjongbloed $
* $Date: 2013-03-26 18:23:37 -0500 (Tue, 26 Mar 2013) $
*/
#ifndef PTLIB_PVIDEOIO_H
#define PTLIB_PVIDEOIO_H
#ifdef P_USE_PRAGMA
#pragma interface
#endif
#include <ptbuildopts.h>
#if P_VIDEO
#include <ptlib/plugin.h>
#include <ptlib/pluginmgr.h>
#include <list>
class PColourConverter;
class PVideoFrameInfo : public PObject
{
PCLASSINFO(PVideoFrameInfo, PObject);
public:
enum ResizeMode
{
eScale,
eCropCentre,
eCropTopLeft,
eMaxResizeMode
};
friend ostream & operator<<(ostream & strm, ResizeMode mode);
enum StandardSizes {
SQCIFWidth = 128, SQCIFHeight = 96,
QCIFWidth = 176, QCIFHeight = 144,
CIFWidth = 352, CIFHeight = 288,
CIF4Width = 704, CIF4Height = 576,
CIF16Width = 1408, CIF16Height = 1152,
HD480Width = 704, HD480Height = 480,
i480Width = 704, i480Height = 480,
HD720Width = 1280, HD720Height = 720,
p720Width = 1280, p720Height = 720,
HD1080Width= 1920, HD1080Height= 1080,
i1080Width = 1920, i1080Height = 1080,
HDTVWidth = 1920, HDTVHeight = 1080,
MaxWidth = 1920, MaxHeight = 1200
};
/// Construct video frame information
PVideoFrameInfo();
PVideoFrameInfo(
unsigned frameWidth,
unsigned frameHeight,
const PString & colourFormat = "YUV420P",
unsigned frameRate = 15,
ResizeMode resizeMode = eScale
);
/** Compare the two PVideoFrameInfo and return their relative rank.
This ranking is by the relative area of the frame resolution, and
frame rate if resolution equal. The final check for equality is on
the colourFormat. The SAR and resize mode take no part.
@return
<code>LessThan</code>, <code>EqualTo</code> or <code>GreaterThan</code>
according to the relative rank of the objects.
*/
virtual Comparison Compare(
const PObject & obj // Object to compare against.
) const;
/** Output the contents of the object to the stream. The exact output is
dependent on the exact semantics of the descendent class. This is
primarily used by the standard <code>#operator<<</code> function.
The default behaviour is to print the class name.
*/
virtual void PrintOn(
ostream & strm // Stream to print the object into.
) const;
/**Set the frame size to be used.
Default behaviour sets the frameWidth and frameHeight variables and
returns true.
*/
virtual PBoolean SetFrameSize(
unsigned width, ///< New width of frame
unsigned height ///< New height of frame
);
/**Get the frame size being used.
Default behaviour returns the value of the frameWidth and frameHeight
variable and returns true.
*/
virtual PBoolean GetFrameSize(
unsigned & width,
unsigned & height
) const;
/** Get the width of the frame being used.
Default behaviour returns the value of the frameWidth variable
*/
virtual unsigned GetFrameWidth() const;
/** Get the height of the frame being used.
Default behaviour returns the value of the frameHeight variable
*/
virtual unsigned GetFrameHeight() const;
/**Set the sar size to be used.
Default behaviour sets the sarWidth and sarHeight variables and
returns PTrue.
*/
virtual PBoolean SetFrameSar(unsigned width, unsigned height);
/**Get the sar size being used.
Default behaviour returns the value of the sarWidth and sarHeight
variable and returns PTrue.
*/
virtual PBoolean GetSarSize(
unsigned & width,
unsigned & height
) const;
/** Get the width of the sar being used.
Default behaviour returns the value of the sarWidth variable
*/
virtual unsigned GetSarWidth() const;
/** Get the height of the sar being used.
Default behaviour returns the value of the sarHeight variable
*/
virtual unsigned GetSarHeight() const;
/**Set the video frame rate to be used on the device.
Default behaviour sets the value of the frameRate variable and then
returns true.
*/
virtual PBoolean SetFrameRate(
unsigned rate ///< Frames per second
);
/**Get the video frame rate used on the device.
Default behaviour returns the value of the frameRate variable.
*/
virtual unsigned GetFrameRate() const;
/**Set the colour format to be used.
Default behaviour sets the value of the colourFormat variable and then
returns true if not an empty string.
*/
virtual PBoolean SetColourFormat(
const PString & colourFormat // New colour format for device.
);
/**Get the colour format to be used.
Default behaviour returns the value of the colourFormat variable.
*/
virtual const PString & GetColourFormat() const;
/**Set the resize mode to be used.
*/
void SetResizeMode(
ResizeMode mode
) { if (resizeMode < eMaxResizeMode) resizeMode = mode; }
/**Get the resize mode to be used.
*/
ResizeMode GetResizeMode() const { return resizeMode; }
/** Get the number of bytes of an image, given a particular width, height and colour format.
*/
PINDEX CalculateFrameBytes() const { return CalculateFrameBytes(frameWidth, frameHeight, colourFormat); }
static PINDEX CalculateFrameBytes(
unsigned width, ///< WIdth of frame
unsigned height, ///< Height of frame
const PString & colourFormat ///< Colour format of frame
);
/** Parse a descriptor string for the video format.
This is of the form [fmt ':' ] size [ '@' rate][ '/' crop ]. The size component
is as for the ParseSize() function.
The fmt string is the colour format such as "RGB32", "YUV420P" etc.
The rate field is a simple integer from 1 to 100.
The crop field is one of "scale", "resize" (synonym for "scale"),
"centre", "center", "topleft" or "crop" (synonym for "topleft").
Note no spaces are allowed in the descriptor.
*/
bool Parse(
const PString & str ///< String to parse
);
/** Parse the standard size string names.
This will parse a size desciption using either standard names: "qcif",
"cif", "vga", "hd1080" etc or WxY form e.g. "640x480".
*/
static bool ParseSize(
const PString & str, ///< String to parse
unsigned & width, ///< Resultant width
unsigned & height ///< Resulatant height
);
/**Get a width/height as a standard size string name.
*/
static PString AsString(
unsigned width, ///< Width to convert
unsigned height ///< Height to convert
);
/**Get all "known" image size names.
Returns all standard names for sizes, e.g. "qcif", "cif", "vga",
"hd1080" etc.
*/
static PStringArray GetSizeNames();
protected:
unsigned frameWidth;
unsigned frameHeight;
unsigned sarWidth;
unsigned sarHeight;
unsigned frameRate;
PString colourFormat;
ResizeMode resizeMode;
};
class PVideoControlInfo : public PObject
{
PCLASSINFO(PVideoControlInfo, PObject);
public:
typedef enum {
ControlPan,
ControlTilt,
ControlZoom
} InputControlType;
static PString AsString(const InputControlType & type);
InputControlType type;
long min;
long max;
long step;
long def;
long flags;
long current;
};
/**This class defines a video Input device control (Camera controls PTZ)
*/
class PVideoInputControl : public PVideoControlInfo
{
PCLASSINFO(PVideoInputControl, PVideoControlInfo);
public:
~PVideoInputControl();
virtual PBoolean Pan(long value, bool absolute = false );
virtual PBoolean Tilt(long value, bool absolute = false);
virtual PBoolean Zoom(long value, bool absolute = false);
long GetPan();
long GetTilt();
long GetZoom();
void Reset();
void SetCurrentPosition(const InputControlType ctype, long current);
typedef std::list<PVideoControlInfo> InputDeviceControls;
protected:
PBoolean GetVideoControlInfo(const InputControlType ctype, PVideoControlInfo & control);
PBoolean GetDefaultPosition(const InputControlType ctype, long & def);
PBoolean GetCurrentPosition(const InputControlType ctype, long & current);
std::list<PVideoControlInfo> m_info;
PMutex ccmutex;
};
/**This class defines a video Input device Interactions (Remote Inputs/Controls)
*/
class PVideoInteractionInfo : public PObject
{
PCLASSINFO(PVideoInteractionInfo, PObject);
public:
typedef enum {
InteractKey, /// Register remote KeyPresses
InteractMouse, /// Register remote Mouse Movement Clicks
InteractNavigate, /// Register remote Navigation commands
InteractRTSP, /// Register remote RTSP (Real Time Streaming Protocol) Inputs
InteractOther /// Register remote application specific Inputs
} InputInteractType;
static PString AsString(const InputInteractType & type);
InputInteractType type;
};
/**This class defines a video device.
This class is used to abstract the few parameters that are common to both\
input and output devices.
Example colour formats are:
"Grey" Simple 8 bit linear grey scale
"Gray" Synonym for Grey
"RGB32" 32 bit RGB
"RGB24" 24 bit RGB
"RGB565" 16 bit RGB (6 bit green)
"RGB555" 15 bit RGB
"YUV422" YUV 4:2:2 packed
"YUV422P" YUV 4:2:2 planar
"YUV411" YUV 4:1:1 packed
"YUV411P" YUV 4:1:1 planar
"YUV420" YUV 4:2:0 packed
"YUV420P" YUV 4:2:0 planar
"YUV410" YUV 4:1:0 packed
"YUV410P" YUV 4:1:0 planar
"MJPEG" Motion JPEG
"UYVY422" YUV 4:2:2 packed as U Y V Y U Y V Y ...
"UYV444" YUV 4:4:4 packed as U Y V U Y V ...
They are used in IEEE 1394 digital cameras. The specification
is found at
http://www.1394ta.org/Download/Technology/Specifications/2000/IIDC_Spec_v1_30.pdf
*/
class PVideoDevice : public PVideoFrameInfo
{
PCLASSINFO(PVideoDevice, PVideoFrameInfo);
protected:
/** Create a new video device (input or output).
*/
PVideoDevice();
public:
/** Delete structures created by PVideoDevice();
*/
virtual ~PVideoDevice();
enum VideoFormat {
PAL,
NTSC,
SECAM,
Auto,
NumVideoFormats
};
/**Get the device name of the open device.
*/
const PString & GetDeviceName() const
{ return deviceName; }
/**Get a list of all of the drivers available.
*/
virtual PStringArray GetDeviceNames() const = 0;
struct OpenArgs {
OpenArgs();
PPluginManager * pluginMgr;
PString driverName;
PString deviceName;
VideoFormat videoFormat;
int channelNumber;
PString colourFormat;
bool convertFormat;
unsigned rate;
unsigned width;
unsigned height;
bool convertSize;
ResizeMode resizeMode;
bool flip;
int brightness;
int whiteness;
int contrast;
int colour;
int hue;
};
/**Open the device given the device name.
*/
virtual PBoolean OpenFull(
const OpenArgs & args, ///< Parameters to set on opened device
PBoolean startImmediate = true ///< Immediately start device
);
/**Open the device given the device name.
*/
virtual PBoolean Open(
const PString & deviceName, ///< Device name to open
PBoolean startImmediate = true ///< Immediately start device
) = 0;
/**Determine if the device is currently open.
*/
virtual PBoolean IsOpen() = 0;
/**Close the device.
*/
virtual PBoolean Close() = 0;
/**Start the video device I/O capture.
*/
virtual PBoolean Start() = 0;
/**Stop the video device I/O capture.
*/
virtual PBoolean Stop() = 0;
#if PTRACING
friend ostream & operator<<(ostream &, VideoFormat);
#endif
/**Set the video format to be used.
Default behaviour sets the value of the videoFormat variable and then
returns true.
*/
virtual PBoolean SetVideoFormat(
VideoFormat videoFormat ///< New video format
);
/**Get the video format being used.
Default behaviour returns the value of the videoFormat variable.
*/
virtual VideoFormat GetVideoFormat() const;
/**Get the number of video channels available on the device.
Default behaviour returns 1.
*/
virtual int GetNumChannels();
/**Set the video channel to be used on the device.
The channel number is an integer from 0 to GetNumChannels()-1. The
special value of -1 will find the first working channel number.
Default behaviour sets the value of the channelNumber variable and then
returns true.
*/
virtual PBoolean SetChannel(
int channelNumber ///< New channel number for device.
);
/**Get the video channel to be used on the device.
Default behaviour returns the value of the channelNumber variable.
*/
virtual int GetChannel() const;
/**Set the colour format to be used, trying converters if available.
This function will set the colour format on the device to one that
is compatible with a registered converter, and install that converter
so that the correct format is used.
*/
virtual PBoolean SetColourFormatConverter(
const PString & colourFormat // New colour format for device.
);
/**Get the video conversion vertical flip state.
Default action is to return false.
*/
virtual PBoolean GetVFlipState();
/**Set the video conversion vertical flip state.
Default action is to return false.
*/
virtual PBoolean SetVFlipState(
PBoolean newVFlipState ///< New vertical flip state
);
/**Get the minimum & maximum size of a frame on the device.
Default behaviour returns the value 1 to UINT_MAX for both and returns
false.
*/
virtual PBoolean GetFrameSizeLimits(
unsigned & minWidth, ///< Variable to receive minimum width
unsigned & minHeight, ///< Variable to receive minimum height
unsigned & maxWidth, ///< Variable to receive maximum width
unsigned & maxHeight ///< Variable to receive maximum height
) ;
/**Set the frame size to be used, trying converters if available.
If the device does not support the size, a set of alternate resolutions
are attempted. A converter is setup if possible.
*/
virtual PBoolean SetFrameSizeConverter(
unsigned width, ///< New width of frame
unsigned height, ///< New height of frame
ResizeMode resizeMode = eMaxResizeMode ///< Mode to use if resizing is required.
);
/**Set the frame size to be used, trying converters if available.
Function used for Backward compatibility only.
If the device does not support the size, a set of alternate resolutions
are attempted. A converter is setup if possible.
*/
virtual PBoolean SetFrameSizeConverter(
unsigned width, ///< New width of frame
unsigned height, ///< New height of frame
PBoolean /*bScaleNotCrop*/ ///< Not used.
) { return SetFrameSizeConverter(width,height,eScale); }
/**Set the nearest available frame size to be used.
Note that devices may not be able to produce the requested size, so
this function picks the nearest available size.
Default behaviour simply calls SetFrameSize().
*/
virtual PBoolean SetNearestFrameSize(
unsigned width, ///< New width of frame
unsigned height ///< New height of frame
);
/**Set the frame size to be used.
Note that devices may not be able to produce the requested size, and
this function will fail. See SetFrameSizeConverter().
Default behaviour sets the frameWidth and frameHeight variables and
returns true.
*/
virtual PBoolean SetFrameSize(
unsigned width, ///< New width of frame
unsigned height ///< New height of frame
);
/**Get the frame size being used.
Default behaviour returns the value of the frameWidth and frameHeight
variable and returns true.
*/
virtual PBoolean GetFrameSize(
unsigned & width,
unsigned & height
) const;
/**Get the maximum frame size in bytes.
Note a particular device may be able to provide variable length
frames (eg motion JPEG) so will be the maximum size of all frames.
*/
virtual PINDEX GetMaxFrameBytes() = 0;
/**Get the last error code. This is a platform dependent number.
*/
int GetLastError() const { return lastError; }
/** Is the device a camera, and obtain video
*/
virtual PBoolean CanCaptureVideo() const = 0;
/**Get the brightness of the image. 0xffff-Very bright. -1 is unknown.
*/
virtual int GetBrightness();
/**Set brightness of the image. 0xffff-Very bright.
*/
virtual PBoolean SetBrightness(unsigned newBrightness);
/**Get the whiteness of the image. 0xffff-Very white. -1 is unknown.
*/
virtual int GetWhiteness();
/**Set whiteness of the image. 0xffff-Very white.
*/
virtual PBoolean SetWhiteness(unsigned newWhiteness);
/**Get the colour of the image. 0xffff-lots of colour. -1 is unknown.
*/
virtual int GetColour();
/**Set colour of the image. 0xffff-lots of colour.
*/
virtual PBoolean SetColour(unsigned newColour);
/**Get the contrast of the image. 0xffff-High contrast. -1 is unknown.
*/
virtual int GetContrast();
/**Set contrast of the image. 0xffff-High contrast.
*/
virtual PBoolean SetContrast(unsigned newContrast);
/**Get the hue of the image. 0xffff-High hue. -1 is unknown.
*/
virtual int GetHue();
/**Set hue of the image. 0xffff-High hue.
*/
virtual PBoolean SetHue(unsigned newHue);
/**Return whiteness, brightness, colour, contrast and hue in one call.
*/
virtual PBoolean GetParameters(
int *whiteness,
int *brightness,
int *colour,
int *contrast,
int *hue
);
/** Set VideoFormat and VideoChannel in one ioctl
*/
virtual PBoolean SetVideoChannelFormat (
int channelNumber,
VideoFormat videoFormat
);
/**Set preferred native colour format from video capture device.
Note empty == no preference.
*/
void SetPreferredColourFormat(const PString & colourFmt) { preferredColourFormat = colourFmt; }
/**Get preferred native colour format from video capture device.
Returns empty == no preference
*/
const PString & GetPreferredColourFormat() { return preferredColourFormat; }
protected:
PINDEX GetMaxFrameBytesConverted(PINDEX rawFrameBytes) const;
PString deviceName;
int lastError;
VideoFormat videoFormat;
int channelNumber;
// Preferred native colour format from video input device, empty == no preference
PString preferredColourFormat;
PBoolean nativeVerticalFlip;
PColourConverter * converter;
PBYTEArray frameStore;
int frameBrightness; // 16 bit entity, -1 is no value
int frameWhiteness;
int frameContrast;
int frameColour;
int frameHue;
};
/**This class defines a video output device.- typically, a window.
*/
class PVideoOutputDevice : public PVideoDevice
{
PCLASSINFO(PVideoOutputDevice, PVideoDevice);
public:
/** Create a new video output device.
*/
PVideoOutputDevice();
/**Close the video output device on destruction.
*/
virtual ~PVideoOutputDevice() { Close(); };
/**Get the list of available video output drivers (plug-ins)
*/
static PStringArray GetDriverNames(
PPluginManager * pluginMgr = NULL ///< Plug in manager, use default if NULL
);
/**Get video output devices that correspond to the specified driver name.
If driverName is an empty string or the value "*" then this will return
a list of unique device names across all of the available drivers. If
two drivers have identical names for devices, then the string returned
will be of the form driver+'\\t'+device.
*/
static PStringArray GetDriversDeviceNames(
const PString & driverName, ///< Name of driver
PPluginManager * pluginMgr = NULL ///< Plug in manager, use default if NULL
);
/**Create the video output device that corresponds to the specified driver name.
*/
static PVideoOutputDevice * CreateDevice(
const PString & driverName, ///< Name of driver
PPluginManager * pluginMgr = NULL ///< Plug in manager, use default if NULL
);
/* Create the matching video output device that corresponds to the device name.
This is typically used with the return values from GetDriversDeviceNames().
*/
static PVideoOutputDevice *CreateDeviceByName(
const PString & deviceName, ///< Name of device
const PString & driverName = PString::Empty(), ///< Name of driver (if any)
PPluginManager * pluginMgr = NULL ///< Plug in manager, use default if NULL
);
/**Create an opened video output device that corresponds to the specified names.
If the driverName parameter is an empty string or "*" then CreateDeviceByName
is used with the deviceName parameter which is assumed to be a value returned
from GetDriversDeviceNames().
*/
static PVideoOutputDevice *CreateOpenedDevice(
const PString & driverName, ///< Name of driver
const PString & deviceName, ///< Name of device
PBoolean startImmediate = true, ///< Immediately start display
PPluginManager * pluginMgr = NULL ///< Plug in manager, use default if NULL
);
/**Create an opened video output device that corresponds to the specified arguments.
*/
static PVideoOutputDevice *CreateOpenedDevice(
const OpenArgs & args, ///< Parameters to set on opened device
PBoolean startImmediate = true ///< Immediately start display
);
/**Close the device.
*/
virtual PBoolean Close() { return true; }
/**Start the video device I/O display.
*/
virtual PBoolean Start() { return true; }
/**Stop the video device I/O display.
*/
virtual PBoolean Stop() { return true; }
/** Is the device a camera, and obtain video
*/
virtual PBoolean CanCaptureVideo() const;
/**Set a section of the output frame buffer.
*/
virtual PBoolean SetFrameData(
unsigned x,
unsigned y,
unsigned width,
unsigned height,
const BYTE * data,
PBoolean endFrame = true
) = 0;
virtual PBoolean SetFrameData(
unsigned x,
unsigned y,
unsigned width,
unsigned height,
const BYTE * data,
PBoolean endFrame,
unsigned flags
);
virtual PBoolean SetFrameData(
unsigned x,
unsigned y,
unsigned width,
unsigned height,
unsigned sarwidth,
unsigned sarheight,
const BYTE * data,
PBoolean endFrame,
unsigned flags,
const void * mark
);
/**Allow the outputdevice decide whether the
decoder should ignore decode hence not render
any output.
Returns: false if to decode and render.
*/
virtual PBoolean DisableDecode();
/**Get the position of the output device, where relevant. For devices such as
files, this always returns zeros. For devices such as Windows, this is the
position of the window on the screen.
Returns: TRUE if the position is available.
*/
virtual PBoolean GetPosition(
int & x, // X position of device surface
int & y // Y position of device surface
) const;
/**Set the position of the output device, where relevant. For devices such as
files, this does nothing. For devices such as Windows, this sets the
position of the window on the screen.
Returns: TRUE if the position can be set.
*/
virtual bool SetPosition(
int x, // X position of device surface
int y // Y position of device surface
);
};
/**This class defines a video output device for RGB in a frame store.
*/
class PVideoOutputDeviceRGB : public PVideoOutputDevice
{
PCLASSINFO(PVideoOutputDeviceRGB, PVideoOutputDevice);
public:
/** Create a new video output device.
*/
PVideoOutputDeviceRGB();
/**Set the colour format to be used.
Note that this function does not do any conversion. If it returns true
then the video device does the colour format in native mode.
To utilise an internal converter use the SetColourFormatConverter()
function.
Default behaviour sets the value of the colourFormat variable and then
returns true.
*/
virtual PBoolean SetColourFormat(
const PString & colourFormat // New colour format for device.
);
/**Set the frame size to be used.
Note that devices may not be able to produce the requested size, and
this function will fail. See SetFrameSizeConverter().
Default behaviour sets the frameWidth and frameHeight variables and
returns true.
*/
virtual PBoolean SetFrameSize(
unsigned width, ///< New width of frame
unsigned height ///< New height of frame
);
/**Get the maximum frame size in bytes.
Note a particular device may be able to provide variable length
frames (eg motion JPEG) so will be the maximum size of all frames.
*/
virtual PINDEX GetMaxFrameBytes();
/**Set a section of the output frame buffer.
*/
virtual PBoolean SetFrameData(
unsigned x,
unsigned y,
unsigned width,
unsigned height,
const BYTE * data,
PBoolean endFrame = true
);
/**Indicate frame may be displayed.
*/
virtual PBoolean FrameComplete() = 0;
protected:
PMutex mutex;
PINDEX bytesPerPixel;
PINDEX scanLineWidth;
bool swappedRedAndBlue;
};
#ifdef SHOULD_BE_MOVED_TO_PLUGIN
/**This class defines a video output device which outputs to a series of PPM files.
*/
class PVideoOutputDevicePPM : public PVideoOutputDeviceRGB
{
PCLASSINFO(PVideoOutputDevicePPM, PVideoOutputDeviceRGB);
public:
/** Create a new video output device.
*/
PVideoOutputDevicePPM();
/**Open the device given the device name.
*/
virtual PBoolean Open(
const PString & deviceName, ///< Device name (filename base) to open
PBoolean startImmediate = true ///< Immediately start device
);
/**Determine if the device is currently open.
*/
virtual PBoolean IsOpen();
/**Close the device.
*/
virtual PBoolean Close();
/**Get a list of all of the drivers available.
*/
virtual PStringArray GetDeviceNames() const;
/**Indicate frame may be displayed.
*/
virtual PBoolean EndFrame();
protected:
unsigned frameNumber;
};
#endif // SHOULD_BE_MOVED_TO_PLUGIN
/**This class defines a video input device.
*/
class PVideoInputDevice : public PVideoDevice
{
PCLASSINFO(PVideoInputDevice, PVideoDevice);
public:
/** Create a new video input device.
*/
//PVideoInputDevice();
/**Close the video input device on destruction.
*/
~PVideoInputDevice() { Close(); }
/**Get the list of available video input drivers (plug-ins)
*/
static PStringArray GetDriverNames(
PPluginManager * pluginMgr = NULL ///< Plug in manager, use default if NULL
);
/**Get video input devices that correspond to the specified driver name.
If driverName is an empty string or the value "*" then this will return
a list of unique device names across all of the available drivers. If
two drivers have identical names for devices, then the string returned
will be of the form driver+'\\t'+device.
*/
static PStringArray GetDriversDeviceNames(
const PString & driverName, ///< Name of driver
PPluginManager * pluginMgr = NULL ///< Plug in manager, use default if NULL
);
/**Create the video input device that corresponds to the specified driver name.
*/
static PVideoInputDevice *CreateDevice(
const PString & driverName, ///< Name of driver
PPluginManager * pluginMgr = NULL ///< Plug in manager, use default if NULL
);
/* Create the matching video input device that corresponds to the device name.
So, for "fake" return a device that will generate fake video.
For "Phillips 680 webcam" (eg) will return appropriate grabber.
Note that Phillips will return the appropriate grabber also.
This is typically used with the return values from GetDriversDeviceNames().
*/
static PVideoInputDevice *CreateDeviceByName(
const PString & deviceName, ///< Name of device
const PString & driverName = PString::Empty(), ///< Name of driver (if any)
PPluginManager * pluginMgr = NULL ///< Plug in manager, use default if NULL
);
/**Create an opened video input device that corresponds to the specified names.
If the driverName parameter is an empty string or "*" then CreateDeviceByName
is used with the deviceName parameter which is assumed to be a value returned
from GetDriversDeviceNames().
*/
static PVideoInputDevice *CreateOpenedDevice(
const PString & driverName, ///< Name of driver
const PString & deviceName, ///< Name of device
PBoolean startImmediate = true, ///< Immediately start grabbing
PPluginManager * pluginMgr = NULL ///< Plug in manager, use default if NULL
);
/**Create an opened video output device that corresponds to the specified arguments.
*/
static PVideoInputDevice *CreateOpenedDevice(
const OpenArgs & args, ///< Parameters to set on opened device
PBoolean startImmediate = true ///< Immediately start display
);
typedef struct {
std::list<PVideoFrameInfo> framesizes;
std::list<PVideoControlInfo> controls;
std::list<PVideoInteractionInfo> interactions;
} Capabilities;
/**Retrieve a list of Device Capabilities
*/
virtual bool GetDeviceCapabilities(
Capabilities * capabilities ///< List of supported capabilities
) const { return GetDeviceCapabilities(GetDeviceName(), capabilities); }
/**Retrieve a list of Device Capabilities for particular device
*/
static PBoolean GetDeviceCapabilities(
const PString & deviceName, ///< Name of device
Capabilities * capabilities, ///< List of supported capabilities
PPluginManager * pluginMgr = NULL ///< Plug in manager, use default if NULL
);
/**Retrieve a list of Device Capabilities for a particular driver
*/
static PBoolean GetDeviceCapabilities(
const PString & deviceName, ///< Name of device
const PString & driverName, ///< Device Driver
Capabilities * caps, ///< List of supported capabilities
PPluginManager * pluginMgr = NULL ///< Plug in manager, use default if NULL
);
/**Get the devices video Input controls
By Default return NULL;
*/
virtual PVideoInputControl * GetVideoInputControls();
/**Open the device given the device name.
*/
virtual PBoolean Open(
const PString & deviceName, ///< Device name to open
PBoolean startImmediate = true ///< Immediately start device
) = 0;
virtual PBoolean Close(
) { return true; }
/** Is the device a camera, and obtain video
*/
virtual PBoolean CanCaptureVideo() const;
/**Determine if the video device I/O capture is in progress.
*/
virtual PBoolean IsCapturing() = 0;
/**Set the nearest available frame size to be used.
Note that devices may not be able to produce the requested size, so
this function picks the nearest available size.
Default behaviour simply calls SetFrameSize().
*/
virtual PBoolean SetNearestFrameSize(
unsigned width, ///< New width of frame
unsigned height ///< New height of frame
);
/**Grab a frame.
*/
virtual PBoolean GetFrame(
PBYTEArray & frame
);
/**Grab a frame, after a delay as specified by the frame rate.
*/
virtual PBoolean GetFrameData(
BYTE * buffer, ///< Buffer to receive frame
PINDEX * bytesReturned, ///< Optional bytes returned.
unsigned int & flags ///< optional flags returned
);
virtual PBoolean GetFrameData(
BYTE * buffer, ///< Buffer to receive frame
PINDEX * bytesReturned = NULL ///< Optional bytes returned.
) = 0;
/**Grab a frame. Do not delay according to the current frame rate parameter.
*/
virtual PBoolean GetFrameDataNoDelay(
BYTE * buffer, ///< Buffer to receive frame
PINDEX * bytesReturned, ///< Optional bytes returned.
unsigned int & flags ///< optional flags returned
);
virtual PBoolean GetFrameDataNoDelay(
BYTE * buffer, ///< Buffer to receive frame
PINDEX * bytesReturned = NULL ///< Optional bytes returned.
) = 0;
/**Pass data to the inputdevice for flowControl determination.
*/
virtual bool FlowControl(const void * flowData);
/**Set the capture modes for implementations that support them.
For example with Video For Windows, this is used to select picture (0)
or video (1) modes.
In picture-mode the implementation requests a single frame from the
connected camera device. The camera device then does nothing until the
frame has been processed and the next is requested.
In video-mode the camera continuously sends new frames.
The default implementation does nothing but returns PFalse.
*/
virtual bool SetCaptureMode(unsigned mode);
/**Returns the current capture mode. See SetCaptureMode() for more details.
A return value of -1 indicates an error or the mode is not supported.
*/
virtual int GetCaptureMode() const;
};
////////////////////////////////////////////////////////
//
// declare macros and structures needed for video input plugins
//
template <class className> class PVideoInputPluginServiceDescriptor : public PDevicePluginServiceDescriptor
{
public:
virtual PObject * CreateInstance(int /*userData*/) const { return new className; }
virtual PStringArray GetDeviceNames(int /*userData*/) const { return className::GetInputDeviceNames(); }
virtual bool GetDeviceCapabilities(const PString & deviceName, void * caps) const
{ return className::GetDeviceCapabilities(deviceName, (PVideoInputDevice::Capabilities *)caps); }
};
#define PCREATE_VIDINPUT_PLUGIN(name) \
static PVideoInputPluginServiceDescriptor<PVideoInputDevice_##name> PVideoInputDevice_##name##_descriptor; \
PCREATE_PLUGIN(name, PVideoInputDevice, &PVideoInputDevice_##name##_descriptor)
PPLUGIN_STATIC_LOAD(FakeVideo, PVideoInputDevice);
#ifdef P_APPSHARE
PPLUGIN_STATIC_LOAD(Application, PVideoInputDevice);
#endif
#if P_FFVDEV
PPLUGIN_STATIC_LOAD(FFMPEG, PVideoInputDevice);
#endif
#if P_VIDFILE
PPLUGIN_STATIC_LOAD(YUVFile, PVideoInputDevice);
#endif
#ifdef P_DIRECTSHOW
PPLUGIN_STATIC_LOAD(DirectShow, PVideoInputDevice);
#endif
////////////////////////////////////////////////////////
//
// declare macros and structures needed for video output plugins
//
template <class className> class PVideoOutputPluginServiceDescriptor : public PDevicePluginServiceDescriptor
{
public:
virtual PObject * CreateInstance(int /*userData*/) const { return new className; }
virtual PStringArray GetDeviceNames(int /*userData*/) const { return className::GetOutputDeviceNames(); }
};
#define PCREATE_VIDOUTPUT_PLUGIN(name) \
static PVideoOutputPluginServiceDescriptor<PVideoOutputDevice_##name> PVideoOutputDevice_##name##_descriptor; \
PCREATE_PLUGIN(name, PVideoOutputDevice, &PVideoOutputDevice_##name##_descriptor)
#if _WIN32
PPLUGIN_STATIC_LOAD(Window, PVideoOutputDevice);
#endif
#if P_SDL
PPLUGIN_STATIC_LOAD(SDL, PVideoOutputDevice);
#endif
////////////////////////////////////////////////////////
//
// declare classes needed for access to simple video font
//
class PVideoFont : public PObject
{
PCLASSINFO(PVideoFont, PObject);
public:
enum {
MAX_L_HEIGHT = 11
};
struct LetterData {
char ascii;
const char *line[MAX_L_HEIGHT];
};
static const LetterData * GetLetterData(char ascii);
};
#endif // P_VIDEO
#endif // PTLIB_PVIDEOIO_H
// End Of File ///////////////////////////////////////////////////////////////
|