summaryrefslogtreecommitdiff
path: root/tvapi/android/include/Tv.h (plain)
blob: ed6b324eebc35faa4bda464d8d78ef30c423dd5e
1#ifndef ANDROID_AMLOGIC_TV_H
2#define ANDROID_AMLOGIC_TV_H
3
4#include <utils/Timers.h>
5#include <include/ITvClient.h>
6#include <binder/MemoryHeapBase.h>
7#include <binder/MemoryBase.h>
8#include <utils/threads.h>
9
10using namespace android;
11
12class ITvService;
13class ITv;
14
15// ref-counted object for callbacks
16class TvListener: virtual public RefBase
17{
18public:
19 virtual void notify(int32_t msgType, const Parcel &ext) = 0;
20};
21
22class Tv : public BnTvClient, public IBinder::DeathRecipient
23{
24public:
25 // construct a tv client from an existing remote
26 static sp<Tv> create(const sp<ITv> &tv);
27 static sp<Tv> connect();
28 ~Tv();
29 void init();
30 status_t reconnect();
31 void disconnect();
32 status_t lock();
33 status_t unlock();
34
35 status_t getStatus()
36 {
37 return mStatus;
38 }
39 status_t processCmd(const Parcel &p, Parcel *r);
40 status_t createSubtitle(const sp<IMemory> &share_mem);
41 status_t createVideoFrame(const sp<IMemory> &share_mem);
42 void setListener(const sp<TvListener> &listener);
43
44 // ITvClient interface
45 virtual void notifyCallback(int32_t msgType, const Parcel &p);
46
47 sp<ITv> remote();
48
49private:
50 Tv();
51 Tv(const Tv &);
52 Tv &operator = (const Tv);
53 virtual void binderDied(const wp<IBinder> &who);
54
55 class DeathNotifier: public IBinder::DeathRecipient
56 {
57 public:
58 DeathNotifier() {}
59 virtual void binderDied(const wp<IBinder> &who);
60 };
61
62 static sp<DeathNotifier> mDeathNotifier;
63
64 // helper function to obtain tv service handle
65 static const sp<ITvService> &getTvService();
66
67 sp<ITv> mTv;
68 status_t mStatus;
69
70 sp<TvListener> mListener;
71
72 friend class DeathNotifier;
73
74 static Mutex mLock;
75 static sp<ITvService> mTvService;
76
77 sp<MemoryHeapBase> mBmpMemHeap;
78 sp<MemoryBase> mBmpMemBase;
79};
80
81
82#endif
83