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
56d6eb0f
Commit
56d6eb0f
authored
Mar 03, 2023
by
ziyue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
批量替换tab为4个空格
parent
a5c3db4e
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
183 行增加
和
183 行删除
+183
-183
api/source/mk_media.cpp
+3
-3
webrtc/DtlsTransport.cpp
+0
-0
webrtc/DtlsTransport.hpp
+0
-0
webrtc/IceServer.cpp
+0
-0
webrtc/IceServer.hpp
+88
-88
webrtc/SctpAssociation.cpp
+0
-0
webrtc/SctpAssociation.hpp
+92
-92
webrtc/StunPacket.cpp
+0
-0
webrtc/StunPacket.hpp
+0
-0
没有找到文件。
api/source/mk_media.cpp
查看文件 @
56d6eb0f
...
@@ -269,9 +269,9 @@ API_EXPORT int API_CALL mk_media_input_aac(mk_media ctx, const void *data, int l
...
@@ -269,9 +269,9 @@ API_EXPORT int API_CALL mk_media_input_aac(mk_media ctx, const void *data, int l
}
}
API_EXPORT
int
API_CALL
mk_media_input_pcm
(
mk_media
ctx
,
void
*
data
,
int
len
,
uint64_t
pts
){
API_EXPORT
int
API_CALL
mk_media_input_pcm
(
mk_media
ctx
,
void
*
data
,
int
len
,
uint64_t
pts
){
assert
(
ctx
&&
data
&&
len
>
0
);
assert
(
ctx
&&
data
&&
len
>
0
);
MediaHelper
::
Ptr
*
obj
=
(
MediaHelper
::
Ptr
*
)
ctx
;
MediaHelper
::
Ptr
*
obj
=
(
MediaHelper
::
Ptr
*
)
ctx
;
return
(
*
obj
)
->
getChannel
()
->
inputPCM
((
char
*
)
data
,
len
,
pts
);
return
(
*
obj
)
->
getChannel
()
->
inputPCM
((
char
*
)
data
,
len
,
pts
);
}
}
API_EXPORT
int
API_CALL
mk_media_input_audio
(
mk_media
ctx
,
const
void
*
data
,
int
len
,
uint64_t
dts
){
API_EXPORT
int
API_CALL
mk_media_input_audio
(
mk_media
ctx
,
const
void
*
data
,
int
len
,
uint64_t
dts
){
...
...
webrtc/DtlsTransport.cpp
查看文件 @
56d6eb0f
差异被折叠。
点击展开。
webrtc/DtlsTransport.hpp
查看文件 @
56d6eb0f
差异被折叠。
点击展开。
webrtc/IceServer.cpp
查看文件 @
56d6eb0f
差异被折叠。
点击展开。
webrtc/IceServer.hpp
查看文件 @
56d6eb0f
...
@@ -30,109 +30,109 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
...
@@ -30,109 +30,109 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
namespace
RTC
namespace
RTC
{
{
using
TransportTuple
=
toolkit
::
Session
;
using
TransportTuple
=
toolkit
::
Session
;
class
IceServer
class
IceServer
{
{
public
:
public
:
enum
class
IceState
enum
class
IceState
{
{
NEW
=
1
,
NEW
=
1
,
CONNECTED
,
CONNECTED
,
COMPLETED
,
COMPLETED
,
DISCONNECTED
DISCONNECTED
};
};
public
:
public
:
class
Listener
class
Listener
{
{
public
:
public
:
virtual
~
Listener
()
=
default
;
virtual
~
Listener
()
=
default
;
public
:
public
:
/**
/**
* These callbacks are guaranteed to be called before ProcessStunPacket()
* These callbacks are guaranteed to be called before ProcessStunPacket()
* returns, so the given pointers are still usable.
* returns, so the given pointers are still usable.
*/
*/
virtual
void
OnIceServerSendStunPacket
(
virtual
void
OnIceServerSendStunPacket
(
const
RTC
::
IceServer
*
iceServer
,
const
RTC
::
StunPacket
*
packet
,
RTC
::
TransportTuple
*
tuple
)
=
0
;
const
RTC
::
IceServer
*
iceServer
,
const
RTC
::
StunPacket
*
packet
,
RTC
::
TransportTuple
*
tuple
)
=
0
;
virtual
void
OnIceServerSelectedTuple
(
virtual
void
OnIceServerSelectedTuple
(
const
RTC
::
IceServer
*
iceServer
,
RTC
::
TransportTuple
*
tuple
)
=
0
;
const
RTC
::
IceServer
*
iceServer
,
RTC
::
TransportTuple
*
tuple
)
=
0
;
virtual
void
OnIceServerConnected
(
const
RTC
::
IceServer
*
iceServer
)
=
0
;
virtual
void
OnIceServerConnected
(
const
RTC
::
IceServer
*
iceServer
)
=
0
;
virtual
void
OnIceServerCompleted
(
const
RTC
::
IceServer
*
iceServer
)
=
0
;
virtual
void
OnIceServerCompleted
(
const
RTC
::
IceServer
*
iceServer
)
=
0
;
virtual
void
OnIceServerDisconnected
(
const
RTC
::
IceServer
*
iceServer
)
=
0
;
virtual
void
OnIceServerDisconnected
(
const
RTC
::
IceServer
*
iceServer
)
=
0
;
};
};
public
:
public
:
IceServer
(
Listener
*
listener
,
const
std
::
string
&
usernameFragment
,
const
std
::
string
&
password
);
IceServer
(
Listener
*
listener
,
const
std
::
string
&
usernameFragment
,
const
std
::
string
&
password
);
public
:
public
:
void
ProcessStunPacket
(
RTC
::
StunPacket
*
packet
,
RTC
::
TransportTuple
*
tuple
);
void
ProcessStunPacket
(
RTC
::
StunPacket
*
packet
,
RTC
::
TransportTuple
*
tuple
);
const
std
::
string
&
GetUsernameFragment
()
const
const
std
::
string
&
GetUsernameFragment
()
const
{
{
return
this
->
usernameFragment
;
return
this
->
usernameFragment
;
}
}
const
std
::
string
&
GetPassword
()
const
const
std
::
string
&
GetPassword
()
const
{
{
return
this
->
password
;
return
this
->
password
;
}
}
IceState
GetState
()
const
IceState
GetState
()
const
{
{
return
this
->
state
;
return
this
->
state
;
}
}
RTC
::
TransportTuple
*
GetSelectedTuple
(
bool
try_last_tuple
=
false
)
const
RTC
::
TransportTuple
*
GetSelectedTuple
(
bool
try_last_tuple
=
false
)
const
{
{
return
try_last_tuple
?
this
->
lastSelectedTuple
.
lock
().
get
()
:
this
->
selectedTuple
;
return
try_last_tuple
?
this
->
lastSelectedTuple
.
lock
().
get
()
:
this
->
selectedTuple
;
}
}
void
SetUsernameFragment
(
const
std
::
string
&
usernameFragment
)
void
SetUsernameFragment
(
const
std
::
string
&
usernameFragment
)
{
{
this
->
oldUsernameFragment
=
this
->
usernameFragment
;
this
->
oldUsernameFragment
=
this
->
usernameFragment
;
this
->
usernameFragment
=
usernameFragment
;
this
->
usernameFragment
=
usernameFragment
;
}
}
void
SetPassword
(
const
std
::
string
&
password
)
void
SetPassword
(
const
std
::
string
&
password
)
{
{
this
->
oldPassword
=
this
->
password
;
this
->
oldPassword
=
this
->
password
;
this
->
password
=
password
;
this
->
password
=
password
;
}
}
bool
IsValidTuple
(
const
RTC
::
TransportTuple
*
tuple
)
const
;
bool
IsValidTuple
(
const
RTC
::
TransportTuple
*
tuple
)
const
;
void
RemoveTuple
(
RTC
::
TransportTuple
*
tuple
);
void
RemoveTuple
(
RTC
::
TransportTuple
*
tuple
);
// This should be just called in 'connected' or completed' state
// This should be just called in 'connected' or completed' state
// and the given tuple must be an already valid tuple.
// and the given tuple must be an already valid tuple.
void
ForceSelectedTuple
(
const
RTC
::
TransportTuple
*
tuple
);
void
ForceSelectedTuple
(
const
RTC
::
TransportTuple
*
tuple
);
const
std
::
list
<
RTC
::
TransportTuple
*>&
GetTuples
()
const
{
return
tuples
;
}
const
std
::
list
<
RTC
::
TransportTuple
*>&
GetTuples
()
const
{
return
tuples
;
}
private
:
private
:
void
HandleTuple
(
RTC
::
TransportTuple
*
tuple
,
bool
hasUseCandidate
);
void
HandleTuple
(
RTC
::
TransportTuple
*
tuple
,
bool
hasUseCandidate
);
/**
/**
* Store the given tuple and return its stored address.
* Store the given tuple and return its stored address.
*/
*/
RTC
::
TransportTuple
*
AddTuple
(
RTC
::
TransportTuple
*
tuple
);
RTC
::
TransportTuple
*
AddTuple
(
RTC
::
TransportTuple
*
tuple
);
/**
/**
* If the given tuple exists return its stored address, nullptr otherwise.
* If the given tuple exists return its stored address, nullptr otherwise.
*/
*/
RTC
::
TransportTuple
*
HasTuple
(
const
RTC
::
TransportTuple
*
tuple
)
const
;
RTC
::
TransportTuple
*
HasTuple
(
const
RTC
::
TransportTuple
*
tuple
)
const
;
/**
/**
* Set the given tuple as the selected tuple.
* Set the given tuple as the selected tuple.
* NOTE: The given tuple MUST be already stored within the list.
* NOTE: The given tuple MUST be already stored within the list.
*/
*/
void
SetSelectedTuple
(
RTC
::
TransportTuple
*
storedTuple
);
void
SetSelectedTuple
(
RTC
::
TransportTuple
*
storedTuple
);
private
:
private
:
// Passed by argument.
// Passed by argument.
Listener
*
listener
{
nullptr
};
Listener
*
listener
{
nullptr
};
// Others.
// Others.
std
::
string
usernameFragment
;
std
::
string
usernameFragment
;
std
::
string
password
;
std
::
string
password
;
std
::
string
oldUsernameFragment
;
std
::
string
oldUsernameFragment
;
std
::
string
oldPassword
;
std
::
string
oldPassword
;
IceState
state
{
IceState
::
NEW
};
IceState
state
{
IceState
::
NEW
};
std
::
list
<
RTC
::
TransportTuple
*>
tuples
;
std
::
list
<
RTC
::
TransportTuple
*>
tuples
;
RTC
::
TransportTuple
*
selectedTuple
;
RTC
::
TransportTuple
*
selectedTuple
;
std
::
weak_ptr
<
RTC
::
TransportTuple
>
lastSelectedTuple
;
std
::
weak_ptr
<
RTC
::
TransportTuple
>
lastSelectedTuple
;
//最大不超过mtu
//最大不超过mtu
static
constexpr
size_t
StunSerializeBufferSize
{
1600
};
static
constexpr
size_t
StunSerializeBufferSize
{
1600
};
uint8_t
StunSerializeBuffer
[
StunSerializeBufferSize
];
uint8_t
StunSerializeBuffer
[
StunSerializeBufferSize
];
};
};
}
// namespace RTC
}
// namespace RTC
#endif
#endif
webrtc/SctpAssociation.cpp
查看文件 @
56d6eb0f
差异被折叠。
点击展开。
webrtc/SctpAssociation.hpp
查看文件 @
56d6eb0f
...
@@ -18,104 +18,104 @@ namespace RTC
...
@@ -18,104 +18,104 @@ namespace RTC
uint16_t
maxRetransmits
{
0u
};
uint16_t
maxRetransmits
{
0u
};
};
};
class
SctpAssociation
class
SctpAssociation
{
{
public
:
public
:
enum
class
SctpState
enum
class
SctpState
{
{
NEW
=
1
,
NEW
=
1
,
CONNECTING
,
CONNECTING
,
CONNECTED
,
CONNECTED
,
FAILED
,
FAILED
,
CLOSED
CLOSED
};
};
private
:
private
:
enum
class
StreamDirection
enum
class
StreamDirection
{
{
INCOMING
=
1
,
INCOMING
=
1
,
OUTGOING
OUTGOING
};
};
public
:
public
:
class
Listener
class
Listener
{
{
public
:
public
:
virtual
void
OnSctpAssociationConnecting
(
RTC
::
SctpAssociation
*
sctpAssociation
)
=
0
;
virtual
void
OnSctpAssociationConnecting
(
RTC
::
SctpAssociation
*
sctpAssociation
)
=
0
;
virtual
void
OnSctpAssociationConnected
(
RTC
::
SctpAssociation
*
sctpAssociation
)
=
0
;
virtual
void
OnSctpAssociationConnected
(
RTC
::
SctpAssociation
*
sctpAssociation
)
=
0
;
virtual
void
OnSctpAssociationFailed
(
RTC
::
SctpAssociation
*
sctpAssociation
)
=
0
;
virtual
void
OnSctpAssociationFailed
(
RTC
::
SctpAssociation
*
sctpAssociation
)
=
0
;
virtual
void
OnSctpAssociationClosed
(
RTC
::
SctpAssociation
*
sctpAssociation
)
=
0
;
virtual
void
OnSctpAssociationClosed
(
RTC
::
SctpAssociation
*
sctpAssociation
)
=
0
;
virtual
void
OnSctpAssociationSendData
(
virtual
void
OnSctpAssociationSendData
(
RTC
::
SctpAssociation
*
sctpAssociation
,
const
uint8_t
*
data
,
size_t
len
)
=
0
;
RTC
::
SctpAssociation
*
sctpAssociation
,
const
uint8_t
*
data
,
size_t
len
)
=
0
;
virtual
void
OnSctpAssociationMessageReceived
(
virtual
void
OnSctpAssociationMessageReceived
(
RTC
::
SctpAssociation
*
sctpAssociation
,
RTC
::
SctpAssociation
*
sctpAssociation
,
uint16_t
streamId
,
uint16_t
streamId
,
uint32_t
ppid
,
uint32_t
ppid
,
const
uint8_t
*
msg
,
const
uint8_t
*
msg
,
size_t
len
)
=
0
;
size_t
len
)
=
0
;
};
};
public
:
public
:
static
bool
IsSctp
(
const
uint8_t
*
data
,
size_t
len
)
static
bool
IsSctp
(
const
uint8_t
*
data
,
size_t
len
)
{
{
// clang-format off
// clang-format off
return
(
return
(
(
len
>=
12
)
&&
(
len
>=
12
)
&&
// Must have Source Port Number and Destination Port Number set to 5000 (hack).
// Must have Source Port Number and Destination Port Number set to 5000 (hack).
(
Utils
::
Byte
::
Get2Bytes
(
data
,
0
)
==
5000
)
&&
(
Utils
::
Byte
::
Get2Bytes
(
data
,
0
)
==
5000
)
&&
(
Utils
::
Byte
::
Get2Bytes
(
data
,
2
)
==
5000
)
(
Utils
::
Byte
::
Get2Bytes
(
data
,
2
)
==
5000
)
);
);
// clang-format on
// clang-format on
}
}
public
:
public
:
SctpAssociation
(
SctpAssociation
(
Listener
*
listener
,
uint16_t
os
,
uint16_t
mis
,
size_t
maxSctpMessageSize
,
bool
isDataChannel
);
Listener
*
listener
,
uint16_t
os
,
uint16_t
mis
,
size_t
maxSctpMessageSize
,
bool
isDataChannel
);
virtual
~
SctpAssociation
();
virtual
~
SctpAssociation
();
public
:
public
:
void
TransportConnected
();
void
TransportConnected
();
size_t
GetMaxSctpMessageSize
()
const
size_t
GetMaxSctpMessageSize
()
const
{
{
return
this
->
maxSctpMessageSize
;
return
this
->
maxSctpMessageSize
;
}
}
SctpState
GetState
()
const
SctpState
GetState
()
const
{
{
return
this
->
state
;
return
this
->
state
;
}
}
void
ProcessSctpData
(
const
uint8_t
*
data
,
size_t
len
);
void
ProcessSctpData
(
const
uint8_t
*
data
,
size_t
len
);
void
SendSctpMessage
(
const
RTC
::
SctpStreamParameters
&
params
,
uint32_t
ppid
,
const
uint8_t
*
msg
,
size_t
len
);
void
SendSctpMessage
(
const
RTC
::
SctpStreamParameters
&
params
,
uint32_t
ppid
,
const
uint8_t
*
msg
,
size_t
len
);
void
HandleDataConsumer
(
const
RTC
::
SctpStreamParameters
&
params
);
void
HandleDataConsumer
(
const
RTC
::
SctpStreamParameters
&
params
);
void
DataProducerClosed
(
const
RTC
::
SctpStreamParameters
&
params
);
void
DataProducerClosed
(
const
RTC
::
SctpStreamParameters
&
params
);
void
DataConsumerClosed
(
const
RTC
::
SctpStreamParameters
&
params
);
void
DataConsumerClosed
(
const
RTC
::
SctpStreamParameters
&
params
);
private
:
private
:
void
ResetSctpStream
(
uint16_t
streamId
,
StreamDirection
);
void
ResetSctpStream
(
uint16_t
streamId
,
StreamDirection
);
void
AddOutgoingStreams
(
bool
force
=
false
);
void
AddOutgoingStreams
(
bool
force
=
false
);
public
:
public
:
/* Callbacks fired by usrsctp events. */
/* Callbacks fired by usrsctp events. */
virtual
void
OnUsrSctpSendSctpData
(
void
*
buffer
,
size_t
len
);
virtual
void
OnUsrSctpSendSctpData
(
void
*
buffer
,
size_t
len
);
virtual
void
OnUsrSctpReceiveSctpData
(
uint16_t
streamId
,
uint16_t
ssn
,
uint32_t
ppid
,
int
flags
,
const
uint8_t
*
data
,
size_t
len
);
virtual
void
OnUsrSctpReceiveSctpData
(
uint16_t
streamId
,
uint16_t
ssn
,
uint32_t
ppid
,
int
flags
,
const
uint8_t
*
data
,
size_t
len
);
virtual
void
OnUsrSctpReceiveSctpNotification
(
union
sctp_notification
*
notification
,
size_t
len
);
virtual
void
OnUsrSctpReceiveSctpNotification
(
union
sctp_notification
*
notification
,
size_t
len
);
private
:
private
:
// Passed by argument.
// Passed by argument.
Listener
*
listener
{
nullptr
};
Listener
*
listener
{
nullptr
};
uint16_t
os
{
1024u
};
uint16_t
os
{
1024u
};
uint16_t
mis
{
1024u
};
uint16_t
mis
{
1024u
};
size_t
maxSctpMessageSize
{
262144u
};
size_t
maxSctpMessageSize
{
262144u
};
bool
isDataChannel
{
false
};
bool
isDataChannel
{
false
};
// Allocated by this.
// Allocated by this.
uint8_t
*
messageBuffer
{
nullptr
};
uint8_t
*
messageBuffer
{
nullptr
};
// Others.
// Others.
SctpState
state
{
SctpState
::
NEW
};
SctpState
state
{
SctpState
::
NEW
};
struct
socket
*
socket
{
nullptr
};
struct
socket
*
socket
{
nullptr
};
uint16_t
desiredOs
{
0u
};
uint16_t
desiredOs
{
0u
};
size_t
messageBufferLen
{
0u
};
size_t
messageBufferLen
{
0u
};
uint16_t
lastSsnReceived
{
0u
};
// Valid for us since no SCTP I-DATA support.
uint16_t
lastSsnReceived
{
0u
};
// Valid for us since no SCTP I-DATA support.
std
::
shared_ptr
<
SctpEnv
>
_env
;
std
::
shared_ptr
<
SctpEnv
>
_env
;
};
};
//保证线程安全
//保证线程安全
class
SctpAssociationImp
:
public
SctpAssociation
,
public
std
::
enable_shared_from_this
<
SctpAssociationImp
>
{
class
SctpAssociationImp
:
public
SctpAssociation
,
public
std
::
enable_shared_from_this
<
SctpAssociationImp
>
{
...
...
webrtc/StunPacket.cpp
查看文件 @
56d6eb0f
差异被折叠。
点击展开。
webrtc/StunPacket.hpp
查看文件 @
56d6eb0f
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论