通过RTSP RTCP RTP加载H264数据流,详细内容见博客:https://blog.csdn.net/li_wen01/article/details/102131820
代码片段和文件信息
/************************************************************
*Copyright (C)lcb0281at163.com lcb0281atgmail.com
*FileName: common.c
*BlogAddr: https://blog.csdn.net/li_wen01
*Description:
*Date: 2019-06-22
*Author: Caibiao Lee
*Version: V1.0
*Others:
*History:
***********************************************************/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include “common.h“
static const char base64digits[] =
“ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/“;
#define BAD -1
#define DECODE64(c) (isascii(c) ? base64val[c] : BAD)
static const signed char base64val[] =
{
BADBADBADBAD BADBADBADBAD BADBADBADBAD BADBADBADBAD
BADBADBADBAD BADBADBADBAD BADBADBADBAD BADBADBADBAD
BADBADBADBAD BADBADBADBAD BADBADBAD 62 BADBADBAD 63
52 53 54 55 56 57 58 59 60 61BADBAD BADBADBADBAD
BAD 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
15 16 17 18 19 20 21 22 23 24 25BAD BADBADBADBAD
BAD 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48 49 50 51BAD BADBADBADBAD
};
void COM_base64_bits_to_64(unsigned char *out const unsigned char *in int inlen)
{
for (; inlen >= 3; inlen -= 3)
{
*out++ = base64digits[in[0] >> 2];
*out++ = base64digits[((in[0] << 4) & 0x30) | (in[1] >> 4)];
*out++ = base64digits[((in[1] << 2) & 0x3c) | (in[2] >> 6)];
*out++ = base64digits[in[2] & 0x3f];
in += 3;
}
if (inlen > 0)
{
unsigned char fragment;
*out++ = base64digits[in[0] >> 2];
fragment = (in[0] << 4) & 0x30;
if (inlen > 1)
fragment |= in[1] >> 4;
*out++ = base64digits[fragment];
*out++ = (inlen < 2) ? ‘=‘ : base64digits[(in[1] << 2) & 0x3c];
*out++ = ‘=‘;
}
*out = ‘ ‘;
}
int COM_base64_64_to_bits(char *out const char *in)
{
int len = 0;
register unsigned char digit1 digit2 digit3 digit4;
if (in[0] == ‘+‘ && in[1] == ‘ ‘)
in += 2;
if (*in == ‘
‘)
return(0);
do {
digit1 = in[0];
if (DECODE64(digit1) == BAD)
return(-1);
digit2 = in[1];
if (DECODE64(digit2) == BAD)
return(-1);
digit3 = in[2];
if (digit3 != ‘=‘ && DECODE64(digit3) == BAD)
return(-1);
digit4 = in[3];
if (digit4 != ‘=‘ && DECODE64(digit4) == BAD)
return(-1);
in += 4;
*out++ = (DECODE64(digit1) << 2) | (DECODE64(digit2) >> 4);
++len;
if (digit3 != ‘=‘)
{
*out++ = ((DECODE64(digit2) << 4) & 0xf0) | (DECODE64(digi
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)