mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-20 21:43:12 -07:00
Set Bitrate in LaunchSpec
This commit is contained in:
parent
fc5d3752a7
commit
b9b4b7321b
5 changed files with 17 additions and 9 deletions
|
@ -35,6 +35,7 @@ typedef struct chiaki_launch_spec_t
|
||||||
unsigned int width;
|
unsigned int width;
|
||||||
unsigned int height;
|
unsigned int height;
|
||||||
unsigned int max_fps;
|
unsigned int max_fps;
|
||||||
|
unsigned int bw_kbps_sent;
|
||||||
} ChiakiLaunchSpec;
|
} ChiakiLaunchSpec;
|
||||||
|
|
||||||
CHIAKI_EXPORT int chiaki_launchspec_format(char *buf, size_t buf_size, ChiakiLaunchSpec *launch_spec);
|
CHIAKI_EXPORT int chiaki_launchspec_format(char *buf, size_t buf_size, ChiakiLaunchSpec *launch_spec);
|
||||||
|
|
|
@ -48,6 +48,7 @@ typedef struct chiaki_connect_video_profile_t
|
||||||
unsigned int width;
|
unsigned int width;
|
||||||
unsigned int height;
|
unsigned int height;
|
||||||
unsigned int max_fps;
|
unsigned int max_fps;
|
||||||
|
unsigned int bitrate;
|
||||||
} ChiakiConnectVideoProfile;
|
} ChiakiConnectVideoProfile;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
|
@ -28,18 +28,18 @@ static const char launchspec_fmt[] =
|
||||||
"{"
|
"{"
|
||||||
"\"resolution\":"
|
"\"resolution\":"
|
||||||
"{"
|
"{"
|
||||||
"\"width\":%u,"
|
"\"width\":%u," // 0
|
||||||
"\"height\":%u"
|
"\"height\":%u" // 1
|
||||||
"},"
|
"},"
|
||||||
"\"maxFps\":%u,"
|
"\"maxFps\":%u," // 2
|
||||||
"\"score\":10"
|
"\"score\":10"
|
||||||
"}"
|
"}"
|
||||||
"],"
|
"],"
|
||||||
"\"network\":{"
|
"\"network\":{"
|
||||||
"\"bwKbpsSent\":2000,"
|
"\"bwKbpsSent\":%u," // 3
|
||||||
"\"bwLoss\":0.001000,"
|
"\"bwLoss\":0.001000,"
|
||||||
"\"mtu\":%u," // 0
|
"\"mtu\":%u," // 4
|
||||||
"\"rtt\":%u," // 1
|
"\"rtt\":%u," // 5
|
||||||
"\"ports\":[53,2053]"
|
"\"ports\":[53,2053]"
|
||||||
"},"
|
"},"
|
||||||
"\"slotId\":1,"
|
"\"slotId\":1,"
|
||||||
|
@ -73,7 +73,7 @@ static const char launchspec_fmt[] =
|
||||||
"\"region\":\"US\","
|
"\"region\":\"US\","
|
||||||
"\"languagesUsed\":[\"en\",\"jp\"]"
|
"\"languagesUsed\":[\"en\",\"jp\"]"
|
||||||
"},"
|
"},"
|
||||||
"\"handshakeKey\":\"%s\"" // 2
|
"\"handshakeKey\":\"%s\"" // 6
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
CHIAKI_EXPORT int chiaki_launchspec_format(char *buf, size_t buf_size, ChiakiLaunchSpec *launch_spec)
|
CHIAKI_EXPORT int chiaki_launchspec_format(char *buf, size_t buf_size, ChiakiLaunchSpec *launch_spec)
|
||||||
|
@ -85,7 +85,7 @@ CHIAKI_EXPORT int chiaki_launchspec_format(char *buf, size_t buf_size, ChiakiLau
|
||||||
|
|
||||||
int written = snprintf(buf, buf_size, launchspec_fmt,
|
int written = snprintf(buf, buf_size, launchspec_fmt,
|
||||||
launch_spec->width, launch_spec->height, launch_spec->max_fps,
|
launch_spec->width, launch_spec->height, launch_spec->max_fps,
|
||||||
launch_spec->mtu, launch_spec->rtt, handshake_key_b64);
|
launch_spec->bw_kbps_sent, launch_spec->mtu, launch_spec->rtt, handshake_key_b64);
|
||||||
if(written < 0 || written >= buf_size)
|
if(written < 0 || written >= buf_size)
|
||||||
return -1;
|
return -1;
|
||||||
return written;
|
return written;
|
||||||
|
|
|
@ -54,22 +54,27 @@ CHIAKI_EXPORT void chiaki_connect_video_profile_preset(ChiakiConnectVideoProfile
|
||||||
case CHIAKI_VIDEO_RESOLUTION_PRESET_360p:
|
case CHIAKI_VIDEO_RESOLUTION_PRESET_360p:
|
||||||
profile->width = 640;
|
profile->width = 640;
|
||||||
profile->height = 360;
|
profile->height = 360;
|
||||||
|
profile->bitrate = 2000;
|
||||||
break;
|
break;
|
||||||
case CHIAKI_VIDEO_RESOLUTION_PRESET_540p:
|
case CHIAKI_VIDEO_RESOLUTION_PRESET_540p:
|
||||||
profile->width = 960;
|
profile->width = 960;
|
||||||
profile->height = 540;
|
profile->height = 540;
|
||||||
|
profile->bitrate = 6000;
|
||||||
break;
|
break;
|
||||||
case CHIAKI_VIDEO_RESOLUTION_PRESET_720p:
|
case CHIAKI_VIDEO_RESOLUTION_PRESET_720p:
|
||||||
profile->width = 1280;
|
profile->width = 1280;
|
||||||
profile->height = 720;
|
profile->height = 720;
|
||||||
|
profile->bitrate = 6000; // TODO: 10000 by default
|
||||||
break;
|
break;
|
||||||
case CHIAKI_VIDEO_RESOLUTION_PRESET_1080p:
|
case CHIAKI_VIDEO_RESOLUTION_PRESET_1080p:
|
||||||
profile->width = 1920;
|
profile->width = 1920;
|
||||||
profile->height = 1080;
|
profile->height = 1080;
|
||||||
|
profile->bitrate = 10000; // TODO
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
profile->width = 0;
|
profile->width = 0;
|
||||||
profile->height = 0;
|
profile->height = 0;
|
||||||
|
profile->bitrate = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -595,7 +600,7 @@ static bool session_thread_request_session(ChiakiSession *session)
|
||||||
|
|
||||||
ChiakiHttpResponse http_response;
|
ChiakiHttpResponse http_response;
|
||||||
CHIAKI_LOGV(session->log, "Session Response Header:");
|
CHIAKI_LOGV(session->log, "Session Response Header:");
|
||||||
chiaki_log_hexdump(session->log, CHIAKI_LOG_VERBOSE, buf, header_size);
|
chiaki_log_hexdump(session->log, CHIAKI_LOG_VERBOSE, (const uint8_t *)buf, header_size);
|
||||||
err = chiaki_http_response_parse(&http_response, buf, header_size);
|
err = chiaki_http_response_parse(&http_response, buf, header_size);
|
||||||
if(err != CHIAKI_ERR_SUCCESS)
|
if(err != CHIAKI_ERR_SUCCESS)
|
||||||
{
|
{
|
||||||
|
|
|
@ -659,6 +659,7 @@ static ChiakiErrorCode stream_connection_send_big(ChiakiStreamConnection *stream
|
||||||
launch_spec.width = session->connect_info.video_profile.width;
|
launch_spec.width = session->connect_info.video_profile.width;
|
||||||
launch_spec.height = session->connect_info.video_profile.height;
|
launch_spec.height = session->connect_info.video_profile.height;
|
||||||
launch_spec.max_fps = session->connect_info.video_profile.max_fps;
|
launch_spec.max_fps = session->connect_info.video_profile.max_fps;
|
||||||
|
launch_spec.bw_kbps_sent = session->connect_info.video_profile.bitrate;
|
||||||
|
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue