mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 12:37:09 +08:00
修复getMediaTracks接口相关功能
This commit is contained in:
parent
46722546a6
commit
566a49e227
@ -95,7 +95,7 @@ vector<Track::Ptr> MediaSource::getTracks(bool ready) const {
|
|||||||
if(!listener){
|
if(!listener){
|
||||||
return vector<Track::Ptr>();
|
return vector<Track::Ptr>();
|
||||||
}
|
}
|
||||||
return listener->getTracks(const_cast<MediaSource &>(*this), ready);
|
return listener->getMediaTracks(const_cast<MediaSource &>(*this), ready);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaSource::setListener(const std::weak_ptr<MediaSourceEvent> &listener){
|
void MediaSource::setListener(const std::weak_ptr<MediaSourceEvent> &listener){
|
||||||
@ -636,12 +636,12 @@ bool MediaSourceEventInterceptor::isRecording(MediaSource &sender, Recorder::typ
|
|||||||
return listener->isRecording(sender, type);
|
return listener->isRecording(sender, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<Track::Ptr> MediaSourceEventInterceptor::getTracks(MediaSource &sender, bool trackReady) const {
|
vector<Track::Ptr> MediaSourceEventInterceptor::getMediaTracks(MediaSource &sender, bool trackReady) const {
|
||||||
auto listener = _listener.lock();
|
auto listener = _listener.lock();
|
||||||
if (!listener) {
|
if (!listener) {
|
||||||
return vector<Track::Ptr>();
|
return vector<Track::Ptr>();
|
||||||
}
|
}
|
||||||
return listener->getTracks(sender, trackReady);
|
return listener->getMediaTracks(sender, trackReady);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaSourceEventInterceptor::startSendRtp(MediaSource &sender, const string &dst_url, uint16_t dst_port, const string &ssrc, bool is_udp, uint16_t src_port, const function<void(uint16_t local_port, const SockException &ex)> &cb){
|
void MediaSourceEventInterceptor::startSendRtp(MediaSource &sender, const string &dst_url, uint16_t dst_port, const string &ssrc, bool is_udp, uint16_t src_port, const function<void(uint16_t local_port, const SockException &ex)> &cb){
|
||||||
|
@ -82,7 +82,7 @@ public:
|
|||||||
// 获取录制状态
|
// 获取录制状态
|
||||||
virtual bool isRecording(MediaSource &sender, Recorder::type type) { return false; };
|
virtual bool isRecording(MediaSource &sender, Recorder::type type) { return false; };
|
||||||
// 获取所有track相关信息
|
// 获取所有track相关信息
|
||||||
virtual vector<Track::Ptr> getTracks(MediaSource &sender, bool trackReady = true) const { return vector<Track::Ptr>(); };
|
virtual vector<Track::Ptr> getMediaTracks(MediaSource &sender, bool trackReady = true) const { return vector<Track::Ptr>(); };
|
||||||
// 开始发送ps-rtp
|
// 开始发送ps-rtp
|
||||||
virtual void startSendRtp(MediaSource &sender, const string &dst_url, uint16_t dst_port, const string &ssrc, bool is_udp, uint16_t src_port, const function<void(uint16_t local_port, const SockException &ex)> &cb) { cb(0, SockException(Err_other, "not implemented"));};
|
virtual void startSendRtp(MediaSource &sender, const string &dst_url, uint16_t dst_port, const string &ssrc, bool is_udp, uint16_t src_port, const function<void(uint16_t local_port, const SockException &ex)> &cb) { cb(0, SockException(Err_other, "not implemented"));};
|
||||||
// 停止发送ps-rtp
|
// 停止发送ps-rtp
|
||||||
@ -112,7 +112,7 @@ public:
|
|||||||
void onRegist(MediaSource &sender, bool regist) override;
|
void onRegist(MediaSource &sender, bool regist) override;
|
||||||
bool setupRecord(MediaSource &sender, Recorder::type type, bool start, const string &custom_path, size_t max_second) override;
|
bool setupRecord(MediaSource &sender, Recorder::type type, bool start, const string &custom_path, size_t max_second) override;
|
||||||
bool isRecording(MediaSource &sender, Recorder::type type) override;
|
bool isRecording(MediaSource &sender, Recorder::type type) override;
|
||||||
vector<Track::Ptr> getTracks(MediaSource &sender, bool trackReady = true) const override;
|
vector<Track::Ptr> getMediaTracks(MediaSource &sender, bool trackReady = true) const override;
|
||||||
void startSendRtp(MediaSource &sender, const string &dst_url, uint16_t dst_port, const string &ssrc, bool is_udp, uint16_t src_port, const function<void(uint16_t local_port, const SockException &ex)> &cb) override;
|
void startSendRtp(MediaSource &sender, const string &dst_url, uint16_t dst_port, const string &ssrc, bool is_udp, uint16_t src_port, const function<void(uint16_t local_port, const SockException &ex)> &cb) override;
|
||||||
bool stopSendRtp(MediaSource &sender, const string &ssrc) override;
|
bool stopSendRtp(MediaSource &sender, const string &ssrc) override;
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ bool MultiMediaSourceMuxer::setupRecord(MediaSource &sender, Recorder::type type
|
|||||||
case Recorder::type_hls : {
|
case Recorder::type_hls : {
|
||||||
if (start && !_hls) {
|
if (start && !_hls) {
|
||||||
//开始录制
|
//开始录制
|
||||||
auto hls = dynamic_pointer_cast<HlsRecorder>(makeRecorder(sender, MediaSink::getTracks(), type, custom_path, max_second));
|
auto hls = dynamic_pointer_cast<HlsRecorder>(makeRecorder(sender, getTracks(), type, custom_path, max_second));
|
||||||
if (hls) {
|
if (hls) {
|
||||||
//设置HlsMediaSource的事件监听器
|
//设置HlsMediaSource的事件监听器
|
||||||
hls->setListener(shared_from_this());
|
hls->setListener(shared_from_this());
|
||||||
@ -164,7 +164,7 @@ bool MultiMediaSourceMuxer::setupRecord(MediaSource &sender, Recorder::type type
|
|||||||
case Recorder::type_mp4 : {
|
case Recorder::type_mp4 : {
|
||||||
if (start && !_mp4) {
|
if (start && !_mp4) {
|
||||||
//开始录制
|
//开始录制
|
||||||
_mp4 = makeRecorder(sender, MediaSink::getTracks(), type, custom_path, max_second);
|
_mp4 = makeRecorder(sender, getTracks(), type, custom_path, max_second);
|
||||||
} else if (!start && _mp4) {
|
} else if (!start && _mp4) {
|
||||||
//停止录制
|
//停止录制
|
||||||
_mp4 = nullptr;
|
_mp4 = nullptr;
|
||||||
@ -197,7 +197,7 @@ void MultiMediaSourceMuxer::startSendRtp(MediaSource &, const string &dst_url, u
|
|||||||
if (!strong_self || ex) {
|
if (!strong_self || ex) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (auto &track : strong_self->MediaSink::getTracks(false)) {
|
for (auto &track : strong_self->getTracks(false)) {
|
||||||
rtp_sender->addTrack(track);
|
rtp_sender->addTrack(track);
|
||||||
}
|
}
|
||||||
rtp_sender->addTrackCompleted();
|
rtp_sender->addTrackCompleted();
|
||||||
@ -232,6 +232,10 @@ bool MultiMediaSourceMuxer::stopSendRtp(MediaSource &sender, const string &ssrc)
|
|||||||
#endif//ENABLE_RTPPROXY
|
#endif//ENABLE_RTPPROXY
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vector<Track::Ptr> MultiMediaSourceMuxer::getMediaTracks(MediaSource &sender, bool trackReady) const {
|
||||||
|
return getTracks(trackReady);
|
||||||
|
}
|
||||||
|
|
||||||
void MultiMediaSourceMuxer::onTrackReady(const Track::Ptr &track) {
|
void MultiMediaSourceMuxer::onTrackReady(const Track::Ptr &track) {
|
||||||
if (CodecL16 == track->getCodecId()) {
|
if (CodecL16 == track->getCodecId()) {
|
||||||
WarnL << "L16音频格式目前只支持RTSP协议推流拉流!!!";
|
WarnL << "L16音频格式目前只支持RTSP协议推流拉流!!!";
|
||||||
|
@ -66,6 +66,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
void setTimeStamp(uint32_t stamp);
|
void setTimeStamp(uint32_t stamp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重置track
|
||||||
|
*/
|
||||||
|
void resetTracks() override;
|
||||||
|
|
||||||
/////////////////////////////////MediaSourceEvent override/////////////////////////////////
|
/////////////////////////////////MediaSourceEvent override/////////////////////////////////
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -108,9 +113,11 @@ public:
|
|||||||
bool stopSendRtp(MediaSource &sender, const string &ssrc) override;
|
bool stopSendRtp(MediaSource &sender, const string &ssrc) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重置track
|
* 获取所有Track
|
||||||
|
* @param trackReady 是否筛选过滤未就绪的track
|
||||||
|
* @return 所有Track
|
||||||
*/
|
*/
|
||||||
void resetTracks() override;
|
vector<Track::Ptr> getMediaTracks(MediaSource &sender, bool trackReady = true) const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/////////////////////////////////MediaSink override/////////////////////////////////
|
/////////////////////////////////MediaSink override/////////////////////////////////
|
||||||
|
@ -127,7 +127,7 @@ public:
|
|||||||
|
|
||||||
if (_recreate_metadata) {
|
if (_recreate_metadata) {
|
||||||
//更新metadata
|
//更新metadata
|
||||||
for (auto &track : _muxer->MediaSink::getTracks()) {
|
for (auto &track : _muxer->getTracks()) {
|
||||||
Metadata::addTrack(_metadata, track);
|
Metadata::addTrack(_metadata, track);
|
||||||
}
|
}
|
||||||
RtmpMediaSource::updateMetaData(_metadata);
|
RtmpMediaSource::updateMetaData(_metadata);
|
||||||
|
Loading…
Reference in New Issue
Block a user