|
Hello.
I used for sdk of some audiovideo card for only audio live streaming.
I have function that called when I'v got a frame from card.
Next I check if this frame is audio frame.
If yes, I build a gstBuffer, fill this buffer with data and push it to appsrc. Everything working, but sometimes I have a little pause because pipeline taked and sended every data, and new frame still did not arrived.
How I can fix that? I need a real-time stream, even if I still did not received audio frame, mayby some silent audio.
Here is my primary parts of code.
string s_desc="appsrc name= MySource ! audioparse channels=1 rate=8000 ! alawenc ! rtppcmapay ! udpsink host="+g_sIp+" port="+g_iPort;
/* Build the pipeline */
pipeline = gst_parse_launch (&s_desc[0], NULL);
/*Get pointer to MySource*/
appsrc = (GstAppSrc*)gst_bin_get_by_name(GST_BIN(pipeline), "MySource");
This callback when I have some frame
if (FrameType == spct_PktAudioFrames) //take only Audio
{
int iLength = dwLength - sizeof(SPCTFRAMEHEADER); //size of packet without Card header
ret = spct_decode(&decode_context, (unsigned char *)pDataBuf+sizeof(SPCTFRAMEHEADER), iLength, &outbuf, &outsize);// decode packet to raw pcm
if(ret != -1 && outsize != 0) // decode one frame success save it
{
buffer=gst_buffer_new_allocate(NULL,outsize,NULL); //allocate new gstbuffer
gst_buffer_fill(buffer,0,outbuf,outsize); //fill
fret=gst_app_src_push_buffer (appsrc,buffer); //push to appsrc
}
}
|