void TTvdVideoDecoder::OnVideoFrameDecoded(
const scoped_refptr<VideoFrame>& frame,
+ bool can_read_without_stalling,
const base::UnguessableToken& release_token) {
TIZEN_MEDIA_LOG(VERBOSE) << "Frame decoded: " << frame->timestamp();
+ can_read_without_stalling_ = can_read_without_stalling;
frame->SetReleaseMailboxCB(base::BindPostTaskToCurrentDefault(base::BindOnce(
&TTvdVideoDecoder::ReleaseVideoFrame, weak_this_, release_token)));
output_cb_.Run(frame);
}
void TTvdVideoDecoder::OnResetDone() {
+ can_read_without_stalling_ = true;
std::move(reset_cb_).Run();
}
void Decode(scoped_refptr<DecoderBuffer> buffer, DecodeCB decode_cb) override;
void Reset(base::OnceClosure closure) override;
bool NeedsBitstreamConversion() const override { return false; }
- bool CanReadWithoutStalling() const override { return false; }
+ bool CanReadWithoutStalling() const override {
+ return can_read_without_stalling_;
+ }
int GetMaxDecodeRequests() const override { return 4; }
VideoDecoderType GetDecoderType() const override {
return VideoDecoderType::kUnknown;
// mojom::TTvdVideoDecoderClient implementation.
void OnVideoFrameDecoded(
const scoped_refptr<VideoFrame>& frame,
+ bool can_read_without_stalling,
const base::UnguessableToken& release_token) override;
void OnTotalMemoryUsageReport(int64_t total_video_memory) override;
void OnWaiting(WaitingReason reason) override;
uint64_t decode_counter_ = 0;
base::flat_map<uint64_t, DecodeCB> pending_decodes_;
base::OnceClosure reset_cb_;
+ bool can_read_without_stalling_ = true;
int64_t last_reported_memory_usage_ = 0;
TotalMemoryUsageCB total_memory_usage_cb_;
base::UnguessableToken release_token = base::UnguessableToken::Create();
video_frames_[release_token] = video_frame;
- client_->OnVideoFrameDecoded(std::move(video_frame),
+ client_->OnVideoFrameDecoded(std::move(video_frame), CanAllocateNewFrame(),
std::move(release_token));
}
base::UnguessableToken release_token = base::UnguessableToken::Create();
video_frames_[release_token] = video_frame;
- client_->OnVideoFrameDecoded(std::move(video_frame), release_token);
+ client_->OnVideoFrameDecoded(std::move(video_frame), CanAllocateNewFrame(),
+ release_token);
}
bool TTvdVideoDecoderImpl::CleanFacade() {
std::move(eos_cb_).Run(DecoderStatus::Codes::kOk);
}
+bool TTvdVideoDecoderImpl::CanAllocateNewFrame() const {
+ return ttvd_decoded_frame_pool_.size() + decoding_results_.size() <
+ kMaxUsedDecodedFrames;
+}
+
void TTvdVideoDecoderImpl::OnMemoryUsageChange(int64_t memory_delta) {
TIZEN_MEDIA_LOG(VERBOSE) << "Video memory delta: " << memory_delta;
total_memory_usage_ += memory_delta;
// in |decoding_requests_|.
void TriggerEos();
+ // Helper to checked whether new frame can be created without exceeding the
+ // limits.
+ bool CanAllocateNewFrame() const;
+
// Updates amount of memory usage by decoded frames currently hold by decoder.
void OnMemoryUsageChange(int64_t memory_delta);
interface TTvdVideoDecoderClient {
OnVideoFrameDecoded(VideoFrame frame,
+ bool can_read_without_stalling,
mojo_base.mojom.UnguessableToken release_token);
// Provides information what is total memory used by decoder to hold video