Skip to content

Commit 2f1264c

Browse files
committedMar 17, 2024·
janus: rtp orientation support
1 parent 69e7cbf commit 2f1264c

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed
 

‎janus/src/client.c

+9
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ us_janus_client_s *us_janus_client_init(janus_callbacks *gw, janus_plugin_sessio
5151
client->session = session;
5252
atomic_init(&client->transmit, false);
5353
atomic_init(&client->transmit_audio, false);
54+
atomic_init(&client->video_orient, 0);
5455

5556
atomic_init(&client->stop, false);
5657

@@ -131,6 +132,7 @@ static void *_common_thread(void *v_client, bool video) {
131132
# endif
132133
};
133134
janus_plugin_rtp_extensions_reset(&packet.extensions);
135+
134136
/*if (rtp->zero_playout_delay) {
135137
// https://github.com/pikvm/pikvm/issues/784
136138
packet.extensions.min_delay = 0;
@@ -142,6 +144,13 @@ static void *_common_thread(void *v_client, bool video) {
142144
packet.extensions.max_delay = 300; // == 3s, i.e. 10ms granularity
143145
}*/
144146

147+
if (rtp.video) {
148+
const uint video_orient = atomic_load(&client->video_orient);
149+
if (video_orient != 0) {
150+
packet.extensions.video_rotation = video_orient;
151+
}
152+
}
153+
145154
client->gw->relay_rtp(client->session, &packet);
146155
}
147156
}

‎janus/src/client.h

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ typedef struct us_janus_client_sx {
3939
janus_plugin_session *session;
4040
atomic_bool transmit;
4141
atomic_bool transmit_audio;
42+
atomic_uint video_orient;
4243

4344
pthread_t video_tid;
4445
pthread_t audio_tid;

‎janus/src/plugin.c

+17-3
Original file line numberDiff line numberDiff line change
@@ -453,12 +453,25 @@ static struct janus_plugin_result *_plugin_handle_message(
453453

454454
} else if (!strcmp(request_str, "watch")) {
455455
bool with_audio = false;
456+
uint video_orient = 0;
456457
{
457458
json_t *const params = json_object_get(msg, "params");
458459
if (params != NULL) {
459-
json_t *const audio = json_object_get(params, "audio");
460-
if (audio != NULL && json_is_boolean(audio)) {
461-
with_audio = (_g_rtpa != NULL && json_boolean_value(audio));
460+
{
461+
json_t *const obj = json_object_get(params, "audio");
462+
if (obj != NULL && json_is_boolean(obj)) {
463+
with_audio = (_g_rtpa != NULL && json_boolean_value(obj));
464+
}
465+
}
466+
{
467+
json_t *const obj = json_object_get(params, "orientation");
468+
if (obj != NULL && json_is_integer(obj)) {
469+
video_orient = json_integer_value(obj);
470+
switch (video_orient) {
471+
case 90: case 180: case 270: break;
472+
default: video_orient = 0; break;
473+
}
474+
}
462475
}
463476
}
464477
}
@@ -498,6 +511,7 @@ static struct janus_plugin_result *_plugin_handle_message(
498511
US_LIST_ITERATE(_g_clients, client, {
499512
if (client->session == session) {
500513
atomic_store(&client->transmit_audio, with_audio);
514+
atomic_store(&client->video_orient, video_orient);
501515
}
502516
has_listeners = (has_listeners || atomic_load(&client->transmit_audio));
503517
});

‎janus/src/rtpv.c

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ char *us_rtpv_make_sdp(us_rtpv_s *rtpv) {
7171
"a=rtcp-fb:%u goog-remb" RN
7272
"a=ssrc:%" PRIu32 " cname:ustreamer" RN
7373
"a=extmap:1 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay" RN
74+
"a=extmap:2 urn:3gpp:video-orientation" RN
7475
"a=sendonly" RN,
7576
pl, pl, pl, pl,
7677
pl, pl, pl,

0 commit comments

Comments
 (0)
Please sign in to comment.