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

Side by Side Diff: content/common/gpu/media/arc/arc_gpu_video_decode_accelerator.h

Issue 1549473002: Add ArcGpuVideoDecodeAccelerator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 11 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
OLDNEW
(Empty)
1 // Copyright 2016 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 CONTENT_COMMON_GPU_MEDIA_ARC_ARC_VIDEO_ACCELERATOR_ADAPTER_H_
6 #define CONTENT_COMMON_GPU_MEDIA_ARC_ARC_VIDEO_ACCELERATOR_ADAPTER_H_
7
8 #include <queue>
9 #include <vector>
10
11 #include "base/callback.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/threading/thread_checker.h"
14 #include "content/common/gpu/media/arc/arc_video_accelerator.h"
15 #include "media/video/video_decode_accelerator.h"
16
17 namespace content {
18 namespace arc {
19
20 // This class is excuted in Chromium's GPU process. It takes decoding requests
21 // from ARC container via IPC channels and translates and send those requests
22 // to the real VDA on Chromium. It also returns the decoded frames back to the
23 // ARC side.
24 class ArcGpuVideoDecodeAccelerator
25 : public ArcVideoAccelerator,
26 public media::VideoDecodeAccelerator::Client {
27 public:
28 ArcGpuVideoDecodeAccelerator();
29
30 // Implementation of the ArcVideoAccelerator interface.
31 bool Initialize(DeviceType device,
32 ArcVideoAccelerator::Client* client) override;
33 bool SetBufferCount(PortType port, size_t* count) override;
34 bool SetBufferFormat(PortType port, const BufferFormat& format) override;
35 bool BindSharedMemory(PortType port,
36 uint32_t index,
37 int ashmem_fd,
38 size_t offset,
39 size_t length) override;
40 bool BindDmabuf(PortType port, uint32_t index, int dmabuf_fd) override;
41 void UseBuffer(PortType port,
42 uint32_t index,
43 const BufferMetadata& metadata) override;
44 void Reset() override;
45
46 // Implementation of the VideoDecodeAccelerator::Client interface.
47 void ProvidePictureBuffers(uint32_t requested_num_of_buffers,
48 const gfx::Size& dimensions,
49 uint32_t texture_target) override;
50 void DismissPictureBuffer(int32_t picture_buffer) override;
51 void PictureReady(const media::Picture& picture) override;
52 void NotifyEndOfBitstreamBuffer(int32_t bitstream_buffer_id) override;
53 void NotifyFlushDone() override;
54 void NotifyResetDone() override;
55 void NotifyError(media::VideoDecodeAccelerator::Error error) override;
56
57 private:
58 struct InputRecord {
59 // The file handle to access the buffer. It is owned by this ArcGVDA and
60 // should be freed if not used.
61 base::ScopedFD handle;
62 off_t offset;
63 size_t length;
64 int32_t bitstream_buffer_id;
65 int64_t timestamp;
66
67 InputRecord();
68 };
69
70 struct PortInfo {
71 MemoryType memory_type;
72 size_t num_buffers;
73
74 PortInfo();
75 };
76
77 // Helper function to Send the end-of-stream output buffer if
78 // |pending_eos_output_buffer_| is true, or reuse the picture in ArcVDA.
79 void SendEosIfNeededOrReusePicture(uint32_t index);
80
81 // Helper functions to validate |port| (and |index|).
82 bool ValidatePort(PortType port);
83 bool ValidatePortAndIndex(PortType port, uint32_t index);
84
85 // Indicates a pending EOS output buffer. When it is true, an EOS output
86 // buffer need to be sent to |arc_client_| once an output buffer is available.
87 bool pending_eos_output_buffer_;
88 scoped_ptr<media::VideoDecodeAccelerator> vda_;
89
90 // Help functions to find the index of the InputRecord which matches to given
91 // |bitstream_buffer_id|. Returns the size of |input_records_| if it cannot be
92 // found.
93 uint32_t FindInputRecordByBitstreamBufferId(int32_t bitstream_buffer_id);
kcwu 2016/01/20 09:11:05 move this to line 85. To keep methods in front of
Owen Lin 2016/02/02 09:08:06 Done.
94
95 // It's safe to use the pointer here, the life cycle of the |arc_client_|
96 // is longer than this ArcGpuVideoDecodeAccelerator.
97 ArcVideoAccelerator::Client* arc_client_;
98
99 // The callback called when reset completes.
100 base::Closure reset_done_callback_;
101
102 PortInfo port_info_[PORT_COUNT];
103
104 // The next bitstream_buffer_id, started from 0.
105 int32_t next_bitstream_buffer_id_;
106
107 gfx::Size coded_size_;
108
109 // The index of buffers returned while Flushing, will be used for sending
110 // EOS buffer back to |arc_client_|.
111 std::queue<uint32_t> buffers_pending_eos_;
112
113 std::vector<InputRecord> input_records_;
114
115 base::ThreadChecker thread_checker_;
116 };
117
118 } // namespace arc
119 } // namespace content
120
121 #endif // CONTENT_COMMON_GPU_MEDIA_ARC_ARC_VIDEO_ACCELERATOR_ADAPTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698