OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef MEDIA_MOJO_INTERFACES_VIDEO_FRAME_STRUCT_TRAITS_H_ |
| 6 #define MEDIA_MOJO_INTERFACES_VIDEO_FRAME_STRUCT_TRAITS_H_ |
| 7 |
| 8 #include "base/logging.h" |
| 9 #include "base/memory/ref_counted.h" |
| 10 #include "media/base/video_frame.h" |
| 11 #include "media/mojo/common/mojo_shared_buffer_video_frame.h" |
| 12 #include "media/mojo/interfaces/media_types.mojom.h" |
| 13 #include "mojo/public/cpp/bindings/struct_traits.h" |
| 14 |
| 15 namespace mojo { |
| 16 |
| 17 template <> |
| 18 struct StructTraits<media::mojom::VideoFrameDataView, |
| 19 scoped_refptr<media::VideoFrame>> { |
| 20 static bool IsNull(const scoped_refptr<media::VideoFrame>& input) { |
| 21 return !!input; |
| 22 } |
| 23 |
| 24 static void SetToNull(scoped_refptr<media::VideoFrame>* input) { |
| 25 *input = nullptr; |
| 26 } |
| 27 |
| 28 static media::VideoPixelFormat format( |
| 29 const scoped_refptr<media::VideoFrame>& input) { |
| 30 return input->format(); |
| 31 } |
| 32 |
| 33 static const gfx::Size& coded_size( |
| 34 const scoped_refptr<media::VideoFrame>& input) { |
| 35 return input->coded_size(); |
| 36 } |
| 37 |
| 38 static const gfx::Rect& visible_rect( |
| 39 const scoped_refptr<media::VideoFrame>& input) { |
| 40 return input->visible_rect(); |
| 41 } |
| 42 |
| 43 static const gfx::Size& natural_size( |
| 44 const scoped_refptr<media::VideoFrame>& input) { |
| 45 return input->natural_size(); |
| 46 } |
| 47 |
| 48 static bool end_of_stream(const scoped_refptr<media::VideoFrame>& input) { |
| 49 return input->metadata()->IsTrue(media::VideoFrameMetadata::END_OF_STREAM); |
| 50 } |
| 51 |
| 52 static base::TimeDelta timestamp( |
| 53 const scoped_refptr<media::VideoFrame>& input) { |
| 54 return input->timestamp(); |
| 55 } |
| 56 |
| 57 static media::mojom::VideoFrameDataPtr data( |
| 58 const scoped_refptr<media::VideoFrame>& input); |
| 59 |
| 60 static bool Read(media::mojom::VideoFrameDataView input, |
| 61 scoped_refptr<media::VideoFrame>* output); |
| 62 }; |
| 63 |
| 64 } // namespace mojo |
| 65 |
| 66 #endif // MEDIA_MOJO_INTERFACES_VIDEO_FRAME_STRUCT_TRAITS_H_ |
OLD | NEW |