• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ANDROID_DRM_EVENT_LISTENER_H_
18 #define ANDROID_DRM_EVENT_LISTENER_H_
19 
20 #include "autofd.h"
21 #include "worker.h"
22 
23 namespace android {
24 
25 class DrmResources;
26 
27 class DrmEventHandler {
28  public:
DrmEventHandler()29   DrmEventHandler() {
30   }
~DrmEventHandler()31   virtual ~DrmEventHandler() {
32   }
33 
34   virtual void HandleEvent(uint64_t timestamp_us) = 0;
35 };
36 
37 class DrmEventListener : public Worker {
38  public:
39   DrmEventListener(DrmResources *drm);
~DrmEventListener()40   virtual ~DrmEventListener() {
41   }
42 
43   int Init();
44 
45   void RegisterHotplugHandler(DrmEventHandler *handler);
46 
47   static void FlipHandler(int fd, unsigned int sequence, unsigned int tv_sec,
48                           unsigned int tv_usec, void *user_data);
49 
50  protected:
51   virtual void Routine();
52 
53  private:
54   void UEventHandler();
55 
56   fd_set fds_;
57   UniqueFd uevent_fd_;
58   int max_fd_ = -1;
59 
60   DrmResources *drm_;
61   DrmEventHandler *hotplug_handler_ = NULL;
62 };
63 }
64 
65 #endif
66