diff options
Diffstat (limited to 'chromecast/media/cma/backend/video_decoder_default.cc')
-rw-r--r-- | chromecast/media/cma/backend/video_decoder_default.cc | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/chromecast/media/cma/backend/video_decoder_default.cc b/chromecast/media/cma/backend/video_decoder_default.cc index 257332e..0d057aa 100644 --- a/chromecast/media/cma/backend/video_decoder_default.cc +++ b/chromecast/media/cma/backend/video_decoder_default.cc @@ -4,13 +4,21 @@ #include "chromecast/media/cma/backend/video_decoder_default.h" +#include <limits> + +#include "base/bind.h" +#include "base/location.h" #include "base/logging.h" +#include "base/thread_task_runner_handle.h" #include "chromecast/public/media/cast_decoder_buffer.h" namespace chromecast { namespace media { -VideoDecoderDefault::VideoDecoderDefault() : delegate_(nullptr) {} +VideoDecoderDefault::VideoDecoderDefault() + : delegate_(nullptr), + last_push_pts_(std::numeric_limits<int64_t>::min()), + weak_factory_(this) {} VideoDecoderDefault::~VideoDecoderDefault() {} @@ -23,8 +31,13 @@ MediaPipelineBackend::BufferStatus VideoDecoderDefault::PushBuffer( CastDecoderBuffer* buffer) { DCHECK(delegate_); DCHECK(buffer); - if (buffer->end_of_stream()) - delegate_->OnEndOfStream(); + if (buffer->end_of_stream()) { + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&VideoDecoderDefault::OnEndOfStream, + weak_factory_.GetWeakPtr())); + } else { + last_push_pts_ = buffer->timestamp(); + } return MediaPipelineBackend::kBufferSuccess; } @@ -35,5 +48,9 @@ bool VideoDecoderDefault::SetConfig(const VideoConfig& config) { return true; } +void VideoDecoderDefault::OnEndOfStream() { + delegate_->OnEndOfStream(); +} + } // namespace media } // namespace chromecast |