Added --param cmdline param to modify UG intenals

These options are now available:
decoder - to force user selected decoder (eg. libavcodec instead
of gpujpeg, which would be chosen by default)
drop-policy - to allow non-blocking put frame (effectively drops
frames that cannot be displayed immediately, eg. when display
frame rate is lower than video frame rate)
This commit is contained in:
Martin Pulec
2016-03-23 14:24:39 +01:00
parent ce056b9e67
commit 57fe2cef91
6 changed files with 45 additions and 4 deletions

View File

@@ -42,14 +42,14 @@
#define UNUSED(x) (x=x)
#include "host.h"
#ifdef __cplusplus
extern "C" {
#endif
void debug_dump(void*lp, int len);
#include "host.h"
#define error_msg(...) log_msg(LOG_LEVEL_ERROR, __VA_ARGS__)
#define verbose_msg(...) log_msg(LOG_LEVEL_VERBOSE, __VA_ARGS__)
///#define debug_msg(...) log_msg(LOG_LEVEL_DEBUG, "[pid/%d +%d %s] ", getpid(), __LINE__, __FILE__), log_msg(LOG_LEVEL_DEBUG, __VA_ARGS__)

View File

@@ -58,6 +58,8 @@ bool ldgm_device_gpu = false;
const char *window_title = NULL;
std::unordered_map<std::string, std::string> commandline_params;
static void common_cleanup()
{
#ifdef USE_MTRACE

View File

@@ -136,4 +136,10 @@ void print_version(void);
}
#endif
#ifdef __cplusplus
#include <unordered_map>
#include <string>
extern std::unordered_map<std::string, std::string> commandline_params;
#endif
#endif

View File

@@ -120,6 +120,7 @@ static constexpr const char *DEFAULT_AUDIO_CODEC = "PCM";
#define OPT_DISABLE_KEY_CTRL (('D' << 8) | 'K')
#define OPT_START_PAUSED (('S' << 8) | 'P')
#define OPT_PROTOCOL (('P' << 8) | 'R')
#define OPT_PARAM (('O' << 8) | 'P')
#define MAX_CAPTURE_COUNT 17
@@ -410,6 +411,22 @@ bool parse_audio_capture_format(const char *optarg)
return true;
}
static void parse_params(char *optarg)
{
char *item, *save_ptr;
while ((item = strtok_r(optarg, ":", &save_ptr))) {
char *key_cstr = item;
if (strchr(item, '=')) {
char *val_cstr = strchr(item, '=') + 1;
*strchr(item, '=') = '\0';
commandline_params[key_cstr] = val_cstr;
} else {
commandline_params[key_cstr] = string();
}
optarg = NULL;
}
}
int main(int argc, char *argv[])
{
#if defined HAVE_SCHED_SETSCHEDULER && defined USE_RT
@@ -529,6 +546,7 @@ int main(int argc, char *argv[])
{"start-paused", no_argument, 0, OPT_START_PAUSED},
{"protocol", required_argument, 0, OPT_PROTOCOL},
{"rtsp-server", optional_argument, 0, 'H'},
{"param", required_argument, 0, OPT_PARAM},
{0, 0, 0, 0}
};
int option_index = 0;
@@ -798,6 +816,9 @@ int main(int argc, char *argv[])
case OPT_START_PAUSED:
start_paused = true;
break;
case OPT_PARAM:
parse_params(optarg);
break;
case '?':
default:
usage();

View File

@@ -570,12 +570,18 @@ static void *decompress_thread(void *args) {
}
{
int putf_flags = 0;
int putf_flags = PUTF_BLOCKING;
if(is_codec_interframe(decoder->received_vid_desc.color_spec)) {
if (is_codec_interframe(decoder->received_vid_desc.color_spec)) {
putf_flags = PUTF_NONBLOCK;
}
if (commandline_params.find("drop-policy") != commandline_params.end()) {
if (commandline_params.at("drop-policy") == "nonblock") {
putf_flags = PUTF_NONBLOCK;
}
}
decoder->frame->ssrc = msg->nofec_frame->ssrc;
int ret = display_put_frame(decoder->display,
decoder->frame, putf_flags);

View File

@@ -78,6 +78,12 @@ static int find_best_decompress(codec_t in_codec, codec_t out_codec,
int best_priority = prio_max + 1;
for (const auto & d : decomps) {
// if user has explicitly requested decoder, skip all others
if (commandline_params.find("decoder") != commandline_params.end()) {
if (d.first != commandline_params.at("decoder")) {
continue;
}
}
// first pass - find the one with best priority (least)
const struct decode_from_to *f = static_cast<const video_decompress_info *>(d.second)->available_decoders;
while (f->from != VIDEO_CODEC_NONE) {