How to signalize EOF from PJMEDIA source port (get_frame())?

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

 



Hi,

I would like to join Marek and thanks for PJSIP library it is very helpful
to develop new applications. 

Best regards,
George.

-----Original Message-----
From: pjsip-bounces@xxxxxxxxxxxxxxx [mailto:pjsip-bounces at lists.pjsip.org]
On Behalf Of Marek Peca
Sent: Thursday, April 30, 2009 8:41 AM
To: pjsip at lists.pjsip.org
Subject: How to signalize EOF from PJMEDIA source port
(get_frame())?

Hello,

first many thanks for excellent PJSIP/PJSUA libraries. Now the problem:
how can I inform pjmedia get_frame() caller, that EOF occured?

I would like to implement my own audio source pjmedia port. The source 
should be active only for a short time (kind of answering message or 
beep), then it should be destroyed. How can I signalize from the port, 
that its playing (talking/beeping) has been done?

I tried to set frame->size to zero, frame->type to 
PJMEDIA_FRAME_TYPE_NONE, return PJ_EEOF, but nothing works, the port 
is called by master next time and further on.

The port has been pjsua_conf_connect()-ed to PJSUA incoming call.

----- code snippet -----

pj_status_t answer_put_frame(struct pjmedia_port *this_port,
 			     const pjmedia_frame *frame) {
   /*NOP*/
   return PJ_EINVALIDOP;
}

pj_status_t answer_get_frame(struct pjmedia_port *this_port,
 			     pjmedia_frame *frame) {
   static size_t n = 0;

   printf("get_frame, size=%d\n", frame->size);

   if ((n += frame->size) > ANSW_SAMPLES) {
     printf("Done!\n");
     frame->type = PJMEDIA_FRAME_TYPE_NONE;
     frame->size = 0;
     return PJ_EEOF;
   }

   /***

     fill frame->buf ...

    ***/

   frame->type = PJMEDIA_FRAME_TYPE_AUDIO;
   return PJ_SUCCESS;
}

pj_status_t answer_on_destroy(struct pjmedia_port *this_port) {
   printf("A: destroy\n");
   return PJ_SUCCESS;
}

pjsua_conf_port_id get_answer() {
   static pj_pool_t *pool;
   static pjmedia_port aport;
   static pjsua_conf_port_id cport;
   pj_str_t name = pj_str("answer");

   pool = pjsua_pool_create("siptlamp", 16, 16);
   pjmedia_port_info_init(&aport.info, &name,
 			 PJMEDIA_PORT_SIGNATURE('A','N','S','W'),
 			 F_SAMPLE, 1, 2*8, 4096);
   aport.put_frame = answer_put_frame;
   aport.get_frame = answer_get_frame;
   aport.on_destroy = answer_on_destroy;
   pjsua_conf_add_port(pool, &aport, &cport);

   return cport;
}

----- end -----


Many thanks for any advice,
Marek.

_______________________________________________
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




[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