Example #1
0
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;
}
Example #2
0
void jitter_control_update_size(JitterControl *ctl, queue_t *q){
	mblk_t *newest=qlast(q);
	mblk_t *oldest=qbegin(q);
	uint32_t newest_ts,oldest_ts;
	if (newest==NULL) return;
	newest_ts=rtp_get_timestamp(newest);
	oldest_ts=rtp_get_timestamp(oldest);
	ctl->cum_jitter_buffer_count++;
	ctl->cum_jitter_buffer_size+=(uint32_t)(newest_ts-oldest_ts);
}
Example #3
0
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);
	}
}
Example #4
0
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);
}
Example #5
0
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);
}
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;
}
Example #7
0
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);
}