# Sdp-utils: janus\_sdp\_get\_video\_profile() function \> I think exception handling is needed

**URL:** <https://janus.discourse.group/t/sdp-utils-janus-sdp-get-video-profile-function-i-think-exception-handling-is-needed/1754>\
**Category:** General\
**Created:** [December 23, 2025, 5:42am UTC](https://janus.discourse.group/t/sdp-utils-janus-sdp-get-video-profile-function-i-think-exception-handling-is-needed/1754 "2025-12-23T05:42:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jaejong](https://avatars.discourse-cdn.com/v4/letter/j/e47774/32.png) [@Jaejong](https://janus.discourse.group/u/Jaejong)\
**Post date:** [December 23, 2025, 5:42am UTC](https://janus.discourse.group/t/sdp-utils-janus-sdp-get-video-profile-function-i-think-exception-handling-is-needed/1754/1 "2025-12-23T05:42:05Z")

</div>

(My english is not that good.)  
I am deeply grateful for Janus.

Exception handling seems necessary when extracting the profile from the following fmtp string if there is a space after the semicolon (;).

```auto
vfmtp ex)
blank_x = "packetization-mode=1;profile-level-id=4D401F;sprop-parameter-sets=SPS,PPS";
blank_o = "packetization-mode=1; profile-level-id=4D401F; sprop-parameter-sets=SPS,PPS"

test 1) janus_sdp_get_video_profile(JANUS_VIDEOCODEC_H264, blank_x)
--> result is "4D401F"

test 2) janus_sdp_get_video_profile(JANUS_VIDEOCODEC_H264, blank_o);
--> result is "=4D401F"

```

src/sdp-utils.c

```auto
char *janus_sdp_get_video_profile(janus_videocodec codec, const char *fmtp) {
	...
	while(index != NULL) {
		if(strstr(index, needle) != NULL) {
			profile = index + strlen(needle); <- *ADD WHITESPACE LENGTH*
			if(strlen(profile) > 0)
				profile = g_strdup(profile);
			else
				profile = NULL;
			break;
		}
		...
	}
	...
}

```

---

<div class="post-metadata">

**Author:** ![lorenzo](https://yyz2.discourse-cdn.com/free1/user_avatar/janus.discourse.group/lorenzo/32/425_2.png) [@lorenzo](https://janus.discourse.group/u/lorenzo)\
**Post date:** [January 23, 2026, 4:50pm UTC](https://janus.discourse.group/t/sdp-utils-janus-sdp-get-video-profile-function-i-think-exception-handling-is-needed/1754/2 "2026-01-23T16:50:21Z")

</div>

You’re right that the parsing could be improved, but I don’t think there’s an easy way to figure out that whitespace length.

---

<div class="post-metadata">

**Author:** ![Jaejong](https://avatars.discourse-cdn.com/v4/letter/j/e47774/32.png) [@Jaejong](https://janus.discourse.group/u/Jaejong)\
**Post date:** [January 24, 2026, 3:14pm UTC](https://janus.discourse.group/t/sdp-utils-janus-sdp-get-video-profile-function-i-think-exception-handling-is-needed/1754/3 "2026-01-24T15:14:26Z")

</div>

lorenzo, Thanks for replying.  
Happy New Year!

(I believe you’ve already looked at the janus\_sdp\_get\_video\_profile() function.)  
Our thoughts may differ, but for now, since we need an appropriate profile-level-id value, we’re using it with the following modification.

I regularly check for code updates and will see what you think about them.

```auto
char *janus_sdp_get_video_profile(janus_videocodec codec, const char *fmtp) {
	...
	const char *needle = NULL;
	if(codec == JANUS_VIDEOCODEC_H264) {
		needle = "profile-level-id=";
	...
	while(index != NULL) {
		#if defined(JANUS_SDP_UTILS_FORGETECH)
		char *pos = NULL;
		if((pos = strstr(index, needle)) != NULL) {
			profile = index + (pos - index) + strlen(needle);
			if(strlen(profile) > 0)
				profile = g_strdup(profile);
			else
				profile = NULL;
			break;
		}
		#else
		if(strstr(index, needle) != NULL) {
			profile = index + strlen(needle);
			if(strlen(profile) > 0)
				profile = g_strdup(profile);
			else
				profile = NULL;
			break;
		}
		#endif
		i++;
		index = list[i];
	}
	g_clear_pointer(&list, g_strfreev);
	return profile;
}

```

---

<div class="post-metadata">

**Author:** ![lorenzo](https://yyz2.discourse-cdn.com/free1/user_avatar/janus.discourse.group/lorenzo/32/425_2.png) [@lorenzo](https://janus.discourse.group/u/lorenzo)\
**Post date:** [January 26, 2026, 9:34am UTC](https://janus.discourse.group/t/sdp-utils-janus-sdp-get-video-profile-function-i-think-exception-handling-is-needed/1754/4 "2026-01-26T09:34:20Z")

</div>

While investigating a fix, I stumbled on pretty much the same exact one you suggested! I just pushed a commit here, that does seem indeed to fix it for me: [Fixed inconsistencies when parsing SDP video profiles · meetecho/janus-gateway@47178fc · GitHub](https://github.com/meetecho/janus-gateway/commit/47178fc53d1d89acd1be876c2c9bfafcf940484a)

Not sure if we have other places where we use strstr the same way ignoring the actual result, in case we’ll need to fix that too. Thanks for the help!

---

<div class="post-metadata">

**Author:** ![Jaejong](https://avatars.discourse-cdn.com/v4/letter/j/e47774/32.png) [@Jaejong](https://janus.discourse.group/u/Jaejong)\
**Post date:** [January 26, 2026, 1:19pm UTC](https://janus.discourse.group/t/sdp-utils-janus-sdp-get-video-profile-function-i-think-exception-handling-is-needed/1754/5 "2026-01-26T13:19:34Z")

</div>

Thank you for checking.  
I will update the Janus code later.
