亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? rtp.c

?? MPEG-4編解碼的實(shí)現(xiàn)(包括MPEG4視音頻編解碼)
?? C
?? 第 1 頁(yè) / 共 5 頁(yè)
字號(hào):
 * @session: the RTP session 
 * @ssrc: the SSRC to be used by the RTP session
 * 
 * This function coerces the local SSRC identifer to be ssrc.  For
 * this function to succeed it must be called immediately after
 * rtp_init or rtp_init_if.  The intended purpose of this
 * function is to co-ordinate SSRC's between layered sessions, it
 * should not be used otherwise.
 *
 * Returns: TRUE on success, FALSE otherwise.  
 */
int rtp_set_my_ssrc(struct rtp *session, uint32_t ssrc)
{
        source *s;
        uint32_t h;

        if (session->ssrc_count != 1 && session->sender_count != 0) {
                return FALSE;
        }
        /* Remove existing source */
        h = ssrc_hash(session->my_ssrc);
        s = session->db[h];
        session->db[h] = NULL;
        /* Fill in new ssrc       */
        session->my_ssrc = ssrc;
        s->ssrc          = ssrc;
        h                = ssrc_hash(ssrc);
        /* Put source back        */
        session->db[h]   = s;
        return TRUE;
}

/**
 * rtp_set_option:
 * @session: The RTP session.
 * @optname: The option name, see #rtp_option.
 * @optval: The value to set.
 *
 * Sets the value of a session option.  See #rtp_option for
 * documentation on the options and their legal values.
 *
 * Returns: TRUE on success, else FALSE.
 */
int rtp_set_option(struct rtp *session, rtp_option optname, int optval)
{
	ASSERT((optval == TRUE) || (optval == FALSE));

	switch (optname) {
		case RTP_OPT_WEAK_VALIDATION:
			session->opt->wait_for_rtcp = optval;
			break;
	        case RTP_OPT_PROMISC:
			session->opt->promiscuous_mode = optval;
			break;
	        case RTP_OPT_FILTER_MY_PACKETS:
			session->opt->filter_my_packets = optval;
			break;
        	default:
			rtp_message(LOG_ALERT, "Ignoring unknown option (%d) in call to rtp_set_option().", optname);
                        return FALSE;
	}
        return TRUE;
}

/**
 * rtp_get_option:
 * @session: The RTP session.
 * @optname: The option name, see #rtp_option.
 * @optval: The return value.
 *
 * Retrieves the value of a session option.  See #rtp_option for
 * documentation on the options and their legal values.
 *
 * Returns: TRUE and the value of the option in optval on success, else FALSE.
 */
int rtp_get_option(struct rtp *session, rtp_option optname, int *optval)
{
	switch (optname) {
		case RTP_OPT_WEAK_VALIDATION:
			*optval = session->opt->wait_for_rtcp;
                        break;
        	case RTP_OPT_PROMISC:
			*optval = session->opt->promiscuous_mode;
                        break;
	        case RTP_OPT_FILTER_MY_PACKETS:
			*optval = session->opt->filter_my_packets;
			break;
        	default:
                        *optval = 0;
			rtp_message(LOG_ALERT, "Ignoring unknown option (%d) in call to rtp_get_option().", optname);
                        return FALSE;
	}
        return TRUE;
}

/**
 * rtp_get_userdata:
 * @session: The RTP session.
 *
 * This function returns the userdata pointer that was passed to the
 * rtp_init() or rtp_init_if() function when creating this session.
 *
 * Returns: pointer to userdata.
 */
uint8_t *rtp_get_userdata(struct rtp *session)
{
	check_database(session);
	return session->userdata;
}

/**
 * rtp_my_ssrc:
 * @session: The RTP Session.
 *
 * Returns: The SSRC we are currently using in this session. Note that our
 * SSRC can change at any time (due to collisions) so applications must not
 * store the value returned, but rather should call this function each time 
 * they need it.
 */
uint32_t rtp_my_ssrc(struct rtp *session)
{
	check_database(session);
	return session->my_ssrc;
}

