return absl::nullopt;
}
+bool DecoderPromotion::NeedsDecoderReselection(
+ const AllocatedDecoder& current_decoder,
+ MediaVideoCodec codec,
+ VideoCodecLevel level,
+ gfx::Size coded_size,
+ VideoChromaSampling sampling,
+ size_t bit_depth,
+ LatencyMode latency,
+ const gpu::GpuDriverBugWorkarounds* workarounds) {
+ base::AutoLock auto_lock(lock_);
+ auto decoder_it = std::find_if(
+ video_decoders_.begin(), video_decoders_.end(),
+ [¤t_decoder](const std::pair<int, Entry>& el) {
+ return el.second.component_name == current_decoder.component_name;
+ });
+ TIZEN_MEDIA_LOG_ASSERT(decoder_it != video_decoders_.end())
+ << "Decoder used for reselection has to be currently allocated";
+ auto new_category =
+ SelectVideoDecoderCategory(GetResourceManager(), codec, level, coded_size,
+ sampling, bit_depth, latency, workarounds);
+ return new_category != decoder_it->second.category;
+}
+
absl::optional<AllocatedDecoder> DecoderPromotion::SelectAudioDecoder(
AllocationCallbacks callbacks) {
base::AutoLock auto_lock(lock_);
return;
}
+ waiting_for_key_ = false;
+ first_frame_done_ = false;
+
if (decoder_state_ != DecoderState::kCreated) {
- if (!CleanFacade()) {
- std::move(init_cb).Run(DecoderStatus::Codes::kFailedToCreateDecoder);
+ if (low_delay != low_delay_) {
+ std::move(init_cb).Run(DecoderStatus::Codes::kCantChangeCodec);
return;
}
- allocated_decoder_.reset();
ttvd_decoded_frame_pool_.clear();
ranges_.Clear();
decoding_results_.clear();
last_processing_frame_ =
std::make_pair(base::TimeDelta(), ProcessingAction::kRender);
- waiting_for_key_ = false;
- first_frame_done_ = false;
- decoder_state_ = DecoderState::kCreated;
+ // Do not clean facade and allocated resource, as decoder is being
+ // reinitialized. It's possible that we can reuse same decoder after
+ // flushing, but this will be known after first frame is received.
+ decoder_state_ = DecoderState::kLazyInitializing;
+ decoder_facade_->Flush(
+ base::BindOnce(std::move(init_cb), DecoderStatus::Codes::kOk));
+ return;
}
CHECK_EQ(decoder_state_, DecoderState::kCreated)
// Use picture size instead of |coded_size| as resource manager might
// return that valid resolutions (e.g 3840x2176) are not supported on
// several boards.
- auto latency = [&]() {
- if (IsForGameStreaming())
- return LatencyMode::kGameMode;
- if (config_.is_rtc())
- return LatencyMode::kLow;
- return LatencyMode::kNormal;
- }();
auto decoder = DecoderPromotion::GetInstance()->SelectDecoder(
codec, config_.level(), config_.visible_rect().size(),
- config_.chroma_sampling, config_.bit_depth, latency, std::move(callbacks),
- &workarounds_);
+ config_.chroma_sampling, config_.bit_depth, GetLatencyMode(),
+ std::move(callbacks), &workarounds_);
if (!decoder) {
return false;
}
<< "Wrong state: " << decoder_state_;
TIZEN_MEDIA_LOG(VERBOSE) << "Initialize";
+ if (allocated_decoder_) {
+ // TODO(vdwasm): Figure out how to reinitialize the decoder in case
+ // the underlying resource needs to change. For now let's fail the reinit
+ // request, which will cause the |DecoderSelector| to just initialize a new
+ // OMX instance.
+ if (DecoderPromotion::GetInstance()->NeedsDecoderReselection(
+ *allocated_decoder_, VideoCodecToMediaVideoCodec(config_.codec()),
+ config_.level(), config_.coded_size(), config_.chroma_sampling,
+ config_.bit_depth, GetLatencyMode(), &workarounds_)) {
+ TIZEN_MEDIA_LOG(WARNING)
+ << "Can't reconfigure without reallocation, incoming config: "
+ << config_.AsHumanReadableString();
+ NotifyInitializationFailed();
+ return;
+ }
+ OnInitializationDone(true);
+ return;
+ }
+
if (!AllocateDecoder()) {
TIZEN_MEDIA_LOG(ERROR) << "Cannot allocate proper decoder";
decoder_state_ = DecoderState::kError;
lazy_frames_in_syncing_);
}
+LatencyMode TTvdVideoDecoderImpl::GetLatencyMode() const {
+ if (IsForGameStreaming())
+ return LatencyMode::kGameMode;
+ if (config_.is_rtc())
+ return LatencyMode::kLow;
+ return LatencyMode::kNormal;
+}
+
void TTvdVideoDecoderImpl::RemoveDecoderDependentResults() {
base::WaitableEvent event;
if (!gpu_task_runner_->PostTask(