SIPRTP and STREAMUTIL Sample merge problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello!

I started using pjsip library recently to develop a load test tool using
SIP and RTP/RTCP protocols, for Windows OS, and I'm using MS Visual Studio
2008 Pro.

I found that the siprtp sample almost suits my needs, except for the fact
that I need to send a specific wav file using RTP and multiple calls (400+).

I found that the payload sent using this sample is always zero, so I found
the streamutil sample, that allows sending WAV files, but doesn't create a
SIP session (needed for my tool) and does not support multiple calls.

Trying to implement the wav_player_port changes, I got stuck on
PJMEDIA_PIA_PTIME, but I found that the problem is not the method itself,
but the parameter that is passed.

Let me explain a little bit more.

Before making the calls, the method init_media is called. Inside of this
method I include a stream creation, using "pjmedia_stream_create" (for each
call), and store the stream into the media_stream struct.

The following code is a snippet from init_media method, where the streams
are created:

[ -------------------------------------- BEGIN CODE
-------------------------------------- ]

/* Init media transport for all calls. */
    for (i=0, count=0; i<app.max_calls; ++i, ++count) {
unsigned j;
pj_status_t status;
 /* Create transport for each media in the call */
for (j=0; j<PJ_ARRAY_SIZE(app.call[0].media); ++j) {
int retry;

app.call[i].media[j].call_index = i;
app.call[i].media[j].media_index = j;
app.call[i].media[j].stream = NULL; /* "pjmedia_stream *stream" was
included into media_stream struct. */

/* Reset stream info. */
pj_bzero(&app.call[i].media[j].si, sizeof(app.call[i].media[j].si));

/* Initialize stream info formats */
app.call[i].media[j].si.type = PJMEDIA_TYPE_AUDIO;
if (app.sender) /* this flag indicate that application will send audio */
app.call[i].media[j].si.dir = PJMEDIA_DIR_ENCODING;
else /* the application will only receive audio */
app.call[i].media[j].si.dir = PJMEDIA_DIR_DECODING;

pj_memcpy(&app.call[i].media[j].si.fmt, codec_info,
sizeof(pjmedia_codec_info));
app.call[i].media[j].si.tx_pt = codec_info->pt;
app.call[i].media[j].si.ssrc = pj_rand();
 /* Copy remote address */
pj_memcpy(&app.call[i].media[j].si.rem_addr, &app.addr,
sizeof(pj_sockaddr_in));

status = -1;
for (retry=0; retry<100; ++retry,rtp_port+=2)  {
struct media_stream *m = &app.call[i].media[j];
 status = pjmedia_transport_udp_create2(app.med_endpt,
   "siprtp",
   &app.local_addr,
   rtp_port, 0,
   &m->transport);

if (status == PJ_SUCCESS) {
rtp_port += 2;
break;
}
 status = pjmedia_stream_create( app.med_endpt, app.pool,
&app.call[i].media[j].si,
m->transport, NULL, &app.call[i].media[j].stream);

if (status != PJ_SUCCESS) {
app_perror(THIS_FILE, "Error creating stream", status);
pjmedia_transport_close(m->transport);
return status;
}
}
}

if (status != PJ_SUCCESS)
goto on_error;
}
[ --------------------------------------- END CODE
--------------------------------------- ]


So far, so good. No problems initializing the media. The problem occurs
after the SDP negotiation is done, when the callback "call_on_media_update"
is triggered.
Inside this callback, I try to get the stream port of the created stream,
to create a new wav_player_port, and then to associate these ports using a
master_port (using the streamutil's code as reference).

My problem occurs after calling "pjmedia_stream_get_port" and before
calling "PJMEDIA_PIA_PTIME".

(It's only a snippet of the code, since it's a bit long):


[ -------------------------------------- BEGIN CODE
-------------------------------------- ]

static void call_on_media_update( pjsip_inv_session *inv,
  pj_status_t status)
{

[ ... ]

call = inv->mod_data[mod_siprtp.id];
pool = inv->dlg->pool;
audio = &call->media[0];

[ ... ]

audio->clock_rate = audio->si.fmt.clock_rate;
audio->samples_per_frame = audio->clock_rate * codec_desc->ptime / 1000;
audio->bytes_per_frame = codec_desc->bit_rate * codec_desc->ptime / 1000 /
8;

pjmedia_rtp_session_init(&audio->out_sess, audio->si.tx_pt,
 pj_rand());
 pjmedia_rtp_session_init(&audio->in_sess, audio->si.fmt.pt, 0);
 pjmedia_rtcp_init(&audio->rtcp, "rtcp", audio->clock_rate,
  audio->samples_per_frame, 0);

/* Attach media to transport */
status = pjmedia_transport_attach(audio->transport, audio,
  &audio->si.rem_addr,
  &audio->si.rem_rtcp,
  sizeof(pj_sockaddr_in),
  &on_rx_rtp,
  &on_rx_rtcp);
  if (status != PJ_SUCCESS) {
app_perror(THIS_FILE, "Error on pjmedia_transport_attach()", status);
return;
}
 status = pjmedia_stream_get_port( audio->stream, &audio->stream_port);
if (status != PJ_SUCCESS) {
app_perror(THIS_FILE, "Unable to get stream port\n", status);
return;
}

/* I put this printf trying to discover the problem */
printf ("Name = %s\n", audio->stream_port->info.name); // APPLICATION
CRASHES HERE.
 wav_ptime = PJMEDIA_PIA_PTIME(&audio->stream_port->info);

[ ... ]
}

[ --------------------------------------- END CODE
--------------------------------------- ]

My problem is that the application crashed when reach the method
"PJMEDIA_PIA_PTIME", so I try to print some values from stream_port and its
look like "stream_port->info" is not defined.

Inside of the method PJMEDIA_PIA_PTIME, the following assert is done
(causing the application to crash):

pj_assert(pia->fmt.type==PJMEDIA_TYPE_AUDIO &&
      pia->fmt.detail_type==PJMEDIA_FORMAT_DETAIL_AUDIO);

Am I missing something? Or doing something wrong?

I really appreciate any help you can provide. In the meantime, thank you so
much for your attention.

Best Regards,
Rodrigo Wantuk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20150310/4fb6f678/attachment.html>


[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux