rtcp多媒体控制协议应用

Posted dong1

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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>
", argv[0]);
    exit(0);
  }

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

  printf("Session: %s/%d
", 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.
");
    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
", enc.en_name);

  ssrc = 0;

  printf("Found sender: SSRC = 0x%x Encoding = %s
", 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);


}

 

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

 

以上是关于rtcp多媒体控制协议应用的主要内容,如果未能解决你的问题,请参考以下文章

RTP,RTCP,RTSP等网络协议有何用途和区别

RTP与RTCP协议介绍(转载)

音视频同步!RTCP 协议解析及代码实现

超越RFC3550 - RTP/RTCP协议族分析

流媒体专家rtp和rtcp协议详解I

WebRTC[54] - WebRTC之RTCP详解