-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstart-screencast.c
65 lines (56 loc) · 1.21 KB
/
start-screencast.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
* SPDX-License-Identifier: ISC
*
* Copyright (c) 2022 Codethink
*/
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include "msg/msg.h"
#include "msg/queue.h"
#include "msg/private.h"
#define PRINT_FMT_START_SCREENCAST__ID_FMT \
"{" \
"\"id\":%i," \
"\"method\":\"Page.startScreencast\"," \
"\"params\":{" \
"\"format\":\"%s\"," \
"\"everyNthFrame\":1" \
"}" \
"}"
#define PRINT_FMT_START_SCREENCAST__ID_FMT_MAXW_MAXH \
"{" \
"\"id\":%i," \
"\"method\":\"Page.startScreencast\"," \
"\"params\":{" \
"\"format\":\"%s\"," \
"\"maxWidth\":%i," \
"\"maxHeight\":%i," \
"\"everyNthFrame\":1" \
"}" \
"}"
char *msg_str_start_screencast(const struct msg *msg, int id)
{
struct msg_container *m;
const char *fmt = msg->data.start_screencast.format;
int h = msg->data.start_screencast.max_height;
int w = msg->data.start_screencast.max_width;
if (fmt == NULL) {
fmt = "jpeg";
}
if (w == 0 || h == 0) {
if (!msg_create(&m, PRINT_FMT_START_SCREENCAST__ID_FMT,
id, fmt)) {
return NULL;
}
} else {
if (!msg_create(&m,
PRINT_FMT_START_SCREENCAST__ID_FMT_MAXW_MAXH,
id, fmt, w, h)) {
return NULL;
}
}
m->type = msg->type;
m->id = id;
return m->str;
}