Skip to content

Commit

Permalink
add env var to control size of multicast streamer buffer (#561)
Browse files Browse the repository at this point in the history
* add env var for multicast streamer

Signed-off-by: Andrey Parfenov <a1994ndrey@gmail.com>
  • Loading branch information
Andrey1994 committed Oct 13, 2022
1 parent 9a94b7f commit 4589e74
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
6 changes: 1 addition & 5 deletions src/board_controller/inc/multicast_streamer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ class MultiCastStreamer : public Streamer
{

public:
static int get_packages_in_chunk ()
{
// todo add env variable to set size
return 3;
}
static int get_packages_in_chunk ();

MultiCastStreamer (const char *ip, int port, int data_len);
~MultiCastStreamer ();
Expand Down
22 changes: 22 additions & 0 deletions src/board_controller/multicast_streamer.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <cstdlib>
#include <string.h>
#include <string>

Expand All @@ -7,6 +8,27 @@
#include "multicast_streamer.h"


int MultiCastStreamer::get_packages_in_chunk ()
{
int size = 3;
if (const char *env_p = std::getenv ("BRAINFLOW_MULTICAST_SIZE"))
{
std::string str_env = env_p;
try
{
int parsed_size = std::stoi (str_env);
if ((parsed_size > 0) && (parsed_size < 15))
{
size = parsed_size;
}
}
catch (...)
{
}
}
return size;
}

MultiCastStreamer::MultiCastStreamer (const char *ip, int port, int data_len)
: Streamer (data_len, "streaming_board", ip, std::to_string (port))
{
Expand Down

0 comments on commit 4589e74

Please sign in to comment.