Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bb875cf

Browse files
committed
EasyStreamClient based on ffmpeg
0 parents  commit bb875cf

52 files changed

Lines changed: 2271 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
#ignore thumbnails created by windows
3+
Thumbs.db
4+
#Ignore files build by Visual Studio
5+
*.obj
6+
*.exe
7+
*.pdb
8+
*.user
9+
*.aps
10+
*.pch
11+
*.vspscc
12+
*_i.c
13+
*_p.c
14+
*.ncb
15+
*.suo
16+
*.tlb
17+
*.tlh
18+
*.bak
19+
*.cache
20+
*.ilk
21+
*.log
22+
[Dd]ebug*/
23+
*.lib
24+
*.sbr
25+
obj/
26+
[Rr]elease*/
27+
_ReSharper*/
28+
[Tt]est[Rr]esult*
29+
*.sdf
30+
*.sdp
31+
*.o
32+
*.exp
33+
[Ll]ogs*/
34+
[Pp]rivate*/
35+
ipch/
36+
*.opensdf
37+
/build/
38+
*.pcmu
39+
*.pcma
40+
*.aac
41+
*.h264
42+
*.h265
43+
*.mpeg4

Buildit

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/sh
2+
3+
usage()
4+
{
5+
echo "0. clean up ./Buildit clean"
6+
echo "1. build 32bit program ./Buildit i386 [target in i386]"
7+
echo "2. build 64bit program ./Buildit x64 [target in x64]"
8+
}
9+
10+
if [ "$*" = "clean" ] ; then
11+
make -f nbproject/Makefile-i386.mk QMAKE= SUBPROJECTS= .clean-conf
12+
make -f nbproject/Makefile-x64.mk QMAKE= SUBPROJECTS= .clean-conf
13+
elif [ "$*" = "x64" ] ; then
14+
make -f nbproject/Makefile-x64.mk QMAKE= SUBPROJECTS= .build-conf
15+
elif [ "$*" = "i386" ] ; then
16+
make -f nbproject/Makefile-i386.mk QMAKE= SUBPROJECTS= .build-conf
17+
elif [ "$*" = "hisiv100" ] ; then
18+
make -f nbproject/Makefile-hisiv100.mk QMAKE= SUBPROJECTS= .build-conf
19+
else
20+
usage;
21+
fi
22+

