Added possibility to send message synchronously

+ in capabilities list, given bitrate is computed according to the
  detected capture format (provided that '-t' argument is given)
This commit is contained in:
Martin Pulec
2015-08-25 17:05:23 +02:00
parent 5b58e21b26
commit 2cc6aab0e2
39 changed files with 576 additions and 199 deletions

View File

@@ -9,9 +9,13 @@
#include "host.h"
#include "messaging.h"
#include "video_capture.h"
#include "video_compress.h"
#include "video.h"
#include <iomanip>
#include <iostream>
#include <sstream>
using namespace std;
@@ -39,14 +43,35 @@ bool color_term = (getenv("TERM") && (strcmp(getenv("TERM"), "xterm") == 0 || st
bool ldgm_device_gpu = false;
const char *window_title = NULL;
#include <sstream>
void print_capabilities(int mask)
void print_capabilities(int mask, struct module *root, bool use_vidcap)
{
if (mask & CAPABILITY_COMPRESS) {
/// try to figure out actual video format and consequently number of pixels per sec
int pixs_per_sec_uncompressed = 0;
if (use_vidcap && root) {
for (int attempt = 0; attempt < 2; ++attempt) {
struct msg_sender *m = (struct msg_sender *) new_message(sizeof(struct msg_sender));
m->type = SENDER_MSG_QUERY_VIDEO_MODE;
struct response *r = send_message_sync(root, "sender", (struct message *) m, 1000);
if (response_get_status(r) == RESPONSE_OK) {
const char *text = response_get_text(r);
struct video_desc desc;
istringstream iss(text);
iss >> desc;
pixs_per_sec_uncompressed = desc.width * desc.height * desc.fps;
break;
}
free_response(r);
sleep(1);
}
}
cout << "Compressions:" << endl;
auto const & compress_capabilities = get_compress_capabilities();
for (auto const & it : compress_capabilities) {
cout << "(" << it.name << ";" << it.quality << ";" << it.bitrate << ";" <<
cout << "(" << it.name << ";" << it.quality << ";" << setiosflags(ios_base::fixed) << setprecision(2) << it.bpp * pixs_per_sec_uncompressed << ";" <<
it.enc_prop.latency << ";" << it.enc_prop.cpu_cores << ";" << it.enc_prop.gpu_gflops << ";" <<
it.dec_prop.latency << ";" << it.dec_prop.cpu_cores << ";" << it.dec_prop.gpu_gflops <<
")\n";