| 39 | } |
| 40 | |
| 41 | int MultiCastStreamer::init_streamer () |
| 42 | { |
| 43 | if ((is_streaming) || (server != NULL) || (db != NULL)) |
| 44 | { |
| 45 | Board::board_logger->error ("multicast streamer is running"); |
| 46 | return (int)BrainFlowExitCodes::GENERAL_ERROR; |
| 47 | } |
| 48 | |
| 49 | server = new MultiCastServer (ip, port); |
| 50 | int res = server->init (); |
| 51 | if (res != (int)MultiCastReturnCodes::STATUS_OK) |
| 52 | { |
| 53 | delete server; |
| 54 | server = NULL; |
| 55 | Board::board_logger->error ("failed to init server multicast socket {}", res); |
| 56 | return (int)BrainFlowExitCodes::GENERAL_ERROR; |
| 57 | } |
| 58 | |
| 59 | db = new DataBuffer (len, 1000); |
| 60 | if (!db->is_ready ()) |
| 61 | { |
| 62 | Board::board_logger->error ("unable to prepare buffer for multicast"); |
| 63 | delete db; |
| 64 | db = NULL; |
| 65 | delete server; |
| 66 | server = NULL; |
| 67 | return (int)BrainFlowExitCodes::INVALID_BUFFER_SIZE_ERROR; |
| 68 | } |
| 69 | |
| 70 | is_streaming = true; |
| 71 | streaming_thread = std::thread ([this] { this->thread_worker (); }); |
| 72 | return (int)BrainFlowExitCodes::STATUS_OK; |
| 73 | } |
| 74 | |
| 75 | void MultiCastStreamer::stream_data (double *data) |
| 76 | { |
nothing calls this directly
no test coverage detected