Same than voip_play, but made to read and play VoIP RTP packets, without checking IP. .. seealso:: voip_play for basic VoIP packets
(lst=None, **kargs)
| 146 | |
| 147 | |
| 148 | def voip_play3(lst=None, **kargs): |
| 149 | """Same than voip_play, but made to |
| 150 | read and play VoIP RTP packets, without |
| 151 | checking IP. |
| 152 | |
| 153 | .. seealso:: voip_play |
| 154 | for basic VoIP packets |
| 155 | """ |
| 156 | proc = subprocess.Popen(sox_base[0] + sox_base[1], stdin=subprocess.PIPE, |
| 157 | stdout=subprocess.PIPE) |
| 158 | dsp, rd = proc.stdin, proc.stdout |
| 159 | |
| 160 | def play(pkt, dsp=dsp): |
| 161 | if pkt and pkt.haslayer(UDP) and pkt.haslayer(RTP): |
| 162 | dsp.write(pkt.getlayer(RTP).load) |
| 163 | try: |
| 164 | if lst is None: |
| 165 | sniff(store=0, prn=play, **kargs) |
| 166 | else: |
| 167 | for p in lst: |
| 168 | play(p) |
| 169 | finally: |
| 170 | try: |
| 171 | dsp.close() |
| 172 | rd.close() |
| 173 | except Exception: |
| 174 | pass |