1 /** 2 Server keeping track of different cameras accessible in Godot. 3 4 Copyright: 5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. 6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) 7 Copyright (c) 2017-2018 Godot-D contributors 8 9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License) 10 11 12 */ 13 module godot.cameraserver; 14 import std.meta : AliasSeq, staticIndexOf; 15 import std.traits : Unqual; 16 import godot.d.traits; 17 import godot.core; 18 import godot.c; 19 import godot.d.bind; 20 import godot.d.reference; 21 import godot.globalenums; 22 import godot.object; 23 import godot.camerafeed; 24 /** 25 Server keeping track of different cameras accessible in Godot. 26 27 The $(D CameraServer) keeps track of different cameras accessible in Godot. These are external cameras such as webcams or the cameras on your phone. 28 It is notably used to provide AR modules with a video feed from the camera. 29 */ 30 @GodotBaseClass struct CameraServerSingleton 31 { 32 package(godot) enum string _GODOT_internal_name = "CameraServer"; 33 public: 34 @nogc nothrow: 35 union { /** */ godot_object _godot_object; /** */ GodotObject _GODOT_base; } 36 alias _GODOT_base this; 37 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 38 package(godot) __gshared bool _classBindingInitialized = false; 39 package(godot) static struct GDNativeClassBinding 40 { 41 __gshared: 42 godot_object _singleton; 43 immutable char* _singletonName = "CameraServer"; 44 @GodotName("add_feed") GodotMethod!(void, CameraFeed) addFeed; 45 @GodotName("feeds") GodotMethod!(Array) feeds; 46 @GodotName("get_feed") GodotMethod!(CameraFeed, long) getFeed; 47 @GodotName("get_feed_count") GodotMethod!(long) getFeedCount; 48 @GodotName("remove_feed") GodotMethod!(void, CameraFeed) removeFeed; 49 } 50 /// 51 pragma(inline, true) bool opEquals(in CameraServerSingleton other) const 52 { return _godot_object.ptr is other._godot_object.ptr; } 53 /// 54 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 55 { _godot_object.ptr = n; return null; } 56 /// 57 pragma(inline, true) bool opEquals(typeof(null) n) const 58 { return _godot_object.ptr is n; } 59 /// 60 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 61 mixin baseCasts; 62 /// Construct a new instance of CameraServerSingleton. 63 /// Note: use `memnew!CameraServerSingleton` instead. 64 static CameraServerSingleton _new() 65 { 66 static godot_class_constructor constructor; 67 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("CameraServer"); 68 if(constructor is null) return typeof(this).init; 69 return cast(CameraServerSingleton)(constructor()); 70 } 71 @disable new(size_t s); 72 /// 73 enum FeedImage : int 74 { 75 /** 76 The RGBA camera image. 77 */ 78 feedRgbaImage = 0, 79 /** 80 The YCbCr camera image. 81 */ 82 feedYcbcrImage = 0, 83 /** 84 The Y component camera image. 85 */ 86 feedYImage = 0, 87 /** 88 The CbCr component camera image. 89 */ 90 feedCbcrImage = 1, 91 } 92 /// 93 enum Constants : int 94 { 95 feedRgbaImage = 0, 96 feedYcbcrImage = 0, 97 feedYImage = 0, 98 feedCbcrImage = 1, 99 } 100 /** 101 Adds a camera feed to the camera server. 102 */ 103 void addFeed(CameraFeed feed) 104 { 105 checkClassBinding!(typeof(this))(); 106 ptrcall!(void)(GDNativeClassBinding.addFeed, _godot_object, feed); 107 } 108 /** 109 Returns an array of $(D CameraFeed)s. 110 */ 111 Array feeds() 112 { 113 checkClassBinding!(typeof(this))(); 114 return ptrcall!(Array)(GDNativeClassBinding.feeds, _godot_object); 115 } 116 /** 117 Returns the $(D CameraFeed) with this id. 118 */ 119 Ref!CameraFeed getFeed(in long index) 120 { 121 checkClassBinding!(typeof(this))(); 122 return ptrcall!(CameraFeed)(GDNativeClassBinding.getFeed, _godot_object, index); 123 } 124 /** 125 Returns the number of $(D CameraFeed)s registered. 126 */ 127 long getFeedCount() 128 { 129 checkClassBinding!(typeof(this))(); 130 return ptrcall!(long)(GDNativeClassBinding.getFeedCount, _godot_object); 131 } 132 /** 133 Removes a $(D CameraFeed). 134 */ 135 void removeFeed(CameraFeed feed) 136 { 137 checkClassBinding!(typeof(this))(); 138 ptrcall!(void)(GDNativeClassBinding.removeFeed, _godot_object, feed); 139 } 140 } 141 /// Returns: the CameraServerSingleton 142 @property @nogc nothrow pragma(inline, true) 143 CameraServerSingleton CameraServer() 144 { 145 checkClassBinding!CameraServerSingleton(); 146 return CameraServerSingleton(CameraServerSingleton.GDNativeClassBinding._singleton); 147 }