static int validate_rtp(rtp_packet *packet, int len)
{
	/* This function checks the header info to make sure that the packet */
	/* is valid. We return TRUE if the packet is valid, FALSE otherwise. */
	/* See Appendix A.1 of the RTP specification.                        */

	/* We only accept RTPv2 packets... */
	if (packet->rtp_pak_v != 2) {
		rtp_message(LOG_WARNING, "rtp_header_validation: v != 2");
		return FALSE;
	}
	/* Check for valid payload types..... 72-76 are RTCP payload type numbers, with */
	/* the high bit missing so we report that someone is running on the wrong port. */
	if (packet->rtp_pak_pt >= 72 && packet->rtp_pak_pt <= 76) {
		rtp_message(LOG_WARNING, "rtp_header_validation: payload-type invalid %d - seq%d", packet->rtp_pak_pt, packet->rtp_pak_seq);
		if (packet->rtp_pak_m) {
			rtp_message(LOG_WARNING, " (RTCP packet on RTP port?)");
		}
		return FALSE;
	}
	/* Check that the length of the packet is sensible... */
	if (len < (12 + (4 * packet->rtp_pak_cc))) {
		rtp_message(LOG_WARNING, "rtp_header_validation: packet length is smaller than the header");
		return FALSE;
	}
	/* Check that the amount of padding specified is sensible. */
	/* Note: have to include the size of any extension header! */
	if (packet->rtp_pak_p) {
		int	payload_len = len - 12 - (packet->rtp_pak_cc * 4);
                if (packet->rtp_pak_x) {
                        /* extension header and data */
                        payload_len -= 4 * (1 + packet->rtp_extn_len);
                }
                if (packet->rtp_data[packet->rtp_data_len - 1] > payload_len) {
                        rtp_message(LOG_WARNING, "rtp_header_validation: padding greater than payload length");
                        return FALSE;
                }
                if (packet->rtp_data[packet->rtp_data_len - 1] < 1) {
			rtp_message(LOG_WARNING, "rtp_header_validation: padding zero");
			return FALSE;
		}
        }
	return TRUE;
}

static void process_rtp(struct rtp *session, uint32_t curr_rtp_ts, rtp_packet *packet, source *s)
{
	int		 i, d, transit;
	rtp_event	 event;
	struct timeval	 event_ts;

	if (packet->rtp_pak_cc > 0) {
		for (i = 0; i < packet->rtp_pak_cc; i++) {
			create_source(session, packet->rtp_csrc[i], FALSE);
		}
	}
	/* Update the source database... */
	if (s->sender == FALSE) {
		s->sender = TRUE;
		session->sender_count++;
	}
	transit    = curr_rtp_ts - packet->rtp_pak_ts;
	d      	   = transit - s->transit;
	s->transit = transit;
	if (d < 0) {
		d = -d;
	}
	s->jitter += d - ((s->jitter + 8) / 16);
	
	/* Callback to the application to process the packet... */
	if (!filter_event(session, packet->rtp_pak_ssrc)) {
		gettimeofday(&event_ts, NULL);
		event.ssrc = packet->rtp_pak_ssrc;
		event.type = RX_RTP;
		event.data = (void *) packet;	/* The callback function MUST free this! */
		event.ts   = &event_ts;
		session->callback(session, &event);
	}
}

