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

Side by Side Diff: chromecast/base/cast_resource.h

Issue 1531543002: [Chromecast] Adding pause/resume operations to VideoPlaneController. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Just rebase of Patch Set 6. Created 4 years, 11 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 2015 The Chromium Authors. All rights reserved. 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 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 CHROMECAST_BASE_CAST_RESOURCE_H_ 5 #ifndef CHROMECAST_BASE_CAST_RESOURCE_H_
6 #define CHROMECAST_BASE_CAST_RESOURCE_H_ 6 #define CHROMECAST_BASE_CAST_RESOURCE_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 9
10 namespace chromecast { 10 namespace chromecast {
11 11
12 // Interface for resources needed to run application. 12 // Interface for resources needed to run application.
halliwell 2016/01/12 03:25:06 This comment is terrible, btw.
esum 2016/01/15 23:02:28 Modified to be a little clearer for the time bein
13 class CastResource { 13 class CastResource {
14 public: 14 public:
15 // Resources necessary to run cast apps. CastResource may contain union of the 15 // Resources necessary to run cast apps. CastResource may contain union of the
16 // following types. 16 // following types.
17 // TODO(yucliu): Split video resources and graphic resources. 17 // TODO(yucliu): Split video resources and graphic resources.
18 enum Resource { 18 enum Resource {
19 kResourceNone = 0, 19 kResourceNone = 0,
20 // All resources necessary to render sounds, for example, audio pipeline, 20 // All resources necessary to render sounds, for example, audio pipeline,
21 // speaker, etc. 21 // speaker, etc.
22 kResourceAudio = 1 << 0, 22 kResourceAudio = 1 << 0,
23 // All resources necessary to render videos or images, for example, video 23 // All resources necessary to render videos or images, for example, video
24 // pipeline, primary graphics plane, display, etc. 24 // pipeline, primary graphics plane, display, etc.
25 kResourceScreenPrimary = 1 << 1, 25 kResourceScreenPrimary = 1 << 1,
26 // All resources necessary to render overlaid images, for example, secondary 26 // All resources necessary to render overlaid images, for example, secondary
27 // graphics plane, LCD, etc. 27 // graphics plane, LCD, etc.
28 kResourceScreenSecondary = 1 << 2, 28 kResourceScreenSecondary = 1 << 2,
29 // Collection of resources used for display only combined with bitwise or. 29 // Collection of resources used for display only combined with bitwise or.
30 kResourceDisplayOnly = (kResourceScreenPrimary | kResourceScreenSecondary), 30 kResourceDisplayOnly = (kResourceScreenPrimary | kResourceScreenSecondary),
31 // Collection of all resources combined with bitwise or. 31 // Collection of all resources combined with bitwise or.
32 kResourceAll = 32 kResourceAll =
33 (kResourceAudio | kResourceScreenPrimary | kResourceScreenSecondary), 33 (kResourceAudio | kResourceScreenPrimary | kResourceScreenSecondary),
34 }; 34 };
35 35
36 class Client { 36 class Client {
halliwell 2016/01/12 03:25:07 Could we clarify what a Client is? It's very much
esum 2016/01/15 23:02:28 Done.
37 public: 37 public:
38 // Called when resource is created. CastResource should not be owned by 38 // Called to register CastResource with client. CastResource should not be
halliwell 2016/01/12 03:25:06 what does "should not be owned by client" mean? I
esum 2016/01/15 23:02:28 Yes. Done.
39 // Client. It can be called from any thread. 39 // owned by Client. It can be called from any thread.
40 virtual void OnResourceAcquired(CastResource* cast_resource) = 0; 40 virtual void RegisterCastResource(CastResource* cast_resource) = 0;
41 // TODO(esum): Add OnResourceAcquired() here once AcquireResource is
42 // allowed to be asynchronous.
43
41 // Called when part or all resources are released. It can be called from any 44 // Called when part or all resources are released. It can be called from any
42 // thread. 45 // thread.
43 // |cast_resource| the CastResource that is released. The pointer may be 46 // |cast_resource| the CastResource that is released. The pointer may be
44 // invalid. Client can't call functions with that pointer. 47 // invalid. Client can't call functions with that pointer.
45 // |remain| the unreleased resource of CastResource. If kResourceNone is 48 // |remain| the unreleased resource of CastResource. If kResourceNone is
46 // returned, Client will remove the resource from its watching 49 // returned, Client will remove the resource from its watching
47 // list. 50 // list.
48 virtual void OnResourceReleased(CastResource* cast_resource, 51 virtual void OnResourceReleased(CastResource* cast_resource,
49 Resource remain) = 0; 52 Resource remain) = 0;
halliwell 2016/01/12 03:25:06 Not a comment on your changes, but I'm having trou
esum 2016/01/15 23:02:28 Discussed and will leave as is now. Will be rename
50 53
51 protected: 54 protected:
52 virtual ~Client() {} 55 virtual ~Client() {}
53 }; 56 };
54 57
55 void SetCastResourceClient(Client* client); 58 void SetCastResourceClient(Client* client);
59 // Called to acquire resources after OEM has granted them, and before
60 // they start getting used by consumers. Implementation must be synchronous
61 // since consumers will start using the resource immediately afterwards.
62 // TODO(esum): We should allow this method to be asynchronous in case an
63 // implementer needs to make expensive calls and doesn't want to block the
64 // UI thread (b/26239576). For now, don't do anything expensive in your
65 // implementation; if you really need to, then this bug has to be resolved.
66 virtual void AcquireResource(Resource resource) = 0;
56 // Called to release resources. Implementation should call 67 // Called to release resources. Implementation should call
57 // Client::OnResourceReleased when resource is released on its side. 68 // Client::OnResourceReleased when resource is released on its side.
58 virtual void ReleaseResource(Resource resource) = 0; 69 virtual void ReleaseResource(Resource resource) = 0;
59 70
60 protected: 71 protected:
61 CastResource() : client_(nullptr) {} 72 CastResource() : client_(nullptr) {}
62 virtual ~CastResource() {} 73 virtual ~CastResource() {}
63 74
64 void NotifyResourceAcquired(); 75 void RegisterWithClient();
65 void NotifyResourceReleased(Resource remain); 76 void NotifyResourceReleased(Resource remain);
66 77
67 private: 78 private:
68 Client* client_; 79 Client* client_;
69 80
70 DISALLOW_COPY_AND_ASSIGN(CastResource); 81 DISALLOW_COPY_AND_ASSIGN(CastResource);
71 }; 82 };
72 83
73 } // namespace chromecast 84 } // namespace chromecast
74 85
75 #endif 86 #endif
OLDNEW
« no previous file with comments | « no previous file | chromecast/base/cast_resource.cc » ('j') | chromecast/browser/media/cma_media_pipeline_client.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698