00001 /* 00002 * This file is part of the rc_genicam_api package. 00003 * 00004 * Copyright (c) 2017 Roboception GmbH 00005 * All rights reserved 00006 * 00007 * Author: Heiko Hirschmueller 00008 * 00009 * Redistribution and use in source and binary forms, with or without 00010 * modification, are permitted provided that the following conditions are met: 00011 * 00012 * 1. Redistributions of source code must retain the above copyright notice, 00013 * this list of conditions and the following disclaimer. 00014 * 00015 * 2. Redistributions in binary form must reproduce the above copyright notice, 00016 * this list of conditions and the following disclaimer in the documentation 00017 * and/or other materials provided with the distribution. 00018 * 00019 * 3. Neither the name of the copyright holder nor the names of its contributors 00020 * may be used to endorse or promote products derived from this software without 00021 * specific prior written permission. 00022 * 00023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00024 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00025 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00026 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 00027 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00028 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00029 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00030 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00031 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00032 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00033 * POSSIBILITY OF SUCH DAMAGE. 00034 */ 00035 00036 #ifndef RC_GENICAM_API_STREAM 00037 #define RC_GENICAM_API_STREAM 00038 00039 #include "device.h" 00040 #include "buffer.h" 00041 00042 namespace rcg 00043 { 00044 00045 class Buffer; 00046 00053 class Stream : public std::enable_shared_from_this<Stream> 00054 { 00055 public: 00056 00062 Stream(const std::shared_ptr<Device> &parent, 00063 const std::shared_ptr<const GenTLWrapper> &gentl, const char *id); 00064 ~Stream(); 00065 00072 std::shared_ptr<Device> getParent() const; 00073 00080 const std::string &getID() const; 00081 00088 void open(); 00089 00095 void close(); 00096 00104 void startStreaming(int na=-1); 00105 00110 void stopStreaming(); 00111 00121 const Buffer *grab(int64_t timeout=-1); 00122 00131 uint64_t getNumDelivered() const; 00132 00141 uint64_t getNumUnderrun() const; 00142 00151 size_t getNumAnnounced() const; 00152 00161 size_t getNumQueued() const; 00162 00171 size_t getNumAwaitDelivery() const; 00172 00181 uint64_t getNumStarted() const; 00182 00191 size_t getPayloadSize() const; 00192 00201 bool getIsGrabbing() const; 00202 00212 bool getDefinesPayloadsize() const; 00213 00222 std::string getTLType() const; 00223 00232 size_t getNumChunksMax() const; 00233 00242 size_t getBufAnnounceMin() const; 00243 00252 size_t getBufAlignment() const; 00253 00263 std::shared_ptr<GenApi::CNodeMapRef> getNodeMap(); 00264 00271 void *getHandle() const; 00272 00273 private: 00274 00275 Stream(class Stream &); // forbidden 00276 Stream &operator=(const Stream &); // forbidden 00277 00278 Buffer buffer; 00279 00280 std::shared_ptr<Device> parent; 00281 std::shared_ptr<const GenTLWrapper> gentl; 00282 std::string id; 00283 00284 int n_open; 00285 void *stream; 00286 void *event; 00287 size_t bn; 00288 00289 std::shared_ptr<CPort> cport; 00290 std::shared_ptr<GenApi::CNodeMapRef> nodemap; 00291 }; 00292 00293 } 00294 00295 #endif