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

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

Issue 1882373004: Migrate content/common/gpu/media code to media/gpu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Squash and rebase Created 4 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
(Empty)
1 // Copyright 2015 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_AVDA_SHARED_STATE_H_
6 #define CONTENT_COMMON_GPU_AVDA_SHARED_STATE_H_
7
8 #include "base/synchronization/waitable_event.h"
9 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
10 #include "media/base/android/media_codec_bridge.h"
11 #include "media/base/android/sdk_media_codec_bridge.h"
12 #include "ui/gl/gl_context.h"
13 #include "ui/gl/gl_image.h"
14 #include "ui/gl/gl_surface.h"
15
16 namespace gfx {
17 class SurfaceTexture;
18 }
19
20 namespace media {
21 class MediaCodecBridge;
22 }
23
24 namespace content {
25 class AVDACodecImage;
26
27 // Shared state to allow communication between the AVDA and the
28 // GLImages that configure GL for drawing the frames.
29 class AVDASharedState : public base::RefCounted<AVDASharedState> {
30 public:
31 AVDASharedState();
32
33 GLint surface_texture_service_id() const {
34 return surface_texture_service_id_;
35 }
36
37 // Set the SurfaceTexture's client texture name, which the SurfaceTexture
38 // might not know about yet (see surface_texture_is_attached()).
39 void set_surface_texture_service_id(GLint id) {
40 surface_texture_service_id_ = id;
41 }
42
43 // Signal the "frame available" event. This may be called from any thread.
44 void SignalFrameAvailable();
45
46 void WaitForFrameAvailable();
47
48 // Context that the surface texture is bound to, or nullptr if it is not in
49 // the attached state.
50 gfx::GLContext* context() const { return context_.get(); }
51
52 gfx::GLSurface* surface() const { return surface_.get(); }
53
54 bool surface_texture_is_attached() const {
55 return surface_texture_is_attached_;
56 }
57
58 // Iterates over all known codec images and updates the MediaCodec attached to
59 // each one.
60 void CodecChanged(media::MediaCodecBridge* codec);
61
62 // Methods for finding and updating the AVDACodecImage associated with a given
63 // picture buffer id. GetImageForPicture() will return null for unknown ids.
64 // Calling SetImageForPicture() with a nullptr will erase the entry.
65 void SetImageForPicture(int picture_buffer_id, AVDACodecImage* image);
66 AVDACodecImage* GetImageForPicture(int picture_buffer_id) const;
67
68 // TODO(liberato): move the surface texture here and make these calls
69 // attach / detach it also. There are several changes going on in avda
70 // concurrently, so I don't want to change that until the dust settles.
71 // AVDACodecImage would no longer hold the surface texture.
72
73 // Call this when the SurfaceTexture is attached to a GL context. This will
74 // update surface_texture_is_attached(), and set the context() and surface()
75 // to match.
76 void DidAttachSurfaceTexture();
77
78 // Call this when the SurfaceTexture is detached from its GL context. This
79 // will cause us to forget the last binding.
80 void DidDetachSurfaceTexture();
81
82 protected:
83 virtual ~AVDASharedState();
84
85 private:
86 friend class base::RefCounted<AVDASharedState>;
87
88 // Platform gl texture Id for |surface_texture_|. This will be zero if
89 // and only if |texture_owner_| is null.
90 // TODO(liberato): This should be GLuint, but we don't seem to have the type.
91 GLint surface_texture_service_id_;
92
93 // For signalling OnFrameAvailable().
94 base::WaitableEvent frame_available_event_;
95
96 // True if and only if the surface texture is currently attached.
97 bool surface_texture_is_attached_;
98
99 // Context and surface that the surface texture is attached to, if it is
100 // currently attached.
101 scoped_refptr<gfx::GLContext> context_;
102 scoped_refptr<gfx::GLSurface> surface_;
103
104 // Maps a picture buffer id to a AVDACodecImage.
105 std::map<int, AVDACodecImage*> codec_images_;
106
107 DISALLOW_COPY_AND_ASSIGN(AVDASharedState);
108 };
109
110 } // namespace content
111
112 #endif // CONTENT_COMMON_GPU_AVDA_SHARED_STATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698