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

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

Issue 532993002: work-in-progress patch to fix context lost black video (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: no block Created 6 years, 3 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 #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 "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop_proxy.h"
10 #include "cc/layers/video_frame_provider.h" 11 #include "cc/layers/video_frame_provider.h"
11 #include "gpu/command_buffer/common/mailbox.h" 12 #include "gpu/command_buffer/common/mailbox.h"
12 #include "ui/gfx/size.h" 13 #include "ui/gfx/size.h"
13 14
14 namespace gpu { 15 namespace gpu {
15 namespace gles2 { 16 namespace gles2 {
16 class GLES2Interface; 17 class GLES2Interface;
17 } // namespace gles2 18 } // namespace gles2
18 } // namespace gpu 19 } // namespace gpu
19 20
20 namespace content { 21 namespace content {
21 22
22 // The proxy class for the gpu thread to notify the compositor thread 23 // The proxy class for the gpu thread to notify the compositor thread
23 // when a new video frame is available. 24 // when a new video frame is available.
24 class StreamTextureProxy { 25 class StreamTextureProxy {
25 public: 26 public:
26 virtual ~StreamTextureProxy() {} 27 virtual ~StreamTextureProxy() {}
27 28
28 // Initialize and bind to the current thread, which becomes the thread that 29 // Initialize and bind to the loop, which becomes the thread that
29 // a connected client will receive callbacks on. 30 // a connected client will receive callbacks on. This can be called
30 virtual void BindToCurrentThread(int32 stream_id) = 0; 31 // on any thread but should only be called on that thread from that
31 32 // point on.
32 // Setting the target for callback when a frame is available. This function 33 virtual void Bind(int32 stream_id,
33 // could be called on both the main thread and the compositor thread. 34 cc::VideoFrameProvider::Client* client,
34 virtual void SetClient(cc::VideoFrameProvider::Client* client) = 0; 35 scoped_refptr<base::MessageLoopProxy> loop) = 0;
35 36
36 // Causes this instance to be deleted on the thread it is bound to. 37 // Causes this instance to be deleted on the thread it is bound to.
37 virtual void Release() = 0; 38 virtual void Release() = 0;
38 39
39 struct Deleter { 40 struct Deleter {
40 inline void operator()(StreamTextureProxy* ptr) const { ptr->Release(); } 41 inline void operator()(StreamTextureProxy* ptr) const { ptr->Release(); }
41 }; 42 };
42 }; 43 };
43 44
44 typedef scoped_ptr<StreamTextureProxy, StreamTextureProxy::Deleter> 45 typedef scoped_ptr<StreamTextureProxy, StreamTextureProxy::Deleter>
45 ScopedStreamTextureProxy; 46 ScopedStreamTextureProxy;
46 47
48 class StreamTextureFactoryContextObserver {
49 public:
50 ~StreamTextureFactoryContextObserver() {}
51 virtual void ResetStreamTextureProxy() = 0;
52 };
53
47 // Factory class for managing stream textures. 54 // Factory class for managing stream textures.
48 class StreamTextureFactory : public base::RefCounted<StreamTextureFactory> { 55 class StreamTextureFactory : public base::RefCounted<StreamTextureFactory> {
49 public: 56 public:
50 // Create the StreamTextureProxy object. 57 // Create the StreamTextureProxy object.
51 virtual StreamTextureProxy* CreateProxy() = 0; 58 virtual StreamTextureProxy* CreateProxy() = 0;
52 59
53 // Send an IPC message to the browser process to request a java surface 60 // Send an IPC message to the browser process to request a java surface
54 // object for the given stream_id. After the the surface is created, 61 // object for the given stream_id. After the the surface is created,
55 // it will be passed back to the WebMediaPlayerAndroid object identified by 62 // it will be passed back to the WebMediaPlayerAndroid object identified by
56 // the player_id. 63 // the player_id.
57 virtual void EstablishPeer(int32 stream_id, int player_id) = 0; 64 virtual void EstablishPeer(int32 stream_id, int player_id) = 0;
58 65
59 // Creates a StreamTexture and returns its id. Sets |*texture_id| to the 66 // Creates a StreamTexture and returns its id. Sets |*texture_id| to the
60 // client-side id of the StreamTexture. The texture is produced into 67 // client-side id of the StreamTexture. The texture is produced into
61 // a mailbox so it can be shipped in a VideoFrame. 68 // a mailbox so it can be shipped in a VideoFrame.
62 virtual unsigned CreateStreamTexture(unsigned texture_target, 69 virtual unsigned CreateStreamTexture(unsigned texture_target,
63 unsigned* texture_id, 70 unsigned* texture_id,
64 gpu::Mailbox* texture_mailbox) = 0; 71 gpu::Mailbox* texture_mailbox) = 0;
65 72
66 // Set the streamTexture size for the given stream Id. 73 // Set the streamTexture size for the given stream Id.
67 virtual void SetStreamTextureSize(int32 texture_id, 74 virtual void SetStreamTextureSize(int32 texture_id,
68 const gfx::Size& size) = 0; 75 const gfx::Size& size) = 0;
69 76
70 virtual gpu::gles2::GLES2Interface* ContextGL() = 0; 77 virtual gpu::gles2::GLES2Interface* ContextGL() = 0;
71 78
79 virtual void AddObserver(StreamTextureFactoryContextObserver* obs) = 0;
80 virtual void RemoveObserver(StreamTextureFactoryContextObserver* obs) = 0;
81
72 protected: 82 protected:
73 friend class base::RefCounted<StreamTextureFactory>; 83 friend class base::RefCounted<StreamTextureFactory>;
74 virtual ~StreamTextureFactory() {} 84 virtual ~StreamTextureFactory() {}
75 }; 85 };
76 86
77 } // namespace content 87 } // namespace content
78 88
79 #endif // CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_H_ 89 #endif // CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698