1 #include "stdafx.h"
4
5 #if TRUE // change it to FALSE to disable camera functionality
6
9
11 {
12 /*
13
14 BEHAVIOR: camera_stream
15 provides video frames from camera
16 COMMENTS:
17 <video style="behavior:camera video" />
18 SAMPLE:
19 See: samples/video/video-camera-behavior.htm
20 */
21
22 struct camera_stream: public event_handler
23 {
24 com::ptr<camera::capture> pcapt;
26 // ctor
27 camera_stream() {}
28 virtual ~camera_stream() {}
29
30 virtual bool subscription(
HELEMENT he, UINT& event_groups )
31 {
33 return true;
34 }
35
36 virtual void attached (
HELEMENT he ) { }
37
38 virtual void detached (
HELEMENT he ) {
delete this; }
40 {
42 return false;
43 // we handle only VIDEO_BIND_RQ requests here
44
45 if( !reason )
46 return true; // first phase, consume the event to mark as we will provide frames
47
49 return true;
50 }
51
56 for(
unsigned n = 0; n < devices.
count(); ++n ) {
60 }
61 return r;
62 }
63
65 {
66 if(pcapt)
67 pcapt->end_capture();
70 }
71
72 // scripting methods
73 BEGIN_FUNCTION_MAP
74 FUNCTION_0("devices",get_devices) // devices() : (array of strings), get list of names of devices
75 FUNCTION_1("streamFrom",stream_from) // streamFrom(indexOrName: int | string), start streaming from the camera
76 END_FUNCTION_MAP
77
78 };
79
80 struct camera_stream_factory: public behavior_factory {
81
82 camera_stream_factory(): behavior_factory("camera") {}
83
84 // the only behavior_factory method:
85 virtual event_handler* create(
HELEMENT he) {
return new camera_stream(); }
86
87 };
88
89 // instantiating and attaching it to the global list
90 camera_stream_factory camera_stream_factory_instance;
91
92
93 }
94
95 #endif
Behaiviors support (a.k.a windowless scriptable controls)
static capture * create_instance(sciter::video_destination *pdst, const sciter::value &source_name_or_index)
void append(const value &v)
bool get_device_name(unsigned index, sciter::string &name)
std::basic_string< WCHAR > string