mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-02-26 10:10:53 +08:00
整理命名空间 (#1409)
* feat: remove using namespace mediakit in header files. (cherry picked from commit d44aeb339a8a0e1f0455be82b21fe4b1b536299f) * feat: remove using namespace mediakit in FFmpegSource.h * feat: remove using namespace mediakit in RtpExt.h * feat: remove using namespace mediakit in header files. * feat: remove using namespace std in header files. * feat: remove using namespace std in header files when zltoolkit remove std in header * 补充命名空间 * 整理命名空间 * 整理命名空间2 * 修复macos ci * 修复编译问题 * 修复编译问题2 * 修复编译问题3 Co-authored-by: Johnny <hellojinqiang@gmail.com> Co-authored-by: Xiaofeng Wang <wasphin@gmail.com>
This commit is contained in:
@@ -30,9 +30,6 @@ extern "C" {
|
||||
#include "SDLAudioDevice.h"
|
||||
#include "FFMpegDecoder.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace toolkit;
|
||||
|
||||
class AudioSRCDelegate {
|
||||
public:
|
||||
virtual ~AudioSRCDelegate() {};
|
||||
@@ -58,7 +55,7 @@ private:
|
||||
int _buf_size = 0;
|
||||
std::shared_ptr<char> _buf;
|
||||
AudioSRCDelegate *_delegate = nullptr;
|
||||
BufferLikeString _target_buf;
|
||||
toolkit::BufferLikeString _target_buf;
|
||||
SDL_AudioCVT _audio_cvt;
|
||||
};
|
||||
|
||||
@@ -79,8 +76,8 @@ private:
|
||||
private:
|
||||
int _sample_rate, _channel;
|
||||
SDL_AudioFormat _format;
|
||||
mutex _mtx;
|
||||
BufferLikeString _buffer;
|
||||
std::mutex _mtx;
|
||||
toolkit::BufferLikeString _buffer;
|
||||
SDLAudioDevice::Ptr _device;
|
||||
};
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#define MAX_DELAY_SECOND 3
|
||||
|
||||
using namespace std;
|
||||
using namespace toolkit;
|
||||
using namespace mediakit;
|
||||
|
||||
static string ffmpeg_err(int errnum) {
|
||||
|
||||
@@ -60,15 +60,15 @@ public:
|
||||
~TaskManager();
|
||||
|
||||
protected:
|
||||
void startThread(const string &name);
|
||||
void startThread(const std::string &name);
|
||||
void stopThread();
|
||||
|
||||
void addEncodeTask(function<void()> task);
|
||||
void addDecodeTask(bool key_frame, function<void()> task);
|
||||
void addEncodeTask(std::function<void()> task);
|
||||
void addDecodeTask(bool key_frame, std::function<void()> task);
|
||||
bool isEnabled() const;
|
||||
|
||||
private:
|
||||
void onThreadRun(const string &name);
|
||||
void onThreadRun(const std::string &name);
|
||||
void pushExit();
|
||||
|
||||
private:
|
||||
@@ -81,36 +81,36 @@ private:
|
||||
private:
|
||||
bool _decode_drop_start = false;
|
||||
bool _exit = false;
|
||||
mutex _task_mtx;
|
||||
semaphore _sem;
|
||||
List<function<void()> > _task;
|
||||
std::shared_ptr<thread> _thread;
|
||||
std::mutex _task_mtx;
|
||||
toolkit::semaphore _sem;
|
||||
toolkit::List<std::function<void()> > _task;
|
||||
std::shared_ptr<std::thread> _thread;
|
||||
};
|
||||
|
||||
class FFmpegDecoder : private TaskManager {
|
||||
public:
|
||||
using Ptr = std::shared_ptr<FFmpegDecoder>;
|
||||
using onDec = function<void(const FFmpegFrame::Ptr &)>;
|
||||
using onDec = std::function<void(const FFmpegFrame::Ptr &)>;
|
||||
|
||||
FFmpegDecoder(const Track::Ptr &track);
|
||||
FFmpegDecoder(const mediakit::Track::Ptr &track);
|
||||
~FFmpegDecoder();
|
||||
|
||||
bool inputFrame(const Frame::Ptr &frame, bool may_async = true);
|
||||
bool inputFrame(const mediakit::Frame::Ptr &frame, bool may_async = true);
|
||||
void setOnDecode(onDec cb);
|
||||
void flush();
|
||||
const AVCodecContext *getContext() const;
|
||||
|
||||
private:
|
||||
void onDecode(const FFmpegFrame::Ptr &frame);
|
||||
bool inputFrame_l(const Frame::Ptr &frame);
|
||||
bool inputFrame_l(const mediakit::Frame::Ptr &frame);
|
||||
bool decodeFrame(const char *data, size_t size, uint32_t dts, uint32_t pts);
|
||||
|
||||
private:
|
||||
bool _do_merger = false;
|
||||
Ticker _ticker;
|
||||
toolkit::Ticker _ticker;
|
||||
onDec _cb;
|
||||
std::shared_ptr<AVCodecContext> _context;
|
||||
FrameMerger _merger{FrameMerger::h264_prefix};
|
||||
mediakit::FrameMerger _merger { mediakit::FrameMerger::h264_prefix };
|
||||
};
|
||||
|
||||
#endif /* FFMpegDecoder_H_ */
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#define DEFAULT_CHANNEL 2
|
||||
#define DEFAULT_SAMPLES 1024
|
||||
|
||||
using namespace std;
|
||||
|
||||
class AudioSRC;
|
||||
|
||||
@@ -43,8 +42,8 @@ private:
|
||||
private:
|
||||
std::shared_ptr<char> _play_buf;
|
||||
SDL_AudioSpec _audio_config;
|
||||
recursive_mutex _channel_mtx;
|
||||
unordered_set<AudioSRC *> _channels;
|
||||
std::recursive_mutex _channel_mtx;
|
||||
std::unordered_set<AudioSRC *> _channels;
|
||||
};
|
||||
|
||||
#endif /* SDLAUDIOMIXER_SDLAUDIODEVICE_H_ */
|
||||
|
||||
@@ -25,12 +25,8 @@ extern "C" {
|
||||
#pragma comment(lib,"SDL2.lib")
|
||||
#endif //defined(_WIN32)
|
||||
|
||||
using namespace toolkit;
|
||||
using namespace mediakit;
|
||||
|
||||
#define REFRESH_EVENT (SDL_USEREVENT + 1)
|
||||
|
||||
|
||||
class SDLDisplayerHelper
|
||||
{
|
||||
public:
|
||||
@@ -44,7 +40,7 @@ public:
|
||||
template<typename FUN>
|
||||
void doTask(FUN &&f){
|
||||
{
|
||||
lock_guard<mutex> lck(_mtxTask);
|
||||
std::lock_guard<std::mutex> lck(_mtxTask);
|
||||
_taskList.emplace_back(f);
|
||||
}
|
||||
SDL_Event event;
|
||||
@@ -61,8 +57,8 @@ public:
|
||||
switch (event.type){
|
||||
case REFRESH_EVENT:{
|
||||
{
|
||||
lock_guard<mutex> lck(_mtxTask);
|
||||
if(_taskList.empty()){
|
||||
std::lock_guard<std::mutex> lck(_mtxTask);
|
||||
if (_taskList.empty()) {
|
||||
//not reachable
|
||||
continue;
|
||||
}
|
||||
@@ -102,17 +98,17 @@ public:
|
||||
using Ptr = std::shared_ptr<YuvDisplayer>;
|
||||
|
||||
YuvDisplayer(void *hwnd = nullptr,const char *title = "untitled"){
|
||||
static onceToken token([]() {
|
||||
if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO) == -1) {
|
||||
string err = "初始化SDL失败:";
|
||||
static toolkit::onceToken token([]() {
|
||||
if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO) == -1) {
|
||||
std::string err = "初始化SDL失败:";
|
||||
err+= SDL_GetError();
|
||||
ErrorL << err;
|
||||
throw std::runtime_error(err);
|
||||
}
|
||||
SDL_LogSetAllPriority(SDL_LOG_PRIORITY_CRITICAL);
|
||||
SDL_LogSetOutputFunction([](void *userdata, int category, SDL_LogPriority priority, const char *message){
|
||||
SDL_LogSetOutputFunction([](void *userdata, int category, SDL_LogPriority priority, const char *message) {
|
||||
DebugL << category << " " << priority << message;
|
||||
},nullptr);
|
||||
}, nullptr);
|
||||
InfoL << "SDL_Init";
|
||||
}, []() {
|
||||
SDLDisplayerHelper::Destory();
|
||||
@@ -194,7 +190,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
private:
|
||||
string _title;
|
||||
std::string _title;
|
||||
SDL_Window *_win = nullptr;
|
||||
SDL_Renderer *_render = nullptr;
|
||||
SDL_Texture *_texture = nullptr;
|
||||
|
||||
@@ -116,7 +116,7 @@ int main(int argc, char *argv[]) {
|
||||
WarnL << "play shutdown: " << ex.what();
|
||||
});
|
||||
|
||||
(*player)[kRtpType] = atoi(argv[2]);
|
||||
(*player)[Client::kRtpType] = atoi(argv[2]);
|
||||
//不等待track ready再回调播放成功事件,这样可以加快秒开速度
|
||||
(*player)[Client::kWaitTrackReady] = false;
|
||||
player->play(argv[1]);
|
||||
|
||||
Reference in New Issue
Block a user