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

Add srt_getversion API function #1024

Merged
merged 3 commits into from
Mar 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion apps/srt-file-transmit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,12 @@ int parse_args(FileTransmitConfig &cfg, int argc, char** argv)
if (print_help)
{
cout << "SRT sample application to transmit files.\n";
cerr << "SRT Library version: " << SRT_VERSION << endl;
cerr << "Built with SRT Library version: " << SRT_VERSION << endl;
const uint32_t srtver = srt_getversion();
const int major = srtver / 0x10000;
const int minor = (srtver / 0x100) % 0x100;
const int patch = srtver % 0x100;
cerr << "SRT Library version: " << major << "." << minor << "." << patch << endl;
cerr << "Usage: srt-file-transmit [options] <input-uri> <output-uri>\n";
cerr << "\n";

Expand Down
7 changes: 6 additions & 1 deletion apps/srt-live-transmit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,12 @@ int parse_args(LiveTransmitConfig &cfg, int argc, char** argv)
if (print_help)
{
cout << "SRT sample application to transmit live streaming.\n";
cerr << "SRT Library version: " << SRT_VERSION << endl;
cerr << "Built with SRT Library version: " << SRT_VERSION << endl;
const uint32_t srtver = srt_getversion();
const int major = srtver / 0x10000;
const int minor = (srtver / 0x100) % 0x100;
const int patch = srtver % 0x100;
cerr << "SRT Library version: " << major << "." << minor << "." << patch << endl;
cerr << "Usage: srt-live-transmit [options] <input-uri> <output-uri>\n";
cerr << "\n";
#ifndef _WIN32
Expand Down
15 changes: 15 additions & 0 deletions docs/API-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ SRT API Functions
* [srt_getsockname](#srt_getsockname)
* [srt_getsockopt, srt_getsockflag](#srt_getsockopt-srt_getsockflag)
* [srt_setsockopt, srt_setsockflag](#srt_setsockopt-srt_setsockflag)
* [srt_getversion](#srt_getversion)
- [**Helper data types for transmission**](#Helper-data-types-for-transmission)
* [SRT_MSGCTRL](#SRT_MSGCTRL)
- [**Transmission**](#Transmission)
Expand Down Expand Up @@ -549,6 +550,20 @@ type with the option value to be set.
* Various other errors that may result from problems when setting a specific
option (see option description for details).

### srt_getversion

```
uint32_t srt_getversion();
```

Get SRT version value. The version format in hex is 0xXXYYZZ for x.y.z in human readable form,
where x = ("%d", (version>>16) & 0xff), etc.

- Returns:

* srt version as an unsigned 32-bit integer


Helper data types for transmission
----------------------------------

Expand Down
2 changes: 1 addition & 1 deletion srtcore/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ inline int32_t SrtParseVersion(const char* v)
return 0;
}

return major*0x10000 + minor*0x100 + patch;
return SrtVersion(major, minor, patch);
}

inline std::string SrtVersionString(int version)
Expand Down