Skip to content

Commit

Permalink
refactor(playermediaframecb): use const IAFPacket *
Browse files Browse the repository at this point in the history
Signed-off-by: pingkai <pingkai010@gmail.com>
  • Loading branch information
pingkai authored and kongjianneu committed Jul 31, 2020
1 parent e94aa25 commit 49a8fab
Show file tree
Hide file tree
Showing 15 changed files with 19 additions and 22 deletions.
2 changes: 1 addition & 1 deletion framework/base/media/AVAFPacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ uint8_t *AVAFPacket::getData()
return mpkt->data;
}

unique_ptr<IAFPacket> AVAFPacket::clone()
unique_ptr<IAFPacket> AVAFPacket::clone() const
{
return unique_ptr<IAFPacket>(new AVAFPacket(mpkt, mIsProtected));
}
Expand Down
2 changes: 1 addition & 1 deletion framework/base/media/AVAFPacket.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class AVAFPacket : public IAFPacket {
mIsProtected = true;
}

std::unique_ptr<IAFPacket> clone() override;
std::unique_ptr<IAFPacket> clone() const override;

int64_t getSize() override;

Expand Down
2 changes: 1 addition & 1 deletion framework/base/media/IAFPacket.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class CICADA_CPLUS_EXTERN IAFPacket {

virtual ~IAFPacket() = default;

virtual std::unique_ptr<IAFPacket> clone() = 0;
virtual std::unique_ptr<IAFPacket> clone() const = 0;

//TODO renturn const uint8_t, now for framework use
virtual uint8_t *getData() = 0;
Expand Down
2 changes: 1 addition & 1 deletion framework/base/media/subTitlePacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ uint8_t *subTitlePacket::getData()
return mpBuffer;
}

std::unique_ptr<IAFPacket> subTitlePacket::clone()
std::unique_ptr<IAFPacket> subTitlePacket::clone() const
{
return std::unique_ptr<IAFPacket>(new subTitlePacket(mpBuffer, mSize, mInfo.pts, mInfo.duration));
}
2 changes: 1 addition & 1 deletion framework/base/media/subTitlePacket.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class subTitlePacket : public IAFPacket {

~subTitlePacket() override;

std::unique_ptr<IAFPacket> clone() override;
std::unique_ptr<IAFPacket> clone() const override;

uint8_t *getData() override;

Expand Down
2 changes: 1 addition & 1 deletion framework/cacheModule/CacheManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ string CacheManager::init()
return mSourceUrl;
}

