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
bdf2783a
Commit
bdf2783a
authored
4 years ago
by
ziyue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
还原原始文件名
parent
704421b7
全部展开
显示空白字符变更
内嵌
并排
正在显示
14 个修改的文件
包含
207 行增加
和
194 行删除
+207
-194
server/WebApi.cpp
+1
-1
webrtc/DtlsTransport.cpp
+1
-1
webrtc/DtlsTransport.hpp
+1
-1
webrtc/IceServer.cpp
+1
-1
webrtc/IceServer.hpp
+1
-1
webrtc/SrtpSession.cpp
+1
-1
webrtc/SrtpSession.hpp
+1
-1
webrtc/StunPacket.cpp
+0
-0
webrtc/StunPacket.hpp
+195
-0
webrtc/Utils.hpp
+0
-0
webrtc/WebRtcTransport.cpp
+1
-1
webrtc/WebRtcTransport.h
+4
-4
webrtc/logger.h
+0
-3
webrtc/stun_packet.h
+0
-179
没有找到文件。
server/WebApi.cpp
查看文件 @
bdf2783a
...
...
@@ -36,7 +36,7 @@
#include "Rtp/RtpServer.h"
#endif
#ifdef ENABLE_WEBRTC
#include "../webrtc/
webrtc_t
ransport.h"
#include "../webrtc/
WebRtcT
ransport.h"
#endif
using
namespace
toolkit
;
...
...
This diff is collapsed.
Click to expand it.
webrtc/
rtc_dtls_transport.cc
→
webrtc/
DtlsTransport.cpp
查看文件 @
bdf2783a
#define MS_CLASS "RTC::DtlsTransport"
// #define MS_LOG_DEV_LEVEL 3
#include "
rtc_dtls_transport.h
"
#include "
DtlsTransport.hpp
"
#include "logger.h"
#include <openssl/asn1.h>
#include <openssl/bn.h>
...
...
This diff is collapsed.
Click to expand it.
webrtc/
rtc_dtls_transport.h
→
webrtc/
DtlsTransport.hpp
查看文件 @
bdf2783a
#ifndef MS_RTC_DTLS_TRANSPORT_HPP
#define MS_RTC_DTLS_TRANSPORT_HPP
#include "
srtp_session.h
"
#include "
SrtpSession.hpp
"
#include <openssl/bio.h>
#include <openssl/ssl.h>
#include <openssl/x509.h>
...
...
This diff is collapsed.
Click to expand it.
webrtc/
ice_server.cc
→
webrtc/
IceServer.cpp
查看文件 @
bdf2783a
...
...
@@ -2,7 +2,7 @@
// #define MS_LOG_DEV_LEVEL 3
#include <utility>
#include "
ice_server.h
"
#include "
IceServer.hpp
"
namespace
RTC
{
...
...
This diff is collapsed.
Click to expand it.
webrtc/
ice_server.h
→
webrtc/
IceServer.hpp
查看文件 @
bdf2783a
#ifndef MS_RTC_ICE_SERVER_HPP
#define MS_RTC_ICE_SERVER_HPP
#include "
stun_packet.h
"
#include "
StunPacket.hpp
"
#include "logger.h"
#include <list>
#include <string>
...
...
This diff is collapsed.
Click to expand it.
webrtc/
srtp_session.cc
→
webrtc/
SrtpSession.cpp
查看文件 @
bdf2783a
#define MS_CLASS "RTC::SrtpSession"
// #define MS_LOG_DEV_LEVEL 3
#include "
srtp_session.h
"
#include "
SrtpSession.hpp
"
#include <cstring> // std::memset(), std::memcpy()
#include "logger.h"
...
...
This diff is collapsed.
Click to expand it.
webrtc/
srtp_session.h
→
webrtc/
SrtpSession.hpp
查看文件 @
bdf2783a
#ifndef MS_RTC_SRTP_SESSION_HPP
#define MS_RTC_SRTP_SESSION_HPP
#include "
utils.h
"
#include "
Utils.hpp
"
#include <srtp2/srtp.h>
#include <vector>
...
...
This diff is collapsed.
Click to expand it.
webrtc/
stun_packet.cc
→
webrtc/
StunPacket.cpp
查看文件 @
bdf2783a
差异被折叠。
点击展开。
webrtc/StunPacket.hpp
0 → 100644
查看文件 @
bdf2783a
#ifndef MS_RTC_STUN_PACKET_HPP
#define MS_RTC_STUN_PACKET_HPP
#include "logger.h"
#include "Utils.hpp"
#include <string>
namespace
RTC
{
class
StunPacket
{
public
:
// STUN message class.
enum
class
Class
:
uint16_t
{
REQUEST
=
0
,
INDICATION
=
1
,
SUCCESS_RESPONSE
=
2
,
ERROR_RESPONSE
=
3
};
// STUN message method.
enum
class
Method
:
uint16_t
{
BINDING
=
1
};
// Attribute type.
enum
class
Attribute
:
uint16_t
{
MAPPED_ADDRESS
=
0x0001
,
USERNAME
=
0x0006
,
MESSAGE_INTEGRITY
=
0x0008
,
ERROR_CODE
=
0x0009
,
UNKNOWN_ATTRIBUTES
=
0x000A
,
REALM
=
0x0014
,
NONCE
=
0x0015
,
XOR_MAPPED_ADDRESS
=
0x0020
,
PRIORITY
=
0x0024
,
USE_CANDIDATE
=
0x0025
,
SOFTWARE
=
0x8022
,
ALTERNATE_SERVER
=
0x8023
,
FINGERPRINT
=
0x8028
,
ICE_CONTROLLED
=
0x8029
,
ICE_CONTROLLING
=
0x802A
};
// Authentication result.
enum
class
Authentication
{
OK
=
0
,
UNAUTHORIZED
=
1
,
BAD_REQUEST
=
2
};
public
:
static
bool
IsStun
(
const
uint8_t
*
data
,
size_t
len
)
{
// clang-format off
return
(
// STUN headers are 20 bytes.
(
len
>=
20
)
&&
// DOC: https://tools.ietf.org/html/draft-ietf-avtcore-rfc5764-mux-fixes
(
data
[
0
]
<
3
)
&&
// Magic cookie must match.
(
data
[
4
]
==
StunPacket
::
magicCookie
[
0
])
&&
(
data
[
5
]
==
StunPacket
::
magicCookie
[
1
])
&&
(
data
[
6
]
==
StunPacket
::
magicCookie
[
2
])
&&
(
data
[
7
]
==
StunPacket
::
magicCookie
[
3
])
);
// clang-format on
}
static
StunPacket
*
Parse
(
const
uint8_t
*
data
,
size_t
len
);
private
:
static
const
uint8_t
magicCookie
[];
public
:
StunPacket
(
Class
klass
,
Method
method
,
const
uint8_t
*
transactionId
,
const
uint8_t
*
data
,
size_t
size
);
~
StunPacket
();
void
Dump
()
const
;
Class
GetClass
()
const
{
return
this
->
klass
;
}
Method
GetMethod
()
const
{
return
this
->
method
;
}
const
uint8_t
*
GetData
()
const
{
return
this
->
data
;
}
size_t
GetSize
()
const
{
return
this
->
size
;
}
void
SetUsername
(
const
char
*
username
,
size_t
len
)
{
this
->
username
.
assign
(
username
,
len
);
}
void
SetPriority
(
uint32_t
priority
)
{
this
->
priority
=
priority
;
}
void
SetIceControlling
(
uint64_t
iceControlling
)
{
this
->
iceControlling
=
iceControlling
;
}
void
SetIceControlled
(
uint64_t
iceControlled
)
{
this
->
iceControlled
=
iceControlled
;
}
void
SetUseCandidate
()
{
this
->
hasUseCandidate
=
true
;
}
void
SetXorMappedAddress
(
const
struct
sockaddr
*
xorMappedAddress
)
{
this
->
xorMappedAddress
=
xorMappedAddress
;
}
void
SetErrorCode
(
uint16_t
errorCode
)
{
this
->
errorCode
=
errorCode
;
}
void
SetMessageIntegrity
(
const
uint8_t
*
messageIntegrity
)
{
this
->
messageIntegrity
=
messageIntegrity
;
}
void
SetFingerprint
()
{
this
->
hasFingerprint
=
true
;
}
const
std
::
string
&
GetUsername
()
const
{
return
this
->
username
;
}
uint32_t
GetPriority
()
const
{
return
this
->
priority
;
}
uint64_t
GetIceControlling
()
const
{
return
this
->
iceControlling
;
}
uint64_t
GetIceControlled
()
const
{
return
this
->
iceControlled
;
}
bool
HasUseCandidate
()
const
{
return
this
->
hasUseCandidate
;
}
uint16_t
GetErrorCode
()
const
{
return
this
->
errorCode
;
}
bool
HasMessageIntegrity
()
const
{
return
(
this
->
messageIntegrity
?
true
:
false
);
}
bool
HasFingerprint
()
const
{
return
this
->
hasFingerprint
;
}
Authentication
CheckAuthentication
(
const
std
::
string
&
localUsername
,
const
std
::
string
&
localPassword
);
StunPacket
*
CreateSuccessResponse
();
StunPacket
*
CreateErrorResponse
(
uint16_t
errorCode
);
void
Authenticate
(
const
std
::
string
&
password
);
void
Serialize
(
uint8_t
*
buffer
);
private
:
// Passed by argument.
Class
klass
;
// 2 bytes.
Method
method
;
// 2 bytes.
const
uint8_t
*
transactionId
{
nullptr
};
// 12 bytes.
uint8_t
*
data
{
nullptr
};
// Pointer to binary data.
size_t
size
{
0u
};
// The full message size (including header).
// STUN attributes.
std
::
string
username
;
// Less than 513 bytes.
uint32_t
priority
{
0u
};
// 4 bytes unsigned integer.
uint64_t
iceControlling
{
0u
};
// 8 bytes unsigned integer.
uint64_t
iceControlled
{
0u
};
// 8 bytes unsigned integer.
bool
hasUseCandidate
{
false
};
// 0 bytes.
const
uint8_t
*
messageIntegrity
{
nullptr
};
// 20 bytes.
bool
hasFingerprint
{
false
};
// 4 bytes.
const
struct
sockaddr
*
xorMappedAddress
{
nullptr
};
// 8 or 20 bytes.
uint16_t
errorCode
{
0u
};
// 4 bytes (no reason phrase).
std
::
string
password
;
};
}
// namespace RTC
#endif
This diff is collapsed.
Click to expand it.
webrtc/
utils.h
→
webrtc/
Utils.hpp
查看文件 @
bdf2783a
File moved
This diff is collapsed.
Click to expand it.
webrtc/
webrtc_transport.cc
→
webrtc/
WebRtcTransport.cpp
查看文件 @
bdf2783a
#include "
webrtc_t
ransport.h"
#include "
WebRtcT
ransport.h"
#include <iostream>
#include "Rtcp/Rtcp.h"
...
...
This diff is collapsed.
Click to expand it.
webrtc/
webrtc_t
ransport.h
→
webrtc/
WebRtcT
ransport.h
查看文件 @
bdf2783a
...
...
@@ -3,10 +3,10 @@
#include <memory>
#include <string>
#include "
rtc_dtls_transport.h
"
#include "
ice_server.h
"
#include "
srtp_session.h
"
#include "
stun_packet.h
"
#include "
DtlsTransport.hpp
"
#include "
IceServer.hpp
"
#include "
SrtpSession.hpp
"
#include "
StunPacket.hpp
"
class
WebRtcTransport
:
public
RTC
::
DtlsTransport
::
Listener
,
public
RTC
::
IceServer
::
Listener
{
public
:
...
...
This diff is collapsed.
Click to expand it.
webrtc/logger.h
查看文件 @
bdf2783a
...
...
@@ -2,9 +2,6 @@
#include <stdio.h>
#include <assert.h>
#define ELOG_DEBUG(fmt, ...) printf(fmt "\n", ##__VA_ARGS__)
#define ELOG_WARN(fmt, ...) printf(fmt "\n", ##__VA_ARGS__)
#define MS_TRACE()
#define MS_ERROR(fmt, ...) printf("error:" fmt "\n", ##__VA_ARGS__)
#define MS_THROW_ERROR(fmt, ...) do{ printf("throw:" fmt "\n", ##__VA_ARGS__); throw std::runtime_error("error"); } while(false);
...
...
This diff is collapsed.
Click to expand it.
webrtc/stun_packet.h
deleted
100644 → 0
查看文件 @
704421b7
#ifndef MS_RTC_STUN_PACKET_HPP
#define MS_RTC_STUN_PACKET_HPP
#include "logger.h"
#include "utils.h"
#include <string>
namespace
RTC
{
class
StunPacket
{
public
:
// STUN message class.
enum
class
Class
:
uint16_t
{
REQUEST
=
0
,
INDICATION
=
1
,
SUCCESS_RESPONSE
=
2
,
ERROR_RESPONSE
=
3
};
// STUN message method.
enum
class
Method
:
uint16_t
{
BINDING
=
1
};
// Attribute type.
enum
class
Attribute
:
uint16_t
{
MAPPED_ADDRESS
=
0x0001
,
USERNAME
=
0x0006
,
MESSAGE_INTEGRITY
=
0x0008
,
ERROR_CODE
=
0x0009
,
UNKNOWN_ATTRIBUTES
=
0x000A
,
REALM
=
0x0014
,
NONCE
=
0x0015
,
XOR_MAPPED_ADDRESS
=
0x0020
,
PRIORITY
=
0x0024
,
USE_CANDIDATE
=
0x0025
,
SOFTWARE
=
0x8022
,
ALTERNATE_SERVER
=
0x8023
,
FINGERPRINT
=
0x8028
,
ICE_CONTROLLED
=
0x8029
,
ICE_CONTROLLING
=
0x802A
};
// Authentication result.
enum
class
Authentication
{
OK
=
0
,
UNAUTHORIZED
=
1
,
BAD_REQUEST
=
2
};
public
:
static
bool
IsStun
(
const
uint8_t
*
data
,
size_t
len
);
static
StunPacket
*
Parse
(
const
uint8_t
*
data
,
size_t
len
);
private
:
static
const
uint8_t
kMagicCookie
[];
public
:
StunPacket
(
Class
klass
,
Method
method
,
const
uint8_t
*
transactionId
,
const
uint8_t
*
data
,
size_t
size
);
~
StunPacket
();
void
Dump
()
const
;
Class
GetClass
()
const
;
Method
GetMethod
()
const
;
const
uint8_t
*
GetData
()
const
;
size_t
GetSize
()
const
;
void
SetUsername
(
const
char
*
username
,
size_t
len
);
void
SetPriority
(
uint32_t
priority
);
void
SetIceControlling
(
uint64_t
iceControlling
);
void
SetIceControlled
(
uint64_t
iceControlled
);
void
SetUseCandidate
();
void
SetXorMappedAddress
(
const
struct
sockaddr
*
xorMappedAddress
);
void
SetErrorCode
(
uint16_t
errorCode
);
void
SetMessageIntegrity
(
const
uint8_t
*
messageIntegrity
);
void
SetFingerprint
();
const
std
::
string
&
GetUsername
()
const
;
uint32_t
GetPriority
()
const
;
uint64_t
GetIceControlling
()
const
;
uint64_t
GetIceControlled
()
const
;
bool
HasUseCandidate
()
const
;
uint16_t
GetErrorCode
()
const
;
bool
HasMessageIntegrity
()
const
;
bool
HasFingerprint
()
const
;
Authentication
CheckAuthentication
(
const
std
::
string
&
localUsername
,
const
std
::
string
&
localPassword
);
StunPacket
*
CreateSuccessResponse
();
StunPacket
*
CreateErrorResponse
(
uint16_t
errorCode
);
void
Authenticate
(
const
std
::
string
&
password
);
void
Serialize
(
uint8_t
*
buffer
);
private
:
// Passed by argument.
Class
klass
;
// 2 bytes.
Method
method
;
// 2 bytes.
const
uint8_t
*
transactionId
{
nullptr
};
// 12 bytes.
uint8_t
*
data
{
nullptr
};
// Pointer to binary data.
size_t
size
{
0
};
// The full message size (including header).
// STUN attributes.
std
::
string
username
;
// Less than 513 bytes.
uint32_t
priority
{
0
};
// 4 bytes unsigned integer.
uint64_t
iceControlling
{
0
};
// 8 bytes unsigned integer.
uint64_t
iceControlled
{
0
};
// 8 bytes unsigned integer.
bool
hasUseCandidate
{
false
};
// 0 bytes.
const
uint8_t
*
messageIntegrity
{
nullptr
};
// 20 bytes.
bool
hasFingerprint
{
false
};
// 4 bytes.
const
struct
sockaddr
*
xorMappedAddress
{
nullptr
};
// 8 or 20 bytes.
uint16_t
errorCode
{
0
};
// 4 bytes (no reason phrase).
std
::
string
password
;
};
/* Inline class methods. */
inline
bool
StunPacket
::
IsStun
(
const
uint8_t
*
data
,
size_t
len
)
{
// clang-format off
return
(
// STUN headers are 20 bytes.
(
len
>=
20
)
&&
// DOC: https://tools.ietf.org/html/draft-ietf-avtcore-rfc5764-mux-fixes
(
data
[
0
]
<
3
)
&&
// Magic cookie must match.
(
data
[
4
]
==
StunPacket
::
kMagicCookie
[
0
])
&&
(
data
[
5
]
==
StunPacket
::
kMagicCookie
[
1
])
&&
(
data
[
6
]
==
StunPacket
::
kMagicCookie
[
2
])
&&
(
data
[
7
]
==
StunPacket
::
kMagicCookie
[
3
])
);
// clang-format on
}
/* Inline instance methods. */
inline
StunPacket
::
Class
StunPacket
::
GetClass
()
const
{
return
this
->
klass
;
}
inline
StunPacket
::
Method
StunPacket
::
GetMethod
()
const
{
return
this
->
method
;
}
inline
const
uint8_t
*
StunPacket
::
GetData
()
const
{
return
this
->
data
;
}
inline
size_t
StunPacket
::
GetSize
()
const
{
return
this
->
size
;
}
inline
void
StunPacket
::
SetUsername
(
const
char
*
username
,
size_t
len
)
{
this
->
username
.
assign
(
username
,
len
);
}
inline
void
StunPacket
::
SetPriority
(
const
uint32_t
priority
)
{
this
->
priority
=
priority
;
}
inline
void
StunPacket
::
SetIceControlling
(
const
uint64_t
iceControlling
)
{
this
->
iceControlling
=
iceControlling
;
}
inline
void
StunPacket
::
SetIceControlled
(
const
uint64_t
iceControlled
)
{
this
->
iceControlled
=
iceControlled
;
}
inline
void
StunPacket
::
SetUseCandidate
()
{
this
->
hasUseCandidate
=
true
;
}
inline
void
StunPacket
::
SetXorMappedAddress
(
const
struct
sockaddr
*
xorMappedAddress
)
{
this
->
xorMappedAddress
=
xorMappedAddress
;
}
inline
void
StunPacket
::
SetErrorCode
(
uint16_t
errorCode
)
{
this
->
errorCode
=
errorCode
;
}
inline
void
StunPacket
::
SetMessageIntegrity
(
const
uint8_t
*
messageIntegrity
)
{
this
->
messageIntegrity
=
messageIntegrity
;
}
inline
void
StunPacket
::
SetFingerprint
()
{
this
->
hasFingerprint
=
true
;
}
inline
const
std
::
string
&
StunPacket
::
GetUsername
()
const
{
return
this
->
username
;
}
inline
uint32_t
StunPacket
::
GetPriority
()
const
{
return
this
->
priority
;
}
inline
uint64_t
StunPacket
::
GetIceControlling
()
const
{
return
this
->
iceControlling
;
}
inline
uint64_t
StunPacket
::
GetIceControlled
()
const
{
return
this
->
iceControlled
;
}
inline
bool
StunPacket
::
HasUseCandidate
()
const
{
return
this
->
hasUseCandidate
;
}
inline
uint16_t
StunPacket
::
GetErrorCode
()
const
{
return
this
->
errorCode
;
}
inline
bool
StunPacket
::
HasMessageIntegrity
()
const
{
return
(
this
->
messageIntegrity
?
true
:
false
);
}
inline
bool
StunPacket
::
HasFingerprint
()
const
{
return
this
->
hasFingerprint
;
}
}
// namespace RTC
#endif
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论