//Download by http://www.NewXing.com
/*
* FILE: cclrtp.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.132 $
* $Date: 2001/04/26 22:58:24 $
*
* 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 "cclrtp.h"
/*
* Encryption stuff.
*/
#define MAX_ENCRYPTION_PAD 16
static int rijndael_initialize(struct rtp *session, u_char *hash, int hash_len);
static int rijndael_decrypt(struct rtp *session, unsigned char *data,
unsigned int size, unsigned char *initVec);
static int rijndael_encrypt(struct rtp *session, unsigned char *data,
unsigned int size, unsigned char *initVec);
static int des_initialize(struct rtp *session, u_char *hash, int hash_len);
static int des_decrypt(struct rtp *session, unsigned char *data,
unsigned int size, unsigned char *initVec);
static int des_encrypt(struct rtp *session, unsigned char *data,
unsigned int size, unsigned char *initVec);
#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
*/
typedef int (*rtp_encrypt_func)(struct rtp *, unsigned char *data,
unsigned int size, unsigned char *initvec);
typedef int (*rtp_decrypt_func)(struct rtp *, unsigned char *data,
unsigned int size, unsigned char *initvec);
/*
* 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;
没有合适的资源?快使用搜索试试~ 我知道了~
rtp rtcp流媒体传输示例
共68个文件
h:33个
c:26个
in:2个
1星 需积分: 23 78 下载量 147 浏览量
2015-05-19
12:10:09
上传
评论
收藏 184KB RAR 举报
温馨提示
实现rtp rtcp的流媒体传输 示例 c++源码
资源推荐
资源详情
资源评论
收起资源包目录
rtpdemo.rar (68个子文件)
rtpdemo
rtpdemo.dsp 8KB
Debug
rtpdemo.ncb 137KB
rtpdemo.plg 2KB
rtp
btree.c 10KB
hmac.h 2KB
ntp.c 822B
base64.h 2KB
net_udp.h 3KB
gettimeofday.c 382B
inet_ntop.c 5KB
boxes-fst.dat 75KB
mbus_parser.h 3KB
addrsize.h 2KB
mbus_parser.c 6KB
asarray.h 1KB
gettimeofday.h 125B
drand48.h 92B
cclrtp.c 104KB
sockstorage.h 2KB
getaddrinfo.c 26KB
md5.c 10KB
README.qfdes 6KB
rijndael-alg-fst.c 14KB
vsnprintf.c 2KB
acconfig.h 936B
rijndael-alg-fst.h 1KB
mbus_addr.c 3KB
base64.c 6KB
util.c 9KB
asarray.c 4KB
hmac.c 6KB
btree.h 2KB
rijndael-api-fst.h 4KB
cdecl_ext.h 2KB
crypt_random.h 2KB
mbus_config.h 3KB
bittypes.h 2KB
md5.h 1KB
config.h.in 2KB
ntp.h 810B
memory.h 3KB
mbus.c 30KB
qfDES.h 3KB
qfDES.c 29KB
cclrtp.h 9KB
util.h 3KB
crypt_random.c 3KB
memory.c 18KB
rijndael-api-fst.c 14KB
vsnprintf.h 311B
cclversion.h 69B
mbus_config.c 24KB
inet_pton.c 5KB
mbus.h 3KB
mbus_addr.h 2KB
rtpdemo.c 5KB
Makefile.in 1KB
addrinfo.h 5KB
config_unix.h 5KB
inet_ntop.h 253B
debug.h 2KB
net_udp.c 24KB
drand48.c 270B
inet_pton.h 234B
config_win32.h 5KB
debug.c 6KB
rtpdemo.dsw 537B
rtpdemo.opt 50KB
共 68 条
- 1
资源评论
- tanguixing2017-12-09艹,第一次下载失败就要逼着来评论。不评论没法下载,这是什么逻辑?暂时不知道,要看完后才知道。
王侯将相宁有种子乎
- 粉丝: 0
- 资源: 15
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功