Include/EasyStreamClientAPI.h

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
Copyright (c) 2013-2015 EasyDarwin.ORG. All rights reserved.
3+
Github: https://github.com/EasyDarwin
4+
WEChat: EasyDarwin
5+
Website: http://www.easydarwin.org
6+
*/
7+
#ifndef _EASY_STREAM_CLIENT_API_H
8+
#define _EASY_STREAM_CLIENT_API_H
9+
10+
#include "EasyTypes.h"
11+
12+
/* 推送事件类型定义 */
13+
typedef enum __EASY_STREAM_CLIENT_STATE_T
14+
{
15+
EASY_STREAM_CLIENT_STATE_CONNECTING = 1, /* 连接中 */
16+
EASY_STREAM_CLIENT_STATE_CONNECTED, /* 连接成功 */
17+
EASY_STREAM_CLIENT_STATE_CONNECT_FAILED, /* 连接失败 */
18+
EASY_STREAM_CLIENT_STATE_CONNECT_ABORT, /* 连接中断 */
19+
EASY_STREAM_CLIENT_STATE_PUSHING, /* 推流中 */
20+
EASY_STREAM_CLIENT_STATE_DISCONNECTED, /* 断开连接 */
21+
EASY_STREAM_CLIENT_STATE_EXIT, /* 退出连接 */
22+
EASY_STREAM_CLIENT_STATE_ERROR
23+
} EASY_STREAM_CLIENT_STATE_T;
24+
25+
/*
26+
_channelPtr: 通道对应对象,暂时不用
27+
_frameType: EASY_SDK_VIDEO_FRAME_FLAG/EASY_SDK_AUDIO_FRAME_FLAG/EASY_SDK_EVENT_FRAME_FLAG/...
28+
_pBuf: 回调的数据部分,具体用法看Demo
29+
_frameInfo: 帧结构数据
30+
*/
31+
typedef int (Easy_APICALL *EasyStreamClientCallBack)(void *_channelPtr, int _frameType, void *pBuf, EASY_FRAME_INFO* _frameInfo);
32+
typedef int (Easy_APICALL *EasyDownloadCallBack)(void *userptr, const char* path);
33+
34+
#ifdef __cplusplus
35+
extern "C"
36+
{
37+
#endif
38+
/* 创建EasyStreamClient句柄 返回0表示成功,返回非0表示失败 ; loglevel : 0 - quiet 1 - debug*/
39+
Easy_API int Easy_APICALL EasyStreamClient_Init(Easy_Handle *handle, int loglevel);
40+
41+
/* 释放EasyStreamClient 参数为EasyStreamClient句柄 */
42+
Easy_API int Easy_APICALL EasyStreamClient_Deinit(Easy_Handle handle);
43+
44+
/* 设置背景音 flag: 1 开启 0:关闭 url:背景音路径包含文件名 ret: 0:成功 < 0:配置失败 1:不支持背景音功能*/
45+
Easy_API int Easy_APICALL EasyStreamClient_SetBackAudio(Easy_Handle handle, int flag, char* url);
46+
47+
/* 设置数据回调 */
48+
Easy_API int Easy_APICALL EasyStreamClient_SetCallback(Easy_Handle handle, EasyStreamClientCallBack callback);
49+
50+
/* 设置叠加图片 */
51+
Easy_API int Easy_APICALL EasyStreamClient_SetOverlayImage(Easy_Handle handle, int left, int top, int scaleWidth, int scaleHeight, const char* imageFilePath);
52+
53+
/* 打开网络流 */
54+
Easy_API int Easy_APICALL EasyStreamClient_OpenStream(Easy_Handle handle, char *url, EASY_RTP_CONNECT_TYPE connType, void *userPtr, int reconn, int timeout, int useExtraData);
55+
56+
/* 获取输入流的context */
57+
Easy_API int Easy_APICALL EasyStreamClient_GetStreamContext(Easy_Handle handle, void** avFormatContext, void** avCodecContext);
58+
59+
/* 获取快照 */
60+
Easy_API int Easy_APICALL EasyStreamClient_GetSnap(Easy_Handle handle);
61+
62+
63+
Easy_API int Easy_APICALL EasyStreamClient_ConvertFrame2Image(const unsigned int videoCodec, const unsigned char* keyFrameData, int keyFrameDataSize, unsigned char** outImage, int* outImageSize);
64+
Easy_API int Easy_APICALL EasyStreamClient_ReleaseImageData(unsigned char** imageData);
65+
66+
67+
68+
/* 设置音频是否启用 */
69+
Easy_API int Easy_APICALL EasyStreamClient_SetAudioEnable(Easy_Handle handle, int enable);
70+
71+
Easy_API int Easy_APICALL EasyStreamClient_SetAudioOutFormat(Easy_Handle handle, unsigned int audioFormat, int samplerate, int channels);
72+
73+
/* 获取音频是否启用 */
74+
Easy_API int Easy_APICALL EasyStreamClient_GetAudioEnable(Easy_Handle handle);
75+
76+
/*录像下载*/
77+
Easy_API int Easy_APICALL EasyStreamClient_SetDownloadCallback(EasyDownloadCallBack callback);
78+
Easy_API int Easy_APICALL EasyStreamClient_DownloadOneRecord(const char* rootPath, const char* streamName, const char* startTime, void* userPtr);
79+
Easy_API int Easy_APICALL EasyStreamClient_DownloadPeriod(const char* rootPath, const char* streamName, const char* startTime, const char* endTime, void* userPtr);
80+
#ifdef __cplusplus
81+
};
82+
#endif
83+
84+
#endif

