mblk_t* rtp_session_create_rtcp_sdes_packet(RtpSession *session, bool_t full) { mblk_t *mp = allocb(sizeof(rtcp_common_header_t), 0); rtcp_common_header_t *rtcp; mblk_t *tmp; mblk_t *m = mp; mblk_t *sdes; queue_t *q; int rc = 0; sdes = (full == TRUE) ? session->full_sdes : session->minimal_sdes; rtcp = (rtcp_common_header_t *)mp->b_wptr; mp->b_wptr += sizeof(rtcp_common_header_t); /* Concatenate all sdes chunks. */ sdes_chunk_set_ssrc(sdes, session->snd.ssrc); m = concatb(m, dupmsg(sdes)); rc++; if (full == TRUE) { q = &session->contributing_sources; for (tmp = qbegin(q); !qend(q, tmp); tmp = qnext(q, mp)) { m = concatb(m, dupmsg(tmp)); rc++; } } rtcp_common_header_init(rtcp, session, RTCP_SDES, rc, msgdsize(mp)); return mp; }
void putc_a85(mwg::u4t v){ if(maxcols>0&&col==0)qbeg(); v%=85; if(v==52)v=85; putc(40+v,file); if(maxcols>0&&++col==maxcols)qend(); }
void ms_yuv_buf_allocator_free(MSYuvBufAllocator *obj) { mblk_t *m; int possibly_leaked = 0; for(m = qbegin(&obj->q); !qend(&obj->q,m); m = qnext(&obj->q, m)){ if (m->b_datap->db_ref > 1) possibly_leaked++; } msgb_allocator_uninit(obj); ms_free(obj); if (possibly_leaked > 0){ ms_warning("ms_yuv_buf_allocator_free(): leaving %i mblk_t still ref'd, possible leak.", possibly_leaked); } }
void rtp_session_remove_contributing_source(RtpSession *session, uint32_t ssrc) { queue_t *q=&session->contributing_sources; mblk_t *tmp; for (tmp=qbegin(q); !qend(q,tmp); tmp=qnext(q,tmp)){ uint32_t csrc=sdes_chunk_get_ssrc(tmp); if (csrc==ssrc) { remq(q,tmp); break; } } tmp=rtcp_create_simple_bye_packet(ssrc, NULL); rtp_session_rtcp_send(session,tmp); }
mblk_t *msgb_allocator_alloc(msgb_allocator_t *a, int size){ queue_t *q=&a->q; mblk_t *m,*found=NULL; /*lookup for an unused msgb (data block with ref count ==1)*/ for(m=qbegin(q);!qend(q,m);m=qnext(q,m)){ if (m->b_datap->db_ref==1 && m->b_datap->db_lim-m->b_datap->db_base>=size){ found=m; break; } } if (found==NULL){ found=allocb(size,0); putq(q,found); } return dupb(found); }
/* put an rtp packet in queue. It is called by rtp_parse()*/ void rtp_putq(queue_t *q, mblk_t *mp) { mblk_t *tmp; rtp_header_t *rtp=(rtp_header_t*)mp->b_rptr,*tmprtp; /* insert message block by increasing time stamp order : the last (at the bottom) message of the queue is the newest*/ ortp_debug("rtp_putq(): Enqueuing packet with ts=%i and seq=%i",rtp->timestamp,rtp->seq_number); if (qempty(q)) { putq(q,mp); return; } tmp=qlast(q); /* we look at the queue from bottom to top, because enqueued packets have a better chance to be enqueued at the bottom, since there are surely newer */ while (!qend(q,tmp)) { tmprtp=(rtp_header_t*)tmp->b_rptr; ortp_debug("rtp_putq(): Seeing packet with seq=%i",tmprtp->seq_number); if (rtp->seq_number == tmprtp->seq_number) { /* this is a duplicated packet. Don't queue it */ ortp_debug("rtp_putq: duplicated message."); freemsg(mp); return; }else if (RTP_SEQ_IS_GREATER(rtp->seq_number,tmprtp->seq_number)){ insq(q,tmp->b_next,mp); return; } tmp=tmp->b_prev; } /* this packet is the oldest, it has to be placed on top of the queue */ insq(q,qfirst(q),mp); }
mblk_t* rtp_session_create_rtcp_sdes_packet(RtpSession *session) { mblk_t *mp=allocb(sizeof(rtcp_common_header_t),0); rtcp_common_header_t *rtcp; mblk_t *tmp,*m=mp; queue_t *q; int rc=0; rtcp = (rtcp_common_header_t*)mp->b_wptr; mp->b_wptr+=sizeof(rtcp_common_header_t); /* concatenate all sdes chunks */ sdes_chunk_set_ssrc(session->sd,session->snd.ssrc); m=concatb(m,dupmsg(session->sd)); rc++; q=&session->contributing_sources; for (tmp=qbegin(q); !qend(q,tmp); tmp=qnext(q,mp)){ m=concatb(m,dupmsg(tmp)); rc++; } rtcp_common_header_init(rtcp,session,RTCP_SDES,rc,msgdsize(mp)); return mp; }
void terminate(){ dump(); if(maxcols>0&&col!=0)qend(); }
void DrawPolygon2(int index, RTREE& rtree2, std::vector<polygon>& polygons, int pmap[][HEIGHT]) { int xmin, ymin, xmax, ymax; box b; findCorner(xmin, ymin, xmax, ymax, b, index); std::vector<value> result; rtree2.query(bgi::intersects(b), std::back_inserter(result)); RTREE rtree(result.begin(), result.end()); // std::this_thread::sleep_for(std::chrono::seconds(index)); // std::cout << bg::wkt<box>(b) << std::endl; // std::cout<<"index = "<<index<<"min_corner = "<<xmin<<","<<ymin<<" max_corner = "<<xmax<<","<<ymax<<std::endl; // std::cout<<"polygon size: "<<polygons.size()<<std::endl; for (int i = xmin; i <= xmax; i++) for (int j = ymin; j <= ymax; j++) { if (pmap[i][j] == -1) { point sought = point(i, j); std::vector<value> result_n; for ( RTREE::const_query_iterator it = qbegin(rtree, bgi::nearest(sought, 100)) ; it != qend(rtree) ; ++it ) { int id = it->second; auto& poly = polygons[id]; auto box = it->first; if (!bg::within(sought, box)) break; if ( bg::within(sought, poly) ) { // std::cout<<"**********************\n"; // pmap[i][j] = id; point pmin = box.min_corner(); point pmax = box.max_corner(); int xmin2 = pmin.get<0>(); int ymin2 = pmin.get<1>(); int xmax2 = pmax.get<0>(); int ymax2 = pmax.get<1>(); for (int w = xmin2; w <= xmax2; w++) { for (int h = ymin2; h <= ymax2; h++) { if (w < xmin || h < ymin || w >= xmax || h >= ymax || pmap[w][h] >= 0) continue; if (bg::within(point(w, h), poly)) { pmap[w][h] = id; } } } break; } } } } // //random color // std::vector<int> colors; // int size = polygons.size(); // for ( int i = 0 ; i < size ; ++i ) // { // colors.push_back(i % 3 + 1); // } // //Draw pixel // // t1 = std::chrono::high_resolution_clock::now(); // cv::Mat mat(HEIGHT, WIDTH, CV_8UC4); // mat = cv::Scalar(0, 0, 0, 0); // for (int i = 0; i < WIDTH; i++) // for (int j = 0; j < HEIGHT; j++) // { // if (pmap[i][j] != -1) { // int c = colors[pmap[i][j]]; // auto color = c == 1 ? RED : c == 2 ? GREEN : BLUE; // line( mat, cv::Point(i, j), cv::Point(i, j), color, 2, 8); // } // } // line(mat, cv::Point(10, 10), cv::Point(251, 240), cv::Scalar(0, 0, 0, 255), 1, 8); // std::vector<int> compression_params; // compression_params.push_back(CV_IMWRITE_PNG_COMPRESSION); // compression_params.push_back(9); // std::string filename = "DrawPolygon7_" + std::to_string(index) + ".png"; // imwrite(filename, mat, compression_params); }