g.711音频文件用rtp发送解决办法
g.711音频文件用rtp发送
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <netdb.h>
#include <time.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h> //close()
#define DEST_PORT 8888
#define DEST_IP "192.168.1.18"
typedef struct
{
/**//* byte 0 */
unsigned char csrc_len:4; /**//* expect 0 */
unsigned char extension:1; /**//* expect 1, see RTP_OP below */
unsigned char padding:1; /**//* expect 0 */
unsigned char version:2; /**//* expect 2 */
/**//* byte 1 */
unsigned char payload:7; /**//* RTP_PAYLOAD_RTSP */
unsigned char marker:1; /**//* expect 1 */
/**//* bytes 2, 3 */
unsigned short seq_no;
/**//* bytes 4-7 */
unsigned long timestamp;
/**//* bytes 8-11 */
unsigned long ssrc; /**//* stream number is used here. */
} RTP_FIXED_HEADER;
int main(int argc, char* argv[])
{
FILE *file_g711 = NULL;
int ret;
int M_bit;
M_bit = 1;
char sendbuf[1500];
memset(sendbuf,0,1500);
unsigned short seq_num = 0;
RTP_FIXED_HEADER *rtp_hdr;
int socket1;
struct sockaddr_in server;
int len = sizeof(server);
float framerate = 25;
unsigned int timestamp_increse = 0,ts_current = 0;
timestamp_increse = 160;
server.sin_family = AF_INET;
server.sin_port = htons(DEST_PORT);
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <netdb.h>
#include <time.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h> //close()
#define DEST_PORT 8888
#define DEST_IP "192.168.1.18"
typedef struct
{
/**//* byte 0 */
unsigned char csrc_len:4; /**//* expect 0 */
unsigned char extension:1; /**//* expect 1, see RTP_OP below */
unsigned char padding:1; /**//* expect 0 */
unsigned char version:2; /**//* expect 2 */
/**//* byte 1 */
unsigned char payload:7; /**//* RTP_PAYLOAD_RTSP */
unsigned char marker:1; /**//* expect 1 */
/**//* bytes 2, 3 */
unsigned short seq_no;
/**//* bytes 4-7 */
unsigned long timestamp;
/**//* bytes 8-11 */
unsigned long ssrc; /**//* stream number is used here. */
} RTP_FIXED_HEADER;
int main(int argc, char* argv[])
{
FILE *file_g711 = NULL;
int ret;
int M_bit;
M_bit = 1;
char sendbuf[1500];
memset(sendbuf,0,1500);
unsigned short seq_num = 0;
RTP_FIXED_HEADER *rtp_hdr;
int socket1;
struct sockaddr_in server;
int len = sizeof(server);
float framerate = 25;
unsigned int timestamp_increse = 0,ts_current = 0;
timestamp_increse = 160;
server.sin_family = AF_INET;
server.sin_port = htons(DEST_PORT);