Include/EasyTypes.h

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
/*
2+
Copyright (c) 2012-2019 TSINGSEE.COM. All rights reserved.
3+
Github: https://github.com/tsingsee
4+
WEChat: tsingsee
5+
Website: http://www.tsingsee.com
6+
*/
7+
#ifndef _Easy_Types_H
8+
#define _Easy_Types_H
9+
10+
#ifdef _WIN32
11+
#define Easy_API __declspec(dllexport)
12+
#define Easy_APICALL __stdcall
13+
#define WIN32_LEAN_AND_MEAN
14+
#else
15+
#define Easy_API __attribute__ ((visibility("default")))
16+
#define Easy_APICALL __attribute__ ((visibility("default")))
17+
#endif
18+
19+
#define Easy_Handle void*
20+
21+
typedef int Easy_I32;
22+
typedef unsigned char Easy_U8;
23+
typedef unsigned char Easy_UChar;
24+
typedef unsigned short Easy_U16;
25+
typedef unsigned int Easy_U32;
26+
typedef unsigned char Easy_Bool;
27+
28+
enum
29+
{
30+
Easy_NoErr = 0,
31+
Easy_RequestFailed = -1,
32+
Easy_Unimplemented = -2,
33+
Easy_RequestArrived = -3,
34+
Easy_OutOfState = -4,
35+
Easy_NotAModule = -5,
36+
Easy_WrongVersion = -6,
37+
Easy_IllegalService = -7,
38+
Easy_BadIndex = -8,
39+
Easy_ValueNotFound = -9,
40+
Easy_BadArgument = -10,
41+
Easy_ReadOnly = -11,
42+
Easy_NotPreemptiveSafe = -12,
43+
Easy_NotEnoughSpace = -13,
44+
Easy_WouldBlock = -14,
45+
Easy_NotConnected = -15,
46+
Easy_FileNotFound = -16,
47+
Easy_NoMoreData = -17,
48+
Easy_AttrDoesntExist = -18,
49+
Easy_AttrNameExists = -19,
50+
Easy_InstanceAttrsNotAllowed = -20,
51+
Easy_InvalidSocket = -21,
52+
Easy_MallocError = -22,
53+
Easy_ConnectError = -23,
54+
Easy_SendError = -24
55+
};
56+
typedef int Easy_Error;
57+
58+
typedef enum __EASY_ACTIVATE_ERR_CODE_ENUM
59+
{
60+
EASY_ACTIVATE_INVALID_KEY = -1, /* 无效Key */
61+
EASY_ACTIVATE_TIME_ERR = -2, /* 时间错误 */
62+
EASY_ACTIVATE_PROCESS_NAME_LEN_ERR = -3, /* 进程名称长度不匹配 */
63+
EASY_ACTIVATE_PROCESS_NAME_ERR = -4, /* 进程名称不匹配 */
64+
EASY_ACTIVATE_VALIDITY_PERIOD_ERR= -5, /* 有效期校验不一致 */
65+
EASY_ACTIVATE_PLATFORM_ERR = -6, /* 平台不匹配 */
66+
EASY_ACTIVATE_COMPANY_ID_LEN_ERR= -7, /* 授权使用商不匹配 */
67+
EASY_ACTIVATE_SUCCESS = 9999, /* 激活成功 */
68+
69+
}EASY_ACTIVATE_ERR_CODE_ENUM;
70+
71+
/* 视频编码 */
72+
#define EASY_SDK_VIDEO_CODEC_H264 0x1C /* H264 */
73+
#define EASY_SDK_VIDEO_CODEC_H265 0xAE /* H265 */
74+
#define EASY_SDK_VIDEO_CODEC_MJPEG 0x08 /* MJPEG */
75+
#define EASY_SDK_VIDEO_CODEC_MPEG4 0x0D /* MPEG4 */
76+
77+
/* 音频编码 */
78+
#define EASY_SDK_AUDIO_CODEC_AAC 0x15002 /* AAC */
79+
#define EASY_SDK_AUDIO_CODEC_G711U 0x10006 /* G711 ulaw*/
80+
#define EASY_SDK_AUDIO_CODEC_G711A 0x10007 /* G711 alaw*/
81+
#define EASY_SDK_AUDIO_CODEC_G726 0x1100B /* G726 */
82+
83+
#define EASY_SDK_EVENT_CODEC_ERROR 0x63657272 /* ERROR */
84+
#define EASY_SDK_EVENT_CODEC_EXIT 0x65786974 /* EXIT */
85+
86+
/* 音视频帧标识 */
87+
#define EASY_SDK_VIDEO_FRAME_FLAG 0x00000001 /* 视频帧标志 */
88+
#define EASY_SDK_AUDIO_FRAME_FLAG 0x00000002 /* 音频帧标志 */
89+
#define EASY_SDK_EVENT_FRAME_FLAG 0x00000004 /* 事件帧标志 */
90+
#define EASY_SDK_RTP_FRAME_FLAG 0x00000008 /* RTP帧标志 */
91+
#define EASY_SDK_SDP_FRAME_FLAG 0x00000010 /* SDP帧标志 */
92+
#define EASY_SDK_MEDIA_INFO_FLAG 0x00000020 /* 媒体类型标志*/
93+
#define EASY_SDK_SNAP_FRAME_FLAG 0x00000040 /* 图片标志*/
94+
95+
/* 视频关键字标识 */
96+
#define EASY_SDK_VIDEO_FRAME_I 0x01 /* I帧 */
97+
#define EASY_SDK_VIDEO_FRAME_P 0x02 /* P帧 */
98+
#define EASY_SDK_VIDEO_FRAME_B 0x03 /* B帧 */
99+
#define EASY_SDK_VIDEO_FRAME_J 0x04 /* JPEG */
100+
101+
/* 连接类型 */
102+
typedef enum __EASY_RTP_CONNECT_TYPE
103+
{
104+
EASY_RTP_OVER_TCP = 0x01, /* RTP Over TCP */
105+
EASY_RTP_OVER_UDP, /* RTP Over UDP */
106+
EASY_RTP_OVER_MULTICAST /* RTP Over MULTICAST */
107+
}EASY_RTP_CONNECT_TYPE;
108+
109+
typedef struct __EASY_AV_Frame
110+
{
111+
Easy_U32 u32AVFrameFlag; /* 帧标志 视频 or 音频 */
112+
Easy_U32 u32AVFrameLen; /* 帧的长度 */
113+
Easy_U32 u32VFrameType; /* 视频的类型,I帧或P帧 */
114+
Easy_U8 *pBuffer; /* 数据 */
115+
Easy_U32 u32TimestampSec; /* 时间戳(秒)*/
116+
Easy_U32 u32TimestampUsec; /* 时间戳(微秒) */
117+
Easy_U32 u32PTS;
118+
} EASY_AV_Frame;
119+
120+
/* 媒体信息 */
121+
typedef struct __EASY_MEDIA_INFO_T
122+
{
123+
Easy_U32 u32VideoCodec; /* 视频编码类型 */
124+
Easy_U32 u32VideoFps; /* 视频帧率 */
125+
126+
Easy_U32 u32AudioCodec; /* 音频编码类型 */
127+
Easy_U32 u32AudioSamplerate; /* 音频采样率 */
128+
Easy_U32 u32AudioChannel; /* 音频通道数 */
129+
Easy_U32 u32AudioBitsPerSample; /* 音频采样精度 */
130+
131+
Easy_U32 u32VpsLength;
132+
Easy_U32 u32SpsLength;
133+
Easy_U32 u32PpsLength;
134+
Easy_U32 u32SeiLength;
135+
Easy_U8 u8Vps[256];
136+
Easy_U8 u8Sps[256];
137+
Easy_U8 u8Pps[128];
138+
Easy_U8 u8Sei[128];
139+
}EASY_MEDIA_INFO_T;
140+
141+
/* 帧信息 */
142+
typedef struct
143+
{
144+
unsigned int codec; /* 音视频格式 */
145+
146+
unsigned int type; /* 视频帧类型 */
147+
unsigned char fps; /* 视频帧率 */
148+
unsigned short width; /* 视频宽 */
149+
unsigned short height; /* 视频高 */
150+
151+
unsigned int reserved1; /* 保留参数1 */
152+
unsigned int reserved2; /* 保留参数2 */
153+
unsigned int reserved3; /* 保留参数3 */
154+
155+
unsigned int sample_rate; /* 音频采样率 */
156+
unsigned int channels; /* 音频声道数 */
157+
unsigned int bits_per_sample; /* 音频采样精度 */
158+
159+
unsigned int length; /* 音视频帧大小 */
160+
unsigned int timestamp_usec; /* 时间戳,微妙 */
161+
unsigned int timestamp_sec; /* 时间戳 秒 */
162+
unsigned int pts;
163+
164+
float bitrate; /* 比特率 */
165+
float losspacket; /* 丢包率 */
166+
}EASY_FRAME_INFO;
167+
168+
#endif

Lib/linux_x64/libavcodec.a

15.4 MB
Binary file not shown.

Lib/linux_x64/libavdevice.a

10.9 KB
Binary file not shown.

Lib/linux_x64/libavfilter.a

5.83 MB
Binary file not shown.

Lib/linux_x64/libavformat.a

4.95 MB
Binary file not shown.

Lib/linux_x64/libavutil.a

960 KB
Binary file not shown.

Lib/linux_x64/libcrypto.a

4.22 MB
Binary file not shown.

0 commit comments

Comments
 (0)