Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
ZLMediaKit
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
张翔宇
ZLMediaKit
Commits
c801de99
Commit
c801de99
authored
Feb 06, 2018
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复http-flv流量统计的bug
parent
d375116e
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
12 行增加
和
9 行删除
+12
-9
src/Http/HttpSession.cpp
+12
-9
没有找到文件。
src/Http/HttpSession.cpp
查看文件 @
c801de99
...
@@ -47,6 +47,8 @@ using namespace ZL::Util;
...
@@ -47,6 +47,8 @@ using namespace ZL::Util;
namespace
ZL
{
namespace
ZL
{
namespace
Http
{
namespace
Http
{
static
int
sock_flags
=
SOCKET_DEFAULE_FLAGS
|
FLAG_MORE
;
unordered_map
<
string
,
HttpSession
::
HttpCMDHandle
>
HttpSession
::
g_mapCmdIndex
;
unordered_map
<
string
,
HttpSession
::
HttpCMDHandle
>
HttpSession
::
g_mapCmdIndex
;
string
dateStr
()
{
string
dateStr
()
{
char
buf
[
64
];
char
buf
[
64
];
...
@@ -163,7 +165,8 @@ void HttpSession::onError(const SockException& err) {
...
@@ -163,7 +165,8 @@ void HttpSession::onError(const SockException& err) {
//WarnL << err.what();
//WarnL << err.what();
static
uint64_t
iFlowThreshold
=
mINI
::
Instance
()[
Broadcast
::
kFlowThreshold
];
static
uint64_t
iFlowThreshold
=
mINI
::
Instance
()[
Broadcast
::
kFlowThreshold
];
if
(
m_previousTagSize
>
iFlowThreshold
*
1024
){
if
(
m_previousTagSize
>
iFlowThreshold
*
1024
){
NoticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastFlowReport
,
m_mediaInfo
,
m_previousTagSize
);
uint64_t
totalBytes
=
m_previousTagSize
;
NoticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastFlowReport
,
m_mediaInfo
,
totalBytes
);
}
}
}
}
...
@@ -413,7 +416,7 @@ inline HttpSession::HttpCode HttpSession::Handle_Req_GET() {
...
@@ -413,7 +416,7 @@ inline HttpSession::HttpCode HttpSession::Handle_Req_GET() {
if
(
iRead
>
0
)
{
if
(
iRead
>
0
)
{
sendBuf
->
setSize
(
iRead
);
sendBuf
->
setSize
(
iRead
);
strongSelf
->
sock
->
setSendPktSize
(
3
);
//强制写入socket缓存
strongSelf
->
sock
->
setSendPktSize
(
3
);
//强制写入socket缓存
strongSelf
->
sock
->
send
(
sendBuf
,
SOCKET_DEFAULE_FLAGS
|
FLAG_MORE
);
strongSelf
->
sock
->
send
(
sendBuf
,
sock_flags
);
}
}
if
(
bClose
)
{
if
(
bClose
)
{
strongSelf
->
shutdown
();
strongSelf
->
shutdown
();
...
@@ -422,7 +425,7 @@ inline HttpSession::HttpCode HttpSession::Handle_Req_GET() {
...
@@ -422,7 +425,7 @@ inline HttpSession::HttpCode HttpSession::Handle_Req_GET() {
}
}
//文件还未读完
//文件还未读完
sendBuf
->
setSize
(
iRead
);
sendBuf
->
setSize
(
iRead
);
int
iSent
=
strongSelf
->
sock
->
send
(
sendBuf
,
SOCKET_DEFAULE_FLAGS
|
FLAG_MORE
);
int
iSent
=
strongSelf
->
sock
->
send
(
sendBuf
,
sock_flags
);
if
(
iSent
==
-
1
)
{
if
(
iSent
==
-
1
)
{
//send error
//send error
//InfoL << "send error";
//InfoL << "send error";
...
@@ -696,28 +699,28 @@ private:
...
@@ -696,28 +699,28 @@ private:
void
HttpSession
::
sendRtmp
(
const
RtmpPacket
::
Ptr
&
pkt
,
uint32_t
ui32TimeStamp
)
{
void
HttpSession
::
sendRtmp
(
const
RtmpPacket
::
Ptr
&
pkt
,
uint32_t
ui32TimeStamp
)
{
auto
size
=
htonl
(
m_previousTagSize
);
auto
size
=
htonl
(
m_previousTagSize
);
send
((
char
*
)
&
size
,
4
);
//send PreviousTagSize
sock
->
send
((
char
*
)
&
size
,
4
,
sock_flags
);
//send PreviousTagSize
RtmpTagHeader
header
;
RtmpTagHeader
header
;
header
.
type
=
pkt
->
typeId
;
header
.
type
=
pkt
->
typeId
;
set_be24
(
header
.
data_size
,
pkt
->
strBuf
.
size
());
set_be24
(
header
.
data_size
,
pkt
->
strBuf
.
size
());
header
.
timestamp_ex
=
(
uint8_t
)
((
ui32TimeStamp
>>
24
)
&
0xff
);
header
.
timestamp_ex
=
(
uint8_t
)
((
ui32TimeStamp
>>
24
)
&
0xff
);
set_be24
(
header
.
timestamp
,
ui32TimeStamp
&
0xFFFFFF
);
set_be24
(
header
.
timestamp
,
ui32TimeStamp
&
0xFFFFFF
);
send
((
char
*
)
&
header
,
sizeof
(
header
)
);
//send tag header
sock
->
send
((
char
*
)
&
header
,
sizeof
(
header
),
sock_flags
);
//send tag header
send
(
std
::
make_shared
<
BufferRtmp
>
(
pkt
)
);
//send tag data
sock
->
send
(
std
::
make_shared
<
BufferRtmp
>
(
pkt
),
sock_flags
);
//send tag data
m_previousTagSize
+=
(
pkt
->
strBuf
.
size
()
+
sizeof
(
header
)
+
4
);
m_previousTagSize
+=
(
pkt
->
strBuf
.
size
()
+
sizeof
(
header
)
+
4
);
m_ticker
.
resetTime
();
m_ticker
.
resetTime
();
}
}
void
HttpSession
::
sendRtmp
(
uint8_t
ui8Type
,
const
std
::
string
&
strBuf
,
uint32_t
ui32TimeStamp
)
{
void
HttpSession
::
sendRtmp
(
uint8_t
ui8Type
,
const
std
::
string
&
strBuf
,
uint32_t
ui32TimeStamp
)
{
auto
size
=
htonl
(
m_previousTagSize
);
auto
size
=
htonl
(
m_previousTagSize
);
s
end
((
char
*
)
&
size
,
4
);
//send PreviousTagSize
s
ock
->
send
((
char
*
)
&
size
,
4
,
sock_flags
);
//send PreviousTagSize
RtmpTagHeader
header
;
RtmpTagHeader
header
;
header
.
type
=
ui8Type
;
header
.
type
=
ui8Type
;
set_be24
(
header
.
data_size
,
strBuf
.
size
());
set_be24
(
header
.
data_size
,
strBuf
.
size
());
header
.
timestamp_ex
=
(
uint8_t
)
((
ui32TimeStamp
>>
24
)
&
0xff
);
header
.
timestamp_ex
=
(
uint8_t
)
((
ui32TimeStamp
>>
24
)
&
0xff
);
set_be24
(
header
.
timestamp
,
ui32TimeStamp
&
0xFFFFFF
);
set_be24
(
header
.
timestamp
,
ui32TimeStamp
&
0xFFFFFF
);
s
end
((
char
*
)
&
header
,
sizeof
(
header
)
);
//send tag header
s
ock
->
send
((
char
*
)
&
header
,
sizeof
(
header
),
sock_flags
);
//send tag header
s
end
(
strBuf
);
//send tag data
s
ock
->
send
(
strBuf
,
sock_flags
);
//send tag data
m_previousTagSize
+=
(
strBuf
.
size
()
+
sizeof
(
header
)
+
4
);
m_previousTagSize
+=
(
strBuf
.
size
()
+
sizeof
(
header
)
+
4
);
m_ticker
.
resetTime
();
m_ticker
.
resetTime
();
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论