B770
B770

Reputation: 1292

Android library to stream local stored audio via RTP

Is it possible to transmit a local stored audio file (e.g. mp3) via RTP? E.g. there is mp3 file that is taken as input and converted/packed into RTP packets and send over the network. Are there any libraries, solutions, examples?

Thanks!

//Edit: What I want to do is to make a phone call with SIP and send/stream the local stored audio file to the called, so that he can hear it.

Upvotes: 1

Views: 4765

Answers (2)

Robert Rowntree
Robert Rowntree

Reputation: 6289

check for possible WebRTC solutions in section 5.... Have not worked with it but sounds like its tailor made for what you are trying to do. Maybe use Ondello api.

OR

You have to build the session for the SIP/RTP connection , providing a backdoor (JNI and native code) to the buffer that receives the Microphone raw stream or the output buffer where the microphone raw stream is encoded to... By doing that you could load the RTP stream on the sender side with your prerecord audio.

With access to that buffer, in the middle of the SIP session, you can Xcopy from an in-memory version of your audio file, swapping that stream into the SIP call. The party at the other end of the call will hear the audio from the audio file an not the Microphone content.

If not success w/ SIP/RTP apis, you could also check this very good java networking lib that allows you to build SIP connections from the ground up and to swap buffers in any manner that you want.

https://github.com/brunodecarvalho/efflux

see my answer on this thread

OPTION 2, Client Server ( no JNI native code req'd here )

Upload the audio from the sender and serve it from your server as RTSP to the receiver. Any Youtube video used to be ( still may be ) encoded for RTSP clients and is pretty well known server-to-android-media-player scenario. I believe this is the SDP description of such a file and the log of the session...

D/chooseit( 6854): Session Descriptor
D/chooseit( 6854): v=0
D/chooseit( 6854): o=GoogleStreamer 1263099257 1890734730 IN IP4 74.125.213.247
D/chooseit( 6854): s=Video
D/chooseit( 6854): c=IN IP4 0.0.0.0
D/chooseit( 6854): b=AS:51
D/chooseit( 6854): t=0 0
D/chooseit( 6854): a=control:*
D/chooseit( 6854): a=range:npt=0-63.800000
D/chooseit( 6854): m=video 0 RTP/AVP 98
D/chooseit( 6854): b=AS:39
D/chooseit( 6854): a=rtpmap:98 H263-2000/90000
D/chooseit( 6854): a=control:trackID=0
D/chooseit( 6854): a=cliprect:0,0,144,176
D/chooseit( 6854): a=framesize:98 176-144
D/chooseit( 6854): a=fmtp:98 profile=0;level=10
D/chooseit( 6854): m=audio 0 RTP/AVP 99
D/chooseit( 6854): b=AS:12
D/chooseit( 6854): a=rtpmap:99 AMR/8000/1
D/chooseit( 6854): a=control:trackID=1
D/chooseit( 6854): a=fmtp:99 octet-align
D/chooseit( 6854): Got response:
D/chooseit( 6854): RTSP/1.0 200 OK
D/chooseit( 6854): Content-Type: application/sdp
D/chooseit( 6854): Cache-Control: must-revalidate
D/chooseit( 6854): Date: Wed, 28 Sep 2011 17:27:22 GMT
D/chooseit( 6854): Expires: Wed, 28 Sep 2011 17:27:22 GMT
D/chooseit( 6854): Last-Modified: Wed, 28 Sep 2011 17:27:22 GMT
D/chooseit( 6854): Content-Base: rtsp://v8.cache8.c.youtube.com/CigLENy73wIaHwlcw_gs85OUchMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp/
D/chooseit( 6854): CSeq: 0
D/chooseit( 6854): Server: Google RTSP 1.0
D/chooseit( 6854): Content-Length: 406
D/chooseit( 6854):
D/chooseit( 6854): for the request:
D/chooseit( 6854): DESCRIBE rtsp://v8.cache8.c.youtube.com/CigLENy73wIaHwlcw_gs85OUchMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp RTSP/1.0
D/chooseit( 6854): CSeq: 0
D/chooseit( 6854): Accept: application/sdp
D/chooseit( 6854): User-Agent: RTSPClientLib/Java
D/chooseit( 6854):
D/chooseit( 6854): Got response:
D/chooseit( 6854): RTSP/1.0 200 OK
D/chooseit( 6854): Session: 328393bf;timeout=90
D/chooseit( 6854): Transport: RTP/AVP;unicast;mode=play;client_port=49060-49061;server_port=10580-10581;source=74.125.213.247;ssrc=55922C32
D/chooseit( 6854): Cache-Control: must-revalidate
D/chooseit( 6854): Date: Wed, 28 Sep 2011 17:27:22 GMT
D/chooseit( 6854): Expires: Wed, 28 Sep 2011 17:27:22 GMT
D/chooseit( 6854): Last-Modified: Wed, 28 Sep 2011 17:27:22 GMT
D/chooseit( 6854): CSeq: 1
D/chooseit( 6854): Server: Google RTSP 1.0
D/chooseit( 6854):
D/chooseit( 6854): for the request:
D/chooseit( 6854): SETUP rtsp://v8.cache8.c.youtube.com/CigLENy73wIaHwlcw_gs85OUchMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp/trackID=1 RTSP/1.0
D/chooseit( 6854): CSeq: 1
D/chooseit( 6854): Transport: RTP/AVP;unicast;client_port=49060-49061
D/chooseit( 6854): User-Agent: RTSPClientLib/Java
D/chooseit( 6854):
D/chooseit( 6854): using client IP addr 192.168.1.125
D/chooseit( 6854): remote ssrc 1435642930
D/chooseit( 6854): raw parms 49060 10580 74.125.213.247
D/chooseit( 6854): session: 328393bf
D/chooseit( 6854): transport: client_port=49060-49061 server_port=10580-10581 source=74.125.213.247 ssrc=55922C32
D/chooseit( 6854): Got response:
D/chooseit( 6854): RTSP/1.0 200 OK
D/chooseit( 6854): Session: 328393bf;timeout=90
D/chooseit( 6854): Range: npt=0.000-63.800
D/chooseit( 6854): RTP-Info: url=rtsp://v8.cache8.c.youtube.com/CigLENy73wIaHwlcw_gs85OUchMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp/trackID=1;seq=9498;rtpt
ime=958652148
D/chooseit( 6854): CSeq: 2
D/chooseit( 6854): Server: Google RTSP 1.0
D/chooseit( 6854):
D/chooseit( 6854): for the request:
D/chooseit( 6854): PLAY rtsp://v8.cache8.c.youtube.com/CigLENy73wIaHwlcw_gs85OUchMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp RTSP/1.0
D/chooseit( 6854): CSeq: 2
D/chooseit( 6854): Session: 328393bf;timeout=90
D/chooseit( 6854): Range: npt=0.000-
D/chooseit( 6854): User-Agent: RTSPClientLib/Java

Upvotes: 1

Phani
Phani

Reputation: 5427

You can use the android.net.rtp in Android API.

Upvotes: 2

Related Questions