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

Side by Side Diff: media/base/android/android_overlay.h

Issue 2856253004: removed AndroidOverlayFactory (Closed)
Patch Set: cl feedvback Created 3 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 MEDIA_BASE_ANDROID_ANDROID_OVERLAY_H_ 5 #ifndef MEDIA_BASE_ANDROID_ANDROID_OVERLAY_H_
6 #define MEDIA_BASE_ANDROID_ANDROID_OVERLAY_H_ 6 #define MEDIA_BASE_ANDROID_ANDROID_OVERLAY_H_
7 7
8 #include "base/android/scoped_java_ref.h" 8 #include "base/android/scoped_java_ref.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "media/base/android_overlay_config.h"
11 #include "media/base/media_export.h" 12 #include "media/base/media_export.h"
12 #include "ui/gfx/geometry/rect.h" 13 #include "ui/gfx/geometry/rect.h"
13 #include "ui/gl/android/scoped_java_surface.h" 14 #include "ui/gl/android/scoped_java_surface.h"
14 15
15 namespace media { 16 namespace media {
16 17
17 // Client interface to an AndroidOverlay. Once constructed, you can expect to 18 // Client interface to an AndroidOverlay. Once constructed, you can expect to
18 // receive either a call to ReadyCB or a call to FailedCB to indicate whether 19 // receive either a call to ReadyCB or a call to FailedCB to indicate whether
19 // the overlay is ready, or isn't going to be ready. If one does get ReadyCB, 20 // the overlay is ready, or isn't going to be ready. If one does get ReadyCB,
20 // then one may GetJavaSurface() to retrieve the java Surface object. One 21 // then one may GetJavaSurface() to retrieve the java Surface object. One
21 // will get DestroyedCB eventually after ReadyCB, assuming that one doesn't 22 // will get DestroyedCB eventually after ReadyCB, assuming that one doesn't
22 // delete the overlay before that. 23 // delete the overlay before that.
23 // When DestroyedCB arrives, you should stop using the Android Surface and 24 // When DestroyedCB arrives, you should stop using the Android Surface and
24 // delete the AndroidOverlay instance. Currently, the exact contract depends 25 // delete the AndroidOverlay instance. Currently, the exact contract depends
25 // on the concrete implementation. Once ContentVideoView is deprecated, it will 26 // on the concrete implementation. Once ContentVideoView is deprecated, it will
26 // be: it is not guaranteed that any AndroidOverlay instances will operate until 27 // be: it is not guaranteed that any AndroidOverlay instances will operate until
27 // the destroyed instance is deleted. This must happen on the thread that was 28 // the destroyed instance is deleted. This must happen on the thread that was
28 // used to create it. It does not have to happen immediately, or before the 29 // used to create it. It does not have to happen immediately, or before the
29 // callback returns. 30 // callback returns.
30 // With CVV, one must still delete the overlay on the main thread, and it 31 // With CVV, one must still delete the overlay on the main thread, and it
31 // doesn't have to happen before this returns. However, one must signal the 32 // doesn't have to happen before this returns. However, one must signal the
32 // CVV onSurfaceDestroyed handler on some thread before returning from the 33 // CVV onSurfaceDestroyed handler on some thread before returning from the
33 // callback. AVDACodecAllocator::ReleaseMediaCodec handles signaling. The 34 // callback. AVDACodecAllocator::ReleaseMediaCodec handles signaling. The
34 // fundamental difference is that CVV blocks the UI thread in the browser, which 35 // fundamental difference is that CVV blocks the UI thread in the browser, which
35 // makes it unsafe to let the gpu main thread proceed without risk of deadlock 36 // makes it unsafe to let the gpu main thread proceed without risk of deadlock
36 // AndroidOverlay isn't technically supposed to do that. 37 // AndroidOverlay isn't technically supposed to do that.
37 class MEDIA_EXPORT AndroidOverlay { 38 class MEDIA_EXPORT AndroidOverlay {
38 public: 39 public:
39 // Called when the overlay is ready for use, via |GetJavaSurface()|.
40 using ReadyCB = base::Callback<void(AndroidOverlay*)>;
41
42 // Called when overlay has failed before |ReadyCB| is called. Will not be
43 // called after ReadyCB. It will be the last callback for the overlay.
44 using FailedCB = base::Callback<void(AndroidOverlay*)>;
45
46 // Called when the overlay has been destroyed. This will not be called unless
47 // ReadyCB has been called. It will be the last callback for the overlay.
48 using DestroyedCB = base::Callback<void(AndroidOverlay*)>;
49
50 // Configuration used to create an overlay.
51 struct Config {
52 public:
53 Config();
54 Config(const Config&);
55 ~Config();
56
57 gfx::Rect rect;
58
59 // Require a secure overlay?
60 bool secure = false;
61
62 ReadyCB ready_cb;
63 FailedCB failed_cb;
64 DestroyedCB destroyed_cb;
65 };
66
67 virtual ~AndroidOverlay() {} 40 virtual ~AndroidOverlay() {}
68 41
69 // Schedules a relayout of this overlay. If called before the client is 42 // Schedules a relayout of this overlay. If called before the client is
70 // notified that the surface is created, then the call will be ignored. 43 // notified that the surface is created, then the call will be ignored.
71 virtual void ScheduleLayout(const gfx::Rect& rect) = 0; 44 virtual void ScheduleLayout(const gfx::Rect& rect) = 0;
72 45
73 // May be called during / after ReadyCB and before DestroyedCB. 46 // May be called during / after ReadyCB and before DestroyedCB.
74 virtual const base::android::JavaRef<jobject>& GetJavaSurface() const = 0; 47 virtual const base::android::JavaRef<jobject>& GetJavaSurface() const = 0;
75 48
76 protected: 49 protected:
77 AndroidOverlay() {} 50 AndroidOverlay() {}
78 51
79 DISALLOW_COPY_AND_ASSIGN(AndroidOverlay); 52 DISALLOW_COPY_AND_ASSIGN(AndroidOverlay);
80 }; 53 };
81 54
82 } // namespace media 55 } // namespace media
83 56
84 #endif // MEDIA_BASE_ANDROID_ANDROID_OVERLAY_H_ 57 #endif // MEDIA_BASE_ANDROID_ANDROID_OVERLAY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698