My Hikvision Doorbell, model DS-KB8113-IME1(B), can successfully register to Asterisk (version 22 running on FreeBSD) and videocall my Linphone App when pressing the doorbell button.
One way video works as expected. When reviewing the log of this working call, I see RTP packets of type 96 (H264) from my doorbell, and sent to my Linphone App. working_videocall.txt (2.2 MB)
But, the opposite direction is not working as expected. When I videocall my doorbell from my Linphone App I see RTP packets of type 96 from my doorbell, but they are not being sent to my Linphone App. Packets of type 00 (PCMU) are being recieved and sent, and two-way audio works as expected. novideo_rtp.txt (600.1 KB)
I inspected the SIP exchanges of the videocall from the Linphone App to the Doorbell and the INVITEs a=sendonly/recvonly all make sense to me. But for some reason Asterisk is not sending the RTP packets with type 96 that it is receiving. SIP.txt (1.0 KB)
Caller initiates video call
Receiver responds for video I am āsendonlyā
Asterisk relays this message to caller
Caller sends invite for video as ārecvonlyā
Is it possible this is a bug with Asteriskās handling of videocalls for the above situation? It seems like Asterisk disables both video feeds, not just the Callerās.
Should my next step be to try to read the source code of Asterisk for this specific situation? Or should I get a Wireshark capture of the actual RTP packets? Thanks for the help!
I am starting to suspect the problem is Asterisk is interpreting the cameraās sendonly response for the video stream and putting the video stream on hold. When a call is put on hold, is that shown in the log? Is there any way I can change this behavior, either in pjsip configuration or dialplan? Otherwise I guess the only way to get this working is modify the behavior in res/res_pjsip_session.c? I donāt believe I can force my doorbell to send āsendrecvā for video, as I saw fixed similar issues for others.
Thank you
Hi @josh4trunks , Iāve found the most likely cause for the video issue. Apparently Hikvsion devices are not able to negotiate media, they are fixed on sending H264 as PT 96 no matter what so they always answer 200 OK with that map. In your case, I think you are using Asterisk as a SIP-Proxy, so when the Linphone offers media, itās most certainly offering H264 in another PT, so at the end no negotiation is made. So Asterisk is expecting packets with the payload type that the Linphone offered and the device is just sending H264 in PT 96.
I have a similar issue with my Hikvision device, I use Asterisk as B2BUA, so when Asterisk sends the invite to my leg B (Hikvision device), it offers H264 PT 99, the device ignores this and still sends the 200 OK with H264 PT 96, so Asterisk receives the packets and doesnāt know what to do with them. I have this configuration in pjsip but Asterisk is still refusing to sends the packets to the other leg:
I think this pinpoints the actual source of the problem but I havenāt found a solution yet. I would be really grateful if you could give me a solution @jcolp. This problem is driving me crazy
Though, I am also using Asterisk as a B2BUA. But clearly Asterisk sending Hikvision m=video with PT of 99 and the Hikvision device is not responding correctly.
Iāll look more into the settings you listed. We basically need asterisk to handle this broken device somehow =[
If Asterisk makes a first offer of payload type 99, that is the only payload type it should receive, If the HikVision makes a second offer of 96, thatās what it expects to receive and is unrelated to what it should send. Itās basically broken. You would have to hack the code, in Asterisk, specifically for this broken endpoint. Itās not something Iād expect you to be able to work round with .conf files
(Actually, I think there is a standard that says the response offer must use the same payload type as in the offer, if it is intending to receive using the same codec.)
We could submit a bug to Hikvision, they did add unlocked SIP feature in the past to some doorbell firmwares.
But, I am not sure how willing they are to address this bug, since it probably doesnāt affect their supported install method of connecting to their intercom/monitor (which acts as a SIP server).
Maybe what we could do is not list h264 as an allowed codec for hikvision. Then asterisk never assigns it a PT in the outgoing offer. But then assuming hikvision still responds with h264(PT=96) we prefer that codec from the answer.
I donāt have time to produce logs at the moment to test. But maybe can look more into this next week.
Also I noticed this sentence in the documentation; so not sure if these settings actually do anything.
āNote that this option is reserved for future functionality.ā
Payload type 96 is the start of the dynamic types range, so there is no fixed mapping between H.264 and a payload type. It will depend on the order in which the types are processed, and any which Asterisk itself reserves.
You can probably modify the code to, effectively reserve 96 for H.264. Thatās what I meant by āhack the codeā. This is not a normal thing to do, so will involved a more detailed knowledge of this part of the code than I currently have.
The PT in the answer is the one that the Hikvision wants to receive (except it wonāt actually be expecting to receive, as it is a camera, not a display, so probably should be sending āa=sendonlyā). I donāt think there is anywhere in the RFCs that would allow Asterisk to accept that as the payload time for a stream on which it had not offered that as a payload type for the media type in question.
Iām going to be setting up an AIphone video doorbell next week - just a FYI - Aiphone seems to be very friendly to Asterisk/FreePBX - based on what I have found out already in talking to their support people. Iāll be running that to Cisco 8845 videophones which prefer H.264 - Iāll report back my experiences. If your Hikvision stuff is still within the 30 day return window, perhaps that would be the best solutionā¦the Open Source community in general has gotten better manufacturer response by refusing to buy stuff that isnāt supported with Open Source, than to work around makers who ignore itā¦just sayinā¦
I tried the settings you suggested but unfortunately they didnāt work. I ended up changing the Asterisk source code to remap the default PT for H264 to PT 96 and itās working now.
Ok, after this week I should have some time to experiment with the settings. I would prefer to fix this with standard settings, since any source changes will need to be maintained between updates. But, at least we know hardcoding 96 works.
Iām definitely past my return window lol. I bought my video doorbell on some Chinese marketplace site for $50. Itās normally at least $120 I would think; I was surprised it was actually Hikvision and not a knock-off or rebrand.
I agree we should support companies that work with open source. But in this case, I knew the doorbell supported SIP (but with bugs!), and liked the vandal resistant design of the model I purchased. Plus Iām used to Hikvision since them and Dahua, make the best image quality security cams.
Make sure to set a static IP on your video doorbell and put an access list in your Internet router blocking the doorbell from access to the Internet. People noticing traffic going from their Hikvision stuff to IP addresses in China was what tipped off the federal government that something was amiss.
Please put this patch as an issue in the github repo for the Asterisk source code, thanks! It may never be integrated into the source code but putting it there allows others to make use of it. Donāt post it here.