Skip to content

Commit

Permalink
refactor(codec): add api to get recover queue size
Browse files Browse the repository at this point in the history
Signed-off-by: pingkai <pingkai010@gmail.com>
  • Loading branch information
pingkai authored and skufly committed Mar 18, 2020
1 parent ec31796 commit e2806ab
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 1 deletion.
6 changes: 6 additions & 0 deletions framework/codec/ActiveDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,5 +429,11 @@ int ActiveDecoder::holdOn(bool hold)
return 0;
}

int ActiveDecoder::getRecoverQueueSize()
{
unique_lock<mutex> uMutex(mMutex);
return int(mHoldingQueue.size() + get_decoder_recover_size());
}

#endif

4 changes: 4 additions & 0 deletions framework/codec/ActiveDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class ActiveDecoder : public Cicada::IDecoder {

int holdOn(bool hold) override;

int getRecoverQueueSize() override;

private:

virtual int enqueue_decoder(std::unique_ptr<IAFPacket> &pPacket) = 0;
Expand All @@ -50,6 +52,8 @@ class ActiveDecoder : public Cicada::IDecoder {

virtual void flush_decoder() = 0;

virtual int get_decoder_recover_size() = 0;


private:
bool needDrop(IAFPacket *packet);
Expand Down
5 changes: 5 additions & 0 deletions framework/codec/Android/mediaCodecDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ namespace Cicada{

void flush_decoder() override;

int get_decoder_recover_size() override
{
return 0;
};

private:
static bool checkSupport(AFCodecID codec, uint64_t flags, int maxSize);

Expand Down
6 changes: 6 additions & 0 deletions framework/codec/Apple/AppleVideoToolBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -797,4 +797,10 @@ namespace Cicada {
mActive = true;
}

int AFVTBDecoder::get_decoder_recover_size()
{
std::lock_guard<std::mutex> lock(mActiveStatusMutex);
return mRecoveryQueue.size();
}

} // namespace
3 changes: 2 additions & 1 deletion framework/codec/Apple/AppleVideoToolBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ namespace Cicada{

void flush_decoder() override;

int get_decoder_recover_size() override;

void flushReorderQueue();

private:
private:
explicit AFVTBDecoder(int dummy)
{
Expand Down
2 changes: 2 additions & 0 deletions framework/codec/IDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ namespace Cicada {

virtual int holdOn(bool hold) = 0;

virtual int getRecoverQueueSize() = 0;

protected:
std::string mName;
int mFlags = 0; // VFLAG_HW,VFLAG_OUT
Expand Down
5 changes: 5 additions & 0 deletions framework/codec/avcodecDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ namespace Cicada{

void flush_decoder() override;

int get_decoder_recover_size() override
{
return 0;
};

private:
decoder_handle_v *mPDecoder = nullptr;
};
Expand Down

0 comments on commit e2806ab

Please sign in to comment.