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
}
API_EXPORT
int
API_CALL
mk_media_input_pcm
(
mk_media
ctx
,
void
*
data
,
int
len
,
uint64_t
pts
){
assert
(
ctx
&&
data
&&
len
>
0
);
MediaHelper
::
Ptr
*
obj
=
(
MediaHelper
::
Ptr
*
)
ctx
;
return
(
*
obj
)
->
getChannel
()
->
inputPCM
((
char
*
)
data
,
len
,
pts
);
assert
(
ctx
&&
data
&&
len
>
0
);
MediaHelper
::
Ptr
*
obj
=
(
MediaHelper
::
Ptr
*
)
ctx
;
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
){
...
...
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.
namespace
RTC
{
using
TransportTuple
=
toolkit
::
Session
;
class
IceServer
{
public
:
enum
class
IceState
{
NEW
=
1
,
CONNECTED
,
COMPLETED
,
DISCONNECTED
};
using
TransportTuple
=
toolkit
::
Session
;
class
IceServer
{
public
:
enum
class
IceState
{
NEW
=
1
,
CONNECTED
,
COMPLETED
,
DISCONNECTED
};
public
:
class
Listener
{
public
:
virtual
~
Listener
()
=
default
;
public
:
class
Listener
{
public
:
virtual
~
Listener
()
=
default
;
public
:
/**
* These callbacks are guaranteed to be called before ProcessStunPacket()
* returns, so the given pointers are still usable.
*/
virtual
void
OnIceServerSendStunPacket
(
const
RTC
::
IceServer
*
iceServer
,
const
RTC
::
StunPacket
*
packet
,
RTC
::
TransportTuple
*
tuple
)
=
0
;
virtual
void
OnIceServerSelectedTuple
(
const
RTC
::
IceServer
*
iceServer
,
RTC
::
TransportTuple
*
tuple
)
=
0
;
virtual
void
OnIceServerConnected
(
const
RTC
::
IceServer
*
iceServer
)
=
0
;
virtual
void
OnIceServerCompleted
(
const
RTC
::
IceServer
*
iceServer
)
=
0
;
virtual
void
OnIceServerDisconnected
(
const
RTC
::
IceServer
*
iceServer
)
=
0
;
};
public
:
/**
* These callbacks are guaranteed to be called before ProcessStunPacket()
* returns, so the given pointers are still usable.
*/
virtual
void
OnIceServerSendStunPacket
(
const
RTC
::
IceServer
*
iceServer
,
const
RTC
::
StunPacket
*
packet
,
RTC
::
TransportTuple
*
tuple
)
=
0
;
virtual
void
OnIceServerSelectedTuple
(
const
RTC
::
IceServer
*
iceServer
,
RTC
::
TransportTuple
*
tuple
)
=
0
;
virtual
void
OnIceServerConnected
(
const
RTC
::
IceServer
*
iceServer
)
=
0
;
virtual
void
OnIceServerCompleted
(
const
RTC
::
IceServer
*
iceServer
)
=
0
;
virtual
void
OnIceServerDisconnected
(
const
RTC
::
IceServer
*
iceServer
)
=
0
;
};
public
:
IceServer
(
Listener
*
listener
,
const
std
::
string
&
usernameFragment
,
const
std
::
string
&
password
);
public
:
IceServer
(
Listener
*
listener
,
const
std
::
string
&
usernameFragment
,
const
std
::
string
&
password
);
public
:
void
ProcessStunPacket
(
RTC
::
StunPacket
*
packet
,
RTC
::
TransportTuple
*
tuple
);
const
std
::
string
&
GetUsernameFragment
()
const
{
return
this
->
usernameFragment
;
}
const
std
::
string
&
GetPassword
()
const
{
return
this
->
password
;
}
IceState
GetState
()
const
{
return
this
->
state
;
}
RTC
::
TransportTuple
*
GetSelectedTuple
(
bool
try_last_tuple
=
false
)
const
{
public
:
void
ProcessStunPacket
(
RTC
::
StunPacket
*
packet
,
RTC
::
TransportTuple
*
tuple
);
const
std
::
string
&
GetUsernameFragment
()
const
{
return
this
->
usernameFragment
;
}
const
std
::
string
&
GetPassword
()
const
{
return
this
->
password
;
}
IceState
GetState
()
const
{
return
this
->
state
;
}
RTC
::
TransportTuple
*
GetSelectedTuple
(
bool
try_last_tuple
=
false
)
const
{
return
try_last_tuple
?
this
->
lastSelectedTuple
.
lock
().
get
()
:
this
->
selectedTuple
;
}
void
SetUsernameFragment
(
const
std
::
string
&
usernameFragment
)
{
this
->
oldUsernameFragment
=
this
->
usernameFragment
;
this
->
usernameFragment
=
usernameFragment
;
}
void
SetPassword
(
const
std
::
string
&
password
)
{
this
->
oldPassword
=
this
->
password
;
this
->
password
=
password
;
}
bool
IsValidTuple
(
const
RTC
::
TransportTuple
*
tuple
)
const
;
void
RemoveTuple
(
RTC
::
TransportTuple
*
tuple
);
// This should be just called in 'connected' or completed' state
// and the given tuple must be an already valid tuple.
void
ForceSelectedTuple
(
const
RTC
::
TransportTuple
*
tuple
);
void
SetUsernameFragment
(
const
std
::
string
&
usernameFragment
)
{
this
->
oldUsernameFragment
=
this
->
usernameFragment
;
this
->
usernameFragment
=
usernameFragment
;
}
void
SetPassword
(
const
std
::
string
&
password
)
{
this
->
oldPassword
=
this
->
password
;
this
->
password
=
password
;
}
bool
IsValidTuple
(
const
RTC
::
TransportTuple
*
tuple
)
const
;
void
RemoveTuple
(
RTC
::
TransportTuple
*
tuple
);
// This should be just called in 'connected' or completed' state
// and the given tuple must be an already valid tuple.
void
ForceSelectedTuple
(
const
RTC
::
TransportTuple
*
tuple
);
const
std
::
list
<
RTC
::
TransportTuple
*>&
GetTuples
()
const
{
return
tuples
;
}
private
:
void
HandleTuple
(
RTC
::
TransportTuple
*
tuple
,
bool
hasUseCandidate
);
/**
* Store the given tuple and return its stored address.
*/
RTC
::
TransportTuple
*
AddTuple
(
RTC
::
TransportTuple
*
tuple
);
/**
* If the given tuple exists return its stored address, nullptr otherwise.
*/
RTC
::
TransportTuple
*
HasTuple
(
const
RTC
::
TransportTuple
*
tuple
)
const
;
/**
* Set the given tuple as the selected tuple.
* NOTE: The given tuple MUST be already stored within the list.
*/
void
SetSelectedTuple
(
RTC
::
TransportTuple
*
storedTuple
);
void
HandleTuple
(
RTC
::
TransportTuple
*
tuple
,
bool
hasUseCandidate
);
/**
* Store the given tuple and return its stored address.
*/
RTC
::
TransportTuple
*
AddTuple
(
RTC
::
TransportTuple
*
tuple
);
/**
* If the given tuple exists return its stored address, nullptr otherwise.
*/
RTC
::
TransportTuple
*
HasTuple
(
const
RTC
::
TransportTuple
*
tuple
)
const
;
/**
* Set the given tuple as the selected tuple.
* NOTE: The given tuple MUST be already stored within the list.
*/
void
SetSelectedTuple
(
RTC
::
TransportTuple
*
storedTuple
);
private
:
// Passed by argument.
Listener
*
listener
{
nullptr
};
// Others.
std
::
string
usernameFragment
;
std
::
string
password
;
std
::
string
oldUsernameFragment
;
std
::
string
oldPassword
;
IceState
state
{
IceState
::
NEW
};
std
::
list
<
RTC
::
TransportTuple
*>
tuples
;
private
:
// Passed by argument.
Listener
*
listener
{
nullptr
};
// Others.
std
::
string
usernameFragment
;
std
::
string
password
;
std
::
string
oldUsernameFragment
;
std
::
string
oldPassword
;
IceState
state
{
IceState
::
NEW
};
std
::
list
<
RTC
::
TransportTuple
*>
tuples
;
RTC
::
TransportTuple
*
selectedTuple
;
std
::
weak_ptr
<
RTC
::
TransportTuple
>
lastSelectedTuple
;
//最大不超过mtu
//最大不超过mtu
static
constexpr
size_t
StunSerializeBufferSize
{
1600
};
uint8_t
StunSerializeBuffer
[
StunSerializeBufferSize
];
};
};
}
// namespace RTC
#endif
webrtc/SctpAssociation.cpp
查看文件 @
56d6eb0f
差异被折叠。
点击展开。
webrtc/SctpAssociation.hpp
查看文件 @
56d6eb0f
...
...
@@ -18,104 +18,104 @@ namespace RTC
uint16_t
maxRetransmits
{
0u
};
};
class
SctpAssociation
{
public
:
enum
class
SctpState
{
NEW
=
1
,
CONNECTING
,
CONNECTED
,
FAILED
,
CLOSED
};
private
:
enum
class
StreamDirection
{
INCOMING
=
1
,
OUTGOING
};
public
:
class
Listener
{
public
:
virtual
void
OnSctpAssociationConnecting
(
RTC
::
SctpAssociation
*
sctpAssociation
)
=
0
;
virtual
void
OnSctpAssociationConnected
(
RTC
::
SctpAssociation
*
sctpAssociation
)
=
0
;
virtual
void
OnSctpAssociationFailed
(
RTC
::
SctpAssociation
*
sctpAssociation
)
=
0
;
virtual
void
OnSctpAssociationClosed
(
RTC
::
SctpAssociation
*
sctpAssociation
)
=
0
;
virtual
void
OnSctpAssociationSendData
(
RTC
::
SctpAssociation
*
sctpAssociation
,
const
uint8_t
*
data
,
size_t
len
)
=
0
;
virtual
void
OnSctpAssociationMessageReceived
(
RTC
::
SctpAssociation
*
sctpAssociation
,
uint16_t
streamId
,
uint32_t
ppid
,
const
uint8_t
*
msg
,
size_t
len
)
=
0
;
};
public
:
static
bool
IsSctp
(
const
uint8_t
*
data
,
size_t
len
)
{
// clang-format off
return
(
(
len
>=
12
)
&&
// Must have Source Port Number and Destination Port Number set to 5000 (hack).
(
Utils
::
Byte
::
Get2Bytes
(
data
,
0
)
==
5000
)
&&
(
Utils
::
Byte
::
Get2Bytes
(
data
,
2
)
==
5000
)
);
// clang-format on
}
public
:
SctpAssociation
(
Listener
*
listener
,
uint16_t
os
,
uint16_t
mis
,
size_t
maxSctpMessageSize
,
bool
isDataChannel
);
virtual
~
SctpAssociation
();
public
:
void
TransportConnected
();
size_t
GetMaxSctpMessageSize
()
const
{
return
this
->
maxSctpMessageSize
;
}
SctpState
GetState
()
const
{
return
this
->
state
;
}
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
HandleDataConsumer
(
const
RTC
::
SctpStreamParameters
&
params
);
void
DataProducerClosed
(
const
RTC
::
SctpStreamParameters
&
params
);
void
DataConsumerClosed
(
const
RTC
::
SctpStreamParameters
&
params
);
private
:
void
ResetSctpStream
(
uint16_t
streamId
,
StreamDirection
);
void
AddOutgoingStreams
(
bool
force
=
false
);
public
:
class
SctpAssociation
{
public
:
enum
class
SctpState
{
NEW
=
1
,
CONNECTING
,
CONNECTED
,
FAILED
,
CLOSED
};
private
:
enum
class
StreamDirection
{
INCOMING
=
1
,
OUTGOING
};
public
:
class
Listener
{
public
:
virtual
void
OnSctpAssociationConnecting
(
RTC
::
SctpAssociation
*
sctpAssociation
)
=
0
;
virtual
void
OnSctpAssociationConnected
(
RTC
::
SctpAssociation
*
sctpAssociation
)
=
0
;
virtual
void
OnSctpAssociationFailed
(
RTC
::
SctpAssociation
*
sctpAssociation
)
=
0
;
virtual
void
OnSctpAssociationClosed
(
RTC
::
SctpAssociation
*
sctpAssociation
)
=
0
;
virtual
void
OnSctpAssociationSendData
(
RTC
::
SctpAssociation
*
sctpAssociation
,
const
uint8_t
*
data
,
size_t
len
)
=
0
;
virtual
void
OnSctpAssociationMessageReceived
(
RTC
::
SctpAssociation
*
sctpAssociation
,
uint16_t
streamId
,
uint32_t
ppid
,
const
uint8_t
*
msg
,
size_t
len
)
=
0
;
};
public
:
static
bool
IsSctp
(
const
uint8_t
*
data
,
size_t
len
)
{
// clang-format off
return
(
(
len
>=
12
)
&&
// Must have Source Port Number and Destination Port Number set to 5000 (hack).
(
Utils
::
Byte
::
Get2Bytes
(
data
,
0
)
==
5000
)
&&
(
Utils
::
Byte
::
Get2Bytes
(
data
,
2
)
==
5000
)
);
// clang-format on
}
public
:
SctpAssociation
(
Listener
*
listener
,
uint16_t
os
,
uint16_t
mis
,
size_t
maxSctpMessageSize
,
bool
isDataChannel
);
virtual
~
SctpAssociation
();
public
:
void
TransportConnected
();
size_t
GetMaxSctpMessageSize
()
const
{
return
this
->
maxSctpMessageSize
;
}
SctpState
GetState
()
const
{
return
this
->
state
;
}
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
HandleDataConsumer
(
const
RTC
::
SctpStreamParameters
&
params
);
void
DataProducerClosed
(
const
RTC
::
SctpStreamParameters
&
params
);
void
DataConsumerClosed
(
const
RTC
::
SctpStreamParameters
&
params
);
private
:
void
ResetSctpStream
(
uint16_t
streamId
,
StreamDirection
);
void
AddOutgoingStreams
(
bool
force
=
false
);
public
:
/* Callbacks fired by usrsctp events. */
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
OnUsrSctpReceiveSctpNotification
(
union
sctp_notification
*
notification
,
size_t
len
);
private
:
// Passed by argument.
Listener
*
listener
{
nullptr
};
uint16_t
os
{
1024u
};
uint16_t
mis
{
1024u
};
size_t
maxSctpMessageSize
{
262144u
};
bool
isDataChannel
{
false
};
// Allocated by this.
uint8_t
*
messageBuffer
{
nullptr
};
// Others.
SctpState
state
{
SctpState
::
NEW
};
struct
socket
*
socket
{
nullptr
};
uint16_t
desiredOs
{
0u
};
size_t
messageBufferLen
{
0u
};
uint16_t
lastSsnReceived
{
0u
};
// Valid for us since no SCTP I-DATA support.
private
:
// Passed by argument.
Listener
*
listener
{
nullptr
};
uint16_t
os
{
1024u
};
uint16_t
mis
{
1024u
};
size_t
maxSctpMessageSize
{
262144u
};
bool
isDataChannel
{
false
};
// Allocated by this.
uint8_t
*
messageBuffer
{
nullptr
};
// Others.
SctpState
state
{
SctpState
::
NEW
};
struct
socket
*
socket
{
nullptr
};
uint16_t
desiredOs
{
0u
};
size_t
messageBufferLen
{
0u
};
uint16_t
lastSsnReceived
{
0u
};
// Valid for us since no SCTP I-DATA support.
std
::
shared_ptr
<
SctpEnv
>
_env
;
};
};
//保证线程安全
class
SctpAssociationImp
:
public
SctpAssociation
,
public
std
::
enable_shared_from_this
<
SctpAssociationImp
>
{
...
...
webrtc/StunPacket.cpp
查看文件 @
56d6eb0f
差异被折叠。
点击展开。
webrtc/StunPacket.hpp
查看文件 @
56d6eb0f
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论