mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-14 02:36:51 -07:00
Specify Video Profile
This commit is contained in:
parent
f886995295
commit
389676899c
9 changed files with 98 additions and 5 deletions
|
@ -51,6 +51,7 @@ struct StreamSessionConnectInfo
|
|||
QString auth;
|
||||
QString morning;
|
||||
QString did;
|
||||
ChiakiConnectVideoProfile video_profile;
|
||||
};
|
||||
|
||||
class StreamSession : public QObject
|
||||
|
|
|
@ -69,6 +69,11 @@ int main(int argc, char *argv[])
|
|||
connect_info.auth = parser.value(auth_option);
|
||||
connect_info.morning = parser.value(morning_option);
|
||||
connect_info.did = parser.value(did_option);
|
||||
|
||||
chiaki_connect_video_profile_preset(&connect_info.video_profile,
|
||||
CHIAKI_VIDEO_RESOLUTION_PRESET_540p,
|
||||
CHIAKI_VIDEO_FPS_PRESET_30);
|
||||
|
||||
if(connect_info.registkey.isEmpty() || connect_info.ostype.isEmpty() || connect_info.auth.isEmpty() || connect_info.morning.isEmpty() || connect_info.did.isEmpty())
|
||||
parser.showHelp(1);
|
||||
return RunStream(app, connect_info);
|
||||
|
@ -95,7 +100,7 @@ int RunMain(QApplication &app)
|
|||
int RunStream(QApplication &app, const StreamSessionConnectInfo &connect_info)
|
||||
{
|
||||
StreamWindow window(connect_info);
|
||||
window.resize(640, 360);
|
||||
window.resize(connect_info.video_profile.width, connect_info.video_profile.height);
|
||||
window.show();
|
||||
|
||||
app.setQuitOnLastWindowClosed(true);
|
||||
|
|
|
@ -48,6 +48,7 @@ StreamSession::StreamSession(const StreamSessionConnectInfo &connect_info, QObje
|
|||
chiaki_connect_info.host = host_str.constData();
|
||||
chiaki_connect_info.regist_key = registkey_str.constData();
|
||||
chiaki_connect_info.ostype = ostype_str.constData();
|
||||
chiaki_connect_info.video_profile = connect_info.video_profile;
|
||||
|
||||
QByteArray auth_str = connect_info.auth.toUtf8();
|
||||
size_t auth_len = auth_str.length();
|
||||
|
|
|
@ -32,6 +32,9 @@ typedef struct chiaki_launch_spec_t
|
|||
unsigned int mtu;
|
||||
unsigned int rtt;
|
||||
uint8_t *handshake_key;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned int max_fps;
|
||||
} ChiakiLaunchSpec;
|
||||
|
||||
CHIAKI_EXPORT int chiaki_launchspec_format(char *buf, size_t buf_size, ChiakiLaunchSpec *launch_spec);
|
||||
|
|
|
@ -44,6 +44,27 @@ extern "C" {
|
|||
#define CHIAKI_SESSION_ID_SIZE_MAX 80
|
||||
#define CHIAKI_HANDSHAKE_KEY_SIZE 0x10
|
||||
|
||||
typedef struct chiaki_connect_video_profile_t
|
||||
{
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned int max_fps;
|
||||
} ChiakiConnectVideoProfile;
|
||||
|
||||
typedef enum {
|
||||
CHIAKI_VIDEO_RESOLUTION_PRESET_360p,
|
||||
CHIAKI_VIDEO_RESOLUTION_PRESET_540p,
|
||||
CHIAKI_VIDEO_RESOLUTION_PRESET_720p,
|
||||
CHIAKI_VIDEO_RESOLUTION_PRESET_1080p
|
||||
} ChiakiVideoResolutionPreset;
|
||||
|
||||
typedef enum {
|
||||
CHIAKI_VIDEO_FPS_PRESET_30,
|
||||
CHIAKI_VIDEO_FPS_PRESET_60
|
||||
} ChiakiVideoFPSPreset;
|
||||
|
||||
CHIAKI_EXPORT void chiaki_connect_video_profile_preset(ChiakiConnectVideoProfile *profile, ChiakiVideoResolutionPreset resolution, ChiakiVideoFPSPreset fps);
|
||||
|
||||
typedef struct chiaki_connect_info_t
|
||||
{
|
||||
const char *host; // null terminated
|
||||
|
@ -52,6 +73,7 @@ typedef struct chiaki_connect_info_t
|
|||
char auth[0x10]; // must be completely filled (pad with \0)
|
||||
uint8_t morning[0x10];
|
||||
uint8_t did[CHIAKI_RP_DID_SIZE];
|
||||
ChiakiConnectVideoProfile video_profile;
|
||||
} ChiakiConnectInfo;
|
||||
|
||||
|
||||
|
@ -111,6 +133,7 @@ typedef struct chiaki_session_t
|
|||
char auth[CHIAKI_KEY_BYTES];
|
||||
uint8_t morning[CHIAKI_KEY_BYTES];
|
||||
uint8_t did[CHIAKI_RP_DID_SIZE];
|
||||
ChiakiConnectVideoProfile video_profile;
|
||||
} connect_info;
|
||||
|
||||
uint8_t nonce[CHIAKI_KEY_BYTES];
|
||||
|
|
|
@ -28,10 +28,10 @@ static const char launchspec_fmt[] =
|
|||
"{"
|
||||
"\"resolution\":"
|
||||
"{"
|
||||
"\"width\":640,"
|
||||
"\"height\":360"
|
||||
"\"width\":%u,"
|
||||
"\"height\":%u"
|
||||
"},"
|
||||
"\"maxFps\":30,"
|
||||
"\"maxFps\":%u,"
|
||||
"\"score\":10"
|
||||
"}"
|
||||
"],"
|
||||
|
@ -83,7 +83,9 @@ CHIAKI_EXPORT int chiaki_launchspec_format(char *buf, size_t buf_size, ChiakiLau
|
|||
if(err != CHIAKI_ERR_SUCCESS)
|
||||
return -1;
|
||||
|
||||
int written = snprintf(buf, buf_size, launchspec_fmt, launch_spec->mtu, launch_spec->rtt, handshake_key_b64);
|
||||
int written = snprintf(buf, buf_size, launchspec_fmt,
|
||||
launch_spec->width, launch_spec->height, launch_spec->max_fps,
|
||||
launch_spec->mtu, launch_spec->rtt, handshake_key_b64);
|
||||
if(written < 0 || written >= buf_size)
|
||||
return -1;
|
||||
return written;
|
||||
|
|
|
@ -35,6 +35,9 @@ CHIAKI_EXPORT void chiaki_log_cb_print(ChiakiLogLevel level, const char *msg, vo
|
|||
const char *color = NULL;
|
||||
switch(level)
|
||||
{
|
||||
case CHIAKI_LOG_VERBOSE:
|
||||
c = 'V';
|
||||
break;
|
||||
case CHIAKI_LOG_DEBUG:
|
||||
c = 'D';
|
||||
color = "34";
|
||||
|
@ -110,6 +113,9 @@ static const char hex_char[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9
|
|||
|
||||
CHIAKI_EXPORT void chiaki_log_hexdump(ChiakiLog *log, ChiakiLogLevel level, const uint8_t *buf, size_t buf_size)
|
||||
{
|
||||
if(log && !(log->level_mask & level))
|
||||
return;
|
||||
|
||||
chiaki_log(log, level, "offset 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef");
|
||||
|
||||
size_t offset = 0;
|
||||
|
@ -161,6 +167,9 @@ CHIAKI_EXPORT void chiaki_log_hexdump(ChiakiLog *log, ChiakiLogLevel level, cons
|
|||
|
||||
CHIAKI_EXPORT void chiaki_log_hexdump_raw(ChiakiLog *log, ChiakiLogLevel level, const uint8_t *buf, size_t buf_size)
|
||||
{
|
||||
if(log && !(log->level_mask & level))
|
||||
return;
|
||||
|
||||
char *str = malloc(buf_size * 2 + 1);
|
||||
if(!str)
|
||||
return;
|
||||
|
|
|
@ -43,6 +43,46 @@
|
|||
|
||||
#define SESSION_EXPECT_TIMEOUT_MS 5000
|
||||
|
||||
CHIAKI_EXPORT void chiaki_connect_video_profile_preset(ChiakiConnectVideoProfile *profile, ChiakiVideoResolutionPreset resolution, ChiakiVideoFPSPreset fps)
|
||||
{
|
||||
switch(resolution)
|
||||
{
|
||||
case CHIAKI_VIDEO_RESOLUTION_PRESET_360p:
|
||||
profile->width = 640;
|
||||
profile->height = 360;
|
||||
break;
|
||||
case CHIAKI_VIDEO_RESOLUTION_PRESET_540p:
|
||||
profile->width = 960;
|
||||
profile->height = 540;
|
||||
break;
|
||||
case CHIAKI_VIDEO_RESOLUTION_PRESET_720p:
|
||||
profile->width = 1280;
|
||||
profile->height = 720;
|
||||
break;
|
||||
case CHIAKI_VIDEO_RESOLUTION_PRESET_1080p:
|
||||
profile->width = 1920;
|
||||
profile->height = 1080;
|
||||
break;
|
||||
default:
|
||||
profile->width = 0;
|
||||
profile->height = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
switch(fps)
|
||||
{
|
||||
case CHIAKI_VIDEO_FPS_PRESET_30:
|
||||
profile->max_fps = 30;
|
||||
break;
|
||||
case CHIAKI_VIDEO_FPS_PRESET_60:
|
||||
profile->max_fps = 60;
|
||||
break;
|
||||
default:
|
||||
profile->max_fps = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CHIAKI_EXPORT const char *chiaki_quit_reason_string(ChiakiQuitReason reason)
|
||||
{
|
||||
switch(reason)
|
||||
|
@ -129,6 +169,8 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_session_init(ChiakiSession *session, Chiaki
|
|||
memcpy(session->connect_info.morning, connect_info->morning, sizeof(session->connect_info.morning));
|
||||
memcpy(session->connect_info.did, connect_info->did, sizeof(session->connect_info.did));
|
||||
|
||||
session->connect_info.video_profile = connect_info->video_profile;
|
||||
|
||||
return CHIAKI_ERR_SUCCESS;
|
||||
error_stop_pipe:
|
||||
chiaki_stop_pipe_fini(&session->stop_pipe);
|
||||
|
@ -329,6 +371,8 @@ static void *session_thread_func(void *arg)
|
|||
chiaki_video_receiver_free(session->video_receiver);
|
||||
session->video_receiver = NULL;
|
||||
|
||||
chiaki_mutex_unlock(&session->state_mutex);
|
||||
|
||||
quit_audio_receiver:
|
||||
chiaki_audio_receiver_free(session->audio_receiver);
|
||||
session->audio_receiver = NULL;
|
||||
|
|
|
@ -532,6 +532,7 @@ static void stream_connection_takion_data_expect_streaminfo(ChiakiStreamConnecti
|
|||
if(msg.type != tkproto_TakionMessage_PayloadType_STREAMINFO || !msg.has_stream_info_payload)
|
||||
{
|
||||
CHIAKI_LOGE(stream_connection->log, "StreamConnection expected streaminfo payload but received something else");
|
||||
chiaki_log_hexdump(stream_connection->log, CHIAKI_LOG_VERBOSE, buf, buf_size);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -583,6 +584,10 @@ static ChiakiErrorCode stream_connection_send_big(ChiakiStreamConnection *stream
|
|||
launch_spec.rtt = session->rtt;
|
||||
launch_spec.handshake_key = session->handshake_key;
|
||||
|
||||
launch_spec.width = session->connect_info.video_profile.width;
|
||||
launch_spec.height = session->connect_info.video_profile.height;
|
||||
launch_spec.max_fps = session->connect_info.video_profile.max_fps;
|
||||
|
||||
union
|
||||
{
|
||||
char json[LAUNCH_SPEC_JSON_BUF_SIZE];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue