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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? rtp.c

?? MPEG-4編解碼的實現(xiàn)(包括MPEG4視音頻編解碼)
?? C
?? 第 1 頁 / 共 5 頁
字號:
/*
 * FILE:     rtp.c
 * AUTHOR:   Colin Perkins   <csp@isi.edu>
 * MODIFIED: Orion Hodson    <o.hodson@cs.ucl.ac.uk>
 *           Markus Germeier <mager@tzi.de>
 *           Bill Fenner     <fenner@research.att.com>
 *           Timur Friedman  <timur@research.att.com>
 *
 * The routines in this file implement the Real-time Transport Protocol,
 * RTP, as specified in RFC1889 with current updates under discussion in
 * the IETF audio/video transport working group. Portions of the code are
 * derived from the algorithms published in that specification.
 *
 * $Revision: 1.24 $ 
 * $Date: 2002/07/05 22:03:53 $
 * 
 * Copyright (c) 1998-2001 University College London
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, is permitted provided that the following conditions 
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *      This product includes software developed by the Computer Science
 *      Department at University College London.
 * 4. Neither the name of the University nor of the Department may be used
 *    to endorse or promote products derived from this software without
 *    specific prior written permission.
 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 */

#include "config_unix.h"
#include "config_win32.h"
#include "memory.h"
#include "debug.h"
#include "net_udp.h"
#include "crypt_random.h"
#include "rijndael-api-fst.h"
#include "drand48.h"
#include "gettimeofday.h"
#include "qfDES.h"
#include "md5.h"
#include "ntp.h"

#include "rtp.h"
typedef struct {
        uint32_t key;   /* Original allocation number   */
        uint32_t size;  /* Size of allocation requested */
        uint32_t pad;   /* Alignment padding to 8 bytes */
        uint32_t magic; /* Magic number                 */
} chk_header;
	  extern int chk_header_okay(const chk_header *ch);

/*
 * Encryption stuff.
 */
#define MAX_ENCRYPTION_PAD 16

static int rijndael_initialize(struct rtp *session, u_char *hash, int hash_len);

static int rijndael_decrypt(void *ifptr, uint8_t *data,
		    unsigned int *size);
static int rijndael_encrypt(void *ifptr, uint8_t *data,
	    unsigned int *size);

static int des_initialize(struct rtp *session, u_char *hash, int hash_len);
static int des_decrypt(void *ifptr, uint8_t *data,
	       unsigned int *size);
static int des_encrypt(void *ifptr, uint8_t *data,
	       unsigned int *size);

#define MAX_DROPOUT    3000
#define MAX_MISORDER   100
#define MIN_SEQUENTIAL 2

/*
 * Definitions for the RTP/RTCP packets on the wire...
 */

#define RTP_SEQ_MOD        0x10000
#define RTP_MAX_SDES_LEN   256

#define RTP_LOWER_LAYER_OVERHEAD 28	/* IPv4 + UDP */

#define RTCP_SR   200
#define RTCP_RR   201
#define RTCP_SDES 202
#define RTCP_BYE  203
#define RTCP_APP  204

typedef struct {
#ifdef WORDS_BIGENDIAN
	unsigned short  version:2;	/* packet type            */
	unsigned short  p:1;		/* padding flag           */
	unsigned short  count:5;	/* varies by payload type */
	unsigned short  pt:8;		/* payload type           */
#else
	unsigned short  count:5;	/* varies by payload type */
	unsigned short  p:1;		/* padding flag           */
	unsigned short  version:2;	/* packet type            */
	unsigned short  pt:8;		/* payload type           */
#endif
	uint16_t        length;		/* packet length          */
} rtcp_common;

typedef struct {
	rtcp_common   common;	
	union {
		struct {
			rtcp_sr		sr;
			rtcp_rr       	rr[1];		/* variable-length list */
		} sr;
		struct {
			uint32_t        ssrc;		/* source this RTCP packet is coming from */
			rtcp_rr       	rr[1];		/* variable-length list */
		} rr;
		struct rtcp_sdes_t {
			uint32_t	ssrc;
			rtcp_sdes_item 	item[1];	/* list of SDES */
		} sdes;
		struct {
			uint32_t        ssrc[1];	/* list of sources */
							/* can't express the trailing text... */
		} bye;
		struct {
			uint32_t        ssrc;           
			uint8_t         name[4];
			uint8_t         data[1];
		} app;
	} r;
} rtcp_t;

typedef struct _rtcp_rr_wrapper {
	struct _rtcp_rr_wrapper	*next;
	struct _rtcp_rr_wrapper	*prev;
        uint32_t                 reporter_ssrc;
	rtcp_rr			*rr;
	struct timeval		*ts;	/* Arrival time of this RR */
} rtcp_rr_wrapper;

/*
 * The RTP database contains source-specific information needed 
 * to make it all work. 
 */

typedef struct _source {
	struct _source	*next;
	struct _source	*prev;
	uint32_t	 ssrc;
	char		*cname;
	char		*name;
	char		*email;
	char		*phone;
	char		*loc;
	char		*tool;
	char		*note;
	char		*priv;
	rtcp_sr		*sr;
	struct timeval	 last_sr;
	struct timeval	 last_active;
	int		 should_advertise_sdes;	/* TRUE if this source is a CSRC which we need to advertise SDES for */
	int		 sender;
	int		 got_bye;		/* TRUE if we've received an RTCP bye from this source */
	uint32_t	 base_seq;
	uint16_t	 max_seq;
	uint32_t	 bad_seq;
	uint32_t	 cycles;
	int		 received;
	int		 received_prior;
	int		 expected_prior;
	int		 probation;
	uint32_t	 jitter;
	uint32_t	 transit;
	uint32_t	 magic;			/* For debugging... */
} source;

/* The size of the hash table used to hold the source database. */
/* Should be large enough that we're unlikely to get collisions */
/* when sources are added, but not too large that we waste too  */
/* much memory. Sedgewick ("Algorithms", 2nd Ed, Addison-Wesley */
/* 1988) suggests that this should be around 1/10th the number  */
/* of entries that we expect to have in the database and should */
/* be a prime number. Everything continues to work if this is   */
/* too low, it just goes slower... for now we assume around 100 */
/* participants is a sensible limit so we set this to 11.       */   
#define RTP_DB_SIZE	11

/*
 *  Options for an RTP session are stored in the "options" struct.
 */

typedef struct {
	int 	promiscuous_mode;
	int	wait_for_rtcp;
	int	filter_my_packets;
} options;

/*
 * Encryption function types
 */

// moved to rtp.h by nori
/*
 * typedef int (*rtp_encrypt_func)(struct rtp *, unsigned char *data,
 *				unsigned int size);
 *
 * typedef int (*rtp_decrypt_func)(struct rtp *, unsigned char *data,
 *				unsigned int size);
 */
typedef int (*rtcp_send_f)(struct rtp *s, uint8_t *buffer, int buflen);

/*
 * The "struct rtp" defines an RTP session.
 */

struct rtp {
	socket_udp	*rtp_socket;
	socket_udp	*rtcp_socket;
	char		*addr;
	uint16_t	 rx_port;
	uint16_t	 tx_port;
	int		 ttl;
	uint32_t	 my_ssrc;
	int		 last_advertised_csrc;
	source		*db[RTP_DB_SIZE];
        rtcp_rr_wrapper  rr[RTP_DB_SIZE][RTP_DB_SIZE]; 	/* Indexed by [hash(reporter)][hash(reportee)] */
	options		*opt;
	uint8_t		*userdata;
	int		 invalid_rtp_count;
	int		 invalid_rtcp_count;
	int		 bye_count;
	int		 csrc_count;
	int		 ssrc_count;
	int		 ssrc_count_prev;		/* ssrc_count at the time we last recalculated our RTCP interval */
	int		 sender_count;
	int		 initial_rtcp;
	int		 sending_bye;			/* TRUE if we're in the process of sending a BYE packet */
	double		 avg_rtcp_size;
	int		 we_sent;
	double		 rtcp_bw;			/* RTCP bandwidth fraction, in octets per second. */
	struct timeval	 last_update;
	struct timeval	 last_rtp_send_time;
	struct timeval	 last_rtcp_send_time;
	struct timeval	 next_rtcp_send_time;
	double		 rtcp_interval;
	int		 sdes_count_pri;
	int		 sdes_count_sec;
	int		 sdes_count_ter;
	uint16_t	 rtp_seq;
	uint32_t	 rtp_pcount;
	uint32_t	 rtp_bcount;
    char *encryption_algorithm;
 	int encryption_enabled;
 	rtp_encrypt_func encrypt_func;
 	rtp_decrypt_func decrypt_func;
 	int encryption_pad_length;
  int encryption_lenadd;
  void *encrypt_userdata; // added by nori
 	union {
 		struct {
 			keyInstance keyInstEncrypt;
 			keyInstance keyInstDecrypt;
 			cipherInstance cipherInst;
 		} rijndael;
 		struct {
 			char            *encryption_key;
 		} des;
 	} crypto_state;
	rtp_callback	 callback;
  rtcp_send_f rtcp_send;
  rtcp_send_packet_t rtcp_send_packet;
	uint32_t	 magic;				/* For debugging...  */
};

static int filter_event(struct rtp *session, uint32_t ssrc)
{
	int	filter;

	rtp_get_option(session, RTP_OPT_FILTER_MY_PACKETS, &filter);
	return filter && (ssrc == rtp_my_ssrc(session));
}

static double tv_diff(struct timeval curr_time, struct timeval prev_time)
{
    /* Return curr_time - prev_time */
    double	ct, pt;

    ct = (double) curr_time.tv_sec + (((double) curr_time.tv_usec) / 1000000.0);
    pt = (double) prev_time.tv_sec + (((double) prev_time.tv_usec) / 1000000.0);
    return (ct - pt);
}

static void tv_add(struct timeval *ts, double offset)
{
	/* Add offset seconds to ts */
	double offset_sec, offset_usec;

	offset_usec = modf(offset, &offset_sec) * 1000000;
	ts->tv_sec  += (long) offset_sec;
	ts->tv_usec += (long) offset_usec;
	if (ts->tv_usec > 1000000) {
		ts->tv_sec++;
		ts->tv_usec -= 1000000;
	}
}

static int tv_gt(struct timeval a, struct timeval b)
{
	/* Returns (a>b) */
	if (a.tv_sec > b.tv_sec) {
		return TRUE;
	}
	if (a.tv_sec < b.tv_sec) {
		return FALSE;
	}
	ASSERT(a.tv_sec == b.tv_sec);
	return a.tv_usec > b.tv_usec;
}

static uint32_t next_csrc(struct rtp *session)
{
	/* This returns each source marked "should_advertise_sdes" in turn. */
	int	 chain, cc;
	source	*s;

	cc = 0;
	for (chain = 0; chain < RTP_DB_SIZE; chain++) {
		/* Check that the linked lists making up the chains in */
		/* the hash table are correctly linked together...     */
		for (s = session->db[chain]; s != NULL; s = s->next) {
			if (s->should_advertise_sdes) {
				if (cc == session->last_advertised_csrc) {
                                        session->last_advertised_csrc++;
                                        if (session->last_advertised_csrc == session->csrc_count) {
                                                session->last_advertised_csrc = 0;
                                        }
					return s->ssrc;
				} else {
					cc++;
				}
			}
		}
	}
	/* We should never get here... */
	abort();
}

static int ssrc_hash(uint32_t ssrc)
{
	/* Hash from an ssrc to a position in the source database.   */
	/* Assumes that ssrc values are uniformly distributed, which */
	/* should be true but probably isn't (Rosenberg has reported */
	/* that many implementations generate ssrc values which are  */
	/* not uniformly distributed over the space, and the H.323   */
	/* spec requires that they are non-uniformly distributed).   */
	/* This routine is written as a function rather than inline  */
	/* code to allow it to be made smart in future: probably we  */
	/* should run MD5 on the ssrc and derive a hash value from   */
	/* that, to ensure it's more uniformly distributed?          */
	return ssrc % RTP_DB_SIZE;
}

static void insert_rr(struct rtp *session, uint32_t reporter_ssrc, rtcp_rr *rr, struct timeval *ts)
{
        /* Insert the reception report into the receiver report      */
        /* database. This database is a two dimensional table of     */
        /* rr_wrappers indexed by hashes of reporter_ssrc and        */
        /* reportee_src.  The rr_wrappers in the database are        */
        /* sentinels to reduce conditions in list operations.        */
	/* The ts is used to determine when to timeout this rr.      */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
99国产精品视频免费观看| 色成年激情久久综合| 色视频一区二区| 中国色在线观看另类| 欧美成人高清电影在线| 久久久亚洲午夜电影| 日韩有码一区二区三区| 欧美无砖砖区免费| 亚洲最大色网站| 欧美亚洲国产一区在线观看网站| 国产精品污网站| 99精品视频在线观看免费| 国产精品高潮呻吟久久| 成人福利视频在线看| 国产视频一区二区在线| 成人白浆超碰人人人人| 亚洲乱码国产乱码精品精的特点| 91视频你懂的| 亚洲国产你懂的| 精品入口麻豆88视频| 国产成人av电影在线观看| 精品成人在线观看| jizz一区二区| 免费在线一区观看| 久久精品视频一区二区三区| 成人avav在线| 天天影视涩香欲综合网| 久久婷婷国产综合国色天香| 成人a级免费电影| 日韩av一区二区三区四区| 久久综合久久久久88| 91国偷自产一区二区三区成为亚洲经典| 亚洲一区二区免费视频| 国产欧美一区二区在线| 欧美人牲a欧美精品| 成人免费视频app| 蜜臀久久久久久久| 亚洲国产精品一区二区久久| 欧美精品一区二区在线观看| 国产一区二区三区精品视频| 精品精品国产高清一毛片一天堂| 成人av在线播放网站| 蜜臀av性久久久久蜜臀aⅴ四虎| 中文字幕乱码久久午夜不卡 | 国产激情精品久久久第一区二区| 亚洲美女屁股眼交| 国产精品女人毛片| 久久一区二区三区四区| 欧美精品v国产精品v日韩精品 | 这里只有精品99re| 欧美色图天堂网| 色一情一乱一乱一91av| 成人夜色视频网站在线观看| 九九**精品视频免费播放| 奇米精品一区二区三区在线观看| 一区二区三区国产精品| 中文av字幕一区| 亚洲欧美日本在线| 亚洲伦理在线精品| 亚洲激情在线播放| 亚洲福利一区二区| 午夜不卡av在线| 精品中文字幕一区二区| 激情另类小说区图片区视频区| 激情综合亚洲精品| a级高清视频欧美日韩| 色哟哟亚洲精品| 日韩视频一区二区三区在线播放| 日韩一区二区在线观看视频播放| 日韩丝袜美女视频| 国产精品久久久久一区二区三区共| 在线看不卡av| eeuss鲁一区二区三区| 91首页免费视频| 在线播放中文一区| 久久婷婷成人综合色| 亚洲美女少妇撒尿| 精品一区二区久久久| 岛国一区二区三区| 91精品国产欧美一区二区| 国产日本亚洲高清| 视频一区在线视频| 99久久婷婷国产精品综合| 欧美日韩mp4| 最近日韩中文字幕| 日韩电影一二三区| 91一区二区在线| 久久综合国产精品| 青青草精品视频| 欧美在线观看视频一区二区| 久久婷婷国产综合精品青草| 亚洲在线视频网站| 99久久久久免费精品国产| 精品播放一区二区| 日韩精品91亚洲二区在线观看| av一区二区三区黑人| 久久网站最新地址| 久草精品在线观看| 精品久久人人做人人爱| 一区二区高清在线| www.亚洲色图| 国产精品午夜电影| av中文字幕在线不卡| 中文字幕亚洲欧美在线不卡| 国产美女娇喘av呻吟久久| 欧美va亚洲va| 国产一区三区三区| 久久九九99视频| 国产成a人亚洲| 综合电影一区二区三区| 一本久久a久久精品亚洲| 亚洲激情自拍偷拍| 欧美大片拔萝卜| 26uuu成人网一区二区三区| 美日韩一区二区| 精品电影一区二区三区 | 亚洲色图.com| 欧美亚洲综合在线| 亚洲成人免费av| 久久久久久久久久久久电影| 国产91精品在线观看| 亚洲日本在线a| 欧美日韩综合在线| 久久成人18免费观看| 欧美国产精品一区| 欧美亚洲自拍偷拍| 国模少妇一区二区三区| 亚洲图片欧美激情| 欧美体内she精视频| 福利一区福利二区| 亚洲人精品午夜| 精品人伦一区二区色婷婷| 91在线观看高清| 蜜桃精品在线观看| 亚洲欧美日韩久久精品| 日韩一级片网站| 色吧成人激情小说| 丁香激情综合国产| 麻豆国产欧美日韩综合精品二区| 一区二区在线电影| 中文字幕免费不卡| 久久久精品蜜桃| 26uuu精品一区二区| 日韩一区二区高清| 一本大道久久a久久综合| 国产成人av一区二区三区在线| 日韩av一区二区在线影视| 亚洲国产欧美日韩另类综合| 亚洲美女视频一区| 亚洲男同1069视频| 综合自拍亚洲综合图不卡区| 国产精品久久一级| 国产女人aaa级久久久级 | 亚洲欧美日韩中文字幕一区二区三区 | 日韩欧美www| 欧美日韩国产一区二区三区地区| 日本韩国精品在线| 欧美天堂亚洲电影院在线播放| 色悠悠亚洲一区二区| 色天使色偷偷av一区二区| 色女孩综合影院| 欧美日韩国产小视频在线观看| 欧美私人免费视频| 欧美一区二区三区免费在线看 | 69堂国产成人免费视频| 欧美日韩国产综合视频在线观看| 精品视频一区 二区 三区| 欧美日韩1234| 国产欧美一区二区精品仙草咪| 国产欧美视频一区二区| 日韩美女久久久| 日产国产欧美视频一区精品| 美日韩一级片在线观看| 成人高清伦理免费影院在线观看| 欧美四级电影在线观看| 精品sm在线观看| 亚洲精品国产成人久久av盗摄 | 国产精品区一区二区三区| 一区二区在线观看免费视频播放| 亚洲国产精品久久人人爱| 青青草视频一区| 在线一区二区视频| 国产亚洲一二三区| 日日摸夜夜添夜夜添国产精品| 国产成人亚洲综合a∨婷婷图片 | 国产激情一区二区三区| 欧美精品丝袜中出| 一区二区三国产精华液| 国产iv一区二区三区| 欧美不卡123| 毛片av一区二区三区| 美女视频一区二区三区| 99久久伊人网影院| 久久一区二区三区四区| 日本不卡高清视频| 欧美猛男gaygay网站| 亚洲欧美成aⅴ人在线观看| 不卡电影一区二区三区| 国产精品午夜电影| 91在线视频免费91|