OLD | NEW |
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 // This file contains an implementation of VideoDecodeAccelerator | 5 // This file contains an implementation of VideoDecodeAccelerator |
6 // that utilizes hardware video decoders, which expose Video4Linux 2 API | 6 // that utilizes hardware video decoders, which expose Video4Linux 2 API |
7 // (http://linuxtv.org/downloads/v4l-dvb-apis/). | 7 // (http://linuxtv.org/downloads/v4l-dvb-apis/). |
8 | 8 |
9 #ifndef CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_DECODE_ACCELERATOR_H_ | 9 #ifndef CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_DECODE_ACCELERATOR_H_ |
10 #define CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_DECODE_ACCELERATOR_H_ | 10 #define CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_DECODE_ACCELERATOR_H_ |
11 | 11 |
12 #include <queue> | 12 #include <queue> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/callback_forward.h" | 15 #include "base/callback_forward.h" |
16 #include "base/memory/linked_ptr.h" | 16 #include "base/memory/linked_ptr.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/threading/thread.h" | 18 #include "base/threading/thread.h" |
19 #include "content/common/content_export.h" | 19 #include "content/common/content_export.h" |
20 #include "content/common/gpu/media/video_decode_accelerator_impl.h" | 20 #include "content/common/gpu/media/video_decode_accelerator_impl.h" |
21 #include "media/base/limits.h" | 21 #include "media/base/limits.h" |
22 #include "media/base/video_decoder_config.h" | 22 #include "media/base/video_decoder_config.h" |
23 #include "media/video/picture.h" | 23 #include "media/video/picture.h" |
24 #include "ui/gfx/size.h" | 24 #include "ui/gfx/size.h" |
25 #include "ui/gl/gl_bindings.h" | 25 #include "ui/gl/gl_bindings.h" |
26 | 26 |
27 namespace base { | 27 namespace base { |
28 class MessageLoopProxy; | 28 class MessageLoopProxy; |
29 } | 29 } // namespace base |
| 30 |
| 31 namespace media { |
| 32 class H264Parser; |
| 33 } // namespace media |
30 | 34 |
31 namespace content { | 35 namespace content { |
32 class H264Parser; | |
33 | |
34 // This class handles video accelerators directly through a V4L2 device exported | 36 // This class handles video accelerators directly through a V4L2 device exported |
35 // by the hardware blocks. | 37 // by the hardware blocks. |
36 // | 38 // |
37 // The threading model of this class is driven by the fact that it needs to | 39 // The threading model of this class is driven by the fact that it needs to |
38 // interface two fundamentally different event queues -- the one Chromium | 40 // interface two fundamentally different event queues -- the one Chromium |
39 // provides through MessageLoop, and the one driven by the V4L2 devices which | 41 // provides through MessageLoop, and the one driven by the V4L2 devices which |
40 // is waited on with epoll(). There are three threads involved in this class: | 42 // is waited on with epoll(). There are three threads involved in this class: |
41 // | 43 // |
42 // * The child thread, which is the main GPU process thread which calls the | 44 // * The child thread, which is the main GPU process thread which calls the |
43 // media::VideoDecodeAccelerator entry points. Calls from this thread | 45 // media::VideoDecodeAccelerator entry points. Calls from this thread |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 bool decoder_flushing_; | 345 bool decoder_flushing_; |
344 // Got a notification from driver that it reached resolution change point | 346 // Got a notification from driver that it reached resolution change point |
345 // in the stream. | 347 // in the stream. |
346 bool resolution_change_pending_; | 348 bool resolution_change_pending_; |
347 // Got a reset request while we were performing resolution change. | 349 // Got a reset request while we were performing resolution change. |
348 bool resolution_change_reset_pending_; | 350 bool resolution_change_reset_pending_; |
349 // Input queue for decoder_thread_: BitstreamBuffers in. | 351 // Input queue for decoder_thread_: BitstreamBuffers in. |
350 std::queue<linked_ptr<BitstreamBufferRef> > decoder_input_queue_; | 352 std::queue<linked_ptr<BitstreamBufferRef> > decoder_input_queue_; |
351 // For H264 decode, hardware requires that we send it frame-sized chunks. | 353 // For H264 decode, hardware requires that we send it frame-sized chunks. |
352 // We'll need to parse the stream. | 354 // We'll need to parse the stream. |
353 scoped_ptr<content::H264Parser> decoder_h264_parser_; | 355 scoped_ptr<media::H264Parser> decoder_h264_parser_; |
354 // Set if the decoder has a pending incomplete frame in an input buffer. | 356 // Set if the decoder has a pending incomplete frame in an input buffer. |
355 bool decoder_partial_frame_pending_; | 357 bool decoder_partial_frame_pending_; |
356 | 358 |
357 // | 359 // |
358 // Hardware state and associated queues. Since decoder_thread_ services | 360 // Hardware state and associated queues. Since decoder_thread_ services |
359 // the hardware, decoder_thread_ owns these too. | 361 // the hardware, decoder_thread_ owns these too. |
360 // | 362 // |
361 | 363 |
362 // Completed decode buffers. | 364 // Completed decode buffers. |
363 std::queue<int> input_ready_queue_; | 365 std::queue<int> input_ready_queue_; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 | 421 |
420 // The codec we'll be decoding for. | 422 // The codec we'll be decoding for. |
421 media::VideoCodecProfile video_profile_; | 423 media::VideoCodecProfile video_profile_; |
422 | 424 |
423 DISALLOW_COPY_AND_ASSIGN(V4L2VideoDecodeAccelerator); | 425 DISALLOW_COPY_AND_ASSIGN(V4L2VideoDecodeAccelerator); |
424 }; | 426 }; |
425 | 427 |
426 } // namespace content | 428 } // namespace content |
427 | 429 |
428 #endif // CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_DECODE_ACCELERATOR_H_ | 430 #endif // CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_DECODE_ACCELERATOR_H_ |
OLD | NEW |