prsyahmi / v380

Extract h264 from V380 camera
MIT License
89 stars 33 forks source link

Send audio #10

Open androidominus opened 3 years ago

androidominus commented 3 years ago

Hello @prsyahmi, thanks for your work.

I was wondering if there is a way to send audio to the camera, i mean, in v380 app there is a button with microphone icon that let me send audio message played from the camera.

Do you know something about it?

Thank you

prsyahmi commented 3 years ago

Hi @androidominus , the sound need to be encoded with adpcm_ms to be sent to camera. I haven't checked the command sequence to send yet. I'm still struggling with receiving part.

hoseiniraji commented 3 years ago

Hello @prsyahmi, thanks for your work.

I'm able to resend audio packets captured in wireshark, which was sent from officially v380 for PC app, but when trying to send audio file from my computer, only can hear some noises.

i used ffmpeg to convert audio with this command:

ffmpeg -i INPUT.mp3 -f wav -acodec adpcm_ms OUTPUT.wav

but still not working!


steps to send audio to camera:

  1. open new TCP socket to camera end point

  2. send request command using a 256-byte buffer with this 16 byte at begining:

     0:3      0x79, 0x01, 0x00, 0x00   // CommandId = 377
     4:7      0xXX, 0xXX, 0xXX, 0xXX   // CameraId for example 123456
     8:11     0xXX, 0xXX, 0xXX, 0xXX   // LoginTicket which received on first authentication
     12:15    0x01, 0x00, 0x00, 0x00   // unknown 
  1. receive 16 byte as response
     0:3     0xDD, 0x01, 0x00, 0x00   // CommandId = 477
     4:7     0xE9, 0x03, 0x00, 0x00    // Result = 1001
     8:15    0x00 .. 0x00              // empty

now socket is allowed to send audio.

  1. audio stream should break down into 256-byte parts.

each frame should be 272 byte. including 16 byte header and 256 byte of data.

header:

     0:3     0xb4, 0x00, 0x00, 0x00   // CommandId: 180
     4:7     0x01, 0x00, 0x16, 0x00   // unknown
     8:11    0x00, 0x00, 0x00, 0x00   // empty
     12:15   0x00, 0x00, 0x01,  0x01   // frame number

last byte of header should be increase by 1 in each frame


also there was some unknown payloads starts with '0xbc' instead of '0xb4' as bellow

0xbc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00

in my last test, this kind of payloads, sents only once between frame number 53 and 54.