Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(368)

Unified Diff: media/mojo/services/mojo_video_decoder_service.cc

Issue 2363303002: [WIP] Proxy RtcVideoDecoder calls to a media::VideoDecoder.
Patch Set: Now working with remote ffmpeg decoder Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/mojo/services/mojo_video_decoder_service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/mojo/services/mojo_video_decoder_service.cc
diff --git a/media/mojo/services/mojo_video_decoder_service.cc b/media/mojo/services/mojo_video_decoder_service.cc
index a535f608234665b88937e7c978e8feda09507f7d..84465d19c6e05b9bdcad01e6b0774a389cde1c3a 100644
--- a/media/mojo/services/mojo_video_decoder_service.cc
+++ b/media/mojo/services/mojo_video_decoder_service.cc
@@ -14,6 +14,7 @@
#include "media/base/video_frame.h"
#include "media/mojo/common/media_type_converters.h"
#include "media/mojo/common/mojo_decoder_buffer_converter.h"
+#include "media/mojo/common/mojo_shared_buffer_video_frame.h"
#include "media/mojo/services/mojo_media_client.h"
#include "mojo/public/c/system/types.h"
#include "mojo/public/cpp/system/buffer.h"
@@ -73,9 +74,43 @@ void MojoVideoDecoderService::OnDecoderInitialized(
void MojoVideoDecoderService::OnDecoderOutput(
const scoped_refptr<VideoFrame>& frame) {
- DVLOG(1) << __FUNCTION__;
+ VLOG(0) << __FUNCTION__;
DCHECK(client_);
- client_->OnVideoFrameDecoded(mojom::VideoFrame::From(frame));
+
+ const size_t y_plane_size =
+ frame->rows(VideoFrame::kYPlane) * frame->stride(VideoFrame::kYPlane);
+ const size_t u_plane_size =
+ frame->rows(VideoFrame::kUPlane) * frame->stride(VideoFrame::kUPlane);
+
+ // Allocate a mojo::SharedBufferHandle big enough to contain |frame|'s data.
+ size_t buffer_size =
+ VideoFrame::AllocationSize(frame->format(), frame->coded_size());
+ mojo::ScopedSharedBufferHandle shared_buffer =
+ mojo::SharedBufferHandle::Create(buffer_size);
+ DCHECK(shared_buffer.is_valid());
+ mojo::ScopedSharedBufferMapping shared_buffer_memory =
+ shared_buffer->Map(buffer_size);
+
+ // Copy data into the shared buffer.
+ size_t offset = 0;
+ static size_t planes[] = {VideoFrame::kYPlane, VideoFrame::kUPlane,
+ VideoFrame::kVPlane};
+ for (size_t plane : planes) {
+ size_t plane_size = frame->rows(plane) * frame->stride(plane);
+ memcpy(reinterpret_cast<uint8_t*>(shared_buffer_memory.get()) + offset,
+ frame->data(plane), plane_size);
+ offset += plane_size;
+ }
+
+ // Create a MojoSharedBufferVideoFrame whose dimensions match |color_frame|.
+ scoped_refptr<VideoFrame> mojo_frame = MojoSharedBufferVideoFrame::Create(
+ frame->format(), frame->coded_size(), frame->visible_rect(),
+ frame->natural_size(), std::move(shared_buffer), buffer_size, 0,
+ y_plane_size, y_plane_size + u_plane_size,
+ frame->stride(VideoFrame::kYPlane), frame->stride(VideoFrame::kUPlane),
+ frame->stride(VideoFrame::kVPlane), frame->timestamp());
+
+ client_->OnVideoFrameDecoded(mojom::VideoFrame::From(mojo_frame));
}
void MojoVideoDecoderService::Decode(mojom::DecoderBufferPtr buffer,
« no previous file with comments | « media/mojo/services/mojo_video_decoder_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698