rtcp多媒体控制协议应用

rtcp package send/recv demo

main.c

#include <stdio.h>
#include <rtp.h>
#include <rtcp.h>
#include <netinet/in.h>
#include <netdb.h>
#include <math.h>
#include <event.h>
#include <syn.h>
#include <payload.h>
#include <sample.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <util.h>
#include <frame.h>
#include <sys/ioctl.h>
#include <sys/stropts.h>
#include "main.h"


#ifdef LINUX
#include <linux/soundcard.h>
#endif /* LINUX */

#define MAX_SOURCES 32

int main(int argc, char **argv) {

  char            buf[4000];
  unsigned short    *samp16 = (unsigned short *) buf;
  bool            found;
  int            audio, port, rv, payloadtype;
  int            count, i, encoding = 0, one = 1;
  ssrc_t        ssrc = 0, sources[MAX_SOURCES];
  struct in_addr    addr;
  struct session    *psn;
  struct synsession    *pssn;
  struct timespec    time;
  struct sampparam    parameters;
  struct encoding    enc;
  mediatime_t        ts;
  struct sampreadparam  sreadparam;


  int            leeway;

  /*
   * Check for correct number of arguments.
   */
  if (argc != 3) {
    fprintf(stderr, "Usage: %s <addr> <port>\n", argv[0]);
    exit(0);
  }

  addr.s_addr = inet_addr(argv[1]);
  port = atoi(argv[2]);

  printf("Session: %s/%d\n", inet_ntoa(addr), port);

  /*
   * Open a synchronization layer session.
   * Use 2k buffers for RTP packets, 64 buffers in pool.
   */
  pssn = synopen(addr, port, 2048, 64);
  if (pssn == NULL) {
    fprintf(stderr, "synopen() returned NULL.\n");
    exit(1);
  }

  /*
   * Get a handle to the RTP layer session.
   */
  synctl(pssn, SYN_CTL_GETRTPSESSION, (char *) &psn, 0);

  /*
   * Look up the encoding represented by payloadtype.
   * Determine if it's a supported encoding.
   */
  enc = getencoding(payloadtype);
  printf("enc.en_name: %s\n", enc.en_name);

  ssrc = 0;

  printf("Found sender: SSRC = 0x%x Encoding = %s\n", ssrc, enc.en_name);

  /*
   * rtcp package send/recv thread.
   */
  rtpctl(psn, RTP_CTL_RTCPCYCLETHREAD, (char *) &payloadtype, 0, ssrc);

  rtpctl(psn, RTP_CTL_RTCPRECVTHREAD, (char *) &one, 0, ssrc);


}

 

运行

 

code::blocks工程 

https://files.cnblogs.com/files/dong1/rtprtcp_linux_demo.tar.gz

 

转载于:https://www.cnblogs.com/dong1/p/10410975.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值