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

Side by Side Diff: media/gpu/content_video_view_overlay.cc

Issue 2692863011: Add ContentVideoViewOverlay to AVDA. (Closed)
Patch Set: fixed avda unittest Created 3 years, 9 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 | « media/gpu/content_video_view_overlay.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "media/gpu/content_video_view_overlay.h"
6
7 #include "base/bind.h"
8 #include "base/logging.h"
9 #include "base/threading/thread_task_runner_handle.h"
10 #include "gpu/ipc/common/gpu_surface_lookup.h"
11
12 namespace media {
13
14 ContentVideoViewOverlay::ContentVideoViewOverlay(
15 AVDACodecAllocator* codec_allocator,
16 int surface_id,
17 const AndroidOverlay::Config& config)
18 : codec_allocator_(codec_allocator),
19 surface_id_(surface_id),
20 config_(config),
21 weak_factory_(this) {
22 if (codec_allocator_->AllocateSurface(this, surface_id_)) {
23 // We have the surface -- post a callback to our OnSurfaceAvailable.
24 base::ThreadTaskRunnerHandle::Get()->PostTask(
25 FROM_HERE, base::Bind(&ContentVideoViewOverlay::OnSurfaceAvailable,
26 weak_factory_.GetWeakPtr(), true));
27 }
28 }
29
30 ContentVideoViewOverlay::~ContentVideoViewOverlay() {
31 // Deallocate the surface. It's okay if we don't own it.
32 codec_allocator_->DeallocateSurface(this, surface_id_);
33 }
34
35 void ContentVideoViewOverlay::ScheduleLayout(const gfx::Rect& rect) {
36 NOTIMPLEMENTED();
37 }
38
39 const base::android::JavaRef<jobject>& ContentVideoViewOverlay::GetJavaSurface()
40 const {
41 return surface_.j_surface();
42 }
43
44 void ContentVideoViewOverlay::OnSurfaceAvailable(bool success) {
45 if (!success) {
46 // Notify that the surface won't be available.
47 config_.failed_cb.Run();
48 // |this| may be deleted.
49 return;
50 }
51
52 // Get the surface and notify our client.
53 surface_ =
54 gpu::GpuSurfaceLookup::GetInstance()->AcquireJavaSurface(surface_id_);
55
56 // If no surface was returned, then fail instead.
57 if (surface_.IsEmpty()) {
58 config_.failed_cb.Run();
59 // |this| may be deleted.
60 return;
61 }
62
63 config_.ready_cb.Run();
64 }
65
66 void ContentVideoViewOverlay::OnSurfaceDestroyed() {
67 config_.destroyed_cb.Run();
68 // |this| may be deleted, or deletion might be posted elsewhere.
69 }
70
71 } // namespace media
OLDNEW
« no previous file with comments | « media/gpu/content_video_view_overlay.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698