int rtp_process_recv_data (struct rtp *session,
			   uint32_t curr_rtp_ts,
			   rtp_packet *packet,
			   int buflen)
{
  uint8_t		*buffer = ((uint8_t *) packet) + RTP_PACKET_HEADER_SIZE;
  source		*s;
  int ret;

  packet->pd.rtp_pd_buflen = buflen;

  if (buflen > 0) {
    if (session->encryption_enabled)
      {
	ret = (session->decrypt_func)(session->encrypt_userdata, buffer, &buflen);
	if (ret != TRUE) return -1;
	packet->pd.rtp_pd_buflen = buflen;
      }
    
    /* Convert header fields to host byte order... */
    packet->rtp_next = packet->rtp_prev = NULL;
    packet->rtp_pak_seq  = ntohs(packet->rtp_pak_seq);
    packet->rtp_pak_ts   = ntohl(packet->rtp_pak_ts);
    packet->rtp_pak_ssrc = ntohl(packet->rtp_pak_ssrc);
    /* Setup internal pointers, etc... */
    if (packet->rtp_pak_cc) {
      int	i;
      packet->rtp_csrc = (uint32_t *)(buffer + 12);
      for (i = 0; i < packet->rtp_pak_cc; i++) {
	packet->rtp_csrc[i] = ntohl(packet->rtp_csrc[i]);
      }
    } else {
      packet->rtp_csrc = NULL;
    }
    if (packet->rtp_pak_x) {
      packet->rtp_extn      = buffer + 12 + (packet->rtp_pak_cc * 4);
      packet->rtp_extn_len  = (packet->rtp_extn[2] << 8) | packet->rtp_extn[3];
      packet->rtp_extn_type = (packet->rtp_extn[0] << 8) | packet->rtp_extn[1];
    } else {
      packet->rtp_extn      = NULL;
      packet->rtp_extn_len  = 0;
      packet->rtp_extn_type = 0;
    }
    packet->rtp_data     = buffer + 12 + (packet->rtp_pak_cc * 4);
    packet->rtp_data_len = buflen -  (packet->rtp_pak_cc * 4) - 12;
    if (packet->rtp_extn != NULL) {
      packet->rtp_data += ((packet->rtp_extn_len + 1) * 4);
      packet->rtp_data_len -= ((packet->rtp_extn_len + 1) * 4);
    }
    if (validate_rtp(packet, buflen)) {
      int weak = 0, promisc = 0;
      rtp_get_option(session, RTP_OPT_WEAK_VALIDATION, &weak);
      if (weak) {
	s = get_source(session, packet->rtp_pak_ssrc);
      } else {
	s = create_source(session, packet->rtp_pak_ssrc, TRUE);
      }
      rtp_get_option(session, RTP_OPT_PROMISC, &promisc);
      if (promisc) {
	if (s == NULL) {
	  create_source(session, packet->rtp_pak_ssrc, FALSE);
	  s = get_source(session, packet->rtp_pak_ssrc);
	}
	if (s->probation == -1) {
	  s->probation = MIN_SEQUENTIAL;
	  s->max_seq = packet->rtp_pak_seq - 1;
	}
	update_seq(s, packet->rtp_pak_seq);
	  
	process_rtp(session, curr_rtp_ts, packet, s);
	return 0; /* We don't free "packet", that's done by the callback function... */
      } 
      if (s != NULL) {
	if (s->probation == -1) {
	  s->probation = MIN_SEQUENTIAL;
	  s->max_seq   = packet->rtp_pak_seq - 1;
	}
	if (update_seq(s, packet->rtp_pak_seq)) {
	  process_rtp(session, curr_rtp_ts, packet, s);
	  return 0;	/* we don't free "packet", that's done by the callback function... */
	} else {
	  /* This source is still on probation... */
	  rtp_message(LOG_INFO, "RTP packet from probationary source ignored...");
	}
      } else {
	rtp_message(LOG_WARNING, "RTP packet from unknown source %d ignored", packet->rtp_pak_ssrc);
      }
    } else {
      session->invalid_rtp_count++;
      rtp_message(LOG_INFO, "Invalid RTP packet discarded");
    }
  }
  return -1; /* We need to free the packet */
}

void rtp_recv_data(struct rtp *session, uint32_t curr_rtp_ts)
{
	/* This routine preprocesses an incoming RTP packet, deciding whether to process it. */
	rtp_packet	*packet = (rtp_packet *) xmalloc(RTP_MAX_PACKET_LEN + RTP_PACKET_HEADER_SIZE);
	uint8_t		*buffer = ((uint8_t *) packet) + RTP_PACKET_HEADER_SIZE;
	int		 buflen;

	buflen = udp_recv(session->rtp_socket, buffer, RTP_MAX_PACKET_LEN);
	if (rtp_process_recv_data(session, curr_rtp_ts, packet, buflen) < 0)
	  xfree(packet);
}

