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