一 mediastream2
特点:由一系列不同功能的Filter,即MSFilter,按照需要连接Link起来。Run起来。
Filter照着模板写,注册上去。跟ffmpeg类似。
音频filter,视频filter,各一个线程。
//把连接的filter都跑一遍,等间隔时间(10毫秒)到了,再次执行。间隔时间可改。
//一般,视频1秒25帧,间隔是40ms,filter运行时间是30ms。
//音频,1秒50次,filter运行时间是10ms。
#define TICKER_INTERVAL 10
void *mw_ticker_run(void *arg)
{
/*Step 1: run the graphs*/
/*Step 2: wait for next tick*/
s->time+=s->interval;
}
项目经验:有遇到接收音视频数据报错--没有数据,是其中一个filter阻塞了,该功能太耗时了,而不是ortp库有问题。
二 ortp抗抖动怎么做的?jitter作用于取数据的时间
ortp是单线程下的多个RTP会话。
对网络抖动的处理:队列最大100个,最大补偿80微秒,跳跃限制5000微秒。
jbp.max_packets= 100;/* maximum number of packet allowed to be queued */
jbp.min_size=RTP_DEFAULT_JITTER_TIME;
#define RTP_DEFAULT_JITTER_TIME 80 /*miliseconds*/
/*
The algorithm computes two values:
slide: an average of difference between the expected and the socket-received timestamp
jitter: an average of the absolute value of the difference between socket-received timestamp and slide.
slide is used to make clock-slide detection and correction.
jitter is added to the initial jitt_comp_time value. It compensates bursty packets arrival (packets
not arriving at regular interval ).
*/
//时钟是8000,音频的。收到50包,开始计算该值。
void jitter_control_new_packet(JitterControl *ctl, uint32_t packet_ts, uint32_t cur_str_ts){
...
if (ctl->adaptive){
if (ctl->count%50==0) {
ctl->adapt_jitt_comp_ts=(int) MAX(ctl->jitt_comp_ts,2*ctl->jitter);
}
...
}
//算出的jitter,只是作用于取数据的时间
ts = jitter_control_get_compensated_timestamp(&session->rtp.jittctl,user_ts);
if (session->rtp.jittctl.enabled==TRUE){
if (session->permissive)
mp = rtp_getq_permissive(&session->rtp.rq, ts,&rejected);
else{
mp = rtp_getq(&session->rtp.rq, ts,&rejected);
}
}
if ( RTP_TIMESTAMP_IS_NEWER_THAN(timestamp,tmprtp->timestamp) )
{
ret=getq(q); /* dequeue the packet, since it has an interesting timestamp*/
ortp_debug("rtp_getq_permissive: Found packet with ts=%i",tmprtp->timestamp);
}