mirror of
https://gitee.com/xia-chu/ZLMediaKit.git
synced 2026-06-29 17:57:48 +08:00
Compare commits
3 Commits
37ea51a2ec
...
4a2c4d0e98
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a2c4d0e98 | ||
|
|
e90da4ca68 | ||
|
|
86a7204bab |
@ -233,6 +233,7 @@ bash build_docker_images.sh
|
|||||||
- [BXC_SipServer](https://github.com/any12345com/BXC_SipServer) c++实现的国标GB28181流媒体信令服务器
|
- [BXC_SipServer](https://github.com/any12345com/BXC_SipServer) c++实现的国标GB28181流媒体信令服务器
|
||||||
- [gosip](https://github.com/panjjo/gosip) golang实现的GB28181服务器
|
- [gosip](https://github.com/panjjo/gosip) golang实现的GB28181服务器
|
||||||
- [FreeEhome](https://github.com/tsingeye/FreeEhome) golang实现的海康ehome服务器
|
- [FreeEhome](https://github.com/tsingeye/FreeEhome) golang实现的海康ehome服务器
|
||||||
|
- [泉视视频监控系统](https://github.com/2929004360/ruoyi-qs-nvr) 支持onvif、海康isup、大华sdk、jt808等协议接入视频管理系统
|
||||||
|
|
||||||
- 播放器
|
- 播放器
|
||||||
- [h265web.js](https://github.com/numberwolf/h265web.js) 基于wasm支持H265的播放器,支持本项目多种专属协议
|
- [h265web.js](https://github.com/numberwolf/h265web.js) 基于wasm支持H265的播放器,支持本项目多种专属协议
|
||||||
|
|||||||
@ -66,6 +66,11 @@ ProtocolOption::ProtocolOption() {
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
struct MediaSourceNull : public MediaSource {
|
||||||
|
MediaSourceNull() : MediaSource("schema", MediaTuple{"vhost", "app", "stream", ""}) {};
|
||||||
|
int readerCount() override { return 0; }
|
||||||
|
};
|
||||||
|
|
||||||
MediaSource &MediaSource::NullMediaSource() {
|
MediaSource &MediaSource::NullMediaSource() {
|
||||||
static std::shared_ptr<MediaSource> s_null = std::make_shared<MediaSourceNull>();
|
static std::shared_ptr<MediaSource> s_null = std::make_shared<MediaSourceNull>();
|
||||||
return *s_null;
|
return *s_null;
|
||||||
@ -272,7 +277,7 @@ bool MediaSource::setupRecord(Recorder::type type, bool start, const string &cus
|
|||||||
WarnL << "未设置MediaSource的事件监听者,setupRecord失败:" << getUrl();
|
WarnL << "未设置MediaSource的事件监听者,setupRecord失败:" << getUrl();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return listener->getMuxer(const_cast<MediaSource &>(*this))->setupRecord(type, start, custom_path, max_second);
|
return listener->getMuxer(const_cast<MediaSource &>(*this))->setupRecord(*this, type, start, custom_path, max_second);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MediaSource::isRecording(Recorder::type type){
|
bool MediaSource::isRecording(Recorder::type type){
|
||||||
|
|||||||
@ -573,11 +573,5 @@ private:
|
|||||||
toolkit::ObjectStatistic<MediaSource> _statistic;
|
toolkit::ObjectStatistic<MediaSource> _statistic;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MediaSourceNull : public MediaSource {
|
|
||||||
MediaSourceNull(const MediaTuple &tuple = { "vhost", "app", "stream", "" })
|
|
||||||
: MediaSource("schema", tuple) { };
|
|
||||||
int readerCount() override { return 0; }
|
|
||||||
};
|
|
||||||
|
|
||||||
} /* namespace mediakit */
|
} /* namespace mediakit */
|
||||||
#endif //ZLMEDIAKIT_MEDIASOURCE_H
|
#endif //ZLMEDIAKIT_MEDIASOURCE_H
|
||||||
|
|||||||
@ -206,7 +206,6 @@ void MultiMediaSourceMuxer::forEachRtpSender(const std::function<void(const std:
|
|||||||
}
|
}
|
||||||
#endif // ENABLE_RTPPROXY
|
#endif // ENABLE_RTPPROXY
|
||||||
MultiMediaSourceMuxer::MultiMediaSourceMuxer(const MediaTuple& tuple, float dur_sec, const ProtocolOption &option): _tuple(tuple) {
|
MultiMediaSourceMuxer::MultiMediaSourceMuxer(const MediaTuple& tuple, float dur_sec, const ProtocolOption &option): _tuple(tuple) {
|
||||||
_null_src = std::make_shared<MediaSourceNull>(tuple);
|
|
||||||
if (!option.stream_replace.empty()) {
|
if (!option.stream_replace.empty()) {
|
||||||
// 支持在on_publish hook中替换stream_id [AUTO-TRANSLATED:375eb2ff]
|
// 支持在on_publish hook中替换stream_id [AUTO-TRANSLATED:375eb2ff]
|
||||||
// Support replacing stream_id in on_publish hook
|
// Support replacing stream_id in on_publish hook
|
||||||
@ -314,13 +313,13 @@ int MultiMediaSourceMuxer::totalReaderCount(MediaSource &sender) {
|
|||||||
|
|
||||||
// 此函数可能跨线程调用 [AUTO-TRANSLATED:e8c5f74d]
|
// 此函数可能跨线程调用 [AUTO-TRANSLATED:e8c5f74d]
|
||||||
// This function may be called across threads
|
// This function may be called across threads
|
||||||
bool MultiMediaSourceMuxer::setupRecord(Recorder::type type, bool start, const string &custom_path, size_t max_second) {
|
bool MultiMediaSourceMuxer::setupRecord(MediaSource &sender, Recorder::type type, bool start, const string &custom_path, size_t max_second) {
|
||||||
CHECK(getOwnerPoller(MediaSource::NullMediaSource())->isCurrentThread(), "Can only call setupRecord in it's owner poller");
|
CHECK(getOwnerPoller(MediaSource::NullMediaSource())->isCurrentThread(), "Can only call setupRecord in it's owner poller");
|
||||||
onceToken token(nullptr, [&]() {
|
onceToken token(nullptr, [&]() {
|
||||||
if (_option.mp4_as_player && type == Recorder::type_mp4) {
|
if (_option.mp4_as_player && type == Recorder::type_mp4) {
|
||||||
// 开启关闭mp4录制,触发观看人数变化相关事件 [AUTO-TRANSLATED:b63a8deb]
|
// 开启关闭mp4录制,触发观看人数变化相关事件 [AUTO-TRANSLATED:b63a8deb]
|
||||||
// Turn on/off mp4 recording, trigger events related to changes in the number of viewers
|
// Turn on/off mp4 recording, trigger events related to changes in the number of viewers
|
||||||
onReaderChanged(*_null_src, totalReaderCount());
|
onReaderChanged(sender, totalReaderCount());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
|||||||
@ -133,7 +133,7 @@ public:
|
|||||||
|
|
||||||
* [AUTO-TRANSLATED:cb1fd8a9]
|
* [AUTO-TRANSLATED:cb1fd8a9]
|
||||||
*/
|
*/
|
||||||
bool setupRecord(Recorder::type type, bool start, const std::string &custom_path, size_t max_second);
|
bool setupRecord(MediaSource &sender, Recorder::type type, bool start, const std::string &custom_path, size_t max_second);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开始录制mp4
|
* 开始录制mp4
|
||||||
@ -266,7 +266,6 @@ private:
|
|||||||
toolkit::EventPoller::Ptr _poller;
|
toolkit::EventPoller::Ptr _poller;
|
||||||
RingType::Ptr _ring;
|
RingType::Ptr _ring;
|
||||||
MediaSinkInterface::Ptr _delegate;
|
MediaSinkInterface::Ptr _delegate;
|
||||||
MediaSourceNull::Ptr _null_src;
|
|
||||||
// 对象个数统计 [AUTO-TRANSLATED:3b43e8c2]
|
// 对象个数统计 [AUTO-TRANSLATED:3b43e8c2]
|
||||||
// Object count statistics
|
// Object count statistics
|
||||||
toolkit::ObjectStatistic<MultiMediaSourceMuxer> _statistic;
|
toolkit::ObjectStatistic<MultiMediaSourceMuxer> _statistic;
|
||||||
|
|||||||
@ -35,7 +35,7 @@ static struct mov_buffer_t s_io = {
|
|||||||
},
|
},
|
||||||
[](void *ctx) {
|
[](void *ctx) {
|
||||||
MP4FileIO *thiz = (MP4FileIO *) ctx;
|
MP4FileIO *thiz = (MP4FileIO *) ctx;
|
||||||
return (int64_t)thiz->onTell();
|
return thiz->onTell();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -128,11 +128,11 @@ int MP4FileDisk::onWrite(const void *data, size_t bytes) {
|
|||||||
return bytes == fwrite(data, 1, bytes, _file.get()) ? 0 : ferror(_file.get());
|
return bytes == fwrite(data, 1, bytes, _file.get()) ? 0 : ferror(_file.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
int MP4FileDisk::onSeek(uint64_t offset) {
|
int MP4FileDisk::onSeek(int64_t offset) {
|
||||||
return fseek64(_file.get(), offset, SEEK_SET);
|
return fseek64(_file.get(), offset, offset >= 0 ? SEEK_SET : SEEK_END);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t MP4FileDisk::onTell() {
|
int64_t MP4FileDisk::onTell() {
|
||||||
return ftell64(_file.get());
|
return ftell64(_file.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,15 +149,23 @@ size_t MP4FileMemory::fileSize() const{
|
|||||||
return _memory.size();
|
return _memory.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t MP4FileMemory::onTell(){
|
int64_t MP4FileMemory::onTell(){
|
||||||
return _offset;
|
return _offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MP4FileMemory::onSeek(uint64_t offset){
|
int MP4FileMemory::onSeek(int64_t offset){
|
||||||
if (offset > _memory.size()) {
|
if (offset < 0) {
|
||||||
return -1;
|
offset += _memory.size();
|
||||||
|
if (offset < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
_offset = offset;
|
||||||
|
} else {
|
||||||
|
if (offset > _memory.size()) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
_offset = offset;
|
||||||
}
|
}
|
||||||
_offset = offset;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,7 +175,7 @@ int MP4FileMemory::onRead(void *data, size_t bytes){
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
bytes = MIN(bytes, _memory.size() - _offset);
|
bytes = MIN(bytes, _memory.size() - _offset);
|
||||||
memcpy(data, _memory.data(), bytes);
|
memcpy(data, _memory.data() + _offset, bytes);
|
||||||
_offset += bytes;
|
_offset += bytes;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,7 +66,7 @@ public:
|
|||||||
|
|
||||||
* [AUTO-TRANSLATED:f8a5b290]
|
* [AUTO-TRANSLATED:f8a5b290]
|
||||||
*/
|
*/
|
||||||
virtual uint64_t onTell() = 0;
|
virtual int64_t onTell() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* seek至文件某处
|
* seek至文件某处
|
||||||
@ -78,7 +78,7 @@ public:
|
|||||||
|
|
||||||
* [AUTO-TRANSLATED:936089eb]
|
* [AUTO-TRANSLATED:936089eb]
|
||||||
*/
|
*/
|
||||||
virtual int onSeek(uint64_t offset) = 0;
|
virtual int onSeek(int64_t offset) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 从文件读取一定数据
|
* 从文件读取一定数据
|
||||||
@ -136,8 +136,8 @@ public:
|
|||||||
void closeFile();
|
void closeFile();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint64_t onTell() override;
|
int64_t onTell() override;
|
||||||
int onSeek(uint64_t offset) override;
|
int onSeek(int64_t offset) override;
|
||||||
int onRead(void *data, size_t bytes) override;
|
int onRead(void *data, size_t bytes) override;
|
||||||
int onWrite(const void *data, size_t bytes) override;
|
int onWrite(const void *data, size_t bytes) override;
|
||||||
|
|
||||||
@ -167,13 +167,13 @@ public:
|
|||||||
std::string getAndClearMemory();
|
std::string getAndClearMemory();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint64_t onTell() override;
|
int64_t onTell() override;
|
||||||
int onSeek(uint64_t offset) override;
|
int onSeek(int64_t offset) override;
|
||||||
int onRead(void *data, size_t bytes) override;
|
int onRead(void *data, size_t bytes) override;
|
||||||
int onWrite(const void *data, size_t bytes) override;
|
int onWrite(const void *data, size_t bytes) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint64_t _offset = 0;
|
int64_t _offset = 0;
|
||||||
std::string _memory;
|
std::string _memory;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user