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

Side by Side Diff: content/renderer/media/android/stream_texture_factory.h

Issue 2192823004: Update StreamTextureProxy to accept a base::Closure (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing comments Created 4 years, 4 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 | « no previous file | content/renderer/media/android/stream_texture_factory.cc » ('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 #ifndef CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_H_
6 #define CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_H_ 6 #define CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 18 matching lines...) Expand all
29 29
30 class ContextProviderCommandBuffer; 30 class ContextProviderCommandBuffer;
31 class StreamTextureFactory; 31 class StreamTextureFactory;
32 32
33 // The proxy class for the gpu thread to notify the compositor thread 33 // The proxy class for the gpu thread to notify the compositor thread
34 // when a new video frame is available. 34 // when a new video frame is available.
35 class StreamTextureProxy : public StreamTextureHost::Listener { 35 class StreamTextureProxy : public StreamTextureHost::Listener {
36 public: 36 public:
37 ~StreamTextureProxy() override; 37 ~StreamTextureProxy() override;
38 38
39 // Initialize and bind to the loop, which becomes the thread that 39 // Initialize and bind to |task_runner|, which becomes the thread that the
40 // a connected client will receive callbacks on. This can be called 40 // provided callback will be run on. This can be called on any thread, but
41 // on any thread, but must be called with the same loop every time. 41 // must be called with the same |task_runner| every time.
42 void BindToLoop(int32_t stream_id, 42 void BindToTaskRunner(
43 cc::VideoFrameProvider::Client* client, 43 int32_t stream_id,
44 scoped_refptr<base::SingleThreadTaskRunner> loop); 44 const base::Closure& received_frame_cb,
45 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
45 46
46 // StreamTextureHost::Listener implementation: 47 // StreamTextureHost::Listener implementation:
47 void OnFrameAvailable() override; 48 void OnFrameAvailable() override;
48 49
49 struct Deleter { 50 struct Deleter {
50 inline void operator()(StreamTextureProxy* ptr) const { ptr->Release(); } 51 inline void operator()(StreamTextureProxy* ptr) const { ptr->Release(); }
51 }; 52 };
52 private: 53 private:
53 friend class StreamTextureFactory; 54 friend class StreamTextureFactory;
54 explicit StreamTextureProxy(StreamTextureHost* host); 55 explicit StreamTextureProxy(StreamTextureHost* host);
55 56
56 void BindOnThread(int32_t stream_id); 57 void BindOnThread(int32_t stream_id);
57 void Release(); 58 void Release();
58 59
59 const std::unique_ptr<StreamTextureHost> host_; 60 const std::unique_ptr<StreamTextureHost> host_;
60 61
61 // Protects access to |client_| and |loop_|. 62 // Protects access to |received_frame_cb_| and |task_runner_|.
62 base::Lock lock_; 63 base::Lock lock_;
63 cc::VideoFrameProvider::Client* client_; 64 base::Closure received_frame_cb_;
64 scoped_refptr<base::SingleThreadTaskRunner> loop_; 65 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
65 66
66 DISALLOW_IMPLICIT_CONSTRUCTORS(StreamTextureProxy); 67 DISALLOW_IMPLICIT_CONSTRUCTORS(StreamTextureProxy);
67 }; 68 };
68 69
69 typedef std::unique_ptr<StreamTextureProxy, StreamTextureProxy::Deleter> 70 typedef std::unique_ptr<StreamTextureProxy, StreamTextureProxy::Deleter>
70 ScopedStreamTextureProxy; 71 ScopedStreamTextureProxy;
71 72
72 // Factory class for managing stream textures. 73 // Factory class for managing stream textures.
73 class CONTENT_EXPORT StreamTextureFactory 74 class CONTENT_EXPORT StreamTextureFactory
74 : public base::RefCounted<StreamTextureFactory> { 75 : public base::RefCounted<StreamTextureFactory> {
(...skipping 30 matching lines...) Expand all
105 106
106 scoped_refptr<ContextProviderCommandBuffer> context_provider_; 107 scoped_refptr<ContextProviderCommandBuffer> context_provider_;
107 scoped_refptr<gpu::GpuChannelHost> channel_; 108 scoped_refptr<gpu::GpuChannelHost> channel_;
108 109
109 DISALLOW_IMPLICIT_CONSTRUCTORS(StreamTextureFactory); 110 DISALLOW_IMPLICIT_CONSTRUCTORS(StreamTextureFactory);
110 }; 111 };
111 112
112 } // namespace content 113 } // namespace content
113 114
114 #endif // CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_H_ 115 #endif // CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_H_
OLDNEW
« no previous file with comments | « no previous file | content/renderer/media/android/stream_texture_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698