meetecho / janus-gateway

Janus WebRTC Server
https://janus.conf.meetecho.com
GNU General Public License v3.0
8.17k stars 2.47k forks source link

[1.x] “h264_profile”,“vp9_profile” of remote publisher's stream type error. #3251

Closed jamken closed 1 year ago

jamken commented 1 year ago

What version of Janus is this happening on? v1.1.4 cascade feature Put the version and the commit identifier (available in version.c or from an info request) here

Have you tested a more recent version of Janus too? this bug existed on the latest code

Was this working before? No

Is there a gdb or libasan trace of the issue? No

Additional context

“h264_profile”,“vp9_profile” of remote publisher's stream type error.

When invode "add_remote_publisher" and "update_remote_publisher" request, its parameter is checked according to the remote_publisher_stream_parameters structure, which is defined as below:

static struct janus_json_parameter remote_publisher_stream_parameters[] = {
    {"mid", JANUS_JSON_STRING, JANUS_JSON_PARAM_REQUIRED},
    {"mindex", JANUS_JSON_INTEGER, JANUS_JSON_PARAM_REQUIRED | JANUS_JSON_PARAM_POSITIVE},
    {"type", JANUS_JSON_STRING, JANUS_JSON_PARAM_REQUIRED},
    {"codec", JANUS_JSON_STRING, 0},
    {"description", JANUS_JSON_STRING, 0},
    {"disabled", JANUS_JSON_BOOL, 0},
    {"stereo", JANUS_JSON_BOOL, 0},
    {"fec", JANUS_JSON_BOOL, 0},
    {"dtx", JANUS_JSON_BOOL, 0},
    {"h264_profile", JANUS_JSON_BOOL, 0},
    {"vp9_profile", JANUS_JSON_BOOL, 0},
    {"simulcast", JANUS_JSON_BOOL, 0},
    {"svc", JANUS_JSON_BOOL, 0},
    {"audiolevel_ext_id", JANUS_JSON_INTEGER, 0},
    {"videoorient_ext_id", JANUS_JSON_INTEGER, 0},
    {"playoutdelay_ext_id", JANUS_JSON_INTEGER, 0},
};

In this definition, "h264_profile" and "vp9_profile" is defined as JANUS_JSON_BOOL type. But when these both parameter is used later, they are interpreted as a string, as the following code:

                    if(ps->vcodec == JANUS_VIDEOCODEC_H264) {
                        const char *h264_profile = json_string_value(json_object_get(s, "h264_profile"));
                        if(h264_profile)
                            ps->h264_profile = g_strdup(h264_profile);
                        else if(videoroom->h264_profile)
                            ps->h264_profile = g_strdup(videoroom->h264_profile);
                    } else if(ps->vcodec == JANUS_VIDEOCODEC_VP9) {
                        const char *vp9_profile = json_string_value(json_object_get(s, "vp9_profile"));
                        if(vp9_profile)
                            ps->vp9_profile = g_strdup(vp9_profile);
                        else if(videoroom->vp9_profile)
                            ps->vp9_profile = g_strdup(videoroom->vp9_profile);
                    }

They should be a mistaken when coding

lminiero commented 1 year ago

The whole team is on vacation, we'll have a look when we're back in a few weeks.

atoppi commented 1 year ago

Thanks for reporting @jamken , the bug has been fixed in the commit above.