webrtc audio

This commit is contained in:
Maxim Devaev
2022-05-29 01:29:01 +03:00
parent 3d4e9fbb1a
commit d4a9862a18
15 changed files with 1072 additions and 310 deletions

View File

@@ -26,44 +26,33 @@
#pragma once
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <assert.h>
#include <stdbool.h>
#include <sys/types.h>
#include <linux/videodev2.h>
#include <pthread.h>
#include "tools.h"
#include "threading.h"
#include "frame.h"
#include "base64.h"
// https://stackoverflow.com/questions/47635545/why-webrtc-chose-rtp-max-packet-size-to-1200-bytes
#define RTP_DATAGRAM_SIZE 1200
#define RTP_DATAGRAM_SIZE 1200
#define RTP_HEADER_SIZE 12
typedef struct {
uint32_t ssrc;
uint16_t seq;
unsigned payload;
bool video;
uint32_t ssrc;
uint8_t datagram[RTP_DATAGRAM_SIZE];
frame_s *sps; // Actually not a frame, just a bytes storage
frame_s *pps;
pthread_mutex_t mutex;
uint16_t seq;
uint8_t datagram[RTP_DATAGRAM_SIZE];
size_t used;
} rtp_s;
typedef void (*rtp_callback_f)(const uint8_t *datagram, size_t size);
typedef void (*rtp_callback_f)(const rtp_s *rtp);
rtp_s *rtp_init(void);
rtp_s *rtp_init(unsigned payload, bool video);
void rtp_destroy(rtp_s *rtp);
char *rtp_make_sdp(rtp_s *rtp);
void rtp_wrap_h264(rtp_s *rtp, const frame_s *frame, rtp_callback_f callback);
void rtp_write_header(rtp_s *rtp, uint32_t pts, bool marked);