环境
$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.1 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.1 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
依赖libread_h264
src/rtp_stream_encoder.h
$ cat src/rtp_stream_encoder.h
#if ! defined(__RTP_STREAM_ENCODER_H__)
#define __RTP_STREAM_ENCODER_H__
#include <stdio.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdbool.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#define rtp_stream_encoder_print(fmt,...) do{printf(fmt,##__VA_ARGS__);char *pos = __FILE__; printf(" | %s,%d", pos, __LINE__);}while(0);
struct rtp_stream_encoder_context_t {
size_t rtp_max_payload_size;
uint8_t *udp_payload;
size_t rtp_payload_size;
bool aggregation;
uint8_t payload_type;//96:h264
uint16_t seq;
uint32_t timestamp;
uint32_t ssrc;
/* udp socket info */
int sockfd;
struct sockaddr_in dest_addr;
};
#if defined(__RTP_STREAM_ENCODER_CMDLINE_PARM__)
struct rtp_stream_encoder_cmdline_parm_t {
char *dest_ip_addr;
uint16_t dest_ip_port;
};
#endif /* #if defined(__RTP_STREAM_CODER_CMDLINE_PARM__) */
int rtp_stream_encoder_context_init(struct rtp_stream_encoder_context_t *ctx);
int rtp_stream_encoder_send_data(struct rtp_stream_encoder_context_t *ctx, int marker);
int rtp_stream_encoder_send_nalu(struct rtp_stream_encoder_context_t *ctx, char *nalu_buffer, size_t nalu_buffer_size, bool last_nalu);
#endif /* #if ! defined(__RTP_STREAM_ENCODER_H__)*/
src/rtp_stream_encoder.c
$ cat src/rtp_stream_encoder.c
#include "rtp_stream_encoder.h"
#inclu