{"action":"created","issue":{"url":"https://api.github.com/repos/meetecho/janus-gateway/issues/258","labels_url":"https://api.github.com/repos/meetecho/janus-gateway/issues/258/labels{/name}","comments_url":"https://api.github.com/repos/meetecho/janus-gateway/issues/258/comments","events_url":"https://api.github.com/repos/meetecho/janus-gateway/issues/258/events","html_url":"https://github.com/meetecho/janus-gateway/issues/258","id":87090059,"number":258,"title":"nack counts all audio for videoroom plugin listener handles","user":{"login":"ploxiln","id":649835,"avatar_url":"https://avatars.githubusercontent.com/u/649835?v=3","gravatar_id":"","url":"https://api.github.com/users/ploxiln","html_url":"https://github.com/ploxiln","followers_url":"https://api.github.com/users/ploxiln/followers","following_url":"https://api.github.com/users/ploxiln/following{/other_user}","gists_url":"https://api.github.com/users/ploxiln/gists{/gist_id}","starred_url":"https://api.github.com/users/ploxiln/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ploxiln/subscriptions","organizations_url":"https://api.github.com/users/ploxiln/orgs","repos_url":"https://api.github.com/users/ploxiln/repos","events_url":"https://api.github.com/users/ploxiln/events{/privacy}","received_events_url":"https://api.github.com/users/ploxiln/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-06-10T20:09:06Z","updated_at":"2015-06-17T21:29:35Z","closed_at":null,"body":"For the videoroom plugin, for listener handles, all nacks are counted as audio packet NACKs, even though most of them are video packet NACKs.\r\n\r\nYou can see these counts in janus admin (trimmed):\r\n```\r\n{\r\n    \"session_id\": 3756909664,\r\n    \"handle_id\": 373788390,\r\n    \"plugin\": \"janus.plugin.videoroom\",\r\n    \"plugin_specific\": {\r\n        \"type\": \"listener\",\r\n        \"room\": 1234,\r\n        \"feed_id\": 361429649,\r\n        \"feed_display\": \"plo2\",\r\n        \"destroyed\": 0\r\n    },\r\n    \"streams\": [\r\n        {\r\n            \"id\": 1,\r\n            \"ready\": -1,\r\n            \"disabled\": \"false\",\r\n            \"ssrc\": {\r\n                \"audio\": 1267177442,\r\n                \"video\": 3383906181\r\n            },\r\n            \"components\": [\r\n                {\r\n                    \"id\": 1,\r\n                    \"state\": \"ready\",\r\n                    \"in_stats\": {\r\n                        \"audio_bytes\": 0,\r\n                        \"video_bytes\": 0,\r\n                        \"data_bytes\": 974,\r\n                        \"audio_nacks\": 103,\r\n                        \"video_nacks\": 0,\r\n                        \"audio_bytes_lastsec\": 0,\r\n                        \"video_bytes_lastsec\": 0\r\n                    },\r\n                    \"out_stats\": {\r\n                        \"audio_bytes\": 1254718,\r\n                        \"video_bytes\": 4051952,\r\n                        \"data_bytes\": 1261,\r\n                        \"audio_nacks\": 0,\r\n                        \"video_nacks\": 0\r\n                    }\r\n                }\r\n            ]\r\n        }\r\n    ]\r\n}\r\n```\r\n\r\npublisher handles don't have this problem:\r\n```\r\n{\r\n    \"session_id\": 414341886,\r\n    \"handle_id\": 2733785551,\r\n    \"plugin\": \"janus.plugin.videoroom\",\r\n    \"plugin_specific\": {\r\n        \"type\": \"publisher\",\r\n        \"room\": 1234,\r\n        \"id\": 361429649,\r\n        \"display\": \"plo2\",\r\n        \"viewers\": 1,\r\n        \"destroyed\": 0\r\n    },\r\n    \"streams\": [\r\n        {\r\n            \"id\": 1,\r\n            \"ready\": -1,\r\n            \"disabled\": \"false\",\r\n            \"ssrc\": {\r\n                \"audio\": 4250683611,\r\n                \"video\": 1177463177,\r\n                \"audio-peer\": 2584759378,\r\n                \"video-peer\": 3035943213\r\n            },\r\n            \"components\": [\r\n                {\r\n                    \"id\": 1,\r\n                    \"state\": \"ready\",\r\n                    \"in_stats\": {\r\n                        \"audio_bytes\": 2549276,\r\n                        \"video_bytes\": 8994731,\r\n                        \"data_bytes\": 1734,\r\n                        \"audio_nacks\": 0,\r\n                        \"video_nacks\": 0,\r\n                        \"audio_bytes_lastsec\": 4165,\r\n                        \"video_bytes_lastsec\": 15634\r\n                    },\r\n                    \"out_stats\": {\r\n                        \"audio_bytes\": 0,\r\n                        \"video_bytes\": 0,\r\n                        \"data_bytes\": 1409,\r\n                        \"audio_nacks\": 54,\r\n                        \"video_nacks\": 13\r\n                    }\r\n                }\r\n            ]\r\n        }\r\n    ]\r\n}\r\n```\r\n\r\nThat was probably excessive quoting... just trying to be thorough... anyway, the problem in the code is here:  https://github.com/meetecho/janus-gateway/blob/master/ice.c#L1421\r\n\r\n```\r\n                                /* Is this audio or video? */                                       \r\n                                int video = 0;                                                      \r\n                                if(!janus_flags_is_set(&handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_BUNDLE)) {\r\n                                        /* Easy enough */                                           \r\n                                        video = (stream->stream_id == handle->video_id ? 1 : 0);    \r\n                                } else {                                                            \r\n                                        /* TODO Bundled streams, check SSRC */                      \r\n                                        guint32 rtcp_ssrc = janus_rtcp_get_sender_ssrc(buf, len);   \r\n                                        video = (stream->video_ssrc_peer == rtcp_ssrc ? 1 : 0);     \r\n                                        //~ JANUS_LOG(LOG_VERB, \"[RTCP] Bundling: this is %s (video=%\"SCNu64\", audio=%\"SCNu64\", got\r\n                                                //~ video ? \"video\" : \"audio\", stream->video_ssrc_peer, stream->audio_ssrc_peer, rt\r\n                                }\r\n```\r\n\r\nFor bundled streams, janus looks at the ssrc to categorize the stream. But the videoroom plugin re-writes SSRCs for viewers. I actually tried digging further into the rtcp packet, to find the RTCP-FB, and the \"media\" field within it, and comparing it to the `stream->video_ssrc`. Neither the outside rtcp ssrc, nor the inside rtcp-fb media ssrc, correspond to `audio_ssrc`, `video_ssrc`, `audio_ssrc_peer`, or `video_ssrc_peer`. This isn't surprising, because of the ssrc re-writing which the plugin does.\r\n\r\nIt looks like it will take a bit of extra plumbing or some other strategy entirely, if we really want to get these statistics to work for videoroom listener handles (and my custom plugin). Thoughts?"},"comment":{"url":"https://api.github.com/repos/meetecho/janus-gateway/issues/comments/112954743","html_url":"https://github.com/meetecho/janus-gateway/issues/258#issuecomment-112954743","issue_url":"https://api.github.com/repos/meetecho/janus-gateway/issues/258","id":112954743,"user":{"login":"ploxiln","id":649835,"avatar_url":"https://avatars.githubusercontent.com/u/649835?v=3","gravatar_id":"","url":"https://api.github.com/users/ploxiln","html_url":"https://github.com/ploxiln","followers_url":"https://api.github.com/users/ploxiln/followers","following_url":"https://api.github.com/users/ploxiln/following{/other_user}","gists_url":"https://api.github.com/users/ploxiln/gists{/gist_id}","starred_url":"https://api.github.com/users/ploxiln/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ploxiln/subscriptions","organizations_url":"https://api.github.com/users/ploxiln/orgs","repos_url":"https://api.github.com/users/ploxiln/repos","events_url":"https://api.github.com/users/ploxiln/events{/privacy}","received_events_url":"https://api.github.com/users/ploxiln/received_events","type":"User","site_admin":false},"created_at":"2015-06-17T21:29:35Z","updated_at":"2015-06-17T21:29:35Z","body":"I can confirm with Chrome graphs :)\r\n\r\n```\r\n                    \"in_stats\": {\r\n                        \"audio_bytes\": 0,\r\n                        \"video_bytes\": 0,\r\n                        \"data_bytes\": 907,\r\n                        \"audio_nacks\": 0,\r\n                        \"video_nacks\": 26,\r\n                        \"audio_bytes_lastsec\": 0,\r\n                        \"video_bytes_lastsec\": 0\r\n                    },\r\n                    \"out_stats\": {\r\n                        \"audio_bytes\": 388268,\r\n                        \"video_bytes\": 2691348,\r\n                        \"data_bytes\": 1806,\r\n                        \"audio_nacks\": 0,\r\n                        \"video_nacks\": 0\r\n                    }\r\n```\r\n\r\n![screen shot 2015-06-17 at 17 28 35](https://cloud.githubusercontent.com/assets/649835/8219214/6395cc28-1516-11e5-816d-5138ab275473.png)\r\n\r\n![screen shot 2015-06-17 at 17 28 47](https://cloud.githubusercontent.com/assets/649835/8219216/66fcbc14-1516-11e5-9f24-911ee9643310.png)\r\n"}}