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.
5 #ifndef CHROMECAST_BASE_CAST_RESOURCE_H_
6 #define CHROMECAST_BASE_CAST_RESOURCE_H_
8 #include "base/macros.h"
10 namespace chromecast
{
12 // Interface for resources needed to run application.
15 // Resources necessary to run cast apps. CastResource may contain union of the
17 // TODO(yucliu): Split video resources and graphic resources.
20 // All resources necessary to render sounds, for example, audio pipeline,
22 kResourceAudio
= 1 << 0,
23 // All resources necessary to render videos or images, for example, video
24 // pipeline, primary graphics plane, display, etc.
25 kResourceScreenPrimary
= 1 << 1,
26 // All resources necessary to render overlaid images, for example, secondary
27 // graphics plane, LCD, etc.
28 kResourceScreenSecondary
= 1 << 2,
29 // Collection of resources used for display only combined with bitwise or.
30 kResourceDisplayOnly
= (kResourceScreenPrimary
| kResourceScreenSecondary
),
31 // Collection of all resources combined with bitwise or.
33 (kResourceAudio
| kResourceScreenPrimary
| kResourceScreenSecondary
),
38 // Called when resource is created. CastResource should not be owned by
39 // Client. It can be called from any thread.
40 virtual void OnResourceAcquired(CastResource
* cast_resource
) = 0;
41 // Called when part or all resources are released. It can be called from any
43 // |cast_resource| the CastResource that is released. The pointer may be
44 // invalid. Client can't call functions with that pointer.
45 // |remain| the unreleased resource of CastResource. If kResourceNone is
46 // returned, Client will remove the resource from its watching
48 virtual void OnResourceReleased(CastResource
* cast_resource
,
57 virtual void SetCastResourceClient(Client
* client
) = 0;
58 // Called to release resources. Implementation should call
59 // Client::OnResourceReleased when resource is released on its side.
60 virtual void ReleaseResource(Resource resource
) = 0;
63 virtual ~CastResource() {}
66 DISALLOW_COPY_AND_ASSIGN(CastResource
);
69 } // namespace chromecast