anass kartit wrote: > Hi Benny, > I have been experimenting with streamutil example with encrypting > packets. I decrypt packets on_rx_rtp as the following but I receive > Invalid_RTP_Version. This means that udp->rtp_pkt does not contain a valid RTP packet. Maybe something wrong with the encryption/decryption? More below. > /* Simulate packet lost on RX direction */ > > if (udp->rx_drop_pct) { > > if ((pj_rand() % 100) <= (int)udp->rx_drop_pct) { > > PJ_LOG(5,(udp->base.name <http://base.name>, > > "RX RTP packet dropped because of pkt lost " > > "simulation")); > > goto read_next_packet; > > } > > } > > encrypt_decrypt(udp->rtp_pkt,udp->rtp_pkt,key); This is indeed the correct place to do decryption. But I'm curious on why do you use same function encrypt_decrypt() for both encrypting and decrypting. I hope that's intentional. > ......and here > > read_next_packet: > > encrypt_decrypt(udp->rtp_pkt,udp->rtp_pkt,key); This is not necessary. regards, -benny > bytes_read = > > sizeof(udp->rtp_pkt); > > udp->rtp_addrlen = > > sizeof(pj_sockaddr_in); > > and I encrypt the packets in transport_send_rtp as the following: > > if (udp->tx_drop_pct) { > > if ((pj_rand() % 100) <= (int)udp->tx_drop_pct) { > > PJ_LOG(5,(udp->base.name <http://base.name>, > > "TX RTP packet dropped because of pkt lost " > > > > "simulation")); > > return PJ_SUCCESS; > > } > > } > > > > id = udp->rtp_write_op_id; > > pw = &udp->rtp_pending_write[id]; > > /* We need to copy packet to our buffer because when the > > * operation is pending, caller might write something else > > * to the original buffer. > > */ > > > > ///crypto > > > > encrypt_decrypt(pkt,cryptbuf,key); > > /////////// > > > > pj_memcpy(pw->buffer, cryptbuf, size); > > sent = size; > > > > what is the problem ? > > > ------------------------------------------------------------------------ > > _______________________________________________ > Visit our blog: http://blog.pjsip.org > > pjsip mailing list > pjsip at lists.pjsip.org > http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org -- Benny Prijono http://www.pjsip.org