-
Notifications
You must be signed in to change notification settings - Fork 2
/
mk_media_service.h
105 lines (90 loc) · 3.19 KB
/
mk_media_service.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
* StreamRtspService.h
*
* Created on: 2016-5-12
* Author:
*/
#ifndef _MK_MEDIA_SERVICE_INCLUDE_H__
#define _MK_MEDIA_SERVICE_INCLUDE_H__
#include <map>
#include <list>
#include "as.h"
#include "mk_rtsp_connection.h"
#include "mk_rtsp_udp_handle.h"
#include "mk_rtmp_connection.h"
#include "mk_media_common.h"
#define RTP_RECV_BUF_SIZE 1500
#define RTP_RECV_BUF_COUNT (100*RTSP_CONNECTION_DEFAULT)
#define FRAME_RECV_BUF_SIZE (1024*1024)
#define FRAME_RECV_BUF_COUNT (2*RTSP_CONNECTION_DEFAULT)
#define RTP_RTCP_START_PORT 10000
#define RTP_RTCP_PORT_COUNT (4*RTSP_CONNECTION_DEFAULT)
#define RTSP_URL_PREFIX "rtsp://"
#define RTMP_URL_PREFIX "rtmp://"
class mk_conn_log:public as_conn_mgr_log
{
public:
mk_conn_log(){};
virtual ~mk_conn_log(){};
virtual void writeLog(int32_t lType, int32_t llevel,const char *szLogDetail, const int32_t lLogLen)
{
uint32_t nLevel = AS_LOG_INFO;
if(CONN_EMERGENCY == llevel) {
nLevel = AS_LOG_EMERGENCY;
}
else if(CONN_ERROR == llevel) {
nLevel = AS_LOG_ERROR;
}
else if(CONN_WARNING == llevel) {
nLevel = AS_LOG_WARNING;
}
else if(CONN_DEBUG == llevel) {
nLevel = AS_LOG_DEBUG;
}
MK_LOG(nLevel,"[connect]:%s",szLogDetail);
}
};
class mk_media_service
{
public:
static mk_media_service& instance()
{
static mk_media_service obj_mk_media_service;
return obj_mk_media_service;
}
virtual ~mk_media_service();
int32_t init(uint32_t EvnCount,uint32_t MaxClient);
void release();
mk_rtsp_server* create_rtsp_server(uint16_t port,rtsp_server_request cb,void* ctx);
void destory_rtsp_server(mk_rtsp_server* pServer);
mk_client_connection* create_client(char* url,handle_client_status cb,void* ctx);
void destory_client(mk_client_connection* pClient);
public:
as_network_svr* get_client_network_svr(uint32_t ulIndex);
as_timer& get_client_check_timer();
void set_rtp_rtcp_udp_port(uint16_t udpPort,uint32_t count);
void get_rtp_rtcp_udp_port(uint16_t& udpPort,uint32_t& count);
void set_rtp_recv_buf_info(uint32_t maxCount);
void get_rtp_recv_buf_info(uint32_t& maxCount);
void set_media_frame_buffer(uint32_t maxSize,uint32_t maxCount);
void get_media_frame_buffer(uint32_t& maxSize,uint32_t& maxCount);
public:
char* get_frame_buf();
void free_frame_buf(char* buf);
private:
mk_media_service();
int32_t create_frame_recv_bufs();
void destory_frame_recv_bufs();
private:
as_network_svr** m_NetWorkArray;
uint32_t m_ulEvnCount;
mk_conn_log m_connLog;
as_timer m_CheckTimer;
uint32_t m_ulFrameBufSize;
uint32_t m_ulFramebufCount;
typedef std::list<char*> RECV_BUF_LIST;
RECV_BUF_LIST m_FrameBufList;
typedef std::list<uint32_t> CLIENT_INDEX_LIST;
CLIENT_INDEX_LIST m_ClientFreeList;
};
#endif /* _MK_MEDIA_SERVICE_INCLUDE_H__ */