Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[apps] Added CSV stats logging and file output #598

Merged
merged 13 commits into from
Apr 11, 2019
Merged
43 changes: 40 additions & 3 deletions apps/apputil.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,25 @@ inline std::string Join(const std::vector<std::string>& in, std::string sep)
return os.str();
}


inline bool CheckTrue(const std::vector<std::string>& in)
{
if (in.empty())
return true;

const std::set<std::string> false_vals = { "0", "no", "off", "false" };
if (false_vals.count(in[0]))
return false;

return true;

//if (in[0] != "false" && in[0] != "off")
// return true;

//return false;
}


typedef std::map<std::string, std::vector<std::string>> options_t;

struct OutList
Expand All @@ -177,6 +196,13 @@ struct OutString
};


struct OutBool
{
typedef bool type;
static type process(const options_t::mapped_type& i) { return CheckTrue(i); }
};


template <class OutType, class OutValue> inline
typename OutType::type Option(const options_t&, OutValue deflt=OutValue()) { return deflt; }

Expand Down Expand Up @@ -221,9 +247,16 @@ inline options_t ProcessOptions(char* const* argv, int argc, std::vector<OptionS
{
const char* a = *p;
// cout << "*D ARG: '" << a << "'\n";
if ( moreoptions && a[0] == '-' )
if (moreoptions && a[0] == '-')
{
current_key = a+1;
string key(a + 1); // omit '-'
size_t pos = key.find_first_of(":");
if (pos == string::npos)
pos = key.find(' ');
string value = pos == string::npos ? "" : key.substr(pos + 1);
key = key.substr(0, pos);

current_key = key;
if ( current_key == "-" )
{
// The -- argument terminates the options.
Expand All @@ -242,11 +275,15 @@ inline options_t ProcessOptions(char* const* argv, int argc, std::vector<OptionS
if (s.names.count(current_key))
{
// cout << "*D found '" << current_key << "' in scheme type=" << int(s.type) << endl;
if ( s.type == OptionScheme::ARG_NONE )
if (s.type == OptionScheme::ARG_NONE )
{
// Anyway, consider it already processed.
break;
}
else if (s.type == OptionScheme::ARG_ONE)
{
params[current_key].push_back(value);
}
type = s.type;
goto Found;
}
Expand Down
4 changes: 2 additions & 2 deletions apps/socketoptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ struct SocketOption
template<>
inline int SocketOption::setso<SocketOption::SRT>(int socket, int /*ignored*/, int sym, const void* data, size_t size)
{
return srt_setsockopt(socket, 0, SRT_SOCKOPT(sym), data, size);
return srt_setsockopt(socket, 0, SRT_SOCKOPT(sym), data, (int) size);
}

template<>
inline int SocketOption::setso<SocketOption::SYSTEM>(int socket, int proto, int sym, const void* data, size_t size)
{
return ::setsockopt(socket, proto, sym, (const char *)data, size);
return ::setsockopt(socket, proto, sym, (const char *)data, (int) size);
}

template<>
Expand Down
Loading