ngraziano / SharpRTSP

A RTSP handling library
Other
538 stars 180 forks source link

Can you help me in extending to get the eventId,endOfEvent,reserved,volume,eventduration fields #31

Closed ghost closed 6 years ago

ghost commented 6 years ago

I see in the RTSP Client Example We can extend the following part private void Rtsp_client_DataReceived(object sender, Rtsp.RtspChunkEventArgs e) { // RTP Packet Header // 0 - Version, P, X, CC, M, PT and Sequence Number //32 - Timestamp //64 - SSRC //96 - CSRCs (optional) //nn - Extension ID and Length //nn - Extension header

      int rtp_version =      (e.Message.Data[0] >> 6);
      int rtp_padding =      (e.Message.Data[0] >> 5) & 0x01;
      int rtp_extension =    (e.Message.Data[0] >> 4) & 0x01;
      int rtp_csrc_count =   (e.Message.Data[0] >> 0) & 0x0F;
      int rtp_marker =       (e.Message.Data[1] >> 7) & 0x01;
      int rtp_payload_type = (e.Message.Data[1] >> 0) & 0x7F;
      uint rtp_sequence_number = ((uint)e.Message.Data[2] << 8) + (uint)(e.Message.Data[3]);
      uint rtp_timestamp = ((uint)e.Message.Data[4] <<24) + (uint)(e.Message.Data[5] << 16) + (uint)(e.Message.Data[6] << 8) + (uint)(e.Message.Data[7]);
      uint rtp_ssrc =      ((uint)e.Message.Data[8] << 24) + (uint)(e.Message.Data[9] << 16) + (uint)(e.Message.Data[10] << 8) + (uint)(e.Message.Data[11]);

      int rtp_payload_start = 4 // V,P,M,SEQ
                          + 4 // time stamp
                          + 4 // ssrc
                          + (4 * rtp_csrc_count); // zero or more csrcs

      uint rtp_extension_id = 0;
      uint rtp_extension_size = 0;
      if (rtp_extension == 1)
      {
          rtp_extension_id = ((uint)e.Message.Data[rtp_payload_start + 0] << 8) + (uint)(e.Message.Data[rtp_payload_start + 1] << 0);
          rtp_extension_size = ((uint)e.Message.Data[rtp_payload_start + 2] << 8) + (uint)(e.Message.Data[rtp_payload_start + 3] << 0);
          rtp_payload_start += 4 + (int)rtp_extension_size;  // extension header and extension payload
      }

to get the eventId and endofEvent and such things. Since you must be having better knowledge

What all you say?

RogerHardiman commented 6 years ago

The RTSP standard is for video. It does not have fields for Event ID, EndOfEvent, EventDuration etc.

Can you tell us more about what you are trying to do please and the server you are trying to connect to.

ghost commented 6 years ago

actually i will be working for RTSP shortly, as of now trying to detect the DTMF in RTP packet and i saw the dissection in "private void Rtsp_client_DataReceived", we can add functionality to get the Event ID, EndOfEvent, EventDuration etc.... like this might be ...

                  // the DTMF key pressed or released. 
                   DTMF_Event = DtmfPayload >> 24; 

                  // the "end" bit. 
                   DTMF_E = (DtmfPayload >> 23) & 0x01; 

                  // reserved bit - not used. 
                   DTMF_R = (DtmfPayload >> 22) & 0x01; 

                  // the DTMF power level (volume). 
                   DTMF_Volume = (DtmfPayload >> 16) & 0x3f; 

                  // tone duration. 
                   DTMF_Duration = DtmfPayload & 0xffff; 
RogerHardiman commented 6 years ago

The 'payload start' tells you where in the RTP packet the DtmfPayload is located. That should be where the RFC 4733 DTMF data is located and then you can use the shifting and AND functions.

ghost commented 6 years ago

can you tell me what codes need to be added after this to get the ` int rtp_version = (e.Message.Data[0] >> 6); int rtp_padding = (e.Message.Data[0] >> 5) & 0x01; int rtp_extension = (e.Message.Data[0] >> 4) & 0x01; int rtp_csrc_count = (e.Message.Data[0] >> 0) & 0x0F; int rtp_marker = (e.Message.Data[1] >> 7) & 0x01; int rtp_payload_type = (e.Message.Data[1] >> 0) & 0x7F; uint rtp_sequence_number = ((uint)e.Message.Data[2] << 8) + (uint)(e.Message.Data[3]); uint rtp_timestamp = ((uint)e.Message.Data[4] <<24) + (uint)(e.Message.Data[5] << 16) + (uint)(e.Message.Data[6] << 8) + (uint)(e.Message.Data[7]); uint rtp_ssrc = ((uint)e.Message.Data[8] << 24) + (uint)(e.Message.Data[9] << 16) + (uint)(e.Message.Data[10] << 8) + (uint)(e.Message.Data[11]);

      int rtp_payload_start = 4 // V,P,M,SEQ
                          + 4 // time stamp
                          + 4 // ssrc
                          + (4 * rtp_csrc_count); // zero or more csrcs

      uint rtp_extension_id = 0;
      uint rtp_extension_size = 0;
      if (rtp_extension == 1)
      {
          rtp_extension_id = ((uint)e.Message.Data[rtp_payload_start + 0] << 8) + (uint)(e.Message.Data[rtp_payload_start + 1] << 0);
          rtp_extension_size = ((uint)e.Message.Data[rtp_payload_start + 2] << 8) + (uint)(e.Message.Data[rtp_payload_start + 3] << 0);
          rtp_payload_start += 4 + (int)rtp_extension_size;  // extension header and extension payload
      }`

DTMF event and end of event etc

RogerHardiman commented 6 years ago

So uint DtmfPayload = e.Message.Data[rtp_payload_start];

Then you will use the bitwise operations eg >> and & from your code.

ghost commented 6 years ago

Hey i was not able to get the DTMF event using my code, if you know, how to get it using the bitwise operation, can you provide me the code.

// the payload data is 4 bytes as per RFC 2833 (see section 3.5) // // 0 1 2 3 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ // | event |E|R| volume | duration | // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ // // Figure 1: Payload Format for Named Events //

RogerHardiman commented 6 years ago

None of us have written code to process RTP packets containing DTMF data. So we cannot help.

Could you post a dump of the RTP Packet in Hex and the code do carry out the bitwise operations and I can see if I can spot something.

ghost commented 6 years ago

can you share your mail id? or mail me on cloverobert@gmail.com I hope that works

RogerHardiman commented 6 years ago

Actually the easiest place is to post it here on github. You can attach files to the post too.

RogerHardiman commented 6 years ago

thread has gone dormant so closing