From 13a6d3ac16e6851fad78be93252834108b6469d2 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Thu, 1 Aug 2019 22:07:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=86=99mp4=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MediaFile/Mp4Maker.cpp | 9 +++++---- src/MediaFile/Mp4Maker.h | 10 ++++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/MediaFile/Mp4Maker.cpp b/src/MediaFile/Mp4Maker.cpp index 305b7ad5..a4ec0d89 100644 --- a/src/MediaFile/Mp4Maker.cpp +++ b/src/MediaFile/Mp4Maker.cpp @@ -147,11 +147,12 @@ void Mp4Maker::onTrackFrame(const Frame::Ptr &frame) { } } -void Mp4Maker::onAllTrackReady() { +void Mp4Maker::onTrackReady(const Track::Ptr & track){ //保存所有的track,为创建MP4MuxerFile做准备 - _tracks.emplace_back(getTrack(TrackVideo)); - _tracks.emplace_back(getTrack(TrackAudio)); - _haveVideo = getTrack(TrackVideo).operator bool(); + _tracks.emplace_back(track); + if(track->getTrackType() == TrackVideo){ + _haveVideo = true; + } } } /* namespace mediakit */ diff --git a/src/MediaFile/Mp4Maker.h b/src/MediaFile/Mp4Maker.h index 1d46a7fa..cef69701 100644 --- a/src/MediaFile/Mp4Maker.h +++ b/src/MediaFile/Mp4Maker.h @@ -70,10 +70,12 @@ private: */ void onTrackFrame(const Frame::Ptr &frame) override ; - /** - * 所有Track准备好了 - */ - void onAllTrackReady() override; + /** + * 某track已经准备好,其ready()状态返回true, + * 此时代表可以获取其例如sps pps等相关信息了 + * @param track + */ + void onTrackReady(const Track::Ptr & track) override; private: void createFile(); void closeFile();