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

Side by Side Diff: media/mojo/common/media_type_converters.cc

Issue 2640153004: Add mailbox-based Mojo VideoFrame variant. (Closed)
Patch Set: Rebase. Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « media/mojo/common/BUILD.gn ('k') | media/mojo/interfaces/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/mojo/common/media_type_converters.h" 5 #include "media/mojo/common/media_type_converters.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 static_cast<media::MojoSharedBufferVideoFrame*>(input.get()); 339 static_cast<media::MojoSharedBufferVideoFrame*>(input.get());
340 mojo::ScopedSharedBufferHandle duplicated_handle = 340 mojo::ScopedSharedBufferHandle duplicated_handle =
341 input_frame->Handle().Clone(); 341 input_frame->Handle().Clone();
342 CHECK(duplicated_handle.is_valid()); 342 CHECK(duplicated_handle.is_valid());
343 343
344 frame->format = input->format(); 344 frame->format = input->format();
345 frame->coded_size = input->coded_size(); 345 frame->coded_size = input->coded_size();
346 frame->visible_rect = input->visible_rect(); 346 frame->visible_rect = input->visible_rect();
347 frame->natural_size = input->natural_size(); 347 frame->natural_size = input->natural_size();
348 frame->timestamp = input->timestamp(); 348 frame->timestamp = input->timestamp();
349 frame->frame_data = std::move(duplicated_handle); 349
350 frame->frame_data_size = input_frame->MappedSize(); 350 media::mojom::SharedBufferVideoFrameDataPtr data =
351 frame->y_stride = input_frame->stride(media::VideoFrame::kYPlane); 351 media::mojom::SharedBufferVideoFrameData::New();
352 frame->u_stride = input_frame->stride(media::VideoFrame::kUPlane); 352 data->frame_data = std::move(duplicated_handle);
353 frame->v_stride = input_frame->stride(media::VideoFrame::kVPlane); 353 data->frame_data_size = input_frame->MappedSize();
354 frame->y_offset = input_frame->PlaneOffset(media::VideoFrame::kYPlane); 354 data->y_stride = input_frame->stride(media::VideoFrame::kYPlane);
355 frame->u_offset = input_frame->PlaneOffset(media::VideoFrame::kUPlane); 355 data->u_stride = input_frame->stride(media::VideoFrame::kUPlane);
356 frame->v_offset = input_frame->PlaneOffset(media::VideoFrame::kVPlane); 356 data->v_stride = input_frame->stride(media::VideoFrame::kVPlane);
357 data->y_offset = input_frame->PlaneOffset(media::VideoFrame::kYPlane);
358 data->u_offset = input_frame->PlaneOffset(media::VideoFrame::kUPlane);
359 data->v_offset = input_frame->PlaneOffset(media::VideoFrame::kVPlane);
360
361 frame->data = media::mojom::VideoFrameData::New();
362 frame->data->set_shared_buffer_data(std::move(data));
357 return frame; 363 return frame;
358 } 364 }
359 365
360 // static 366 // static
361 scoped_refptr<media::VideoFrame> 367 scoped_refptr<media::VideoFrame>
362 TypeConverter<scoped_refptr<media::VideoFrame>, media::mojom::VideoFramePtr>:: 368 TypeConverter<scoped_refptr<media::VideoFrame>, media::mojom::VideoFramePtr>::
363 Convert(const media::mojom::VideoFramePtr& input) { 369 Convert(const media::mojom::VideoFramePtr& input) {
364 if (input->end_of_stream) 370 if (input->end_of_stream)
365 return media::VideoFrame::CreateEOSFrame(); 371 return media::VideoFrame::CreateEOSFrame();
366 372
373 // Handle non EOS frame. It must be a MojoSharedBufferVideoFrame.
374 // TODO(jrummell): Support other types of VideoFrame.
375 DCHECK(input->data->is_shared_buffer_data());
376 const media::mojom::SharedBufferVideoFrameDataPtr& data =
377 input->data->get_shared_buffer_data();
378
367 return media::MojoSharedBufferVideoFrame::Create( 379 return media::MojoSharedBufferVideoFrame::Create(
368 input->format, input->coded_size, input->visible_rect, 380 input->format, input->coded_size, input->visible_rect,
369 input->natural_size, std::move(input->frame_data), 381 input->natural_size, std::move(data->frame_data),
370 base::saturated_cast<size_t>(input->frame_data_size), 382 base::saturated_cast<size_t>(data->frame_data_size),
371 base::saturated_cast<size_t>(input->y_offset), 383 base::saturated_cast<size_t>(data->y_offset),
372 base::saturated_cast<size_t>(input->u_offset), 384 base::saturated_cast<size_t>(data->u_offset),
373 base::saturated_cast<size_t>(input->v_offset), input->y_stride, 385 base::saturated_cast<size_t>(data->v_offset), data->y_stride,
374 input->u_stride, input->v_stride, input->timestamp); 386 data->u_stride, data->v_stride, input->timestamp);
375 } 387 }
376 388
377 } // namespace mojo 389 } // namespace mojo
OLDNEW
« no previous file with comments | « media/mojo/common/BUILD.gn ('k') | media/mojo/interfaces/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698