Astra SDK  v2.1.3
DataStream.hpp
1 // This file is part of the Orbbec Astra SDK [https://orbbec3d.com]
2 // Copyright (c) 2015-2017 Orbbec 3D
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 // Be excellent to each other.
17 #ifndef ASTRA_DATASTREAM_HPP
18 #define ASTRA_DATASTREAM_HPP
19 
20 #include "capi/astra_core.h"
21 #include <astra_core/StreamDescription.hpp>
22 #include <stdexcept>
23 
24 namespace astra {
25 
32  class DataStream
33  {
34  public:
35  DataStream()
36  {}
37 
44  : connection_(connection)
45  {
46  if(connection_ != nullptr)
47  {
48  astra_stream_get_description(connection,&description_);
49  }
50  }
51 
57  bool is_available()
58  {
59  bool isAvailable = false;
60  if (connection_ == nullptr)
61  {
62  return isAvailable;
63  }
64  astra_stream_is_available(connection_, &isAvailable);
65  return isAvailable;
66  }
67 
71  void start()
72  {
73  if(connection_ == nullptr)
74  {
75  throw std::logic_error("Cannot start a stream that is not available");
76  }
77  astra_stream_start(connection_);
78  }
79 
83  void stop()
84  {
85  if(connection_ == nullptr)
86  {
87  throw std::logic_error("Cannot stop a stream that is not available");
88  }
89  astra_stream_stop(connection_);
90  }
91 
92  private:
93  astra_streamconnection_t connection_{nullptr};
94  astra_stream_desc_t description_;
95  };
96 }
97 
98 #endif // ASTRA_DATASTREAM_HPP
Data Stream
Definition: DataStream.hpp:33
void start()
start stream
Definition: DataStream.hpp:71
void stop()
stop stream
Definition: DataStream.hpp:83
DataStream(astra_streamconnection_t connection)
default constructs
Definition: DataStream.hpp:43
bool is_available()
start stream
Definition: DataStream.hpp:57
Definition: astra_plugin.h:24
Definition: astra_types.h:42