#include "content/renderer/media/tizen/elementary_media_stream_source/control_thread/ms_decoding_stream.h"
+#include "content/renderer/media/tizen/elementary_media_stream_source/common/logger.h"
#include "content/renderer/media/tizen/elementary_media_stream_source/control_thread/demuxer_client.h"
#include "content/renderer/media/tizen/elementary_media_stream_source/worker_thread/demuxer_dispatcher_client.h"
-#include "content/renderer/media/tizen/elementary_media_stream_source/common/logger.h"
namespace content::elementary_media_stream_source::control_thread {
void MsDecodingStream::OnPipelineClosed() {
EMSS_DEBUG();
- if (auto demuxer_dispatcher = dispatcher_.lock())
+ if (auto demuxer_dispatcher = dispatcher_.lock()) {
demuxer_dispatcher->DispatchTask(
&worker_thread::DemuxerDispatcherClient::OnPipelineClosed);
+ }
}
-void MsDecodingStream::OnPipelineResuming() {}
+void MsDecodingStream::OnPipelineResuming() {
+ EMSS_DEBUG();
-void MsDecodingStream::OnPipelineSuspended() {}
+ if (auto demuxer_dispatcher = dispatcher_.lock()) {
+ demuxer_dispatcher->DispatchTask(
+ &worker_thread::DemuxerDispatcherClient::OnPipelineResuming);
+ }
+}
+
+void MsDecodingStream::OnPipelineSuspended() {
+ EMSS_DEBUG();
+
+ if (auto demuxer_dispatcher = dispatcher_.lock()) {
+ demuxer_dispatcher->DispatchTask(
+ &worker_thread::DemuxerDispatcherClient::OnPipelineSuspended);
+ }
+}
void MsDecodingStream::SetDuration(base::TimeDelta) {}
base::OnceClosure on_error_reported) {
EMSS_DEBUG() << error << ", message = " << message;
- if (auto client = client_.lock())
+ if (auto client = client_.lock()) {
client->OnPlayerError(error, message);
+ }
// We're on control thread and we can safely assume that the error was already
// reported to JS after the client call above.
std::move(on_error_reported).Run();
}
-void MsDecodingStream::OnResumeComplete() {}
+void MsDecodingStream::OnResumeComplete() {
+ EMSS_DEBUG();
+
+ if (auto client = client_.lock()) {
+ client->OnResumeComplete();
+ }
+}
//////////////////// PlatformDemuxerAdapterClient ////////////////////
std::shared_ptr<Sink> sink);
~DecodingStream();
+ void Resume();
+ void Suspend();
+
void DecodeFrames(std::vector<Packet> frames);
void ResetSink();
EMSS_DEBUG_TYPED() << "Destructing object";
}
+template <TrackType StreamType>
+void MsDecodingStream::DecodingStream<StreamType>::Resume() {
+ EMSS_LOG_TYPED(INFO);
+
+ if (!config_.IsValidConfig()) {
+ return;
+ }
+
+ StartInitializingDecoder(config_);
+}
+
+template <TrackType StreamType>
+void MsDecodingStream::DecodingStream<StreamType>::Suspend() {
+ EMSS_LOG_TYPED(INFO);
+
+ DestroyCurrentDecoder();
+
+ while (!pending_decodes_.empty()) {
+ EMSS_LOG_TYPED(VERBOSE)
+ << "Flushing: " << pending_decodes_.front()->AsHumanReadableString();
+ pending_decodes_.pop();
+ }
+}
+
template <TrackType StreamType>
void MsDecodingStream::DecodingStream<StreamType>::DecodeFrames(
std::vector<Packet> frames) {
}
}
-void MsDecodingStream::OnPipelineResuming() {}
+void MsDecodingStream::OnPipelineResuming() {
+ EMSS_LOG(INFO);
-void MsDecodingStream::OnPipelineSuspended() {}
+ if (audio_stream_) {
+ audio_stream_->Resume();
+ }
+ if (video_stream_) {
+ video_stream_->Resume();
+ }
+
+ if (auto dispatcher = dispatcher_.lock()) {
+ dispatcher->DispatchTask(
+ &control_thread::DemuxerDispatcherClient::OnResumeComplete);
+ }
+}
+
+void MsDecodingStream::OnPipelineSuspended() {
+ EMSS_LOG(INFO);
+
+ if (audio_stream_) {
+ audio_stream_->Suspend();
+ }
+ if (video_stream_) {
+ video_stream_->Suspend();
+ }
+ if (gmb_pool_) {
+ gmb_pool_.reset();
+ }
+}
void MsDecodingStream::OnReadRequested(TrackType) {}
scoped_refptr<media::VideoFrame> frame,
VideoOutputProcessedCb on_frame_processed) {
EMSS_VERBOSE();
- EMSS_LOG_ASSERT(gmb_pool_);
+
+ if (!gmb_pool_) {
+ EMSS_DEBUG() << "GMB pool was deleted, discarding "
+ << frame->timestamp().InMilliseconds();
+ return;
+ }
gmb_pool_->MaybeCreateHardwareFrame(std::move(frame),
std::move(on_frame_processed));