static int validate_rtcp(uint8_t *packet, int len)
{
	/* Validity check for a compound RTCP packet. This function returns */
	/* TRUE if the packet is okay, FALSE if the validity check fails.   */
        /*                                                                  */
	/* The following checks can be applied to RTCP packets [RFC1889]:   */
        /* o RTP version field must equal 2.                                */
        /* o The payload type field of the first RTCP packet in a compound  */
        /*   packet must be equal to SR or RR.                              */
        /* o The padding bit (P) should be zero for the first packet of a   */
        /*   compound RTCP packet because only the last should possibly     */
        /*   need padding.                                                  */
        /* o The length fields of the individual RTCP packets must total to */
        /*   the overall length of the compound RTCP packet as received.    */

	rtcp_t	*pkt  = (rtcp_t *) packet;
	rtcp_t	*end  = (rtcp_t *) (((char *) pkt) + len);
	rtcp_t	*r    = pkt;
	int	 l    = 0;
	int	 pc   = 1;
	int	 p    = 0;

	/* All RTCP packets must be compound packets (RFC1889, section 6.1) */
	if (((ntohs(pkt->common.length) + 1) * 4) == len) {
		rtp_message(LOG_WARNING, "Bogus RTCP packet: not a compound packet");
		return FALSE;
	}

	/* Check the RTCP version, payload type and padding of the first in  */
	/* the compund RTCP packet...                                        */
	if (pkt->common.version != 2) {
		rtp_message(LOG_WARNING, "Bogus RTCP packet: version number != 2 in the first sub-packet");
		return FALSE;
	}
	if (pkt->common.p != 0) {
		rtp_message(LOG_WARNING, "Bogus RTCP packet: padding bit is set on first packet in compound");
		return FALSE;
	}
	if ((pkt->common.pt != RTCP_SR) && (pkt->common.pt != RTCP_RR)) {
		rtp_message(LOG_WARNING, "Bogus RTCP packet: compund packet does not start with SR or RR");
		return FALSE;
	}

	/* Check all following parts of the compund RTCP packet. The RTP version */
	/* number must be 2, and the padding bit must be zero on all apart from  */
	/* the last packet.                                                      */
	do {
		if (p == 1) {
			rtp_message(LOG_WARNING, "Bogus RTCP packet: padding bit set before last in compound (sub-packet %d)", pc);
			return FALSE;
		}
		if (r->common.p) {
			p = 1;
		}
		if (r->common.version != 2) {
			rtp_message(LOG_WARNING, "Bogus RTCP packet: version number != 2 in sub-packet %d", pc);
			return FALSE;
		}
		l += (ntohs(r->common.length) + 1) * 4;
		r  = (rtcp_t *) (((uint32_t *) r) + ntohs(r->common.length) + 1);
		pc++;	/* count of sub-packets, for debugging... */
	} while (r < end);

	/* Check that the length of the packets matches the length of the UDP */
	/* packet in which they were received...                              */
	if (l != len) {
		rtp_message(LOG_WARNING, "Bogus RTCP packet: RTCP packet length does not match UDP packet length (%d != %d)", l, len);
		return FALSE;
	}
	if (r != end) {
		rtp_message(LOG_WARNING, "Bogus RTCP packet: RTCP packet length does not match UDP packet length (%p != %p)", r, end);
		return FALSE;
	}

	return TRUE;
}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
高清不卡一二三区| 日本乱人伦一区| 日本不卡一区二区| 亚洲久草在线视频| 中文字幕av不卡| 久久免费精品国产久精品久久久久| 在线观看一区二区视频| 国产成人8x视频一区二区| 亚洲最快最全在线视频| √…a在线天堂一区| 国产清纯美女被跳蛋高潮一区二区久久w| 欧美一级欧美三级| 欧美喷水一区二区| 在线观看日韩av先锋影音电影院| 91香蕉视频在线| 91免费精品国自产拍在线不卡 | 亚洲精选免费视频| 国产精品国产三级国产a| 国产亚洲欧美色| 在线不卡一区二区| 6080日韩午夜伦伦午夜伦| 欧美日韩亚洲另类| 欧美日韩一区久久| 欧美疯狂性受xxxxx喷水图片| 欧美亚洲国产一区在线观看网站| 91日韩精品一区| 国产69精品久久久久777| 国产iv一区二区三区| 国产91精品一区二区麻豆亚洲| 国产福利视频一区二区三区| 国产不卡视频一区二区三区| 国产东北露脸精品视频| 成人免费黄色大片| 在线中文字幕一区| 7777精品久久久大香线蕉| 91精品国产高清一区二区三区蜜臀 | 国产日韩欧美制服另类| 日韩美一区二区三区| 精品国产乱子伦一区| 久久久久久久久久电影| 中文字幕在线不卡国产视频| 亚洲一区二区三区在线| 日韩va亚洲va欧美va久久| 麻豆精品在线播放| 成人午夜电影网站| 欧洲精品在线观看| 日韩一区二区精品在线观看| 久久新电视剧免费观看| 国产精品福利一区二区三区| 亚洲麻豆国产自偷在线| 一区二区欧美国产| 极品销魂美女一区二区三区| 风间由美中文字幕在线看视频国产欧美| 国产综合色产在线精品| 91视频国产观看| 日韩丝袜情趣美女图片| 国产日韩精品久久久| 亚洲精品高清在线| 久久精品国产色蜜蜜麻豆| 成人激情小说乱人伦| 欧美视频中文一区二区三区在线观看| 欧美蜜桃一区二区三区| 久久综合久久鬼色| 亚洲精品视频在线观看网站| 日本不卡一二三| 成人免费看视频| 欧美三级电影网| 国产欧美日韩精品a在线观看| 一区二区三区中文字幕| 激情综合色丁香一区二区| eeuss鲁一区二区三区| 欧美二区三区91| 久久综合资源网| 亚洲福利视频一区| 国产一区二区美女| 91福利在线导航| 久久久综合视频| 日日摸夜夜添夜夜添精品视频| 国产在线播精品第三| 欧美日韩一卡二卡三卡| 欧美国产1区2区| 美腿丝袜亚洲一区| 91官网在线免费观看| 久久久青草青青国产亚洲免观| 亚洲综合丝袜美腿| eeuss鲁片一区二区三区在线看| 日韩欧美综合在线| 亚洲一区二区欧美激情| 成人午夜电影小说| 日韩精品在线网站| 五月婷婷综合网| 日本韩国欧美一区| 国产精品久久久久久久久免费桃花| 日本亚洲最大的色成网站www| 不卡高清视频专区| 日韩午夜在线观看| 亚洲bt欧美bt精品777| 99久久精品一区| 国产日本欧美一区二区| 另类小说色综合网站| 欧美日韩日日骚| 亚洲乱码国产乱码精品精小说 | 欧美国产在线观看| 精品一区二区三区久久久| 欧美性猛交xxxx黑人交| 亚洲少妇屁股交4| 成人黄色免费短视频| 26uuu亚洲综合色| 麻豆精品视频在线观看视频| 欧美巨大另类极品videosbest | 色婷婷国产精品| 中文在线一区二区| 国产在线一区二区综合免费视频| 91麻豆精品国产91久久久久久 | 午夜免费久久看| 欧美视频在线一区二区三区 | 日韩精品国产精品| 欧美精品在线一区二区| 亚洲成av人片| 3d动漫精品啪啪一区二区竹菊 | 午夜电影一区二区| 精品视频1区2区3区| 亚洲成av人片一区二区三区| 99国产一区二区三精品乱码| 久久久不卡网国产精品二区| 日韩av电影天堂| 91精品国产91久久综合桃花| 日日欢夜夜爽一区| 欧美一区二区三区在线电影| 亚洲v日本v欧美v久久精品| 欧美精品在线观看一区二区| 三级久久三级久久久| 色天使色偷偷av一区二区 | 国产剧情一区二区| 久久久久99精品一区| 粗大黑人巨茎大战欧美成人| 国产精品污污网站在线观看| 成人综合在线观看| 亚洲视频一区在线| 99久久久久久99| 亚洲一本大道在线| 精品久久久久久亚洲综合网| 国产精品一区一区三区| 中文字幕av一区二区三区高| 99re这里只有精品6| 亚洲国产cao| 日韩免费看的电影| 蜜桃精品视频在线| 不卡在线视频中文字幕| 欧美一区日本一区韩国一区| 国产精品自产自拍| 一区二区三区精品视频| 欧美成人一区二区| 日本精品免费观看高清观看| 精品一区二区三区在线播放| 亚洲蜜桃精久久久久久久| 欧美一区二区三区四区久久| 成人爱爱电影网址| 日本不卡中文字幕| 亚洲精品亚洲人成人网在线播放| 日韩一区和二区| 日本乱人伦aⅴ精品| 国产精品白丝jk黑袜喷水| 午夜久久电影网| 亚洲人成亚洲人成在线观看图片| 精品国产在天天线2019| 欧美日韩在线一区二区| a级高清视频欧美日韩| 国产在线不卡视频| 日本免费新一区视频| 亚洲靠逼com| 中文字幕中文字幕在线一区| 日韩欧美美女一区二区三区| 91国产成人在线| 97se亚洲国产综合自在线不卡| 国产在线播放一区二区三区| 日韩有码一区二区三区| 亚洲免费在线视频| 中日韩免费视频中文字幕| 精品国产伦一区二区三区观看方式 | 尤物视频一区二区| 欧美激情艳妇裸体舞| 欧美精品一区二区三区一线天视频 | 日本视频一区二区三区| 伊人色综合久久天天人手人婷| 久久久www成人免费无遮挡大片| 欧美一区二区视频观看视频 | 国产欧美日韩在线看| 日韩免费视频线观看| 91精品国产91久久久久久最新毛片| 色哟哟国产精品| 99久久免费精品| 不卡在线视频中文字幕| 成人午夜精品在线| 成人午夜激情在线| 成人毛片视频在线观看| 成人理论电影网| 99久久国产免费看| 日本精品免费观看高清观看| 91在线观看一区二区|