码迷,mamicode.com
首页 > 其他好文 > 详细

rtcp多媒体控制协议应用

时间:2019-02-21 11:09:57      阅读:203      评论:0      收藏:0      [点我收藏+]

标签:struct   net   return   exit   \n   atoi   span   odi   hand   

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);


}

 

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

 

rtcp多媒体控制协议应用

标签:struct   net   return   exit   \n   atoi   span   odi   hand   

原文地址:https://www.cnblogs.com/dong1/p/10410975.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!