void CacheManager::sendMediaFrame(const unique_ptr<IAFPacket> &frame, StreamType type)
void CacheManager::sendMediaFrame(const IAFPacket *frame, StreamType type)
{
if (!mNeedProcessFrame) {
return;
Expand Down
2 changes: 1 addition & 1 deletion framework/cacheModule/CacheManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class CacheManager {

void setCacheSuccessCallback(function<void()> resultCallback);

void sendMediaFrame(const std::unique_ptr<IAFPacket> &frame, StreamType type);
void sendMediaFrame(const IAFPacket *frame, StreamType type);

private:
std::mutex mStopMutex{};
Expand Down
2 changes: 1 addition & 1 deletion framework/cacheModule/CacheModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ CacheRet CacheModule::checkCanCache()
}


void CacheModule::addFrame(const unique_ptr<IAFPacket> &frame, StreamType type)
void CacheModule::addFrame(const IAFPacket *frame, StreamType type)
{
std::unique_lock<mutex> lock(mReumxerMutex);

Expand Down
2 changes: 1 addition & 1 deletion framework/cacheModule/CacheModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class CacheModule {

bool isMediaInfoSet();

void addFrame(const unique_ptr<IAFPacket>& frame, StreamType type);
void addFrame(const IAFPacket *frame, StreamType type);

void setErrorCallback(function<void(int, string)> callback);

Expand Down
2 changes: 1 addition & 1 deletion framework/cacheModule/cache/CacheFileRemuxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ CacheFileRemuxer::~CacheFileRemuxer()
mFrameInfoQueue.clear();
}

void CacheFileRemuxer::addFrame(const unique_ptr<IAFPacket> &frame, StreamType type)
void CacheFileRemuxer::addFrame(const IAFPacket *frame, StreamType type)
{
if (frame == nullptr) {
mFrameEof = true;
Expand Down
2 changes: 1 addition & 1 deletion framework/cacheModule/cache/CacheFileRemuxer.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CacheFileRemuxer {

~CacheFileRemuxer();

void addFrame(const unique_ptr<IAFPacket> &frame, StreamType type);
void addFrame(const IAFPacket *frame, StreamType type);

bool prepare();

Expand Down
4 changes: 2 additions & 2 deletions mediaPlayer/MediaPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ namespace Cicada {
mPlayUrlChangedCallback = urlChangedCallbak;
}

void MediaPlayer::onMediaFrameCallback(void *arg, const unique_ptr<IAFPacket> &frame, StreamType type)
void MediaPlayer::onMediaFrameCallback(void *arg, const IAFPacket *frame, StreamType type)
{
MediaPlayer *player = (MediaPlayer *) arg;

Expand All @@ -1096,7 +1096,7 @@ namespace Cicada {
player->mediaFrameCallback(frame, type);
}

void MediaPlayer::mediaFrameCallback(const unique_ptr<IAFPacket> &frame, StreamType type)
void MediaPlayer::mediaFrameCallback(const IAFPacket *frame, StreamType type)
{
#ifdef ENABLE_CACHE_MODULE
if (mCacheManager) {
Expand Down
4 changes: 2 additions & 2 deletions mediaPlayer/MediaPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,8 @@ namespace Cicada {

void abrChanged(int stream);

static void onMediaFrameCallback(void *arg, const unique_ptr<IAFPacket> &frame, StreamType type);
void mediaFrameCallback(const unique_ptr<IAFPacket> &frame, StreamType type);
static void onMediaFrameCallback(void *arg, const IAFPacket *frame, StreamType type);
void mediaFrameCallback(const IAFPacket *frame, StreamType type);

private:
void configPlayer(const MediaPlayerConfig *config) const;
Expand Down
9 changes: 3 additions & 6 deletions mediaPlayer/SuperMediaPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2508,8 +2508,7 @@ int SuperMediaPlayer::ReadPacket()
if (pFrame->getInfo().streamIndex == mCurrentVideoIndex || pFrame->getInfo().streamIndex == mWillChangedVideoStreamIndex) {

if (mMediaFrameCb && (!pMedia_Frame->isProtected() || mDrmKeyValid)) {
// TODO: change to std::unique_ptr<IAFPacket>
mMediaFrameCb(mMediaFrameCbArg, pMedia_Frame, ST_TYPE_VIDEO);
mMediaFrameCb(mMediaFrameCbArg, pMedia_Frame.get(), ST_TYPE_VIDEO);
}

mBufferController->AddPacket(move(pMedia_Frame), BUFFER_TYPE_VIDEO);
Expand Down Expand Up @@ -2602,15 +2601,13 @@ int SuperMediaPlayer::ReadPacket()
}

if (mMediaFrameCb && (!pMedia_Frame->isProtected() || mDrmKeyValid)) {
// TODO: change to std::unique_ptr<IAFPacket>
mMediaFrameCb(mMediaFrameCbArg, pMedia_Frame, ST_TYPE_AUDIO);
mMediaFrameCb(mMediaFrameCbArg, pMedia_Frame.get(), ST_TYPE_AUDIO);
}

mBufferController->AddPacket(move(pMedia_Frame), BUFFER_TYPE_AUDIO);
} else if (pFrame->getInfo().streamIndex == mCurrentSubtitleIndex || pFrame->getInfo().streamIndex == mWillChangedSubtitleStreamIndex) {
if (mMediaFrameCb && (!pMedia_Frame->isProtected() || mDrmKeyValid)) {
// TODO: change to std::unique_ptr<IAFPacket>
mMediaFrameCb(mMediaFrameCbArg, pMedia_Frame, ST_TYPE_SUB);
mMediaFrameCb(mMediaFrameCbArg, pMedia_Frame.get(), ST_TYPE_SUB);
}

mBufferController->AddPacket(move(pMedia_Frame), BUFFER_TYPE_SUBTITLE);
Expand Down
2 changes: 1 addition & 1 deletion mediaPlayer/native_cicada_player_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ typedef enum PropertyKey {

class AMediaFrame;

typedef void (*playerMediaFrameCb)(void *arg, const std::unique_ptr<IAFPacket>& frame, StreamType type);
typedef void (*playerMediaFrameCb)(void *arg, const IAFPacket *frame, StreamType type);

typedef int (*readCB)(void *arg, uint8_t *buffer, int size);

Expand Down

0 comments on commit 49a8fab

Please sign in to comment.