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

Side by Side Diff: content/common/gpu/media/v4l2_video_decode_accelerator.h

Issue 1135943005: Revert of content/common: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
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/ref_counted.h" 17 #include "base/memory/ref_counted.h"
18 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
19 #include "base/synchronization/waitable_event.h" 19 #include "base/synchronization/waitable_event.h"
20 #include "base/threading/thread.h" 20 #include "base/threading/thread.h"
21 #include "content/common/content_export.h" 21 #include "content/common/content_export.h"
22 #include "content/common/gpu/media/v4l2_device.h" 22 #include "content/common/gpu/media/v4l2_device.h"
23 #include "media/base/limits.h" 23 #include "media/base/limits.h"
24 #include "media/base/video_decoder_config.h" 24 #include "media/base/video_decoder_config.h"
25 #include "media/video/picture.h" 25 #include "media/video/picture.h"
26 #include "media/video/video_decode_accelerator.h" 26 #include "media/video/video_decode_accelerator.h"
27 #include "ui/gfx/geometry/size.h" 27 #include "ui/gfx/geometry/size.h"
28 #include "ui/gl/gl_bindings.h" 28 #include "ui/gl/gl_bindings.h"
29 29
30 namespace base {
31 class MessageLoopProxy;
32 } // namespace base
33
30 namespace media { 34 namespace media {
31 class H264Parser; 35 class H264Parser;
32 } // namespace media 36 } // namespace media
33 37
34 namespace content { 38 namespace content {
35 // This class handles video accelerators directly through a V4L2 device exported 39 // This class handles video accelerators directly through a V4L2 device exported
36 // by the hardware blocks. 40 // by the hardware blocks.
37 // 41 //
38 // The threading model of this class is driven by the fact that it needs to 42 // The threading model of this class is driven by the fact that it needs to
39 // interface two fundamentally different event queues -- the one Chromium 43 // interface two fundamentally different event queues -- the one Chromium
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 // thread while we wait for AssignPictureBuffers from the client. 75 // thread while we wait for AssignPictureBuffers from the client.
72 class CONTENT_EXPORT V4L2VideoDecodeAccelerator 76 class CONTENT_EXPORT V4L2VideoDecodeAccelerator
73 : public media::VideoDecodeAccelerator { 77 : public media::VideoDecodeAccelerator {
74 public: 78 public:
75 V4L2VideoDecodeAccelerator( 79 V4L2VideoDecodeAccelerator(
76 EGLDisplay egl_display, 80 EGLDisplay egl_display,
77 EGLContext egl_context, 81 EGLContext egl_context,
78 const base::WeakPtr<Client>& io_client_, 82 const base::WeakPtr<Client>& io_client_,
79 const base::Callback<bool(void)>& make_context_current, 83 const base::Callback<bool(void)>& make_context_current,
80 const scoped_refptr<V4L2Device>& device, 84 const scoped_refptr<V4L2Device>& device,
81 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); 85 const scoped_refptr<base::MessageLoopProxy>& io_message_loop_proxy);
82 ~V4L2VideoDecodeAccelerator() override; 86 ~V4L2VideoDecodeAccelerator() override;
83 87
84 // media::VideoDecodeAccelerator implementation. 88 // media::VideoDecodeAccelerator implementation.
85 // Note: Initialize() and Destroy() are synchronous. 89 // Note: Initialize() and Destroy() are synchronous.
86 bool Initialize(media::VideoCodecProfile profile, 90 bool Initialize(media::VideoCodecProfile profile,
87 Client* client) override; 91 Client* client) override;
88 void Decode(const media::BitstreamBuffer& bitstream_buffer) override; 92 void Decode(const media::BitstreamBuffer& bitstream_buffer) override;
89 void AssignPictureBuffers( 93 void AssignPictureBuffers(
90 const std::vector<media::PictureBuffer>& buffers) override; 94 const std::vector<media::PictureBuffer>& buffers) override;
91 void ReusePictureBuffer(int32 picture_buffer_id) override; 95 void ReusePictureBuffer(int32 picture_buffer_id) override;
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 308
305 // Callback that indicates a picture has been cleared. 309 // Callback that indicates a picture has been cleared.
306 void PictureCleared(); 310 void PictureCleared();
307 311
308 // This method determines whether a resolution change event processing 312 // This method determines whether a resolution change event processing
309 // is indeed required by returning true iff: 313 // is indeed required by returning true iff:
310 // - width or height of the new format is different than previous format; or 314 // - width or height of the new format is different than previous format; or
311 // - V4L2_CID_MIN_BUFFERS_FOR_CAPTURE has changed. 315 // - V4L2_CID_MIN_BUFFERS_FOR_CAPTURE has changed.
312 bool IsResolutionChangeNecessary(); 316 bool IsResolutionChangeNecessary();
313 317
314 // Our original calling task runner for the child thread. 318 // Our original calling message loop for the child thread.
315 scoped_refptr<base::SingleThreadTaskRunner> child_task_runner_; 319 scoped_refptr<base::MessageLoopProxy> child_message_loop_proxy_;
316 320
317 // Task runner of the IO thread. 321 // Message loop of the IO thread.
318 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; 322 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_;
319 323
320 // WeakPtr<> pointing to |this| for use in posting tasks from the decoder or 324 // WeakPtr<> pointing to |this| for use in posting tasks from the decoder or
321 // device worker threads back to the child thread. Because the worker threads 325 // device worker threads back to the child thread. Because the worker threads
322 // are members of this class, any task running on those threads is guaranteed 326 // are members of this class, any task running on those threads is guaranteed
323 // that this object is still alive. As a result, tasks posted from the child 327 // that this object is still alive. As a result, tasks posted from the child
324 // thread to the decoder or device thread should use base::Unretained(this), 328 // thread to the decoder or device thread should use base::Unretained(this),
325 // and tasks posted the other way should use |weak_this_|. 329 // and tasks posted the other way should use |weak_this_|.
326 base::WeakPtr<V4L2VideoDecodeAccelerator> weak_this_; 330 base::WeakPtr<V4L2VideoDecodeAccelerator> weak_this_;
327 331
328 // To expose client callbacks from VideoDecodeAccelerator. 332 // To expose client callbacks from VideoDecodeAccelerator.
329 // NOTE: all calls to these objects *MUST* be executed on 333 // NOTE: all calls to these objects *MUST* be executed on
330 // child_task_runner_. 334 // child_message_loop_proxy_.
331 scoped_ptr<base::WeakPtrFactory<Client> > client_ptr_factory_; 335 scoped_ptr<base::WeakPtrFactory<Client> > client_ptr_factory_;
332 base::WeakPtr<Client> client_; 336 base::WeakPtr<Client> client_;
333 // Callbacks to |io_client_| must be executed on |io_task_runner_|. 337 // Callbacks to |io_client_| must be executed on |io_message_loop_proxy_|.
334 base::WeakPtr<Client> io_client_; 338 base::WeakPtr<Client> io_client_;
335 339
336 // 340 //
337 // Decoder state, owned and operated by decoder_thread_. 341 // Decoder state, owned and operated by decoder_thread_.
338 // Before decoder_thread_ has started, the decoder state is managed by 342 // Before decoder_thread_ has started, the decoder state is managed by
339 // the child (main) thread. After decoder_thread_ has started, the decoder 343 // the child (main) thread. After decoder_thread_ has started, the decoder
340 // thread should be the only one managing these. 344 // thread should be the only one managing these.
341 // 345 //
342 346
343 // This thread services tasks posted from the VDA API entry points by the 347 // This thread services tasks posted from the VDA API entry points by the
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 457
454 // The WeakPtrFactory for |weak_this_|. 458 // The WeakPtrFactory for |weak_this_|.
455 base::WeakPtrFactory<V4L2VideoDecodeAccelerator> weak_this_factory_; 459 base::WeakPtrFactory<V4L2VideoDecodeAccelerator> weak_this_factory_;
456 460
457 DISALLOW_COPY_AND_ASSIGN(V4L2VideoDecodeAccelerator); 461 DISALLOW_COPY_AND_ASSIGN(V4L2VideoDecodeAccelerator);
458 }; 462 };
459 463
460 } // namespace content 464 } // namespace content
461 465
462 #endif // CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_DECODE_ACCELERATOR_H_ 466 #endif // CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_DECODE_ACCELERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698