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
9f16cc12
Commit
9f16cc12
authored
Oct 24, 2018
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
简化命名空间
parent
ed1402e9
显示空白字符变更
内嵌
并排
正在显示
133 个修改的文件
包含
453 行增加
和
789 行删除
+453
-789
ZLToolKit
+1
-1
c_wrapper/src/common.cpp
+1
-4
c_wrapper/src/flvrecorder.cpp
+1
-1
c_wrapper/src/httpdownloader.cpp
+1
-3
c_wrapper/src/media.cpp
+1
-2
c_wrapper/src/player.cpp
+1
-5
c_wrapper/src/proxyplayer.cpp
+1
-2
src/Codec/AACEncoder.cpp
+3
-5
src/Codec/AACEncoder.h
+2
-4
src/Codec/H264Encoder.cpp
+4
-5
src/Codec/H264Encoder.h
+2
-4
src/Common/Factory.cpp
+4
-0
src/Common/Factory.h
+4
-1
src/Common/MediaSource.cpp
+4
-8
src/Common/MediaSource.h
+3
-6
src/Common/config.cpp
+3
-3
src/Common/config.h
+4
-4
src/Device/Device.cpp
+5
-7
src/Device/Device.h
+3
-8
src/Device/MediaSourceMaker.cpp
+9
-0
src/Device/MediaSourceMaker.h
+24
-0
src/Device/PlayerProxy.cpp
+3
-6
src/Device/PlayerProxy.h
+4
-5
src/H264/H264Parser.cpp
+1
-1
src/H264/h264_parser.cpp
+1
-2
src/H264/h264_poc.cpp
+1
-2
src/H264/macros.h
+1
-1
src/Http/HttpClient.cpp
+2
-4
src/Http/HttpClient.h
+3
-20
src/Http/HttpClientImp.cpp
+3
-5
src/Http/HttpClientImp.h
+4
-5
src/Http/HttpCookie.cpp
+3
-5
src/Http/HttpCookie.h
+2
-4
src/Http/HttpDownloader.cpp
+3
-6
src/Http/HttpDownloader.h
+2
-4
src/Http/HttpRequestSplitter.cpp
+3
-5
src/Http/HttpRequestSplitter.h
+2
-4
src/Http/HttpRequester.cpp
+2
-5
src/Http/HttpRequester.h
+2
-4
src/Http/HttpSession.cpp
+16
-19
src/Http/HttpSession.h
+3
-6
src/Http/HttpsSession.h
+3
-5
src/Http/WebSocketSplitter.cpp
+3
-25
src/Http/WebSocketSplitter.h
+2
-4
src/Http/strCoding.cpp
+2
-4
src/Http/strCoding.h
+2
-4
src/MediaFile/HLSMaker.cpp
+3
-6
src/MediaFile/HLSMaker.h
+3
-6
src/MediaFile/MediaReader.cpp
+6
-10
src/MediaFile/MediaReader.h
+3
-8
src/MediaFile/MediaRecorder.cpp
+9
-13
src/MediaFile/MediaRecorder.h
+3
-8
src/MediaFile/Mp4Maker.cpp
+7
-10
src/MediaFile/Mp4Maker.h
+3
-8
src/MediaFile/TSMaker.cpp
+1
-2
src/MediaFile/TSMaker.h
+1
-2
src/Player/Frame.cpp
+5
-0
src/Player/Frame.h
+3
-3
src/Player/MediaPlayer.cpp
+3
-7
src/Player/MediaPlayer.h
+3
-9
src/Player/Player.cpp
+1
-3
src/Player/Player.h
+1
-0
src/Player/PlayerBase.cpp
+3
-8
src/Player/PlayerBase.h
+3
-9
src/Player/Track.h
+3
-2
src/Rtmp/FlvMuxer.cpp
+2
-4
src/Rtmp/FlvMuxer.h
+3
-6
src/Rtmp/Rtmp.h
+1
-4
src/Rtmp/RtmpMediaSource.h
+3
-9
src/Rtmp/RtmpParser.cpp
+2
-28
src/Rtmp/RtmpParser.h
+3
-8
src/Rtmp/RtmpPlayer.cpp
+3
-6
src/Rtmp/RtmpPlayer.h
+3
-9
src/Rtmp/RtmpPlayerImp.h
+3
-7
src/Rtmp/RtmpProtocol.cpp
+3
-5
src/Rtmp/RtmpProtocol.h
+3
-6
src/Rtmp/RtmpPusher.cpp
+3
-6
src/Rtmp/RtmpPusher.h
+2
-4
src/Rtmp/RtmpSession.cpp
+4
-6
src/Rtmp/RtmpSession.h
+3
-7
src/Rtmp/RtmpToRtspMediaSource.cpp
+5
-9
src/Rtmp/RtmpToRtspMediaSource.h
+3
-8
src/Rtmp/amf.cpp
+1
-3
src/Rtmp/utils.cpp
+1
-3
src/RtmpCodec/AACRtmpCodec.cpp
+3
-13
src/RtmpCodec/AACRtmpCodec.h
+2
-4
src/RtmpCodec/H264RtmpCodec.cpp
+2
-14
src/RtmpCodec/H264RtmpCodec.h
+4
-2
src/RtmpCodec/RtmpCodec.cpp
+4
-0
src/RtmpCodec/RtmpCodec.h
+3
-9
src/RtpCodec/AACRtpCodec.cpp
+4
-1
src/RtpCodec/AACRtpCodec.h
+2
-0
src/RtpCodec/H264RtpCodec.cpp
+5
-1
src/RtpCodec/H264RtpCodec.h
+3
-1
src/RtpCodec/RtpCodec.h
+3
-4
src/RtpCodec/RtpMaker.h
+4
-7
src/RtpCodec/RtpMakerAAC.cpp
+5
-8
src/RtpCodec/RtpMakerAAC.h
+3
-5
src/RtpCodec/RtpMakerH264.cpp
+5
-8
src/RtpCodec/RtpMakerH264.h
+4
-6
src/Rtsp/RtpBroadCaster.cpp
+6
-11
src/Rtsp/RtpBroadCaster.h
+5
-8
src/Rtsp/RtpParser.cpp
+2
-4
src/Rtsp/RtpParser.h
+3
-6
src/Rtsp/Rtsp.h
+2
-1
src/Rtsp/RtspMaker.cpp
+3
-5
src/Rtsp/RtspMaker.h
+2
-4
src/Rtsp/RtspMediaSource.h
+3
-7
src/Rtsp/RtspPlayer.cpp
+5
-8
src/Rtsp/RtspPlayer.h
+3
-9
src/Rtsp/RtspPlayerImp.h
+3
-6
src/Rtsp/RtspSdp.cpp
+3
-0
src/Rtsp/RtspSdp.h
+2
-4
src/Rtsp/RtspSession.cpp
+5
-8
src/Rtsp/RtspSession.h
+3
-10
src/Rtsp/RtspToRtmpMediaSource.cpp
+4
-8
src/Rtsp/RtspToRtmpMediaSource.h
+3
-6
src/Rtsp/UDPServer.cpp
+3
-6
src/Rtsp/UDPServer.h
+3
-6
src/Shell/ShellCMD.cpp
+4
-8
src/Shell/ShellSession.cpp
+4
-8
src/Shell/ShellSession.h
+3
-8
tests/DeviceHK/DeviceHK.cpp
+2
-4
tests/DeviceHK/DeviceHK.h
+3
-5
tests/H264Decoder.h
+2
-4
tests/YuvDisplayer.h
+2
-1
tests/test_benchmark.cpp
+2
-6
tests/test_httpApi.cpp
+6
-8
tests/test_httpClient.cpp
+2
-5
tests/test_player.cpp
+2
-6
tests/test_rtmpPusher.cpp
+3
-6
tests/test_rtmpPusherMp4.cpp
+3
-6
tests/test_server.cpp
+27
-34
没有找到文件。
ZLToolKit
@
6e69a082
Subproject commit
d7487e37dd915e8391c1d6a45f1773af13b366a7
Subproject commit
6e69a082a2f6e6161785b00c7421bf1a811ed34a
c_wrapper/src/common.cpp
查看文件 @
9f16cc12
...
...
@@ -39,10 +39,7 @@
#include "cleaner.h"
using
namespace
std
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Rtmp
;
using
namespace
ZL
::
Rtsp
;
using
namespace
ZL
::
Http
;
using
namespace
toolkit
;
static
TcpServer
::
Ptr
s_pRtspSrv
;
static
TcpServer
::
Ptr
s_pRtmpSrv
;
...
...
c_wrapper/src/flvrecorder.cpp
查看文件 @
9f16cc12
...
...
@@ -5,7 +5,7 @@
#include "flvrecorder.h"
#include "Rtmp/FlvMuxer.h"
using
namespace
ZL
::
Rtmp
;
using
namespace
toolkit
;
API_EXPORT
FlvRecorderContex
API_CALL
createFlvRecorder
(){
DebugL
;
...
...
c_wrapper/src/httpdownloader.cpp
查看文件 @
9f16cc12
...
...
@@ -33,9 +33,7 @@
#include "cleaner.h"
using
namespace
std
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Http
;
using
namespace
toolkit
;
static
recursive_mutex
s_mtxMapDownloader
;
static
unordered_map
<
void
*
,
HttpDownloader
::
Ptr
>
s_mapDownloader
;
...
...
c_wrapper/src/media.cpp
查看文件 @
9f16cc12
...
...
@@ -32,8 +32,7 @@
#include "cleaner.h"
using
namespace
std
;
using
namespace
ZL
::
DEV
;
using
namespace
ZL
::
Util
;
using
namespace
toolkit
;
static
recursive_mutex
s_mtxMapMedia
;
static
unordered_map
<
void
*
,
DevChannel
::
Ptr
>
s_mapMedia
;
...
...
c_wrapper/src/player.cpp
查看文件 @
9f16cc12
...
...
@@ -35,11 +35,7 @@
#include "cleaner.h"
using
namespace
std
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Thread
;
using
namespace
ZL
::
Player
;
using
namespace
ZL
::
Rtmp
;
using
namespace
ZL
::
Rtsp
;
using
namespace
toolkit
;
static
recursive_mutex
s_mtxMapPlayer
;
static
unordered_map
<
void
*
,
MediaPlayer
::
Ptr
>
s_mapPlayer
;
...
...
c_wrapper/src/proxyplayer.cpp
查看文件 @
9f16cc12
...
...
@@ -28,8 +28,7 @@
#include "Device/PlayerProxy.h"
#include "Util/onceToken.h"
using
namespace
ZL
::
DEV
;
using
namespace
ZL
::
Util
;
using
namespace
toolkit
;
static
recursive_mutex
s_mtxMapProxyPlayer
;
static
unordered_map
<
void
*
,
PlayerProxy
::
Ptr
>
s_mapProxyPlayer
;
...
...
src/Codec/AACEncoder.cpp
查看文件 @
9f16cc12
...
...
@@ -38,10 +38,9 @@ extern "C" {
}
#endif
using
namespace
ZL
::
Util
;
using
namespace
toolkit
;
namespace
ZL
{
namespace
Codec
{
namespace
mediakit
{
AACEncoder
::
AACEncoder
()
{
...
...
@@ -117,8 +116,7 @@ int AACEncoder::inputData(char *pcPcmBufr, int iLen, unsigned char **ppucOutBuff
return
nRet
;
}
}
/* namespace Codec */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif //ENABLE_FAAC
...
...
src/Codec/AACEncoder.h
查看文件 @
9f16cc12
...
...
@@ -28,8 +28,7 @@
#ifndef CODEC_AACENCODER_H_
#define CODEC_AACENCODER_H_
namespace
ZL
{
namespace
Codec
{
namespace
mediakit
{
class
AACEncoder
{
public
:
...
...
@@ -51,7 +50,6 @@ private:
};
}
/* namespace Codec */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif
/* CODEC_AACENCODER_H_ */
src/Codec/H264Encoder.cpp
查看文件 @
9f16cc12
...
...
@@ -28,10 +28,10 @@
#include "H264Encoder.h"
#include "Util/TimeTicker.h"
using
namespace
ZL
::
Util
;
namespace
ZL
{
namespace
Codec
{
using
namespace
toolkit
;
namespace
mediakit
{
H264Encoder
::
H264Encoder
()
{
...
...
@@ -347,8 +347,7 @@ int H264Encoder::inputData(char* apcYuv[3], int aiYuvLen[3], int64_t i64Pts, H26
return
iNal
;
}
}
/* namespace Codec */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif //ENABLE_X264
...
...
src/Codec/H264Encoder.h
查看文件 @
9f16cc12
...
...
@@ -38,8 +38,7 @@ extern "C" {
}
#endif //__cplusplus
namespace
ZL
{
namespace
Codec
{
namespace
mediakit
{
class
H264Encoder
{
public
:
...
...
@@ -60,7 +59,6 @@ private:
H264Frame
_aFrames
[
10
];
};
}
/* namespace Codec */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif
/* CODEC_H264ENCODER_H_ */
src/Common/Factory.cpp
查看文件 @
9f16cc12
...
...
@@ -4,6 +4,8 @@
#include "Factory.h"
namespace
mediakit
{
Sdp
::
Ptr
Factory
::
getSdpByTrack
(
const
Track
::
Ptr
&
track
)
{
switch
(
track
->
getCodecId
()){
case
CodecH264
:{
...
...
@@ -101,3 +103,5 @@ RtpCodec::Ptr Factory::getRtpDecoderById(CodecId codecId, uint32_t ui32SampleRat
}
}
}
//namespace mediakit
src/Common/Factory.h
查看文件 @
9f16cc12
...
...
@@ -10,7 +10,9 @@
#include "Rtsp/RtspSdp.h"
using
namespace
std
;
using
namespace
ZL
::
Rtsp
;
using
namespace
toolkit
;
namespace
mediakit
{
class
Factory
{
public
:
...
...
@@ -53,5 +55,6 @@ public:
static
RtpCodec
::
Ptr
getRtpDecoderById
(
CodecId
codecId
,
uint32_t
ui32SampleRate
);
};
}
//namespace mediakit
#endif //ZLMEDIAKIT_FACTORY_H
src/Common/MediaSource.cpp
查看文件 @
9f16cc12
...
...
@@ -31,12 +31,9 @@
#include "Rtsp/Rtsp.h"
#include "Network/sockutil.h"
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Network
;
using
namespace
ZL
::
MediaFile
;
using
namespace
toolkit
;
namespace
ZL
{
namespace
Media
{
namespace
mediakit
{
recursive_mutex
MediaSource
::
g_mtxMediaSrc
;
MediaSource
::
SchemaVhostAppStreamMap
MediaSource
::
g_mapMediaSrc
;
...
...
@@ -174,5 +171,4 @@ void MediaInfo::parse(const string &url){
}
}
/* namespace Media */
}
/* namespace ZL */
\ No newline at end of file
}
/* namespace mediakit */
\ No newline at end of file
src/Common/MediaSource.h
查看文件 @
9f16cc12
...
...
@@ -40,11 +40,9 @@
#include "Rtsp/Rtsp.h"
using
namespace
std
;
using
namespace
Config
;
using
namespace
ZL
::
Util
;
using
namespace
toolkit
;
namespace
ZL
{
namespace
Media
{
namespace
mediakit
{
class
MediaSourceEvent
{
...
...
@@ -234,8 +232,7 @@ private:
static
recursive_mutex
g_mtxMediaSrc
;
//访问静态的媒体源表的互斥锁
};
}
/* namespace Media */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif //ZLMEDIAKIT_MEDIASOURCE_H
src/Common/config.cpp
查看文件 @
9f16cc12
...
...
@@ -30,9 +30,9 @@
#include "Util/onceToken.h"
#include "Network/sockutil.h"
using
namespace
ZL
::
Network
;
using
namespace
toolkit
;
namespace
Config
{
namespace
mediakit
{
bool
loadIniConfig
(
const
char
*
ini_path
){
string
ini
;
...
...
@@ -293,6 +293,6 @@ onceToken token([](){
}
//namespace Hls
}
// namespace
Config
}
// namespace
mediakit
src/Common/config.h
查看文件 @
9f16cc12
...
...
@@ -34,9 +34,9 @@
#include "Util/NoticeCenter.h"
using
namespace
std
;
using
namespace
ZL
::
Util
;
using
namespace
toolkit
;
namespace
Config
{
namespace
mediakit
{
//加载配置文件,如果配置文件不存在,那么会导出默认配置并生成配置文件
//加载配置文件成功后会触发kBroadcastUpdateConfig广播
...
...
@@ -131,7 +131,7 @@ extern const char kBroadcastReloadConfig[];
#define RELOAD_KEY_REGISTER(arg,key) \
do{ \
static onceToken s_token([](){ \
NoticeCenter::Instance().addListener(ReloadConfigTag,
Config::
Broadcast::kBroadcastReloadConfig,[](BroadcastReloadConfigArgs){ \
NoticeCenter::Instance().addListener(ReloadConfigTag,Broadcast::kBroadcastReloadConfig,[](BroadcastReloadConfigArgs){ \
RELOAD_KEY(arg,key); \
}); \
}); \
...
...
@@ -234,6 +234,6 @@ extern const char kFileBufSize[];
extern
const
char
kFilePath
[];
}
//namespace Hls
}
// namespace
Config
}
// namespace
mediakit
#endif
/* COMMON_CONFIG_H */
src/Device/Device.cpp
查看文件 @
9f16cc12
...
...
@@ -31,10 +31,9 @@
#include "Util/base64.h"
#include "Util/TimeTicker.h"
using
namespace
ZL
::
Util
;
using
namespace
toolkit
;
namespace
ZL
{
namespace
DEV
{
namespace
mediakit
{
DevChannel
::
DevChannel
(
const
char
*
strVhost
,
const
char
*
strApp
,
...
...
@@ -107,7 +106,7 @@ void DevChannel::inputH264(const char* pcData, int iDataLen, uint32_t uiStamp) {
auto
lam
=
[
this
](
const
RtpPacket
::
Ptr
&
pkt
,
bool
bKeyPos
)
{
onGetRTP
(
pkt
,
bKeyPos
);
};
GET_CONFIG_AND_REGISTER
(
uint32_t
,
videoMtu
,
Config
::
Rtp
::
kVideoMtuSize
);
GET_CONFIG_AND_REGISTER
(
uint32_t
,
videoMtu
,
Rtp
::
kVideoMtuSize
);
_pRtpMaker_h264
.
reset
(
new
RtpMaker_H264
(
lam
,
ui32Ssrc
,
videoMtu
));
}
if
(
!
_bSdp_gotH264
&&
_video
)
{
...
...
@@ -139,7 +138,7 @@ void DevChannel::inputAAC(const char *pcDataWithoutAdts,int iDataLen, uint32_t u
auto
lam
=
[
this
](
const
RtpPacket
::
Ptr
&
pkt
,
bool
keyPos
)
{
onGetRTP
(
pkt
,
keyPos
);
};
GET_CONFIG_AND_REGISTER
(
uint32_t
,
audioMtu
,
Config
::
Rtp
::
kAudioMtuSize
);
GET_CONFIG_AND_REGISTER
(
uint32_t
,
audioMtu
,
Rtp
::
kAudioMtuSize
);
_pRtpMaker_aac
.
reset
(
new
RtpMaker_AAC
(
lam
,
ssrc
,
audioMtu
,
_audio
->
iSampleRate
));
}
if
(
!
_bSdp_gotAAC
&&
_audio
&&
pcAdtsHeader
)
{
...
...
@@ -304,6 +303,5 @@ void DevChannel::initAudio(const AudioInfo& info) {
_pAdtsHeader
->
no_raw_data_blocks_in_frame
=
0
;
}
}
/* namespace DEV */
}
/* namespace ZL */
}
/* namespace mediakit */
src/Device/Device.h
查看文件 @
9f16cc12
...
...
@@ -39,22 +39,18 @@
#include "Util/TimeTicker.h"
using
namespace
std
;
using
namespace
ZL
::
Rtsp
;
using
namespace
ZL
::
Util
;
using
namespace
toolkit
;
#ifdef ENABLE_FAAC
#include "Codec/AACEncoder.h"
using
namespace
ZL
::
Codec
;
#endif //ENABLE_FAAC
#ifdef ENABLE_X264
#include "Codec/H264Encoder.h"
using
namespace
ZL
::
Codec
;
#endif //ENABLE_X264
namespace
ZL
{
namespace
DEV
{
namespace
mediakit
{
class
VideoInfo
{
public
:
...
...
@@ -124,7 +120,6 @@ private:
};
}
/* namespace DEV */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif
/* DEVICE_DEVICE_H_ */
src/Device/MediaSourceMaker.cpp
0 → 100644
查看文件 @
9f16cc12
//
// Created by xzl on 2018/10/24.
//
#include "MediaSourceMaker.h"
namespace
mediakit
{
}
\ No newline at end of file
src/Device/MediaSourceMaker.h
0 → 100644
查看文件 @
9f16cc12
//
// Created by xzl on 2018/10/24.
//
#ifndef ZLMEDIAKIT_MEDIASOURCEMAKER_H
#define ZLMEDIAKIT_MEDIASOURCEMAKER_H
#include "Player/Track.h"
#include "Rtsp/RtspMediaSource.h"
#include "Rtmp/RtmpMediaSource.h"
namespace
mediakit
{
class
MediaSourceMaker
{
public
:
MediaSourceMaker
()
{}
virtual
~
MediaSourceMaker
()
{}
private
:
RtspMediaSource
::
Ptr
_rtspSrc
;
RtmpMediaSource
::
Ptr
_rtmpSrc
;
};
}
//namespace mediakit
#endif //ZLMEDIAKIT_MEDIASOURCEMAKER_H
src/Device/PlayerProxy.cpp
查看文件 @
9f16cc12
...
...
@@ -32,11 +32,9 @@
#include "Util/logger.h"
#include "Thread/AsyncTaskThread.h"
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Thread
;
using
namespace
toolkit
;
namespace
ZL
{
namespace
DEV
{
namespace
mediakit
{
static
uint8_t
s_mute_adts
[]
=
{
0xff
,
0xf1
,
0x6c
,
0x40
,
0x2d
,
0x3f
,
0xfc
,
0x00
,
0xe0
,
0x34
,
0x20
,
0xad
,
0xf2
,
0x3f
,
0xb5
,
0xdd
,
0x73
,
0xac
,
0xbd
,
0xca
,
0xd7
,
0x7d
,
0x4a
,
0x13
,
0x2d
,
0x2e
,
0xa2
,
0x62
,
0x02
,
0x70
,
0x3c
,
0x1c
,
...
...
@@ -220,5 +218,4 @@ void PlayerProxy::makeMuteAudio(uint32_t stamp) {
}
}
/* namespace Player */
}
/* namespace ZL */
}
/* namespace mediakit */
src/Device/PlayerProxy.h
查看文件 @
9f16cc12
...
...
@@ -33,10 +33,10 @@
#include "Util/TimeTicker.h"
using
namespace
std
;
using
namespace
ZL
::
Player
;
using
namespace
toolkit
;
namespace
ZL
{
namespace
DEV
{
namespace
mediakit
{
class
PlayerProxy
:
public
MediaPlayer
,
public
std
::
enable_shared_from_this
<
PlayerProxy
>
,
public
MediaSourceEvent
{
public
:
...
...
@@ -71,7 +71,6 @@ private:
int
_iAudioIndex
=
0
;
};
}
/* namespace Player */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif
/* SRC_DEVICE_PLAYERPROXY_H_ */
src/H264/H264Parser.cpp
查看文件 @
9f16cc12
...
...
@@ -26,8 +26,8 @@
#include "H264Parser.h"
#include "Util/logger.h"
using
namespace
toolkit
;
using
namespace
ZL
::
Util
;
H264Parser
::
H264Parser
(){
...
...
src/H264/h264_parser.cpp
查看文件 @
9f16cc12
...
...
@@ -7,8 +7,7 @@
#include <memory>
#include "macros.h"
#include "Util/logger.h"
using
namespace
ZL
::
Util
;
using
namespace
toolkit
;
template
<
class
ForwardIterator
>
void
STLDeleteContainerPairSecondPointers
(
ForwardIterator
begin
,
...
...
src/H264/h264_poc.cpp
查看文件 @
9f16cc12
...
...
@@ -8,8 +8,7 @@
#include "macros.h"
#include "h264_parser.h"
#include "h264_poc.h"
using
namespace
ZL
::
Util
;
using
namespace
toolkit
;
namespace
media
{
...
...
src/H264/macros.h
查看文件 @
9f16cc12
...
...
@@ -88,7 +88,7 @@ static type& name = *new type arguments
#include <assert.h>
#include "Util/logger.h"
using
namespace
ZL
::
Util
;
using
namespace
toolkit
;
#define DCHECK(x) if(!(x)) { ErrorL << "DCHECK " << #x <<endl; }
#define DCHECK_GT(x,y) if(!((x) > (y))) { ErrorL << "DCHECK_GT:" << #x << #y << endl; }
...
...
src/Http/HttpClient.cpp
查看文件 @
9f16cc12
...
...
@@ -27,8 +27,7 @@
#include "HttpClient.h"
#include "Rtsp/Rtsp.h"
namespace
ZL
{
namespace
Http
{
namespace
mediakit
{
HttpClient
::
HttpClient
()
{
...
...
@@ -272,6 +271,5 @@ void HttpClient::checkCookie(HttpClient::HttpHeader &headers) {
}
}
/* namespace Http */
}
/* namespace ZL */
}
/* namespace mediakit */
src/Http/HttpClient.h
查看文件 @
9f16cc12
...
...
@@ -38,11 +38,9 @@
#include "HttpCookie.h"
using
namespace
std
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Network
;
using
namespace
toolkit
;
namespace
ZL
{
namespace
Http
{
namespace
mediakit
{
class
HttpArgs
:
public
StrCaseMap
{
public
:
...
...
@@ -311,21 +309,6 @@ private:
float
_fTimeOutSec
=
0
;
};
}
/* namespace Http */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif
/* Http_HttpClient_h */
src/Http/HttpClientImp.cpp
查看文件 @
9f16cc12
...
...
@@ -24,10 +24,9 @@
* SOFTWARE.
*/
#include
<Http/HttpClientImp.h>
#include
"Http/HttpClientImp.h"
namespace
ZL
{
namespace
Http
{
namespace
mediakit
{
HttpClientImp
::
HttpClientImp
()
{
// TODO Auto-generated constructor stub
...
...
@@ -87,5 +86,4 @@ int HttpClientImp::send(const Buffer::Ptr &buf) {
}
#endif //ENABLE_OPENSSL
}
/* namespace Http */
}
/* namespace ZL */
}
/* namespace mediakit */
src/Http/HttpClientImp.h
查看文件 @
9f16cc12
...
...
@@ -30,11 +30,11 @@
#include "HttpClient.h"
#ifdef ENABLE_OPENSSL
#include "Util/SSLBox.h"
using
namespace
ZL
::
Util
;
#endif //ENABLE_OPENSSL
namespace
ZL
{
namespace
Http
{
using
namespace
toolkit
;
namespace
mediakit
{
class
HttpClientImp
:
public
HttpClient
{
public
:
...
...
@@ -59,7 +59,6 @@ private:
#endif //ENABLE_OPENSSL
};
}
/* namespace Http */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif
/* SRC_HTTP_HTTPCLIENTIMP_H_ */
src/Http/HttpCookie.cpp
查看文件 @
9f16cc12
...
...
@@ -26,10 +26,9 @@
#include "HttpCookie.h"
#include "Util/util.h"
using
namespace
ZL
::
Util
;
using
namespace
toolkit
;
namespace
ZL
{
namespace
Http
{
namespace
mediakit
{
void
HttpCookie
::
setPath
(
const
string
&
path
){
_path
=
path
;
...
...
@@ -104,5 +103,4 @@ vector<HttpCookie::Ptr> HttpCookieStorage::get(const string &host, const string
}
}
/* namespace Http */
}
/* namespace ZL */
}
/* namespace mediakit */
src/Http/HttpCookie.h
查看文件 @
9f16cc12
...
...
@@ -34,8 +34,7 @@
#include <mutex>
using
namespace
std
;
namespace
ZL
{
namespace
Http
{
namespace
mediakit
{
class
HttpCookie
{
public
:
...
...
@@ -75,7 +74,6 @@ private:
};
}
/* namespace Http */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif //ZLMEDIAKIT_HTTPCOOKIE_H
src/Http/HttpDownloader.cpp
查看文件 @
9f16cc12
...
...
@@ -27,11 +27,9 @@
#include "HttpDownloader.h"
#include "Util/MD5.h"
#include "Util/File.h"
using
namespace
toolkit
;
using
namespace
ZL
::
Util
;
namespace
ZL
{
namespace
Http
{
namespace
mediakit
{
HttpDownloader
::
HttpDownloader
()
{
...
...
@@ -115,5 +113,4 @@ void HttpDownloader::closeFile() {
}
}
/* namespace Http */
}
/* namespace ZL */
}
/* namespace mediakit */
src/Http/HttpDownloader.h
查看文件 @
9f16cc12
...
...
@@ -29,8 +29,7 @@
#include "HttpClientImp.h"
namespace
ZL
{
namespace
Http
{
namespace
mediakit
{
class
HttpDownloader
:
public
HttpClientImp
{
public
:
...
...
@@ -60,7 +59,6 @@ private:
bool
_bDownloadSuccess
=
false
;
};
}
/* namespace Http */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif
/* SRC_HTTP_HTTPDOWNLOADER_H_ */
src/Http/HttpRequestSplitter.cpp
查看文件 @
9f16cc12
...
...
@@ -28,10 +28,9 @@
#include "HttpRequestSplitter.h"
#include "Util/logger.h"
#include "Util/util.h"
using
namespace
ZL
::
Util
;
using
namespace
toolkit
;
namespace
ZL
{
namespace
Http
{
namespace
mediakit
{
void
HttpRequestSplitter
::
input
(
const
char
*
data
,
uint64_t
len
)
{
const
char
*
ptr
=
data
;
...
...
@@ -126,6 +125,5 @@ void HttpRequestSplitter::reset() {
}
}
/* namespace Http */
}
/* namespace ZL */
}
/* namespace mediakit */
src/Http/HttpRequestSplitter.h
查看文件 @
9f16cc12
...
...
@@ -30,8 +30,7 @@
#include <string>
using
namespace
std
;
namespace
ZL
{
namespace
Http
{
namespace
mediakit
{
class
HttpRequestSplitter
{
public
:
...
...
@@ -79,7 +78,6 @@ private:
int64_t
_content_len
=
0
;
};
}
/* namespace Http */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif //ZLMEDIAKIT_HTTPREQUESTSPLITTER_H
src/Http/HttpRequester.cpp
查看文件 @
9f16cc12
...
...
@@ -25,8 +25,7 @@
*/
#include "HttpRequester.h"
namespace
ZL
{
namespace
Http
{
namespace
mediakit
{
HttpRequester
::
HttpRequester
(){
...
...
@@ -63,6 +62,4 @@ void HttpRequester::startRequester(const string &url,const HttpRequesterResult &
}
}
//namespace Http
}
//namespace ZL
}
//namespace mediakit
src/Http/HttpRequester.h
查看文件 @
9f16cc12
...
...
@@ -29,8 +29,7 @@
#include "HttpClientImp.h"
namespace
ZL
{
namespace
Http
{
namespace
mediakit
{
class
HttpRequester
:
public
HttpClientImp
{
...
...
@@ -50,7 +49,6 @@ private:
HttpRequesterResult
_onResult
;
};
}
//namespace Http
}
//namespace ZL
}
//namespace mediakit
#endif
/* Htt_HttpRequester_h */
src/Http/HttpSession.cpp
查看文件 @
9f16cc12
...
...
@@ -43,11 +43,9 @@
#include "Util/base64.h"
#include "Util/SHA1.h"
#include "Rtmp/utils.h"
using
namespace
toolkit
;
using
namespace
ZL
::
Util
;
namespace
ZL
{
namespace
Http
{
namespace
mediakit
{
static
int
kSockFlags
=
SOCKET_DEFAULE_FLAGS
|
FLAG_MORE
;
...
...
@@ -109,7 +107,7 @@ HttpSession::HttpSession(const std::shared_ptr<ThreadPool> &pTh, const Socket::P
//设置15秒发送超时时间
pSock
->
setSendTimeOutSecond
(
15
);
GET_CONFIG_AND_REGISTER
(
string
,
rootPath
,
Config
::
Http
::
kRootPath
);
GET_CONFIG_AND_REGISTER
(
string
,
rootPath
,
Http
::
kRootPath
);
_strPath
=
rootPath
;
}
...
...
@@ -178,7 +176,7 @@ void HttpSession::onError(const SockException& err) {
}
void
HttpSession
::
onManager
()
{
GET_CONFIG_AND_REGISTER
(
uint32_t
,
keepAliveSec
,
Config
::
Http
::
kKeepAliveSecond
);
GET_CONFIG_AND_REGISTER
(
uint32_t
,
keepAliveSec
,
Http
::
kKeepAliveSecond
);
if
(
_ticker
.
elapsedTime
()
>
keepAliveSec
*
1000
){
//1分钟超时
...
...
@@ -298,7 +296,7 @@ inline bool HttpSession::Handle_Req_GET(int64_t &content_len) {
string
strFile
=
_strPath
+
"/"
+
_mediaInfo
.
_vhost
+
_parser
.
Url
();
/////////////HTTP连接是否需要被关闭////////////////
GET_CONFIG_AND_REGISTER
(
uint32_t
,
reqCnt
,
Config
::
Http
::
kMaxReqCount
);
GET_CONFIG_AND_REGISTER
(
uint32_t
,
reqCnt
,
Http
::
kMaxReqCount
);
bool
bClose
=
(
strcasecmp
(
_parser
[
"Connection"
].
data
(),
"close"
)
==
0
)
||
(
++
_iReqCnt
>
reqCnt
);
//访问的是文件夹
...
...
@@ -369,7 +367,7 @@ inline bool HttpSession::Handle_Req_GET(int64_t &content_len) {
//回复Content部分
std
::
shared_ptr
<
int64_t
>
piLeft
(
new
int64_t
(
iRangeEnd
-
iRangeStart
+
1
));
GET_CONFIG_AND_REGISTER
(
uint32_t
,
sendBufSize
,
Config
::
Http
::
kSendBufSize
);
GET_CONFIG_AND_REGISTER
(
uint32_t
,
sendBufSize
,
Http
::
kSendBufSize
);
weak_ptr
<
HttpSession
>
weakSelf
=
dynamic_pointer_cast
<
HttpSession
>
(
shared_from_this
());
auto
onFlush
=
[
pFilePtr
,
bClose
,
weakSelf
,
piLeft
]()
{
...
...
@@ -529,9 +527,9 @@ inline void HttpSession::sendResponse(const char* pcStatus, const KeyValue& head
}
inline
HttpSession
::
KeyValue
HttpSession
::
makeHttpHeader
(
bool
bClose
,
int64_t
iContentSize
,
const
char
*
pcContentType
)
{
KeyValue
headerOut
;
GET_CONFIG_AND_REGISTER
(
string
,
charSet
,
Config
::
Http
::
kCharSet
);
GET_CONFIG_AND_REGISTER
(
uint32_t
,
keepAliveSec
,
Config
::
Http
::
kKeepAliveSecond
);
GET_CONFIG_AND_REGISTER
(
uint32_t
,
reqCnt
,
Config
::
Http
::
kMaxReqCount
);
GET_CONFIG_AND_REGISTER
(
string
,
charSet
,
Http
::
kCharSet
);
GET_CONFIG_AND_REGISTER
(
uint32_t
,
keepAliveSec
,
Http
::
kKeepAliveSecond
);
GET_CONFIG_AND_REGISTER
(
uint32_t
,
reqCnt
,
Http
::
kMaxReqCount
);
headerOut
.
emplace
(
"Date"
,
dateStr
());
headerOut
.
emplace
(
"Server"
,
SERVER_NAME
);
...
...
@@ -552,7 +550,7 @@ inline HttpSession::KeyValue HttpSession::makeHttpHeader(bool bClose, int64_t iC
string
HttpSession
::
urlDecode
(
const
string
&
str
){
auto
ret
=
strCoding
::
UrlUTF8Decode
(
str
);
#ifdef _WIN32
GET_CONFIG_AND_REGISTER
(
string
,
charSet
,
Config
::
Http
::
kCharSet
);
GET_CONFIG_AND_REGISTER
(
string
,
charSet
,
Http
::
kCharSet
);
bool
isGb2312
=
!
strcasecmp
(
charSet
.
data
(),
"gb2312"
);
if
(
isGb2312
)
{
ret
=
strCoding
::
UTF8ToGB2312
(
ret
);
...
...
@@ -570,7 +568,7 @@ inline void HttpSession::urlDecode(Parser &parser){
inline
bool
HttpSession
::
emitHttpEvent
(
bool
doInvoke
){
///////////////////是否断开本链接///////////////////////
GET_CONFIG_AND_REGISTER
(
uint32_t
,
reqCnt
,
Config
::
Http
::
kMaxReqCount
);
GET_CONFIG_AND_REGISTER
(
uint32_t
,
reqCnt
,
Http
::
kMaxReqCount
);
bool
bClose
=
(
strcasecmp
(
_parser
[
"Connection"
].
data
(),
"close"
)
==
0
)
||
(
++
_iReqCnt
>
reqCnt
);
auto
Origin
=
_parser
[
"Origin"
];
...
...
@@ -594,7 +592,7 @@ inline bool HttpSession::emitHttpEvent(bool doInvoke){
};
///////////////////广播HTTP事件///////////////////////////
bool
consumed
=
false
;
//该事件是否被消费
NoticeCenter
::
Instance
().
emitEvent
(
Config
::
Broadcast
::
kBroadcastHttpRequest
,
_parser
,
invoker
,
consumed
,
*
this
);
NoticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastHttpRequest
,
_parser
,
invoker
,
consumed
,
*
this
);
if
(
!
consumed
&&
doInvoke
){
//该事件无人消费,所以返回404
invoker
(
"404 Not Found"
,
KeyValue
(),
""
);
...
...
@@ -606,8 +604,8 @@ inline bool HttpSession::emitHttpEvent(bool doInvoke){
return
consumed
;
}
inline
bool
HttpSession
::
Handle_Req_POST
(
int64_t
&
content_len
)
{
GET_CONFIG_AND_REGISTER
(
uint64_t
,
maxReqSize
,
Config
::
Http
::
kMaxReqSize
);
GET_CONFIG_AND_REGISTER
(
int
,
maxReqCnt
,
Config
::
Http
::
kMaxReqCount
);
GET_CONFIG_AND_REGISTER
(
uint64_t
,
maxReqSize
,
Http
::
kMaxReqSize
);
GET_CONFIG_AND_REGISTER
(
int
,
maxReqCnt
,
Http
::
kMaxReqCount
);
int64_t
totalContentLen
=
_parser
[
"Content-Length"
].
empty
()
?
-
1
:
atoll
(
_parser
[
"Content-Length"
].
data
());
...
...
@@ -686,7 +684,7 @@ void HttpSession::responseDelay(const string &Origin,bool bClose,
sendResponse
(
codeOut
.
data
(),
headerOut
,
contentOut
);
}
inline
void
HttpSession
::
sendNotFound
(
bool
bClose
)
{
GET_CONFIG_AND_REGISTER
(
string
,
notFound
,
Config
::
Http
::
kNotFound
);
GET_CONFIG_AND_REGISTER
(
string
,
notFound
,
Http
::
kNotFound
);
sendResponse
(
"404 Not Found"
,
makeHttpHeader
(
bClose
,
notFound
.
size
()),
notFound
);
}
...
...
@@ -728,5 +726,4 @@ std::shared_ptr<FlvMuxer> HttpSession::getSharedPtr(){
return
dynamic_pointer_cast
<
FlvMuxer
>
(
shared_from_this
());
}
}
/* namespace Http */
}
/* namespace ZL */
}
/* namespace mediakit */
src/Http/HttpSession.h
查看文件 @
9f16cc12
...
...
@@ -37,11 +37,9 @@
#include "WebSocketSplitter.h"
using
namespace
std
;
using
namespace
ZL
::
Rtmp
;
using
namespace
ZL
::
Network
;
using
namespace
toolkit
;
namespace
ZL
{
namespace
Http
{
namespace
mediakit
{
class
HttpSession
:
public
TcpSession
,
public
FlvMuxer
,
...
...
@@ -128,7 +126,6 @@ private:
};
}
/* namespace Http */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif
/* SRC_HTTP_HTTPSESSION_H_ */
src/Http/HttpsSession.h
查看文件 @
9f16cc12
...
...
@@ -31,10 +31,9 @@
#include "Util/SSLBox.h"
#include "Util/TimeTicker.h"
using
namespace
ZL
::
Util
;
using
namespace
toolkit
;
namespace
ZL
{
namespace
Http
{
namespace
mediakit
{
class
HttpsSession
:
public
HttpSession
{
public
:
...
...
@@ -284,7 +283,6 @@ typedef WebSocketSession<EchoSession,HttpSession> EchoWebSocketSession;
typedef
WebSocketSession
<
EchoSession
,
HttpsSession
>
SSLEchoWebSocketSession
;
}
/* namespace Http */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif
/* SRC_HTTP_HTTPSSESSION_H_ */
src/Http/WebSocketSplitter.cpp
查看文件 @
9f16cc12
...
...
@@ -30,11 +30,9 @@
#include <arpa/inet.h>
#include "Util/logger.h"
#include "Util/util.h"
using
namespace
ZL
::
Util
;
using
namespace
toolkit
;
namespace
ZL
{
namespace
Http
{
namespace
mediakit
{
/**
*
...
...
@@ -210,27 +208,7 @@ void WebSocketSplitter::encode(const WebSocketHeader &header,uint8_t *data, cons
}
/* namespace Http */
}
/* namespace ZL */
}
/* namespace mediakit */
...
...
src/Http/WebSocketSplitter.h
查看文件 @
9f16cc12
...
...
@@ -34,8 +34,7 @@
using
namespace
std
;
namespace
ZL
{
namespace
Http
{
namespace
mediakit
{
class
WebSocketHeader
{
public
:
...
...
@@ -130,8 +129,7 @@ private:
uint64_t
_playload_offset
=
0
;
};
}
/* namespace Http */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif //ZLMEDIAKIT_WEBSOCKETSPLITTER_H
src/Http/strCoding.cpp
查看文件 @
9f16cc12
...
...
@@ -31,8 +31,7 @@
#include <windows.h>
#endif//defined(_WIN32)
namespace
ZL
{
namespace
Http
{
namespace
mediakit
{
//////////////////////////通用///////////////////////
void
UTF8ToUnicode
(
wchar_t
*
pOut
,
const
char
*
pText
)
...
...
@@ -239,5 +238,4 @@ string strCoding::GB2312ToUTF8(const string &str) {
}
/* namespace Http */
}
/* namespace ZL */
}
/* namespace mediakit */
src/Http/strCoding.h
查看文件 @
9f16cc12
...
...
@@ -32,8 +32,7 @@
using
namespace
std
;
namespace
ZL
{
namespace
Http
{
namespace
mediakit
{
class
strCoding
{
public
:
...
...
@@ -51,7 +50,6 @@ private:
virtual
~
strCoding
(
void
);
};
}
/* namespace Http */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif
/* SRC_HTTP_STRCODING_H_ */
src/MediaFile/HLSMaker.cpp
查看文件 @
9f16cc12
...
...
@@ -27,11 +27,9 @@
#include "HLSMaker.h"
#include "Util/File.h"
#include "Util/uv_errno.h"
using
namespace
toolkit
;
using
namespace
ZL
::
Util
;
namespace
ZL
{
namespace
MediaFile
{
namespace
mediakit
{
HLSMaker
::
HLSMaker
(
const
string
&
strM3u8File
,
uint32_t
ui32BufSize
,
...
...
@@ -184,6 +182,5 @@ bool HLSMaker::removets() {
return
true
;
}
}
/* namespace MediaFile */
}
/* namespace ZL */
}
/* namespace mediakit */
src/MediaFile/HLSMaker.h
查看文件 @
9f16cc12
...
...
@@ -34,11 +34,9 @@
#include "Util/util.h"
#include "Util/logger.h"
#include <deque>
using
namespace
toolkit
;
using
namespace
ZL
::
Util
;
namespace
ZL
{
namespace
MediaFile
{
namespace
mediakit
{
class
HLSMaker
{
public
:
...
...
@@ -75,7 +73,6 @@ private:
bool
removets
();
};
}
/* namespace MediaFile */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif
/* HLSMAKER_H_ */
src/MediaFile/MediaReader.cpp
查看文件 @
9f16cc12
...
...
@@ -28,16 +28,13 @@
#include "Common/config.h"
#include "Util/mini.h"
#include "Http/HttpSession.h"
using
namespace
toolkit
;
using
namespace
ZL
::
Util
;
namespace
ZL
{
namespace
MediaFile
{
namespace
mediakit
{
#ifdef ENABLE_MP4V2
MediaReader
::
MediaReader
(
const
string
&
strVhost
,
const
string
&
strApp
,
const
string
&
strId
)
{
GET_CONFIG_AND_REGISTER
(
string
,
recordPath
,
Config
::
Record
::
kFilePath
);
GET_CONFIG_AND_REGISTER
(
string
,
recordPath
,
Record
::
kFilePath
);
auto
strFileName
=
recordPath
+
"/"
+
strVhost
+
"/"
+
strApp
+
"/"
+
strId
;
...
...
@@ -169,7 +166,7 @@ MediaReader::~MediaReader() {
void
MediaReader
::
startReadMP4
()
{
auto
strongSelf
=
shared_from_this
();
GET_CONFIG_AND_REGISTER
(
uint32_t
,
sampleMS
,
Config
::
Record
::
kSampleMS
);
GET_CONFIG_AND_REGISTER
(
uint32_t
,
sampleMS
,
Record
::
kSampleMS
);
AsyncTaskThread
::
Instance
().
DoTaskDelay
(
reinterpret_cast
<
uint64_t
>
(
this
),
sampleMS
,
[
strongSelf
](){
return
strongSelf
->
readSample
();
...
...
@@ -323,7 +320,7 @@ void MediaReader::seek(int iSeekTime,bool bReStart){
MediaSource
::
Ptr
MediaReader
::
onMakeMediaSource
(
const
string
&
strSchema
,
const
string
&
strVhost
,
const
string
&
strApp
,
const
string
&
strId
){
#ifdef ENABLE_MP4V2
GET_CONFIG_AND_REGISTER
(
string
,
appName
,
Config
::
Record
::
kAppName
);
GET_CONFIG_AND_REGISTER
(
string
,
appName
,
Record
::
kAppName
);
if
(
strApp
!=
appName
)
{
return
nullptr
;
...
...
@@ -343,5 +340,4 @@ MediaSource::Ptr MediaReader::onMakeMediaSource(const string &strSchema,const st
}
/* namespace MediaFile */
}
/* namespace ZL */
}
/* namespace mediakit */
src/MediaFile/MediaReader.h
查看文件 @
9f16cc12
...
...
@@ -34,13 +34,9 @@
#ifdef ENABLE_MP4V2
#include <mp4v2/mp4v2.h>
#endif //ENABLE_MP4V2
using
namespace
toolkit
;
using
namespace
ZL
::
DEV
;
using
namespace
ZL
::
Rtsp
;
using
namespace
ZL
::
Rtmp
;
namespace
ZL
{
namespace
MediaFile
{
namespace
mediakit
{
class
MediaReader
:
public
std
::
enable_shared_from_this
<
MediaReader
>
,
public
MediaSourceEvent
{
public
:
...
...
@@ -103,7 +99,6 @@ private:
#endif //ENABLE_MP4V2
};
}
/* namespace MediaFile */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif
/* SRC_MEDIAFILE_MEDIAREADER_H_ */
src/MediaFile/MediaRecorder.cpp
查看文件 @
9f16cc12
...
...
@@ -30,12 +30,9 @@
#include "Util/util.h"
#include "Util/mini.h"
#include "Network/sockutil.h"
using
namespace
toolkit
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Network
;
namespace
ZL
{
namespace
MediaFile
{
namespace
mediakit
{
MediaRecorder
::
MediaRecorder
(
const
string
&
strVhost_tmp
,
const
string
&
strApp
,
...
...
@@ -44,10 +41,10 @@ MediaRecorder::MediaRecorder(const string &strVhost_tmp,
bool
enableHls
,
bool
enableMp4
)
{
GET_CONFIG_AND_REGISTER
(
string
,
hlsPath
,
Config
::
Hls
::
kFilePath
);
GET_CONFIG_AND_REGISTER
(
uint32_t
,
hlsBufSize
,
Config
::
Hls
::
kFileBufSize
);
GET_CONFIG_AND_REGISTER
(
uint32_t
,
hlsDuration
,
Config
::
Hls
::
kSegmentDuration
);
GET_CONFIG_AND_REGISTER
(
uint32_t
,
hlsNum
,
Config
::
Hls
::
kSegmentNum
);
GET_CONFIG_AND_REGISTER
(
string
,
hlsPath
,
Hls
::
kFilePath
);
GET_CONFIG_AND_REGISTER
(
uint32_t
,
hlsBufSize
,
Hls
::
kFileBufSize
);
GET_CONFIG_AND_REGISTER
(
uint32_t
,
hlsDuration
,
Hls
::
kSegmentDuration
);
GET_CONFIG_AND_REGISTER
(
uint32_t
,
hlsNum
,
Hls
::
kSegmentNum
);
string
strVhost
=
strVhost_tmp
;
if
(
trim
(
strVhost
).
empty
()){
...
...
@@ -61,8 +58,8 @@ MediaRecorder::MediaRecorder(const string &strVhost_tmp,
}
#ifdef ENABLE_MP4V2
GET_CONFIG_AND_REGISTER
(
string
,
recordPath
,
Config
::
Record
::
kFilePath
);
GET_CONFIG_AND_REGISTER
(
string
,
recordAppName
,
Config
::
Record
::
kAppName
);
GET_CONFIG_AND_REGISTER
(
string
,
recordPath
,
Record
::
kFilePath
);
GET_CONFIG_AND_REGISTER
(
string
,
recordAppName
,
Record
::
kAppName
);
if
(
enableMp4
){
auto
mp4FilePath
=
recordPath
+
"/"
+
strVhost
+
"/"
+
recordAppName
+
"/"
+
strApp
+
"/"
+
strId
+
"/"
;
...
...
@@ -96,5 +93,4 @@ void MediaRecorder::inputAAC(void* pData, uint32_t ui32Length, uint32_t ui32Time
#endif //ENABLE_MP4V2
}
}
/* namespace MediaFile */
}
/* namespace ZL */
}
/* namespace mediakit */
src/MediaFile/MediaRecorder.h
查看文件 @
9f16cc12
...
...
@@ -35,13 +35,9 @@
#endif //ENABLE_MP4V2
#include "HLSMaker.h"
using
namespace
toolkit
;
using
namespace
std
;
using
namespace
ZL
::
Player
;
namespace
ZL
{
namespace
MediaFile
{
namespace
mediakit
{
class
MediaRecorder
{
public
:
...
...
@@ -70,7 +66,6 @@ private:
};
}
/* namespace MediaFile */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif
/* SRC_MEDIAFILE_MEDIARECORDER_H_ */
src/MediaFile/Mp4Maker.cpp
查看文件 @
9f16cc12
...
...
@@ -34,11 +34,9 @@
#include "Util/mini.h"
#include "Util/util.h"
#include "Util/NoticeCenter.h"
using
namespace
toolkit
;
using
namespace
ZL
::
Util
;
namespace
ZL
{
namespace
MediaFile
{
namespace
mediakit
{
string
timeStr
(
const
char
*
fmt
)
{
std
::
tm
tm_snapshot
;
...
...
@@ -116,7 +114,7 @@ void Mp4Maker::inputAAC(void *pData, uint32_t ui32Length, uint32_t ui32TimeStamp
}
void
Mp4Maker
::
_inputH264
(
void
*
pData
,
uint32_t
ui32Length
,
uint32_t
ui32Duration
,
int
iType
)
{
GET_CONFIG_AND_REGISTER
(
uint32_t
,
recordSec
,
Config
::
Record
::
kFileSecond
);
GET_CONFIG_AND_REGISTER
(
uint32_t
,
recordSec
,
Record
::
kFileSecond
);
if
(
iType
==
5
&&
(
_hMp4
==
MP4_INVALID_FILE_HANDLE
||
_ticker
.
elapsedTime
()
>
recordSec
*
1000
)){
//在I帧率处新建MP4文件
...
...
@@ -129,7 +127,7 @@ void Mp4Maker::_inputH264(void* pData, uint32_t ui32Length, uint32_t ui32Duratio
}
void
Mp4Maker
::
_inputAAC
(
void
*
pData
,
uint32_t
ui32Length
,
uint32_t
ui32Duration
)
{
GET_CONFIG_AND_REGISTER
(
uint32_t
,
recordSec
,
Config
::
Record
::
kFileSecond
);
GET_CONFIG_AND_REGISTER
(
uint32_t
,
recordSec
,
Record
::
kFileSecond
);
//todo(xzl) 修复此处
...
...
@@ -161,7 +159,7 @@ void Mp4Maker::createFile() {
_info
.
strFileName
=
strTime
+
".mp4"
;
_info
.
strFilePath
=
strFile
;
GET_CONFIG_AND_REGISTER
(
string
,
appName
,
Config
::
Record
::
kAppName
);
GET_CONFIG_AND_REGISTER
(
string
,
appName
,
Record
::
kAppName
);
_info
.
strUrl
=
_info
.
strVhost
+
"/"
+
appName
+
"/"
...
...
@@ -230,12 +228,11 @@ void Mp4Maker::closeFile() {
stat
(
_strFile
.
data
(),
&
fileData
);
_info
.
ui64FileSize
=
fileData
.
st_size
;
//----record 业务逻辑----//
NoticeCenter
::
Instance
().
emitEvent
(
Config
::
Broadcast
::
kBroadcastRecordMP4
,
_info
,
*
this
);
NoticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastRecordMP4
,
_info
,
*
this
);
}
}
}
/* namespace MediaFile */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif //ENABLE_MP4V2
src/MediaFile/Mp4Maker.h
查看文件 @
9f16cc12
...
...
@@ -37,13 +37,9 @@
#include "Util/logger.h"
#include "Util/TimeTicker.h"
#include "Util/TimeTicker.h"
using
namespace
toolkit
;
using
namespace
std
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Player
;
namespace
ZL
{
namespace
MediaFile
{
namespace
mediakit
{
class
Mp4Info
{
...
...
@@ -98,8 +94,7 @@ private:
Mp4Info
_info
;
};
}
/* namespace MediaFile */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif ///ENABLE_MP4V2
...
...
src/MediaFile/TSMaker.cpp
查看文件 @
9f16cc12
...
...
@@ -26,8 +26,7 @@
#include "TSMaker.h"
#include "Util/logger.h"
using
namespace
ZL
::
Util
;
using
namespace
toolkit
;
TSMaker
::
TSMaker
()
{
m_pOutVideoTs
=
NULL
;
...
...
src/MediaFile/TSMaker.h
查看文件 @
9f16cc12
...
...
@@ -34,9 +34,8 @@
#include <string>
#include <iostream>
#include "Util/File.h"
using
namespace
std
;
using
namespace
ZL
::
Util
;
using
namespace
toolkit
;
#define TS_PACKET_SIZE 188
#define TS_PACKET_HEADER 4
...
...
src/Player/Frame.cpp
查看文件 @
9f16cc12
...
...
@@ -3,3 +3,7 @@
//
#include "Frame.h"
namespace
mediakit
{
}
\ No newline at end of file
src/Player/Frame.h
查看文件 @
9f16cc12
...
...
@@ -7,9 +7,9 @@
#include "Util/RingBuffer.h"
#include "Network/Socket.h"
using
namespace
toolkit
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Network
;
namespace
mediakit
{
typedef
enum
{
CodecInvalid
=
-
1
,
...
...
@@ -290,6 +290,6 @@ public:
}
;
}
//namespace mediakit
#endif //ZLMEDIAKIT_FRAME_H
src/Player/MediaPlayer.cpp
查看文件 @
9f16cc12
...
...
@@ -28,12 +28,9 @@
#include "MediaPlayer.h"
#include "Rtmp/RtmpPlayerImp.h"
#include "Rtsp/RtspPlayerImp.h"
using
namespace
toolkit
;
using
namespace
ZL
::
Rtmp
;
using
namespace
ZL
::
Rtsp
;
namespace
ZL
{
namespace
Player
{
namespace
mediakit
{
MediaPlayer
::
MediaPlayer
()
{
}
...
...
@@ -78,5 +75,4 @@ void MediaPlayer::teardown() {
}
}
/* namespace Player */
}
/* namespace ZL */
}
/* namespace mediakit */
src/Player/MediaPlayer.h
查看文件 @
9f16cc12
...
...
@@ -34,14 +34,9 @@
#include "Rtsp/RtspPlayer.h"
#include "Rtmp/RtmpPlayer.h"
#include "Thread/TaskExecutor.h"
using
namespace
toolkit
;
using
namespace
std
;
using
namespace
ZL
::
Rtsp
;
using
namespace
ZL
::
Rtmp
;
using
namespace
ZL
::
Thread
;
namespace
ZL
{
namespace
Player
{
namespace
mediakit
{
class
MediaPlayer
:
public
PlayerImp
<
PlayerBase
,
PlayerBase
>
{
public
:
...
...
@@ -58,7 +53,6 @@ private:
};
}
/* namespace Player */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif
/* SRC_PLAYER_MEDIAPLAYER_H_ */
src/Player/Player.cpp
查看文件 @
9f16cc12
...
...
@@ -28,9 +28,7 @@
#include "Player.h"
#include "H264/SPSParser.h"
#include "Util/logger.h"
using
namespace
ZL
::
Util
;
using
namespace
toolkit
;
void
writeAdtsHeader
(
const
AACFrame
&
hed
,
uint8_t
*
pcAdts
)
{
pcAdts
[
0
]
=
(
hed
.
syncword
>>
4
&
0xFF
);
//8bit
...
...
src/Player/Player.h
查看文件 @
9f16cc12
...
...
@@ -31,6 +31,7 @@
#include "Frame.h"
using
namespace
std
;
using
namespace
mediakit
;
unsigned
const
samplingFrequencyTable
[
16
]
=
{
96000
,
88200
,
64000
,
48000
,
...
...
src/Player/PlayerBase.cpp
查看文件 @
9f16cc12
...
...
@@ -29,13 +29,9 @@
#include "Rtsp/Rtsp.h"
#include "Rtsp/RtspPlayerImp.h"
#include "Rtmp/RtmpPlayerImp.h"
using
namespace
toolkit
;
using
namespace
std
;
using
namespace
ZL
::
Rtmp
;
using
namespace
ZL
::
Rtsp
;
namespace
ZL
{
namespace
Player
{
namespace
mediakit
{
const
char
PlayerBase
::
kNetAdapter
[]
=
"net_adapter"
;
const
char
PlayerBase
::
kRtpType
[]
=
"rtp_type"
;
...
...
@@ -55,5 +51,4 @@ PlayerBase::Ptr PlayerBase::createPlayer(const char* strUrl) {
return
PlayerBase
::
Ptr
(
new
RtspPlayerImp
());
}
}
/* namespace Player */
}
/* namespace ZL */
}
/* namespace mediakit */
src/Player/PlayerBase.h
查看文件 @
9f16cc12
...
...
@@ -38,14 +38,9 @@
#include "Common/MediaSource.h"
#include "Frame.h"
#include "Track.h"
using
namespace
toolkit
;
using
namespace
std
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Media
;
using
namespace
ZL
::
Network
;
namespace
ZL
{
namespace
Player
{
namespace
mediakit
{
class
PlayerBase
:
public
mINI
{
public
:
...
...
@@ -170,7 +165,6 @@ protected:
MediaSource
::
Ptr
_pMediaSrc
;
};
}
/* namespace Player */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif
/* SRC_PLAYER_PLAYERBASE_H_ */
src/Player/Track.h
查看文件 @
9f16cc12
...
...
@@ -11,9 +11,9 @@
#include "Util/RingBuffer.h"
#include "Rtsp/Rtsp.h"
#include "Player.h"
using
namespace
toolkit
;
using
namespace
std
;
using
namespace
ZL
::
Util
;
namespace
mediakit
{
class
Track
:
public
FrameRing
,
public
CodecInfo
{
public
:
...
...
@@ -324,5 +324,6 @@ private:
int
_channel
=
0
;
};
}
//namespace mediakit
#endif //ZLMEDIAKIT_TRACK_H
src/Rtmp/FlvMuxer.cpp
查看文件 @
9f16cc12
...
...
@@ -8,8 +8,7 @@
#define FILE_BUF_SIZE (64 * 1024)
namespace
ZL
{
namespace
Rtmp
{
namespace
mediakit
{
FlvMuxer
::
FlvMuxer
()
{
...
...
@@ -227,5 +226,4 @@ FlvRecorder::~FlvRecorder() {
}
}
//namespace Rtmp
}
//namespace ZL
}
//namespace mediakit
src/Rtmp/FlvMuxer.h
查看文件 @
9f16cc12
...
...
@@ -8,11 +8,9 @@
#include "Rtmp.h"
#include "RtmpMediaSource.h"
#include "Network/Socket.h"
using
namespace
toolkit
;
using
namespace
ZL
::
Network
;
namespace
ZL
{
namespace
Rtmp
{
namespace
mediakit
{
class
FlvMuxer
{
public
:
...
...
@@ -55,7 +53,6 @@ private:
};
}
//namespace Rtmp
}
//namespace ZL
}
//namespace mediakit
#endif //ZLMEDIAKIT_FLVRECORDER_H
src/Rtmp/Rtmp.h
查看文件 @
9f16cc12
...
...
@@ -31,10 +31,7 @@
#include "Util/util.h"
#include "Util/logger.h"
#include "Network/sockutil.h"
using
namespace
std
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Network
;
using
namespace
toolkit
;
#define PORT 1935
#define DEFAULT_CHUNK_LEN 128
...
...
src/Rtmp/RtmpMediaSource.h
查看文件 @
9f16cc12
...
...
@@ -44,14 +44,9 @@
#include "Util/ResourcePool.h"
#include "Util/NoticeCenter.h"
#include "Thread/ThreadPool.h"
using
namespace
toolkit
;
using
namespace
std
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Thread
;
using
namespace
ZL
::
Media
;
namespace
ZL
{
namespace
Rtmp
{
namespace
mediakit
{
class
RtmpMediaSource
:
public
MediaSource
{
public
:
...
...
@@ -122,7 +117,6 @@ protected:
bool
_bRegisted
=
false
;
};
}
/* namespace Rtmp */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif
/* SRC_RTMP_RTMPMEDIASOURCE_H_ */
src/Rtmp/RtmpParser.cpp
查看文件 @
9f16cc12
...
...
@@ -26,8 +26,7 @@
#include "RtmpParser.h"
namespace
ZL
{
namespace
Rtmp
{
namespace
mediakit
{
RtmpParser
::
RtmpParser
(
const
AMFValue
&
val
)
{
auto
videoCodec
=
val
[
"videocodecid"
];
...
...
@@ -232,29 +231,4 @@ inline void RtmpParser::onCheckMedia(const AMFValue& obj) {
}
}
/* namespace Rtmp */
}
/* namespace ZL */
}
/* namespace mediakit */
src/Rtmp/RtmpParser.h
查看文件 @
9f16cc12
...
...
@@ -34,16 +34,12 @@
#include "Player/Player.h"
#include "Util/TimeTicker.h"
#include "Player/PlayerBase.h"
using
namespace
std
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Player
;
using
namespace
toolkit
;
#define H264_CODEC_ID 7
#define AAC_CODEC_ID 10
namespace
ZL
{
namespace
Rtmp
{
namespace
mediakit
{
class
RtmpParser
:
public
PlayerBase
{
public
:
...
...
@@ -112,7 +108,6 @@ private:
};
}
/* namespace Rtmp */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif
/* SRC_RTMP_RTMPPARSER_H_ */
src/Rtmp/RtmpPlayer.cpp
查看文件 @
9f16cc12
...
...
@@ -30,11 +30,9 @@
#include "Util/util.h"
#include "Util/onceToken.h"
#include "Thread/ThreadPool.h"
using
namespace
toolkit
;
using
namespace
ZL
::
Util
;
namespace
ZL
{
namespace
Rtmp
{
namespace
mediakit
{
unordered_map
<
string
,
RtmpPlayer
::
rtmpCMDHandle
>
RtmpPlayer
::
g_mapCmd
;
RtmpPlayer
::
RtmpPlayer
()
{
...
...
@@ -351,6 +349,5 @@ void RtmpPlayer::seekToTime(float fTime){
}
}
/* namespace Rtmp */
}
/* namespace ZL */
}
/* namespace mediakit */
src/Rtmp/RtmpPlayer.h
查看文件 @
9f16cc12
...
...
@@ -39,14 +39,9 @@
#include "Util/TimeTicker.h"
#include "Network/Socket.h"
#include "Network/TcpClient.h"
using
namespace
toolkit
;
using
namespace
std
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Player
;
using
namespace
ZL
::
Network
;
namespace
ZL
{
namespace
Rtmp
{
namespace
mediakit
{
class
RtmpPlayer
:
public
PlayerBase
,
public
TcpClient
,
public
RtmpProtocol
{
public
:
...
...
@@ -156,7 +151,6 @@ private:
Ticker
_aNowStampTicker
[
2
];
};
}
/* namespace Rtmp */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif
/* SRC_RTMP_RtmpPlayer2_H_ */
src/Rtmp/RtmpPlayerImp.h
查看文件 @
9f16cc12
...
...
@@ -35,13 +35,10 @@
#include "RtmpMediaSource.h"
#include "Poller/Timer.h"
#include "Util/TimeTicker.h"
using
namespace
toolkit
;
using
namespace
std
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Player
;
namespace
mediakit
{
namespace
ZL
{
namespace
Rtmp
{
class
RtmpPlayerImp
:
public
PlayerImp
<
RtmpPlayer
,
RtmpParser
>
{
public
:
typedef
std
::
shared_ptr
<
RtmpPlayerImp
>
Ptr
;
...
...
@@ -92,7 +89,6 @@ private:
};
}
/* namespace Rtmp */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif
/* SRC_RTMP_RTMPPLAYERIMP_H_ */
src/Rtmp/RtmpProtocol.cpp
查看文件 @
9f16cc12
...
...
@@ -29,7 +29,7 @@
#include "Util/util.h"
#include "Util/onceToken.h"
#include "Thread/ThreadPool.h"
using
namespace
ZL
::
Util
;
using
namespace
toolkit
;
#ifdef ENABLE_OPENSSL
#include "Util/SSLBox.h"
...
...
@@ -72,8 +72,7 @@ static string openssl_HMACsha256(const void *key,unsigned int key_len,
#define S2_FMS_KEY_SIZE 68
#define C1_OFFSET_SIZE 4
namespace
ZL
{
namespace
Rtmp
{
namespace
mediakit
{
RtmpProtocol
::
RtmpProtocol
()
{
_nextHandle
=
[
this
](){
...
...
@@ -697,5 +696,4 @@ BufferRaw::Ptr RtmpProtocol::obtainBuffer(const void *data, int len) {
return
buffer
;
}
}
/* namespace Rtmp */
}
/* namespace ZL */
}
/* namespace mediakit */
src/Rtmp/RtmpProtocol.h
查看文件 @
9f16cc12
...
...
@@ -39,11 +39,9 @@
#include "Util/ResourcePool.h"
using
namespace
std
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Network
;
using
namespace
toolkit
;
namespace
ZL
{
namespace
Rtmp
{
namespace
mediakit
{
class
RtmpProtocol
{
public
:
...
...
@@ -119,7 +117,6 @@ private:
function
<
void
()
>
_nextHandle
;
};
}
/* namespace Rtmp */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif
/* SRC_RTMP_RTMPPROTOCOL_H_ */
src/Rtmp/RtmpPusher.cpp
查看文件 @
9f16cc12
...
...
@@ -29,11 +29,9 @@
#include "Util/util.h"
#include "Util/onceToken.h"
#include "Thread/ThreadPool.h"
using
namespace
toolkit
;
using
namespace
ZL
::
Util
;
namespace
ZL
{
namespace
Rtmp
{
namespace
mediakit
{
static
int
kSockFlags
=
SOCKET_DEFAULE_FLAGS
|
FLAG_MORE
;
...
...
@@ -286,6 +284,5 @@ void RtmpPusher::onRtmpChunk(RtmpPacket &chunkData) {
}
}
/* namespace Rtmp */
}
/* namespace ZL */
}
/* namespace mediakit */
src/Rtmp/RtmpPusher.h
查看文件 @
9f16cc12
...
...
@@ -31,8 +31,7 @@
#include "RtmpMediaSource.h"
#include "Network/TcpClient.h"
namespace
ZL
{
namespace
Rtmp
{
namespace
mediakit
{
class
RtmpPusher
:
public
RtmpProtocol
,
public
TcpClient
{
public
:
...
...
@@ -123,7 +122,6 @@ private:
Event
_onPublished
;
};
}
/* namespace Rtmp */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif
/* SRC_RTMP_RTMPPUSHER_H_ */
src/Rtmp/RtmpSession.cpp
查看文件 @
9f16cc12
...
...
@@ -29,8 +29,7 @@
#include "Common/config.h"
#include "Util/onceToken.h"
namespace
ZL
{
namespace
Rtmp
{
namespace
mediakit
{
static
int
kSockFlags
=
SOCKET_DEFAULE_FLAGS
|
FLAG_MORE
;
...
...
@@ -191,7 +190,7 @@ void RtmpSession::onCmd_publish(AMFDecoder &dec) {
onRes
(
err
);
});
};
auto
flag
=
NoticeCenter
::
Instance
().
emitEvent
(
Config
::
Broadcast
::
kBroadcastRtmpPublish
,
auto
flag
=
NoticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastRtmpPublish
,
_mediaInfo
,
invoker
,
*
this
);
...
...
@@ -506,7 +505,7 @@ void RtmpSession::onRtmpChunk(RtmpPacket &chunkData) {
if
(
!
_pPublisherSrc
)
{
throw
std
::
runtime_error
(
"Not a rtmp publisher!"
);
}
GET_CONFIG_AND_REGISTER
(
bool
,
rtmp_modify_stamp
,
Config
::
Rtmp
::
kModifyStamp
);
GET_CONFIG_AND_REGISTER
(
bool
,
rtmp_modify_stamp
,
Rtmp
::
kModifyStamp
);
if
(
rtmp_modify_stamp
){
chunkData
.
timeStamp
=
_stampTicker
[
chunkData
.
typeId
%
2
].
elapsedTime
();
}
...
...
@@ -565,5 +564,4 @@ void RtmpSession::cancelDelyaTask(){
}
}
/* namespace Rtmp */
}
/* namespace ZL */
}
/* namespace mediakit */
src/Rtmp/RtmpSession.h
查看文件 @
9f16cc12
...
...
@@ -37,12 +37,9 @@
#include "Util/util.h"
#include "Util/TimeTicker.h"
#include "Network/TcpSession.h"
using
namespace
toolkit
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Network
;
namespace
ZL
{
namespace
Rtmp
{
namespace
mediakit
{
class
RtmpSession
:
public
TcpSession
,
public
RtmpProtocol
,
public
MediaSourceEvent
{
public
:
...
...
@@ -107,7 +104,6 @@ private:
};
}
/* namespace Rtmp */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif
/* SRC_RTMP_RTMPSESSION_H_ */
src/Rtmp/RtmpToRtspMediaSource.cpp
查看文件 @
9f16cc12
...
...
@@ -29,12 +29,9 @@
#include "Util/util.h"
#include "Util/base64.h"
#include "Network/sockutil.h"
using
namespace
toolkit
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Network
;
namespace
ZL
{
namespace
Rtmp
{
namespace
mediakit
{
RtmpToRtspMediaSource
::
RtmpToRtspMediaSource
(
const
string
&
vhost
,
const
string
&
app
,
...
...
@@ -89,7 +86,7 @@ void RtmpToRtspMediaSource::makeSDP() {
// _pRtspSrc->onGetRTP(pkt,bKeyPos);
// };
//
// GET_CONFIG_AND_REGISTER(uint32_t,videoMtu,
Config::
Rtp::kVideoMtuSize);
// GET_CONFIG_AND_REGISTER(uint32_t,videoMtu,Rtp::kVideoMtuSize);
// _pRtpMaker_h264.reset(new RtpMaker_H264(lam, ssrc0,videoMtu));
//
// char strTemp[100];
...
...
@@ -131,7 +128,7 @@ void RtmpToRtspMediaSource::makeSDP() {
// auto lam = [this](const RtpPacket::Ptr &pkt, bool bKeyPos) {
// _pRtspSrc->onGetRTP(pkt,bKeyPos);
// };
// GET_CONFIG_AND_REGISTER(uint32_t,audioMtu,
Config::
Rtp::kAudioMtuSize);
// GET_CONFIG_AND_REGISTER(uint32_t,audioMtu,Rtp::kAudioMtuSize);
// _pRtpMaker_aac.reset(new RtpMaker_AAC(lam, ssrc1, audioMtu,_pParser->getAudioSampleRate()));
//
// char configStr[32];
...
...
@@ -159,5 +156,4 @@ void RtmpToRtspMediaSource::makeSDP() {
}
}
/* namespace Rtmp */
}
/* namespace ZL */
}
/* namespace mediakit */
src/Rtmp/RtmpToRtspMediaSource.h
查看文件 @
9f16cc12
...
...
@@ -43,14 +43,10 @@
#include "Util/util.h"
#include "Util/logger.h"
#include "MediaFile/MediaRecorder.h"
using
namespace
std
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Rtsp
;
using
namespace
ZL
::
MediaFile
;
using
namespace
toolkit
;
namespace
ZL
{
namespace
Rtmp
{
namespace
mediakit
{
class
RtmpToRtspMediaSource
:
public
RtmpMediaSource
{
public
:
...
...
@@ -100,7 +96,6 @@ private:
void
makeSDP
();
};
}
/* namespace Rtmp */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif
/* SRC_RTMP_RTMPTORTSPMEDIASOURCE_H_ */
src/Rtmp/amf.cpp
查看文件 @
9f16cc12
...
...
@@ -30,9 +30,7 @@
#include "Util/util.h"
#include "Util/logger.h"
#include "Network/sockutil.h"
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Network
;
using
namespace
toolkit
;
/////////////////////AMFValue/////////////////////////////
inline
void
AMFValue
::
destroy
()
{
...
...
src/Rtmp/utils.cpp
查看文件 @
9f16cc12
...
...
@@ -30,9 +30,7 @@
#include <stdarg.h>
#include "Util/util.h"
#include "Network/sockutil.h"
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Network
;
using
namespace
toolkit
;
/*
* Used to do unaligned loads on archs that don't support them. GCC can mostly
...
...
src/RtmpCodec/AACRtmpCodec.cpp
查看文件 @
9f16cc12
...
...
@@ -5,8 +5,7 @@
#include <Player/Player.h>
#include "AACRtmpCodec.h"
namespace
ZL
{
namespace
Rtmp
{
namespace
mediakit
{
AACRtmpDecoder
::
AACRtmpDecoder
()
{
_adts
=
obtainFrame
();
...
...
@@ -127,13 +126,4 @@ void AACRtmpEncoder::makeAudioConfigPkt() {
}
//namespace Rtmp
}
//
namespace
ZL
\ No newline at end of file
}
//
namespace
mediakit
\ No newline at end of file
src/RtmpCodec/AACRtmpCodec.h
查看文件 @
9f16cc12
...
...
@@ -7,8 +7,7 @@
#include "RtmpCodec.h"
namespace
ZL
{
namespace
Rtmp
{
namespace
mediakit
{
/**
* aac Rtmp转adts类
*/
...
...
@@ -64,7 +63,6 @@ private:
uint8_t
_ui8AudioFlags
;
};
}
//namespace Rtmp
}
//namespace ZL
}
//namespace mediakit
#endif //ZLMEDIAKIT_AACRTMPCODEC_H
src/RtmpCodec/H264RtmpCodec.cpp
查看文件 @
9f16cc12
...
...
@@ -4,6 +4,7 @@
#include "H264RtmpCodec.h"
namespace
mediakit
{
H264RtmpDecoder
::
H264RtmpDecoder
()
{
_h264frame
=
obtainFrame
();
...
...
@@ -185,20 +186,7 @@ void H264RtmpEncoder::makeVideoConfigPkt() {
}
}
//namespace mediakit
...
...
src/RtmpCodec/H264RtmpCodec.h
查看文件 @
9f16cc12
...
...
@@ -7,9 +7,9 @@
#include "RtmpCodec.h"
#include "Util/ResourcePool.h"
using
namespace
toolkit
;
using
namespace
ZL
::
Rtmp
;
namespace
mediakit
{
/**
* h264 Rtmp解码类
*/
...
...
@@ -64,4 +64,6 @@ private:
void
makeVideoConfigPkt
();
};
}
//namespace mediakit
#endif //ZLMEDIAKIT_H264RTMPCODEC_H
src/RtmpCodec/RtmpCodec.cpp
查看文件 @
9f16cc12
...
...
@@ -3,3 +3,6 @@
//
#include "RtmpCodec.h"
namespace
mediakit
{
}
\ No newline at end of file
src/RtmpCodec/RtmpCodec.h
查看文件 @
9f16cc12
...
...
@@ -8,12 +8,9 @@
#include "Rtmp/Rtmp.h"
#include "Player/Frame.h"
#include "Util/RingBuffer.h"
using
namespace
toolkit
;
using
namespace
ZL
::
Util
;
namespace
ZL
{
namespace
Rtmp
{
namespace
mediakit
{
class
RtmpRingInterface
{
public
:
...
...
@@ -78,9 +75,6 @@ public:
};
}
//namespace Rtmp
}
//namespace ZL
}
//namespace mediakit
#endif //ZLMEDIAKIT_RTMPCODEC_H
src/RtpCodec/AACRtpCodec.cpp
查看文件 @
9f16cc12
...
...
@@ -4,6 +4,8 @@
#include "AACRtpCodec.h"
namespace
mediakit
{
AACRtpEncoder
::
AACRtpEncoder
(
uint32_t
ui32Ssrc
,
uint32_t
ui32MtuSize
,
uint32_t
ui32SampleRate
,
...
...
@@ -20,7 +22,7 @@ AACRtpEncoder::AACRtpEncoder(uint32_t ui32Ssrc,
void
AACRtpEncoder
::
inputFrame
(
const
Frame
::
Ptr
&
frame
)
{
RtpCodec
::
inputFrame
(
frame
);
GET_CONFIG_AND_REGISTER
(
uint32_t
,
cycleMS
,
Config
::
Rtp
::
kCycleMS
);
GET_CONFIG_AND_REGISTER
(
uint32_t
,
cycleMS
,
Rtp
::
kCycleMS
);
auto
uiStamp
=
frame
->
stamp
();
auto
pcData
=
frame
->
data
()
+
frame
->
prefixSize
();
auto
iLen
=
frame
->
size
()
-
frame
->
prefixSize
();
...
...
@@ -125,6 +127,7 @@ void AACRtpDecoder::onGetAAC(const AACFrame::Ptr &frame) {
_adts
=
obtainFrame
();
}
}
//namespace mediakit
src/RtpCodec/AACRtpCodec.h
查看文件 @
9f16cc12
...
...
@@ -7,6 +7,7 @@
#include "RtpCodec.h"
namespace
mediakit
{
/**
* aac rtp转adts类
*/
...
...
@@ -75,5 +76,6 @@ private:
unsigned
char
_aucSectionBuf
[
1600
];
};
}
//namespace mediakit
#endif //ZLMEDIAKIT_AACRTPCODEC_H
src/RtpCodec/H264RtpCodec.cpp
查看文件 @
9f16cc12
...
...
@@ -4,6 +4,7 @@
#include "H264RtpCodec.h"
namespace
mediakit
{
H264RtpDecoder
::
H264RtpDecoder
()
{
_h264frame
=
obtainFrame
();
...
...
@@ -121,7 +122,7 @@ H264RtpEncoder::H264RtpEncoder(uint32_t ui32Ssrc,
void
H264RtpEncoder
::
inputFrame
(
const
Frame
::
Ptr
&
frame
)
{
RtpCodec
::
inputFrame
(
frame
);
GET_CONFIG_AND_REGISTER
(
uint32_t
,
cycleMS
,
Config
::
Rtp
::
kCycleMS
);
GET_CONFIG_AND_REGISTER
(
uint32_t
,
cycleMS
,
Rtp
::
kCycleMS
);
auto
pcData
=
frame
->
data
()
+
frame
->
prefixSize
();
auto
uiStamp
=
frame
->
stamp
();
auto
iLen
=
frame
->
size
()
-
frame
->
prefixSize
();
...
...
@@ -203,3 +204,5 @@ void H264RtpEncoder::makeH264Rtp(const void* data, unsigned int len, bool mark,
RtpCodec
::
inputRtp
(
rtppkt
,
type
==
5
);
_ui16Sequence
++
;
}
}
//
namespace
mediakit
\ No newline at end of file
src/RtpCodec/H264RtpCodec.h
查看文件 @
9f16cc12
...
...
@@ -7,8 +7,9 @@
#include "RtpCodec.h"
#include "Util/ResourcePool.h"
using
namespace
toolkit
;
using
namespace
ZL
::
Util
;
namespace
mediakit
{
/**
* h264 rtp解码类
...
...
@@ -74,5 +75,6 @@ private:
unsigned
char
_aucSectionBuf
[
1600
];
};
}
//namespace mediakit{
#endif //ZLMEDIAKIT_H264RTPCODEC_H
src/RtpCodec/RtpCodec.h
查看文件 @
9f16cc12
...
...
@@ -9,10 +9,9 @@
#include "Util/RingBuffer.h"
#include "Rtsp/Rtsp.h"
#include "Player/PlayerBase.h"
using
namespace
toolkit
;
using
namespace
std
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Player
;
namespace
mediakit
{
class
RtpPacket
:
public
CodecInfo
{
public
:
...
...
@@ -156,7 +155,7 @@ public:
virtual
~
RtpCodec
(){}
};
}
//namespace mediakit
...
...
src/RtpCodec/RtpMaker.h
查看文件 @
9f16cc12
...
...
@@ -34,12 +34,9 @@
#include "Util/TimeTicker.h"
#include "Util/ResourcePool.h"
#include "Thread/ThreadPool.h"
using
namespace
toolkit
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Thread
;
namespace
ZL
{
namespace
Rtsp
{
namespace
mediakit
{
class
RtpMaker
{
public
:
...
...
@@ -102,7 +99,7 @@ private:
onGetRTP
callBack
;
};
}
/
* namespace RTP */
}
/* namespace ZL */
}
/
/namespace mediakit
#endif
/* RTP_RTPMAKER_H_ */
src/RtpCodec/RtpMakerAAC.cpp
查看文件 @
9f16cc12
...
...
@@ -28,15 +28,12 @@
#include "RtpMakerAAC.h"
#include "Util/mini.h"
#include "Network/sockutil.h"
using
namespace
toolkit
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Network
;
namespace
ZL
{
namespace
Rtsp
{
namespace
mediakit
{
void
RtpMaker_AAC
::
makeRtp
(
const
char
*
pcData
,
int
iLen
,
uint32_t
uiStamp
)
{
GET_CONFIG_AND_REGISTER
(
uint32_t
,
cycleMS
,
Config
::
Rtp
::
kCycleMS
);
GET_CONFIG_AND_REGISTER
(
uint32_t
,
cycleMS
,
Rtp
::
kCycleMS
);
uiStamp
%=
cycleMS
;
char
*
ptr
=
(
char
*
)
pcData
;
...
...
@@ -99,5 +96,4 @@ inline void RtpMaker_AAC::makeAACRtp(const void *pData, unsigned int uiLen, bool
_ui16Sequence
++
;
}
}
/* namespace RTP */
}
/* namespace ZL */
}
//
namespace
mediakit
\ No newline at end of file
src/RtpCodec/RtpMakerAAC.h
查看文件 @
9f16cc12
...
...
@@ -35,10 +35,9 @@
#include "Util/ResourcePool.h"
using
namespace
std
;
using
namespace
ZL
::
Util
;
using
namespace
toolkit
;
namespace
ZL
{
namespace
Rtsp
{
namespace
mediakit
{
class
RtpMaker_AAC
:
public
RtpMaker
{
public
:
...
...
@@ -56,7 +55,6 @@ private:
unsigned
char
_aucSectionBuf
[
1600
];
};
}
/* namespace RTP */
}
/* namespace ZL */
}
//namespace mediakit
#endif
/* RTP_RTPMAKERAAC_H_ */
src/RtpCodec/RtpMakerH264.cpp
查看文件 @
9f16cc12
...
...
@@ -28,15 +28,12 @@
#include "RtpMakerH264.h"
#include "Util/mini.h"
#include "Network/sockutil.h"
using
namespace
toolkit
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Network
;
namespace
ZL
{
namespace
Rtsp
{
namespace
mediakit
{
void
RtpMaker_H264
::
makeRtp
(
const
char
*
pcData
,
int
iLen
,
uint32_t
uiStamp
)
{
GET_CONFIG_AND_REGISTER
(
uint32_t
,
cycleMS
,
Config
::
Rtp
::
kCycleMS
);
GET_CONFIG_AND_REGISTER
(
uint32_t
,
cycleMS
,
Rtp
::
kCycleMS
);
uiStamp
%=
cycleMS
;
int
iSize
=
_iMtuSize
-
2
;
...
...
@@ -118,5 +115,4 @@ inline void RtpMaker_H264::makeH264Rtp(const void* data, unsigned int len, bool
//InfoL<<timeStamp<<" "<<time<<" "<<sampleRate;
}
}
/* namespace RTP */
}
/* namespace ZL */
}
//
namespace
mediakit
\ No newline at end of file
src/RtpCodec/RtpMakerH264.h
查看文件 @
9f16cc12
...
...
@@ -34,11 +34,9 @@
#include "Util/RingBuffer.h"
using
namespace
std
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Rtsp
;
using
namespace
toolkit
;
namespace
ZL
{
namespace
Rtsp
{
namespace
mediakit
{
class
RtpMaker_H264
:
public
RtpMaker
{
public
:
...
...
@@ -56,7 +54,7 @@ private:
unsigned
char
aucSectionBuf
[
1600
];
};
}
/* namespace RTP */
}
/* namespace ZL */
}
//namespace mediakit
#endif
/* RTP_RTPMAKERH264_H_ */
src/Rtsp/RtpBroadCaster.cpp
查看文件 @
9f16cc12
...
...
@@ -32,10 +32,9 @@
#include "RtspSession.h"
using
namespace
std
;
using
namespace
ZL
::
Network
;
using
namespace
toolkit
;
namespace
ZL
{
namespace
Rtsp
{
namespace
mediakit
{
MultiCastAddressMaker
&
MultiCastAddressMaker
::
Instance
()
{
static
MultiCastAddressMaker
instance
;
...
...
@@ -51,8 +50,8 @@ static uint32_t addressToInt(const string &ip){
std
::
shared_ptr
<
uint32_t
>
MultiCastAddressMaker
::
obtain
(
uint32_t
iTry
)
{
lock_guard
<
recursive_mutex
>
lck
(
_mtx
);
GET_CONFIG_AND_REGISTER
(
string
,
addrMinStr
,
Config
::
MultiCast
::
kAddrMin
);
GET_CONFIG_AND_REGISTER
(
string
,
addrMaxStr
,
Config
::
MultiCast
::
kAddrMax
);
GET_CONFIG_AND_REGISTER
(
string
,
addrMinStr
,
MultiCast
::
kAddrMin
);
GET_CONFIG_AND_REGISTER
(
string
,
addrMaxStr
,
MultiCast
::
kAddrMax
);
uint32_t
addrMin
=
addressToInt
(
addrMinStr
);
uint32_t
addrMax
=
addressToInt
(
addrMaxStr
);
...
...
@@ -112,7 +111,7 @@ RtpBroadCaster::RtpBroadCaster(const string &strLocalIp,const string &strVhost,c
throw
std
::
runtime_error
(
strErr
);
}
auto
fd
=
_apUdpSock
[
i
]
->
rawFD
();
GET_CONFIG_AND_REGISTER
(
uint32_t
,
udpTTL
,
Config
::
MultiCast
::
kUdpTTL
);
GET_CONFIG_AND_REGISTER
(
uint32_t
,
udpTTL
,
MultiCast
::
kUdpTTL
);
SockUtil
::
setMultiTTL
(
fd
,
udpTTL
);
SockUtil
::
setMultiLOOP
(
fd
,
false
);
...
...
@@ -184,8 +183,4 @@ RtpBroadCaster::Ptr RtpBroadCaster::get(const string &strLocalIp,const string &s
}
}
/* namespace Rtsp */
}
/* namespace ZL */
}
//namespace mediakit
src/Rtsp/RtpBroadCaster.h
查看文件 @
9f16cc12
...
...
@@ -39,11 +39,9 @@
#include "Network/Socket.h"
using
namespace
std
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Network
;
using
namespace
toolkit
;
namespace
ZL
{
namespace
Rtsp
{
namespace
mediakit
{
class
MultiCastAddressMaker
{
...
...
@@ -51,8 +49,8 @@ public:
static
MultiCastAddressMaker
&
Instance
();
static
bool
isMultiCastAddress
(
uint32_t
iAddr
){
static
uint32_t
addrMin
=
mINI
::
Instance
()[
Config
::
MultiCast
::
kAddrMin
].
as
<
uint32_t
>
();
static
uint32_t
addrMax
=
mINI
::
Instance
()[
Config
::
MultiCast
::
kAddrMax
].
as
<
uint32_t
>
();
static
uint32_t
addrMin
=
mINI
::
Instance
()[
MultiCast
::
kAddrMin
].
as
<
uint32_t
>
();
static
uint32_t
addrMax
=
mINI
::
Instance
()[
MultiCast
::
kAddrMax
].
as
<
uint32_t
>
();
return
iAddr
>=
addrMin
&&
iAddr
<=
addrMax
;
}
static
string
toString
(
uint32_t
iAddr
){
...
...
@@ -93,7 +91,6 @@ private:
};
}
/* namespace Rtsp */
}
/* namespace ZL */
}
//namespace mediakit
#endif
/* SRC_RTSP_RTPBROADCASTER_H_ */
src/Rtsp/RtpParser.cpp
查看文件 @
9f16cc12
...
...
@@ -33,8 +33,7 @@
using
namespace
std
;
namespace
ZL
{
namespace
Rtsp
{
namespace
mediakit
{
static
int
getTimeInSDP
(
const
string
&
sdp
)
{
auto
strRange
=
FindField
(
sdp
.
data
(),
"a=range:npt="
,
"
\r\n
"
);
...
...
@@ -127,5 +126,4 @@ vector<Track::Ptr> RtpParser::getTracks() const {
}
}
/* namespace Rtsp */
}
/* namespace ZL */
}
/* namespace mediakit */
src/Rtsp/RtpParser.h
查看文件 @
9f16cc12
...
...
@@ -35,11 +35,9 @@
#include "RtpCodec/RtpCodec.h"
using
namespace
std
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Player
;
using
namespace
toolkit
;
namespace
ZL
{
namespace
Rtsp
{
namespace
mediakit
{
class
RtpParser
:
public
PlayerBase
{
public
:
...
...
@@ -83,7 +81,6 @@ private:
RtpCodec
::
Ptr
_videoRtpDecoder
;
};
}
/* namespace Rtsp */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif
/* SRC_RTP_RTPPARSER_H_ */
src/Rtsp/Rtsp.h
查看文件 @
9f16cc12
...
...
@@ -35,7 +35,8 @@
#include "Player/Frame.h"
using
namespace
std
;
using
namespace
ZL
::
Util
;
using
namespace
toolkit
;
using
namespace
mediakit
;
class
RtspTrack
{
...
...
src/Rtsp/RtspMaker.cpp
查看文件 @
9f16cc12
...
...
@@ -5,8 +5,7 @@
#include "RtspMaker.h"
#include "Common/Factory.h"
namespace
ZL
{
namespace
Rtsp
{
namespace
mediakit
{
void
RtspMaker
::
addTrack
(
const
Track
::
Ptr
&
track
,
uint32_t
ssrc
,
int
mtu
)
{
if
(
track
->
getCodecId
()
==
CodecInvalid
)
{
...
...
@@ -19,5 +18,4 @@ void RtspMaker::addTrack(const Track::Ptr &track, uint32_t ssrc, int mtu) {
}
}
}
/* namespace Rtsp */
}
/* namespace ZL */
\ No newline at end of file
}
/* namespace mediakit */
\ No newline at end of file
src/Rtsp/RtspMaker.h
查看文件 @
9f16cc12
...
...
@@ -7,8 +7,7 @@
#include "RtspSdp.h"
namespace
ZL
{
namespace
Rtsp
{
namespace
mediakit
{
/**
* rtsp生成器
*/
...
...
@@ -131,7 +130,6 @@ private:
};
}
/* namespace Rtsp */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif //ZLMEDIAKIT_RTSPMAKER_H
src/Rtsp/RtspMediaSource.h
查看文件 @
9f16cc12
...
...
@@ -45,12 +45,9 @@
#include "Thread/ThreadPool.h"
using
namespace
std
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Thread
;
using
namespace
ZL
::
Media
;
using
namespace
toolkit
;
namespace
ZL
{
namespace
Rtsp
{
namespace
mediakit
{
class
RtspMediaSource
:
public
MediaSource
{
public
:
...
...
@@ -102,7 +99,6 @@ protected:
RingType
::
Ptr
_pRing
;
//rtp环形缓冲
};
}
/* namespace Rtsp */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif
/* SRC_RTSP_RTSPMEDIASOURCE_H_ */
src/Rtsp/RtspPlayer.cpp
查看文件 @
9f16cc12
...
...
@@ -37,11 +37,9 @@
#include "Util/util.h"
#include "Util/base64.h"
#include "Network/sockutil.h"
using
namespace
toolkit
;
using
namespace
ZL
::
Util
;
namespace
ZL
{
namespace
Rtsp
{
namespace
mediakit
{
#define POP_HEAD(trackidx) \
auto it = _amapRtpSort[trackidx].begin(); \
...
...
@@ -656,8 +654,8 @@ bool RtspPlayer::handleOneRtp(int iTrackidx, unsigned char *pucData, unsigned in
//开始排序缓存
if
(
_abSortStarted
[
iTrackidx
])
{
_amapRtpSort
[
iTrackidx
].
emplace
(
rtppt
.
sequence
,
pt_ptr
);
GET_CONFIG_AND_REGISTER
(
uint32_t
,
clearCount
,
Config
::
Rtp
::
kClearCount
);
GET_CONFIG_AND_REGISTER
(
uint32_t
,
maxRtpCount
,
Config
::
Rtp
::
kMaxRtpCount
);
GET_CONFIG_AND_REGISTER
(
uint32_t
,
clearCount
,
Rtp
::
kClearCount
);
GET_CONFIG_AND_REGISTER
(
uint32_t
,
maxRtpCount
,
Rtp
::
kMaxRtpCount
);
if
(
_aui64SeqOkCnt
[
iTrackidx
]
>=
clearCount
)
{
//网络环境改善,需要清空排序缓存
_aui64SeqOkCnt
[
iTrackidx
]
=
0
;
...
...
@@ -841,7 +839,6 @@ int RtspPlayer::getTrackIndexByTrackType(TrackType trackType) const {
return
-
1
;
}
}
/* namespace Rtsp */
}
/* namespace ZL */
}
/* namespace mediakit */
src/Rtsp/RtspPlayer.h
查看文件 @
9f16cc12
...
...
@@ -41,14 +41,9 @@
#include "Network/TcpClient.h"
using
namespace
std
;
using
namespace
ZL
::
Rtsp
;
using
namespace
ZL
::
Player
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Poller
;
using
namespace
ZL
::
Network
;
using
namespace
toolkit
;
namespace
ZL
{
namespace
Rtsp
{
namespace
mediakit
{
//实现了rtsp播放器协议部分的功能
class
RtspPlayer
:
public
PlayerBase
,
public
TcpClient
{
...
...
@@ -142,7 +137,6 @@ private:
Ticker
_aNowStampTicker
[
2
];
};
}
/* namespace Rtsp */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif
/* SRC_RTSPPLAYER_RTSPPLAYER_H_TXT_ */
src/Rtsp/RtspPlayerImp.h
查看文件 @
9f16cc12
...
...
@@ -37,11 +37,9 @@
#include "Util/TimeTicker.h"
using
namespace
std
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Player
;
using
namespace
toolkit
;
namespace
ZL
{
namespace
Rtsp
{
namespace
mediakit
{
class
RtspPlayerImp
:
public
PlayerImp
<
RtspPlayer
,
RtpParser
>
{
public
:
...
...
@@ -95,7 +93,6 @@ private:
};
}
/* namespace Rtsp */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif
/* SRC_RTP_RTPPARSERTESTER_H_ */
src/Rtsp/RtspSdp.cpp
查看文件 @
9f16cc12
#
include
"RtspSdp.h"
#include "Common/Factory.h"
namespace
mediakit
{
void
Sdp
::
createRtpEncoder
(
uint32_t
ssrc
,
int
mtu
)
{
_encoder
=
Factory
::
getRtpEncoderById
(
getCodecId
(),
ssrc
,
...
...
@@ -10,5 +12,6 @@ void Sdp::createRtpEncoder(uint32_t ssrc, int mtu) {
getTrackType
()
*
2
);
}
}
src/Rtsp/RtspSdp.h
查看文件 @
9f16cc12
...
...
@@ -10,8 +10,7 @@
#include "Util/base64.h"
#include "Player/Track.h"
namespace
ZL
{
namespace
Rtsp
{
namespace
mediakit
{
/**
* sdp基类
...
...
@@ -259,8 +258,7 @@ private:
};
}
/* namespace Rtsp */
}
/* namespace ZL */
}
/* namespace mediakit */
...
...
src/Rtsp/RtspSession.cpp
查看文件 @
9f16cc12
...
...
@@ -36,12 +36,10 @@
#include "Util/NoticeCenter.h"
#include "Network/sockutil.h"
using
namespace
Config
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Network
;
using
namespace
std
;
using
namespace
toolkit
;
namespace
ZL
{
namespace
Rtsp
{
namespace
mediakit
{
static
int
kSockFlags
=
SOCKET_DEFAULE_FLAGS
|
FLAG_MORE
;
...
...
@@ -301,7 +299,7 @@ void RtspSession::onAuthFailed(const weak_ptr<RtspSession> &weakSelf,const strin
int
n
;
char
response
[
2
*
1024
];
GET_CONFIG_AND_REGISTER
(
bool
,
authBasic
,
Config
::
Rtsp
::
kAuthBasic
);
GET_CONFIG_AND_REGISTER
(
bool
,
authBasic
,
Rtsp
::
kAuthBasic
);
if
(
!
authBasic
)
{
//我们需要客户端优先以md5方式认证
strongSelf
->
_strNonce
=
makeRandStr
(
32
);
...
...
@@ -1089,6 +1087,5 @@ inline void RtspSession::sendRTCP() {
#endif
}
/* namespace Session */
}
/* namespace ZL */
/* namespace mediakit */
src/Rtsp/RtspSession.h
查看文件 @
9f16cc12
...
...
@@ -41,15 +41,9 @@
#include "Http/HttpRequestSplitter.h"
using
namespace
std
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Rtsp
;
using
namespace
ZL
::
Player
;
using
namespace
ZL
::
Network
;
using
namespace
ZL
::
Http
;
using
namespace
toolkit
;
namespace
ZL
{
namespace
Rtsp
{
namespace
mediakit
{
class
RtspSession
;
...
...
@@ -205,7 +199,6 @@ private:
};
}
/* namespace Session */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif
/* SESSION_RTSPSESSION_H_ */
src/Rtsp/RtspToRtmpMediaSource.cpp
查看文件 @
9f16cc12
...
...
@@ -30,13 +30,9 @@
#include "RtspToRtmpMediaSource.h"
#include "Util/util.h"
#include "Network/sockutil.h"
using
namespace
toolkit
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Network
;
namespace
ZL
{
namespace
Rtsp
{
namespace
mediakit
{
RtspToRtmpMediaSource
::
RtspToRtmpMediaSource
(
const
string
&
vhost
,
const
string
&
app
,
...
...
@@ -220,5 +216,5 @@ void RtspToRtmpMediaSource::makeMetaData() {
#endif
_pRtmpSrc
->
onGetMetaData
(
metaData
);
}
}
/* namespace Rtsp */
}
/* namespace
ZL
*/
}
/* namespace
mediakit
*/
src/Rtsp/RtspToRtmpMediaSource.h
查看文件 @
9f16cc12
...
...
@@ -32,12 +32,10 @@
#include "Rtmp/amf.h"
#include "Rtmp/RtmpMediaSource.h"
#include "MediaFile/MediaRecorder.h"
using
namespace
toolkit
;
using
namespace
ZL
::
Rtmp
;
using
namespace
ZL
::
MediaFile
;
namespace
mediakit
{
namespace
ZL
{
namespace
Rtsp
{
class
RtspToRtmpMediaSource
:
public
RtspMediaSource
{
public
:
typedef
std
::
shared_ptr
<
RtspToRtmpMediaSource
>
Ptr
;
...
...
@@ -109,7 +107,6 @@ private:
};
}
/* namespace Rtsp */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif
/* SRC_RTSP_RTSPTORTMPMEDIASOURCE_H_ */
src/Rtsp/UDPServer.cpp
查看文件 @
9f16cc12
...
...
@@ -26,11 +26,9 @@
#include "UDPServer.h"
#include "Util/TimeTicker.h"
using
namespace
toolkit
;
using
namespace
ZL
::
Util
;
namespace
ZL
{
namespace
Rtsp
{
namespace
mediakit
{
UDPServer
&
UDPServer
::
Instance
()
{
static
UDPServer
*
instance
(
new
UDPServer
());
...
...
@@ -116,7 +114,6 @@ void UDPServer::onRcvData(int iTrackIndex, const Buffer::Ptr &pBuf, struct socka
}
}
}
/* namespace Rtsp */
}
/* namespace ZL */
}
/* namespace mediakit */
src/Rtsp/UDPServer.h
查看文件 @
9f16cc12
...
...
@@ -36,11 +36,9 @@
#include "Network/Socket.h"
using
namespace
std
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Network
;
using
namespace
toolkit
;
namespace
ZL
{
namespace
Rtsp
{
namespace
mediakit
{
class
UDPServer
{
public
:
...
...
@@ -63,7 +61,6 @@ private:
mutex
_mtxDataHandler
;
};
}
/* namespace Rtsp */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif
/* RTSP_UDPSERVER_H_ */
src/Shell/ShellCMD.cpp
查看文件 @
9f16cc12
...
...
@@ -4,12 +4,9 @@
#include "Util/CMD.h"
#include "Common/MediaSource.h"
using
namespace
toolkit
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Media
;
namespace
ZL
{
namespace
Shell
{
namespace
mediakit
{
class
CMD_media
:
public
CMD
{
...
...
@@ -94,5 +91,4 @@ static onceToken s_token([]() {
},
nullptr
);
}
/* namespace Shell */
}
/* namespace ZL */
\ No newline at end of file
}
/* namespace mediakit */
\ No newline at end of file
src/Shell/ShellSession.cpp
查看文件 @
9f16cc12
...
...
@@ -29,12 +29,9 @@
#include "Util/CMD.h"
#include "Util/onceToken.h"
#include "Util/NoticeCenter.h"
using
namespace
toolkit
;
using
namespace
Config
;
using
namespace
ZL
::
Util
;
namespace
ZL
{
namespace
Shell
{
namespace
mediakit
{
ShellSession
::
ShellSession
(
const
std
::
shared_ptr
<
ThreadPool
>
&
_th
,
const
Socket
::
Ptr
&
_sock
)
:
...
...
@@ -47,7 +44,7 @@ ShellSession::~ShellSession() {
void
ShellSession
::
onRecv
(
const
Buffer
::
Ptr
&
buf
)
{
//DebugL << hexdump(buf->data(), buf->size());
GET_CONFIG_AND_REGISTER
(
uint32_t
,
maxReqSize
,
Config
::
Shell
::
kMaxReqSize
);
GET_CONFIG_AND_REGISTER
(
uint32_t
,
maxReqSize
,
Shell
::
kMaxReqSize
);
if
(
_strRecvBuf
.
size
()
+
buf
->
size
()
>=
maxReqSize
)
{
WarnL
<<
"接收缓冲区溢出!"
;
shutdown
();
...
...
@@ -161,5 +158,4 @@ inline void ShellSession::printShellPrefix() {
send
(
StrPrinter
<<
_strUserName
<<
"@"
<<
SERVER_NAME
<<
"# "
<<
endl
);
}
}
/* namespace Shell */
}
/* namespace ZL */
}
/* namespace mediakit */
src/Shell/ShellSession.h
查看文件 @
9f16cc12
...
...
@@ -31,13 +31,9 @@
#include "Common/config.h"
#include "Util/TimeTicker.h"
#include "Network/TcpSession.h"
using
namespace
toolkit
;
using
namespace
std
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Network
;
namespace
ZL
{
namespace
Shell
{
namespace
mediakit
{
class
ShellSession
:
public
TcpSession
{
public
:
...
...
@@ -60,7 +56,6 @@ private:
string
_strUserName
;
};
}
/* namespace Shell */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif
/* SRC_SHELL_SHELLSESSION_H_ */
tests/DeviceHK/DeviceHK.cpp
查看文件 @
9f16cc12
...
...
@@ -27,8 +27,7 @@
#include "DeviceHK.h"
#include "Util/TimeTicker.h"
#include "Util/MD5.h"
namespace
ZL
{
namespace
DEV
{
namespace
mediakit
{
#define HK_APP_NAME "live"
...
...
@@ -261,7 +260,6 @@ void DevChannelHK::onGetDecData(char* pBuf, int nSize, FRAME_INFO* pFrameInfo) {
}
}
}
/* namespace DEV */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif //ENABLE_HKDEVICE
tests/DeviceHK/DeviceHK.h
查看文件 @
9f16cc12
...
...
@@ -35,10 +35,9 @@
#include "Util/logger.h"
#include "Util/TimeTicker.h"
using
namespace
ZL
::
Util
;
using
namespace
toolkit
;
namespace
ZL
{
namespace
DEV
{
namespace
mediakit
{
class
connectInfo
{
public
:
...
...
@@ -130,7 +129,6 @@ protected:
bool
m_bAudioSeted
=
false
;
};
}
/* namespace DEV */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif
/* DEVICE_DEVICEHK_H_ */
tests/H264Decoder.h
查看文件 @
9f16cc12
...
...
@@ -41,8 +41,7 @@ extern "C" {
using
namespace
std
;
namespace
ZL
{
namespace
Codec
{
namespace
mediakit
{
class
H264Decoder
{
...
...
@@ -95,8 +94,7 @@ private:
};
}
/* namespace Codec */
}
/* namespace ZL */
}
/* namespace mediakit */
#endif
/* H264Decoder_H_ */
...
...
tests/YuvDisplayer.h
查看文件 @
9f16cc12
...
...
@@ -38,7 +38,8 @@ extern "C" {
#pragma comment(lib,"SDL2.lib")
#endif //defined(_WIN32)
using
namespace
ZL
::
Util
;
using
namespace
toolkit
;
using
namespace
mediakit
;
#define REFRESH_EVENT (SDL_USEREVENT + 1)
...
...
tests/test_benchmark.cpp
查看文件 @
9f16cc12
...
...
@@ -36,12 +36,8 @@
#include "Thread/WorkThreadPool.h"
using
namespace
std
;
using
namespace
ZL
::
DEV
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Rtsp
;
using
namespace
ZL
::
Thread
;
using
namespace
ZL
::
Network
;
using
namespace
toolkit
;
using
namespace
mediakit
;
int
main
(
int
argc
,
char
*
argv
[])
{
//设置退出信号处理函数
...
...
tests/test_httpApi.cpp
查看文件 @
9f16cc12
...
...
@@ -43,13 +43,11 @@
#include "Util/NoticeCenter.h"
using
namespace
std
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Http
;
using
namespace
ZL
::
Thread
;
using
namespace
ZL
::
Network
;
using
namespace
toolkit
;
using
namespace
mediakit
;
static
onceToken
s_token
([](){
NoticeCenter
::
Instance
().
addListener
(
nullptr
,
Config
::
Broadcast
::
kBroadcastHttpRequest
,[](
BroadcastHttpRequestArgs
){
NoticeCenter
::
Instance
().
addListener
(
nullptr
,
Broadcast
::
kBroadcastHttpRequest
,[](
BroadcastHttpRequestArgs
){
//const Parser &parser,HttpSession::HttpResponseInvoker &invoker,bool &consumed
if
(
strstr
(
parser
.
Url
().
data
(),
"/api/"
)
!=
parser
.
Url
().
data
()){
return
;
...
...
@@ -98,7 +96,7 @@ int main(int argc,char *argv[]){
Logger
::
Instance
().
add
(
std
::
make_shared
<
ConsoleChannel
>
(
"stdout"
,
LTrace
));
Logger
::
Instance
().
setWriter
(
std
::
make_shared
<
AsyncLogWriter
>
());
//加载配置文件,如果配置文件不存在就创建一个
Config
::
loadIniConfig
();
loadIniConfig
();
#ifdef ENABLE_OPENSSL
//请把证书"test_httpApi.pem"放置在本程序可执行程序同目录下
...
...
@@ -113,12 +111,12 @@ int main(int argc,char *argv[]){
//开启http服务器
TcpServer
::
Ptr
httpSrv
(
new
TcpServer
());
httpSrv
->
start
<
EchoWebSocketSession
>
(
mINI
::
Instance
()[
Config
::
Http
::
kPort
]);
//默认80
httpSrv
->
start
<
EchoWebSocketSession
>
(
mINI
::
Instance
()[
Http
::
kPort
]);
//默认80
#ifdef ENABLE_OPENSSL
//如果支持ssl,还可以开启https服务器
TcpServer
::
Ptr
httpsSrv
(
new
TcpServer
());
httpsSrv
->
start
<
SSLEchoWebSocketSession
>
(
mINI
::
Instance
()[
Config
::
Http
::
kSSLPort
]);
//默认443
httpsSrv
->
start
<
SSLEchoWebSocketSession
>
(
mINI
::
Instance
()[
Http
::
kSSLPort
]);
//默认443
#endif //ENABLE_OPENSSL
InfoL
<<
"你可以在浏览器输入:http://127.0.0.1/api/my_api?key0=val0&key1=参数1"
<<
endl
;
...
...
tests/test_httpClient.cpp
查看文件 @
9f16cc12
...
...
@@ -36,11 +36,8 @@
#include "Http/HttpDownloader.h"
using
namespace
std
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Http
;
using
namespace
ZL
::
Poller
;
using
namespace
ZL
::
Network
;
using
namespace
toolkit
;
using
namespace
mediakit
;
int
main
(
int
argc
,
char
*
argv
[])
{
//设置退出信号处理函数
...
...
tests/test_player.cpp
查看文件 @
9f16cc12
...
...
@@ -36,12 +36,8 @@
#include "Network/sockutil.h"
using
namespace
std
;
using
namespace
ZL
::
Codec
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Thread
;
using
namespace
ZL
::
Network
;
using
namespace
ZL
::
Rtsp
;
using
namespace
ZL
::
Player
;
using
namespace
toolkit
;
using
namespace
mediakit
;
int
main
(
int
argc
,
char
*
argv
[])
{
//设置退出信号处理函数
...
...
tests/test_rtmpPusher.cpp
查看文件 @
9f16cc12
...
...
@@ -34,11 +34,8 @@
#include "Common/config.h"
using
namespace
std
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Rtmp
;
using
namespace
ZL
::
Thread
;
using
namespace
ZL
::
Network
;
using
namespace
ZL
::
DEV
;
using
namespace
toolkit
;
using
namespace
mediakit
;
//推流器,保持强引用
RtmpPusher
::
Ptr
pusher
;
...
...
@@ -98,7 +95,7 @@ int domain(const string &playUrl, const string &pushUrl) {
player
->
play
(
playUrl
.
data
());
//监听RtmpMediaSource注册事件,在PlayerProxy播放成功后触发
NoticeCenter
::
Instance
().
addListener
(
nullptr
,
Config
::
Broadcast
::
kBroadcastMediaChanged
,
NoticeCenter
::
Instance
().
addListener
(
nullptr
,
Broadcast
::
kBroadcastMediaChanged
,
[
pushUrl
](
BroadcastMediaChangedArgs
)
{
//媒体源"app/stream"已经注册,这时方可新建一个RtmpPusher对象并绑定该媒体源
if
(
bRegist
&&
schema
==
RTMP_SCHEMA
){
...
...
tests/test_rtmpPusherMp4.cpp
查看文件 @
9f16cc12
...
...
@@ -35,11 +35,8 @@
#include "MediaFile/MediaReader.h"
using
namespace
std
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Rtmp
;
using
namespace
ZL
::
Thread
;
using
namespace
ZL
::
Network
;
using
namespace
ZL
::
DEV
;
using
namespace
toolkit
;
using
namespace
mediakit
;
//推流器,保持强引用
RtmpPusher
::
Ptr
pusher
;
...
...
@@ -101,7 +98,7 @@ int domain(const string & filePath,const string & pushUrl){
Logger
::
Instance
().
setWriter
(
std
::
make_shared
<
AsyncLogWriter
>
());
//录像应用名称默认为record
string
appName
=
mINI
::
Instance
()[
Config
::
Record
::
kAppName
];
string
appName
=
mINI
::
Instance
()[
Record
::
kAppName
];
//app必须record,filePath(流id)为相对于httpRoot/record的路径,否则MediaReader会找到不该文件
//限制app为record是为了防止服务器上的文件被肆意访问
createPusher
(
appName
,
filePath
,
pushUrl
);
...
...
tests/test_server.cpp
查看文件 @
9f16cc12
...
...
@@ -50,20 +50,13 @@
#include "Device/PlayerProxy.h"
using
namespace
std
;
using
namespace
ZL
::
DEV
;
using
namespace
ZL
::
Util
;
using
namespace
ZL
::
Http
;
using
namespace
ZL
::
Rtsp
;
using
namespace
ZL
::
Rtmp
;
using
namespace
ZL
::
Shell
;
using
namespace
ZL
::
Thread
;
using
namespace
ZL
::
Network
;
using
namespace
toolkit
;
using
namespace
mediakit
;
#define REALM "realm_zlmedaikit"
static
onceToken
s_token
([](){
NoticeCenter
::
Instance
().
addListener
(
nullptr
,
Config
::
Broadcast
::
kBroadcastOnGetRtspRealm
,[](
BroadcastOnGetRtspRealmArgs
){
NoticeCenter
::
Instance
().
addListener
(
nullptr
,
Broadcast
::
kBroadcastOnGetRtspRealm
,[](
BroadcastOnGetRtspRealmArgs
){
if
(
string
(
"1"
)
==
args
.
m_streamid
){
// live/1需要认证
EventPoller
::
Instance
().
async
([
invoker
](){
...
...
@@ -80,7 +73,7 @@ static onceToken s_token([](){
}
});
NoticeCenter
::
Instance
().
addListener
(
nullptr
,
Config
::
Broadcast
::
kBroadcastOnRtspAuth
,[](
BroadcastOnRtspAuthArgs
){
NoticeCenter
::
Instance
().
addListener
(
nullptr
,
Broadcast
::
kBroadcastOnRtspAuth
,[](
BroadcastOnRtspAuthArgs
){
InfoL
<<
"用户:"
<<
user_name
<<
(
must_no_encrypt
?
" Base64"
:
" MD5"
)
<<
" 方式登录"
;
string
user
=
user_name
;
//假设我们异步读取数据库
...
...
@@ -110,7 +103,7 @@ static onceToken s_token([](){
});
NoticeCenter
::
Instance
().
addListener
(
nullptr
,
Config
::
Broadcast
::
kBroadcastRtmpPublish
,[](
BroadcastRtmpPublishArgs
){
NoticeCenter
::
Instance
().
addListener
(
nullptr
,
Broadcast
::
kBroadcastRtmpPublish
,[](
BroadcastRtmpPublishArgs
){
InfoL
<<
args
.
m_vhost
<<
" "
<<
args
.
m_app
<<
" "
<<
args
.
m_streamid
<<
" "
<<
args
.
m_param_strs
;
EventPoller
::
Instance
().
async
([
invoker
](){
invoker
(
""
);
//鉴权成功
...
...
@@ -118,7 +111,7 @@ static onceToken s_token([](){
});
});
NoticeCenter
::
Instance
().
addListener
(
nullptr
,
Config
::
Broadcast
::
kBroadcastMediaPlayed
,[](
BroadcastMediaPlayedArgs
){
NoticeCenter
::
Instance
().
addListener
(
nullptr
,
Broadcast
::
kBroadcastMediaPlayed
,[](
BroadcastMediaPlayedArgs
){
InfoL
<<
args
.
m_schema
<<
" "
<<
args
.
m_vhost
<<
" "
<<
args
.
m_app
<<
" "
<<
args
.
m_streamid
<<
" "
<<
args
.
m_param_strs
;
EventPoller
::
Instance
().
async
([
invoker
](){
invoker
(
""
);
//鉴权成功
...
...
@@ -126,7 +119,7 @@ static onceToken s_token([](){
});
});
NoticeCenter
::
Instance
().
addListener
(
nullptr
,
Config
::
Broadcast
::
kBroadcastShellLogin
,[](
BroadcastShellLoginArgs
){
NoticeCenter
::
Instance
().
addListener
(
nullptr
,
Broadcast
::
kBroadcastShellLogin
,[](
BroadcastShellLoginArgs
){
InfoL
<<
"shell login:"
<<
user_name
<<
" "
<<
passwd
;
EventPoller
::
Instance
().
async
([
invoker
](){
invoker
(
""
);
//鉴权成功
...
...
@@ -135,13 +128,13 @@ static onceToken s_token([](){
});
//此处用于测试rtmp保存为flv录像,保存在http根目录下
NoticeCenter
::
Instance
().
addListener
(
nullptr
,
Config
::
Broadcast
::
kBroadcastMediaChanged
,[](
BroadcastMediaChangedArgs
){
NoticeCenter
::
Instance
().
addListener
(
nullptr
,
Broadcast
::
kBroadcastMediaChanged
,[](
BroadcastMediaChangedArgs
){
if
(
schema
==
RTMP_SCHEMA
){
static
map
<
string
,
FlvRecorder
::
Ptr
>
s_mapFlvRecorder
;
static
mutex
s_mtxFlvRecorder
;
lock_guard
<
mutex
>
lck
(
s_mtxFlvRecorder
);
if
(
bRegist
){
GET_CONFIG_AND_REGISTER
(
string
,
http_root
,
Config
::
Http
::
kRootPath
);
GET_CONFIG_AND_REGISTER
(
string
,
http_root
,
Http
::
kRootPath
);
auto
path
=
http_root
+
"/"
+
vhost
+
"/"
+
app
+
"/"
+
stream
+
"_"
+
to_string
(
time
(
NULL
))
+
".flv"
;
FlvRecorder
::
Ptr
recorder
(
new
FlvRecorder
);
try
{
...
...
@@ -166,13 +159,13 @@ static onceToken s_token([](){
int
main
(
int
argc
,
char
*
argv
[])
{
//设置退出信号处理函数
signal
(
SIGINT
,
[](
int
)
{
EventPoller
::
Instance
().
shutdown
();
});
signal
(
SIGHUP
,
[](
int
)
{
Config
::
loadIniConfig
();
});
signal
(
SIGHUP
,
[](
int
)
{
loadIniConfig
();
});
//设置日志
Logger
::
Instance
().
add
(
std
::
make_shared
<
ConsoleChannel
>
(
"stdout"
,
LTrace
));
Logger
::
Instance
().
setWriter
(
std
::
make_shared
<
AsyncLogWriter
>
());
//加载配置文件,如果配置文件不存在就创建一个
Config
::
loadIniConfig
();
loadIniConfig
();
{
//这里是拉流地址,支持rtmp/rtsp协议,负载必须是H264+AAC
//如果是其他不识别的音视频将会被忽略(譬如说h264+adpcm转发后会去除音频)
...
...
@@ -214,11 +207,11 @@ int main(int argc,char *argv[]) {
}
#endif //ENABLE_OPENSSL
uint16_t
shellPort
=
mINI
::
Instance
()[
Config
::
Shell
::
kPort
];
uint16_t
rtspPort
=
mINI
::
Instance
()[
Config
::
Rtsp
::
kPort
];
uint16_t
rtmpPort
=
mINI
::
Instance
()[
Config
::
Rtmp
::
kPort
];
uint16_t
httpPort
=
mINI
::
Instance
()[
Config
::
Http
::
kPort
];
uint16_t
httpsPort
=
mINI
::
Instance
()[
Config
::
Http
::
kSSLPort
];
uint16_t
shellPort
=
mINI
::
Instance
()[
Shell
::
kPort
];
uint16_t
rtspPort
=
mINI
::
Instance
()[
Rtsp
::
kPort
];
uint16_t
rtmpPort
=
mINI
::
Instance
()[
Rtmp
::
kPort
];
uint16_t
httpPort
=
mINI
::
Instance
()[
Http
::
kPort
];
uint16_t
httpsPort
=
mINI
::
Instance
()[
Http
::
kSSLPort
];
//简单的telnet服务器,可用于服务器调试,但是不能使用23端口,否则telnet上了莫名其妙的现象
//测试方法:telnet 127.0.0.1 9000
...
...
@@ -238,31 +231,31 @@ int main(int argc,char *argv[]) {
httpsSrv
->
start
<
HttpsSession
>
(
httpsPort
);
//默认443
#endif //ENABLE_OPENSSL
NoticeCenter
::
Instance
().
addListener
(
ReloadConfigTag
,
Config
::
Broadcast
::
kBroadcastReloadConfig
,[
&
](
BroadcastReloadConfigArgs
){
NoticeCenter
::
Instance
().
addListener
(
ReloadConfigTag
,
Broadcast
::
kBroadcastReloadConfig
,[
&
](
BroadcastReloadConfigArgs
){
//重新创建服务器
if
(
shellPort
!=
mINI
::
Instance
()[
Config
::
Shell
::
kPort
].
as
<
uint16_t
>
()){
shellPort
=
mINI
::
Instance
()[
Config
::
Shell
::
kPort
];
if
(
shellPort
!=
mINI
::
Instance
()[
Shell
::
kPort
].
as
<
uint16_t
>
()){
shellPort
=
mINI
::
Instance
()[
Shell
::
kPort
];
shellSrv
->
start
<
ShellSession
>
(
shellPort
);
InfoL
<<
"重启shell服务器:"
<<
shellPort
;
}
if
(
rtspPort
!=
mINI
::
Instance
()[
Config
::
Rtsp
::
kPort
].
as
<
uint16_t
>
()){
rtspPort
=
mINI
::
Instance
()[
Config
::
Rtsp
::
kPort
];
if
(
rtspPort
!=
mINI
::
Instance
()[
Rtsp
::
kPort
].
as
<
uint16_t
>
()){
rtspPort
=
mINI
::
Instance
()[
Rtsp
::
kPort
];
rtspSrv
->
start
<
RtspSession
>
(
rtspPort
);
InfoL
<<
"重启rtsp服务器"
<<
rtspPort
;
}
if
(
rtmpPort
!=
mINI
::
Instance
()[
Config
::
Rtmp
::
kPort
].
as
<
uint16_t
>
()){
rtmpPort
=
mINI
::
Instance
()[
Config
::
Rtmp
::
kPort
];
if
(
rtmpPort
!=
mINI
::
Instance
()[
Rtmp
::
kPort
].
as
<
uint16_t
>
()){
rtmpPort
=
mINI
::
Instance
()[
Rtmp
::
kPort
];
rtmpSrv
->
start
<
RtmpSession
>
(
rtmpPort
);
InfoL
<<
"重启rtmp服务器"
<<
rtmpPort
;
}
if
(
httpPort
!=
mINI
::
Instance
()[
Config
::
Http
::
kPort
].
as
<
uint16_t
>
()){
httpPort
=
mINI
::
Instance
()[
Config
::
Http
::
kPort
];
if
(
httpPort
!=
mINI
::
Instance
()[
Http
::
kPort
].
as
<
uint16_t
>
()){
httpPort
=
mINI
::
Instance
()[
Http
::
kPort
];
httpSrv
->
start
<
HttpSession
>
(
httpPort
);
InfoL
<<
"重启http服务器"
<<
httpPort
;
}
#ifdef ENABLE_OPENSSL
if
(
httpsPort
!=
mINI
::
Instance
()[
Config
::
Http
::
kSSLPort
].
as
<
uint16_t
>
()){
httpsPort
=
mINI
::
Instance
()[
Config
::
Http
::
kSSLPort
];
if
(
httpsPort
!=
mINI
::
Instance
()[
Http
::
kSSLPort
].
as
<
uint16_t
>
()){
httpsPort
=
mINI
::
Instance
()[
Http
::
kSSLPort
];
httpsSrv
->
start
<
HttpsSession
>
(
httpsPort
);
InfoL
<<
"重启https服务器"
<<
httpsPort
;
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论